Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

more usage of c++17 stuff for more streamlined code #364

Merged
merged 16 commits into from
Jan 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Interpreter/DataValue.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#ifndef DATA_VALUE_H_
#define DATA_VALUE_H_

#include "Util/string_view.h"
#include <string_view>

#include <gsl/span>

Expand Down Expand Up @@ -87,9 +87,9 @@ inline DataValue make_value(bool n) {
return DV;
}

inline DataValue make_value(view::string_view str) {
inline DataValue make_value(std::string_view str) {
DataValue DV;
DV.value = str.to_string();
DV.value = std::string(str);
return DV;
}

Expand Down
12 changes: 6 additions & 6 deletions Interpreter/interpret.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@ Symbol *InstallIteratorSymbol() {
/*
** Lookup a constant string by its value.
*/
Symbol *LookupStringConstSymbol(view::string_view value) {
Symbol *LookupStringConstSymbol(std::string_view value) {

auto it = std::find_if(GlobalSymList.begin(), GlobalSymList.end(), [value](Symbol *s) {
return (s->type == CONST_SYM && is_string(s->value) && to_string(s->value) == value);
Expand All @@ -708,7 +708,7 @@ Symbol *InstallStringConstSymbolEx(const QString &str) {
/*
** install string str in the global symbol table with a string name
*/
Symbol *InstallStringConstSymbol(view::string_view str) {
Symbol *InstallStringConstSymbol(std::string_view str) {

static int stringConstIndex = 0;

Expand All @@ -729,7 +729,7 @@ Symbol *LookupSymbolEx(const QString &name) {
return LookupSymbol(name.toStdString());
}

Symbol *LookupSymbol(view::string_view name) {
Symbol *LookupSymbol(std::string_view name) {

// first look for a local symbol
auto local = std::find_if(LocalSymList.begin(), LocalSymList.end(), [name](Symbol *s) {
Expand Down Expand Up @@ -835,9 +835,9 @@ Symbol *PromoteToGlobal(Symbol *sym) {
*Context.StackP++ = (dataVal); \
} while (0)

#define PEEK(dataVal, peekIndex) \
do { \
(dataVal) = *(Context.StackP - (peekIndex)-1); \
#define PEEK(dataVal, peekIndex) \
do { \
(dataVal) = *(Context.StackP - (peekIndex) - 1); \
} while (0)

#define POP_INT(number) \
Expand Down
8 changes: 4 additions & 4 deletions Interpreter/interpret.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#define INTERPRET_H_

#include "DataValue.h"
#include "Util/string_view.h"
#include <string_view>

#include <gsl/span>

Expand Down Expand Up @@ -144,13 +144,13 @@ bool AddSym(Symbol *sym, QString *msg);
Inst *GetPC();
Program *FinishCreatingProgram();
Symbol *InstallIteratorSymbol();
Symbol *InstallStringConstSymbol(view::string_view str);
Symbol *InstallStringConstSymbol(std::string_view str);
Symbol *InstallStringConstSymbolEx(const QString &str);
Symbol *InstallSymbol(const std::string &name, SymTypes type, const DataValue &value);
Symbol *InstallSymbolEx(const QString &name, enum SymTypes type, const DataValue &value);
Symbol *LookupStringConstSymbol(view::string_view value);
Symbol *LookupStringConstSymbol(std::string_view value);
Symbol *LookupSymbolEx(const QString &name);
Symbol *LookupSymbol(view::string_view name);
Symbol *LookupSymbol(std::string_view name);
void BeginCreatingProgram();
void FillLoopAddrs(const Inst *breakAddr, const Inst *continueAddr);
void StartLoopAddrList();
Expand Down
6 changes: 3 additions & 3 deletions Regex/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ constexpr R literal_escape(Ch ch) noexcept {
* octal escape. RegexError is thrown if \x0, \x00, \0, \00, \000, or
* \0000 is specified.
*--------------------------------------------------------------------*/
template <class R, class Ch>
R numeric_escape(Ch ch, const char **parse) {
template <class R, class Ch, class Iterator>
R numeric_escape(Ch ch, Iterator *parse) {

static const char digits[] = "fedcbaFEDCBA9876543210";

Expand Down Expand Up @@ -105,7 +105,7 @@ R numeric_escape(Ch ch, const char **parse) {
return '\0'; // Not a numeric escape
}

const char *scan = *parse;
Iterator scan = *parse;
scan++; // Only change *parse on success.

const char *pos_ptr = ::strchr(digit_str, static_cast<int>(*scan));
Expand Down
Loading