Website Summary Files Commits Branches @commit @diff @stats
path: root / JSImpl / src / ASTInterpreter.h
diff options
context:
space:
mode:
1 files changed, 17 insertions, 7 deletions
-rw-r--r--JSImpl/src/ASTInterpreter.h24
diff --git a/JSImpl/src/ASTInterpreter.h b/JSImpl/src/ASTInterpreter.h
index 1ffecde..4d5b46f 100644
--- a/JSImpl/src/ASTInterpreter.h
+++ b/JSImpl/src/ASTInterpreter.h
@@ -11,10 +11,10 @@ public:
ASTInterpreter();
~ASTInterpreter();
- typedef double value_type;
- typedef std::stack<value_type> ValueStack;
+ typedef double value_type;
+ typedef IPLStack<value_type> ValueStack;
- ValueStack Run(Expression* program);
+ ValueStack Run(Expression* program);
virtual void Visit(LiteralNull* e) override;
virtual void Visit(LiteralUndefined* e) override;
@@ -36,9 +36,19 @@ public:
virtual void Visit(FunctionDeclaration* e) override;
virtual void Visit(TopStatements* e) override;
virtual void Visit(EmptyExpression* e) override;
+
+ value_type& ModifyVariable(const IPLString& name);
private:
- void RunExpression(const ExpressionPtr& e);
- bool EvalToBool(const ExpressionPtr& e);
- ValueStack m_Evaluation;
- std::unordered_map<std::string, ValueStack> m_Variables;
+ void RunExpression(const ExpressionPtr& e);
+ bool EvalToBool(const ExpressionPtr& e);
+
+ void EnterScope();
+ void LeaveScope();
+ friend struct VariableScope;
+
+ ValueStack m_Evaluation;
+ IPLUnorderedMap<IPLString, ValueStack> m_Variables;
+
+ typedef IPLVector<IPLString> Scope;
+ IPLStack<Scope> m_Scopes;
};