Allow local variables to be used in eval.

This commit is contained in:
Jeff Hutchinson 2021-09-20 21:00:33 -04:00
parent 5137e54a7c
commit 2d50f52cf1
5 changed files with 90 additions and 54 deletions

View file

@ -276,6 +276,35 @@ namespace Compiler
void consoleAllocReset();
extern bool gSyntaxError;
extern bool gIsEvalCompile;
};
class FuncVars
{
struct Var
{
S32 reg;
TypeReq currentType;
StringTableEntry name;
bool isConstant;
};
public:
S32 assign(StringTableEntry var, TypeReq currentType, S32 lineNumber, bool isConstant = false);
S32 lookup(StringTableEntry var, S32 lineNumber);
TypeReq lookupType(StringTableEntry var, S32 lineNumber);
inline S32 count() { return counter; }
std::unordered_map<S32, StringTableEntry> variableNameMap;
void clear();
private:
std::unordered_map<StringTableEntry, Var> vars;
S32 counter = 0;
};
/// Utility class to emit and patch bytecode