Website Summary Files Commits Branches @commit @diff @stats
path: root / JSImpl / src / ASTInterpreter.h
diff options
context:
space:
mode:
Commit64a545c0c9988755a1b022bffd5f4303d0070af2 (patch)
Author
 Dimitar Trendafilov <dimitar@coherent-labs.com>
2020-11-09 22:09:38 +0200
Committer
 Dimitar Trendafilov <dimitar@coherent-labs.com>
2020-11-09 22:09:38 +0200
Files99816280741e7e6d6a8460ed216484b84fd4aefc /JSImpl/src/ASTInterpreter.h
IPL-64a545c0c9988755a1b022bffd5f4303d0070af2.tar
IPL-64a545c0c9988755a1b022bffd5f4303d0070af2.tar.gz
IPL-64a545c0c9988755a1b022bffd5f4303d0070af2.zip
Parent1d2838877d4b905c68578e5bd4c01ab2857099ee (diff)
Parentf4598a0e6deb5fb1a63b4fc125804aa85ca818bd (diff)
Merge branch 'feature/interpreter_string'
1 files changed, 7 insertions, 5 deletions
-rw-r--r--JSImpl/src/ASTInterpreter.h12
diff --git a/JSImpl/src/ASTInterpreter.h b/JSImpl/src/ASTInterpreter.h
index db89013..cce6108 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,9 @@ 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 double value_type;
- typedef IPLVector<value_type> ValueStack;
+ typedef std::variant<double, IPLString> Value;
+ typedef IPLSharedPtr<Value> ValuePtr;
+ typedef IPLVector<ValuePtr> ValueStack;
ValueStack Run(Expression* program);
@@ -39,13 +40,14 @@ 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
{
public:
virtual void PrintVariable(const char* name, double value) = 0;
+ virtual void PrintVariable(const char* name, const IPLString& value) = 0;
};
void Print(Printer& p);