Skip to content
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
56 changes: 28 additions & 28 deletions src/compiler/llex.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,23 +99,23 @@ class InputScanner {

public:
// Accessors
inline int getCurrent() const noexcept { return current; }
inline int getLineNumber() const noexcept { return linenumber; }
inline int getLastLine() const noexcept { return lastline; }
inline ZIO* getZIO() const noexcept { return z; }
inline TString* getSource() const noexcept { return source; }
int getCurrent() const noexcept { return current; }
int getLineNumber() const noexcept { return linenumber; }
int getLastLine() const noexcept { return lastline; }
ZIO* getZIO() const noexcept { return z; }
TString* getSource() const noexcept { return source; }

inline void setCurrent(int c) noexcept { current = c; }
inline void setLineNumber(int line) noexcept { linenumber = line; }
inline void setLastLine(int line) noexcept { lastline = line; }
inline void setZIO(ZIO* zio) noexcept { z = zio; }
inline void setSource(TString* src) noexcept { source = src; }
void setCurrent(int c) noexcept { current = c; }
void setLineNumber(int line) noexcept { linenumber = line; }
void setLastLine(int line) noexcept { lastline = line; }
void setZIO(ZIO* zio) noexcept { z = zio; }
void setSource(TString* src) noexcept { source = src; }

inline int& getLineNumberRef() noexcept { return linenumber; }
int& getLineNumberRef() noexcept { return linenumber; }

// Operations
inline void next() noexcept { current = zgetc(z); }
inline bool currIsNewline() const noexcept { return current == '\n' || current == '\r'; }
void next() noexcept { current = zgetc(z); }
bool currIsNewline() const noexcept { return current == '\n' || current == '\r'; }
};

/* Phase 94: Subsystem for token state management */
Expand All @@ -126,10 +126,10 @@ class TokenState {

public:
// Accessors
inline const Token& getCurrent() const noexcept { return current; }
inline Token& getCurrentRef() noexcept { return current; }
inline const Token& getLookahead() const noexcept { return lookahead; }
inline Token& getLookaheadRef() noexcept { return lookahead; }
const Token& getCurrent() const noexcept { return current; }
Token& getCurrentRef() noexcept { return current; }
const Token& getLookahead() const noexcept { return lookahead; }
Token& getLookaheadRef() noexcept { return lookahead; }
};

/* Phase 94: Subsystem for string interning and buffer management */
Expand All @@ -143,17 +143,17 @@ class StringInterner {

public:
// Accessors
inline Mbuffer* getBuffer() const noexcept { return buff; }
inline Table* getTable() const noexcept { return h; }
inline TString* getEnvName() const noexcept { return envn; }
inline TString* getBreakName() const noexcept { return brkn; }
inline TString* getGlobalName() const noexcept { return glbn; }

inline void setBuffer(Mbuffer* b) noexcept { buff = b; }
inline void setTable(Table* table) noexcept { h = table; }
inline void setEnvName(TString* env) noexcept { envn = env; }
inline void setBreakName(TString* brk) noexcept { brkn = brk; }
inline void setGlobalName(TString* gbl) noexcept { glbn = gbl; }
Mbuffer* getBuffer() const noexcept { return buff; }
Table* getTable() const noexcept { return h; }
TString* getEnvName() const noexcept { return envn; }
TString* getBreakName() const noexcept { return brkn; }
TString* getGlobalName() const noexcept { return glbn; }

void setBuffer(Mbuffer* b) noexcept { buff = b; }
void setTable(Table* table) noexcept { h = table; }
void setEnvName(TString* env) noexcept { envn = env; }
void setBreakName(TString* brk) noexcept { brkn = brk; }
void setGlobalName(TString* gbl) noexcept { glbn = gbl; }
};

/* Phase 95: Lexical state - focused on tokenization only
Expand Down
152 changes: 76 additions & 76 deletions src/compiler/lparser.h
Original file line number Diff line number Diff line change
Expand Up @@ -221,27 +221,27 @@ class Labellist {
}

/* Accessor methods matching old interface */
inline Labeldesc* getArr() noexcept { return vec.data(); }
inline const Labeldesc* getArr() const noexcept { return vec.data(); }
inline int getN() const noexcept { return static_cast<int>(vec.size()); }
inline int getSize() const noexcept { return static_cast<int>(vec.capacity()); }
Labeldesc* getArr() noexcept { return vec.data(); }
const Labeldesc* getArr() const noexcept { return vec.data(); }
int getN() const noexcept { return static_cast<int>(vec.size()); }
int getSize() const noexcept { return static_cast<int>(vec.capacity()); }

/* Modifying size */
inline void setN(int new_n) { vec.resize(static_cast<size_t>(new_n)); }
void setN(int new_n) { vec.resize(static_cast<size_t>(new_n)); }

/* Direct vector access for modern operations */
inline void push_back(const Labeldesc& desc) { vec.push_back(desc); }
inline void reserve(int capacity) { vec.reserve(static_cast<size_t>(capacity)); }
inline Labeldesc& operator[](int index) { return vec[static_cast<size_t>(index)]; }
inline const Labeldesc& operator[](int index) const { return vec[static_cast<size_t>(index)]; }
void push_back(const Labeldesc& desc) { vec.push_back(desc); }
void reserve(int capacity) { vec.reserve(static_cast<size_t>(capacity)); }
Labeldesc& operator[](int index) { return vec[static_cast<size_t>(index)]; }
const Labeldesc& operator[](int index) const { return vec[static_cast<size_t>(index)]; }

/* For luaM_growvector replacement */
inline void ensureCapacity(int needed) {
void ensureCapacity(int needed) {
if (needed > getSize()) {
vec.reserve(static_cast<size_t>(needed));
}
}
inline Labeldesc* allocateNew() {
Labeldesc* allocateNew() {
vec.resize(vec.size() + 1);
return &vec.back();
}
Expand All @@ -264,25 +264,25 @@ class Dyndata {
}

/* Direct actvar accessor methods - avoid temporary object creation */
inline Vardesc* actvarGetArr() noexcept { return actvar_vec.data(); }
inline const Vardesc* actvarGetArr() const noexcept { return actvar_vec.data(); }
inline int actvarGetN() const noexcept { return static_cast<int>(actvar_vec.size()); }
inline int actvarGetSize() const noexcept { return static_cast<int>(actvar_vec.capacity()); }
Vardesc* actvarGetArr() noexcept { return actvar_vec.data(); }
const Vardesc* actvarGetArr() const noexcept { return actvar_vec.data(); }
int actvarGetN() const noexcept { return static_cast<int>(actvar_vec.size()); }
int actvarGetSize() const noexcept { return static_cast<int>(actvar_vec.capacity()); }

inline void actvarSetN(int new_n) { actvar_vec.resize(static_cast<size_t>(new_n)); }
inline Vardesc& actvarAt(int index) { return actvar_vec[static_cast<size_t>(index)]; }
inline const Vardesc& actvarAt(int index) const { return actvar_vec[static_cast<size_t>(index)]; }
void actvarSetN(int new_n) { actvar_vec.resize(static_cast<size_t>(new_n)); }
Vardesc& actvarAt(int index) { return actvar_vec[static_cast<size_t>(index)]; }
const Vardesc& actvarAt(int index) const { return actvar_vec[static_cast<size_t>(index)]; }

inline Vardesc* actvarAllocateNew() {
Vardesc* actvarAllocateNew() {
actvar_vec.resize(actvar_vec.size() + 1);
return &actvar_vec.back();
}

/* Phase 116: std::span accessors for actvar array */
inline std::span<Vardesc> actvarGetSpan() noexcept {
std::span<Vardesc> actvarGetSpan() noexcept {
return std::span(actvar_vec.data(), actvar_vec.size());
}
inline std::span<const Vardesc> actvarGetSpan() const noexcept {
std::span<const Vardesc> actvarGetSpan() const noexcept {
return std::span(actvar_vec.data(), actvar_vec.size());
}

Expand All @@ -292,13 +292,13 @@ class Dyndata {
Dyndata* dyn;
public:
explicit ActvarAccessor(Dyndata* d) : dyn(d) {}
inline int getN() const noexcept { return dyn->actvarGetN(); }
inline void setN(int n) { dyn->actvarSetN(n); }
inline Vardesc& operator[](int i) { return dyn->actvarAt(i); }
inline Vardesc* allocateNew() { return dyn->actvarAllocateNew(); }
int getN() const noexcept { return dyn->actvarGetN(); }
void setN(int n) { dyn->actvarSetN(n); }
Vardesc& operator[](int i) { return dyn->actvarAt(i); }
Vardesc* allocateNew() { return dyn->actvarAllocateNew(); }
};

inline ActvarAccessor actvar() noexcept { return ActvarAccessor{this}; }
ActvarAccessor actvar() noexcept { return ActvarAccessor{this}; }
};


Expand All @@ -324,35 +324,35 @@ class CodeBuffer {

public:
/* Inline accessors for reading */
inline int getPC() const noexcept { return pc; }
inline int getLastTarget() const noexcept { return lasttarget; }
inline int getPreviousLine() const noexcept { return previousline; }
inline int getNAbsLineInfo() const noexcept { return nabslineinfo; }
inline lu_byte getInstructionsWithAbs() const noexcept { return iwthabs; }
int getPC() const noexcept { return pc; }
int getLastTarget() const noexcept { return lasttarget; }
int getPreviousLine() const noexcept { return previousline; }
int getNAbsLineInfo() const noexcept { return nabslineinfo; }
lu_byte getInstructionsWithAbs() const noexcept { return iwthabs; }

/* Setters */
inline void setPC(int pc_) noexcept { pc = pc_; }
inline void setLastTarget(int lasttarget_) noexcept { lasttarget = lasttarget_; }
inline void setPreviousLine(int previousline_) noexcept { previousline = previousline_; }
inline void setNAbsLineInfo(int nabslineinfo_) noexcept { nabslineinfo = nabslineinfo_; }
inline void setInstructionsWithAbs(lu_byte iwthabs_) noexcept { iwthabs = iwthabs_; }
void setPC(int pc_) noexcept { pc = pc_; }
void setLastTarget(int lasttarget_) noexcept { lasttarget = lasttarget_; }
void setPreviousLine(int previousline_) noexcept { previousline = previousline_; }
void setNAbsLineInfo(int nabslineinfo_) noexcept { nabslineinfo = nabslineinfo_; }
void setInstructionsWithAbs(lu_byte iwthabs_) noexcept { iwthabs = iwthabs_; }

/* Increment/decrement methods */
inline void incrementPC() noexcept { pc++; }
inline void decrementPC() noexcept { pc--; }
inline int postIncrementPC() noexcept { return pc++; }
inline void incrementNAbsLineInfo() noexcept { nabslineinfo++; }
inline void decrementNAbsLineInfo() noexcept { nabslineinfo--; }
inline int postIncrementNAbsLineInfo() noexcept { return nabslineinfo++; }
inline lu_byte postIncrementInstructionsWithAbs() noexcept { return iwthabs++; }
inline void decrementInstructionsWithAbs() noexcept { iwthabs--; }
void incrementPC() noexcept { pc++; }
void decrementPC() noexcept { pc--; }
int postIncrementPC() noexcept { return pc++; }
void incrementNAbsLineInfo() noexcept { nabslineinfo++; }
void decrementNAbsLineInfo() noexcept { nabslineinfo--; }
int postIncrementNAbsLineInfo() noexcept { return nabslineinfo++; }
lu_byte postIncrementInstructionsWithAbs() noexcept { return iwthabs++; }
void decrementInstructionsWithAbs() noexcept { iwthabs--; }

/* Reference accessors for compound assignments */
inline int& getPCRef() noexcept { return pc; }
inline int& getLastTargetRef() noexcept { return lasttarget; }
inline int& getPreviousLineRef() noexcept { return previousline; }
inline int& getNAbsLineInfoRef() noexcept { return nabslineinfo; }
inline lu_byte& getInstructionsWithAbsRef() noexcept { return iwthabs; }
int& getPCRef() noexcept { return pc; }
int& getLastTargetRef() noexcept { return lasttarget; }
int& getPreviousLineRef() noexcept { return previousline; }
int& getNAbsLineInfoRef() noexcept { return nabslineinfo; }
lu_byte& getInstructionsWithAbsRef() noexcept { return iwthabs; }
};


Expand All @@ -364,17 +364,17 @@ class ConstantPool {

public:
/* Inline accessors */
inline Table* getCache() const noexcept { return cache; }
inline int getCount() const noexcept { return count; }
Table* getCache() const noexcept { return cache; }
int getCount() const noexcept { return count; }

inline void setCache(Table* cache_) noexcept { cache = cache_; }
inline void setCount(int count_) noexcept { count = count_; }
void setCache(Table* cache_) noexcept { cache = cache_; }
void setCount(int count_) noexcept { count = count_; }

/* Increment */
inline void incrementCount() noexcept { count++; }
void incrementCount() noexcept { count++; }

/* Reference accessor */
inline int& getCountRef() noexcept { return count; }
int& getCountRef() noexcept { return count; }
};


Expand All @@ -388,22 +388,22 @@ class VariableScope {

public:
/* Inline accessors */
inline int getFirstLocal() const noexcept { return firstlocal; }
inline int getFirstLabel() const noexcept { return firstlabel; }
inline short getNumDebugVars() const noexcept { return ndebugvars; }
inline short getNumActiveVars() const noexcept { return nactvar; }
int getFirstLocal() const noexcept { return firstlocal; }
int getFirstLabel() const noexcept { return firstlabel; }
short getNumDebugVars() const noexcept { return ndebugvars; }
short getNumActiveVars() const noexcept { return nactvar; }

inline void setFirstLocal(int firstlocal_) noexcept { firstlocal = firstlocal_; }
inline void setFirstLabel(int firstlabel_) noexcept { firstlabel = firstlabel_; }
inline void setNumDebugVars(short ndebugvars_) noexcept { ndebugvars = ndebugvars_; }
inline void setNumActiveVars(short nactvar_) noexcept { nactvar = nactvar_; }
void setFirstLocal(int firstlocal_) noexcept { firstlocal = firstlocal_; }
void setFirstLabel(int firstlabel_) noexcept { firstlabel = firstlabel_; }
void setNumDebugVars(short ndebugvars_) noexcept { ndebugvars = ndebugvars_; }
void setNumActiveVars(short nactvar_) noexcept { nactvar = nactvar_; }

/* Increment */
inline short postIncrementNumDebugVars() noexcept { return ndebugvars++; }
short postIncrementNumDebugVars() noexcept { return ndebugvars++; }

/* Reference accessors */
inline short& getNumDebugVarsRef() noexcept { return ndebugvars; }
inline short& getNumActiveVarsRef() noexcept { return nactvar; }
short& getNumDebugVarsRef() noexcept { return ndebugvars; }
short& getNumActiveVarsRef() noexcept { return nactvar; }
};


Expand All @@ -414,14 +414,14 @@ class RegisterAllocator {

public:
/* Inline accessors */
inline lu_byte getFreeReg() const noexcept { return freereg; }
inline void setFreeReg(lu_byte freereg_) noexcept { freereg = freereg_; }
lu_byte getFreeReg() const noexcept { return freereg; }
void setFreeReg(lu_byte freereg_) noexcept { freereg = freereg_; }

/* Decrement */
inline void decrementFreeReg() noexcept { freereg--; }
void decrementFreeReg() noexcept { freereg--; }

/* Reference accessor */
inline lu_byte& getFreeRegRef() noexcept { return freereg; }
lu_byte& getFreeRegRef() noexcept { return freereg; }
};


Expand All @@ -433,15 +433,15 @@ class UpvalueTracker {

public:
/* Inline accessors */
inline lu_byte getNumUpvalues() const noexcept { return nups; }
inline lu_byte getNeedClose() const noexcept { return needclose; }
lu_byte getNumUpvalues() const noexcept { return nups; }
lu_byte getNeedClose() const noexcept { return needclose; }

inline void setNumUpvalues(lu_byte nups_) noexcept { nups = nups_; }
inline void setNeedClose(lu_byte needclose_) noexcept { needclose = needclose_; }
void setNumUpvalues(lu_byte nups_) noexcept { nups = nups_; }
void setNeedClose(lu_byte needclose_) noexcept { needclose = needclose_; }

/* Reference accessors */
inline lu_byte& getNumUpvaluesRef() noexcept { return nups; }
inline lu_byte& getNeedCloseRef() noexcept { return needclose; }
lu_byte& getNumUpvaluesRef() noexcept { return nups; }
lu_byte& getNeedCloseRef() noexcept { return needclose; }
};


Expand Down
Loading
Loading