diff options
| Commit | b93662dbcc9d30c69cce7d1342606cafc60bb3f0 (patch) | |
|---|---|---|
| Author | 2020-11-01 20:48:23 +0200 | |
| Committer | 2020-11-09 22:08:19 +0200 | |
| Files | 31e6eaa74e028fb21d64deb4220da652b95b69bc /JSImpl/src | |
| IPL-b93662dbcc9d30c69cce7d1342606cafc60bb3f0.tar IPL-b93662dbcc9d30c69cce7d1342606cafc60bb3f0.tar.gz IPL-b93662dbcc9d30c69cce7d1342606cafc60bb3f0.zip | ||
| Parent | 70a7bd82774843a5750fb96c0d7e51553505811c (diff) | |
Fix name of ASTInterpreter value type
2 files changed, 11 insertions, 11 deletions
| -rw-r--r-- | JSImpl/src/ASTInterpreter.cpp | 12 | ||||
| -rw-r--r-- | JSImpl/src/ASTInterpreter.h | 10 |
diff --git a/JSImpl/src/ASTInterpreter.cpp b/JSImpl/src/ASTInterpreter.cpp index d5017aa..ae0d2b5 100644 --- a/JSImpl/src/ASTInterpreter.cpp +++ b/JSImpl/src/ASTInterpreter.cpp @@ -9,13 +9,13 @@ namespace { template <typename T> - ASTInterpreter::value_type MakeValue(T&& v) + ASTInterpreter::ValuePtr MakeValue(T&& v) { return IPLMakeSharePtr<double>(v); } template <typename T> - ASTInterpreter::value_type MakeValue(const T& v) + ASTInterpreter::ValuePtr MakeValue(const T& v) { return IPLMakeSharePtr<double>(v); } @@ -29,7 +29,7 @@ public: {} ~LValueExtractor() {} - ASTInterpreter::value_type Run(Expression* program) + ASTInterpreter::ValuePtr Run(Expression* program) { m_LValue = nullptr; program->Accept(*this); @@ -39,7 +39,7 @@ public: virtual void Visit(IdentifierExpression* e) override { m_LValue = m_Interpreter->ModifyVariable(e->GetName()); } ASTInterpreter* m_Interpreter; - ASTInterpreter::value_type m_LValue; + ASTInterpreter::ValuePtr m_LValue; }; @@ -134,7 +134,7 @@ void ASTInterpreter::LeaveScope() m_Scopes.pop(); } -ASTInterpreter::value_type& ASTInterpreter::ModifyVariable(const IPLString& name) +ASTInterpreter::ValuePtr& ASTInterpreter::ModifyVariable(const IPLString& name) { auto values = m_Variables.find(name); if (values != m_Variables.end()) { @@ -143,7 +143,7 @@ ASTInterpreter::value_type& ASTInterpreter::ModifyVariable(const IPLString& name else { assert(0 && "not-defined"); } - static value_type undefined; + static ValuePtr undefined; return undefined; } diff --git a/JSImpl/src/ASTInterpreter.h b/JSImpl/src/ASTInterpreter.h index 16aebfa..e8dae37 100644 --- a/JSImpl/src/ASTInterpreter.h +++ b/JSImpl/src/ASTInterpreter.h @@ -2,6 +2,8 @@ #include "ExpressionVisitor.h" +#include <variant> + class ASTInterpreter : public ExpressionVisitor { public: @@ -9,10 +11,8 @@ public: ~ASTInterpreter(); - // TODO: Changing this to a shared_ptr<Value> (or GC-enabled value*) will - // allow for much simpler implementation of all varible assignments. - typedef IPLSharedPtr<double> value_type; - typedef IPLVector<value_type> ValueStack; + typedef IPLSharedPtr<double> ValuePtr; + typedef IPLVector<ValuePtr> ValueStack; ValueStack Run(Expression* program); @@ -39,7 +39,7 @@ public: virtual void Visit(EmptyExpression* e) override; virtual void Visit(CallExpression* e) override; - value_type& ModifyVariable(const IPLString& name); + ValuePtr& ModifyVariable(const IPLString& name); bool HasVariable(const IPLString& name); class Printer |
