summaryrefslogtreecommitdiff
path: root/evaluate.h
diff options
context:
space:
mode:
Diffstat (limited to 'evaluate.h')
-rw-r--r--evaluate.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/evaluate.h b/evaluate.h
index e2dc241..9571626 100644
--- a/evaluate.h
+++ b/evaluate.h
@@ -23,6 +23,7 @@ public:
class ScopeVal;
+class Assembly;
class Value{
public:
@@ -31,17 +32,21 @@ public:
number, // numval
string, // strval
scope, // scopeval
+ lazy, // asmval
+ function, // asmval
};
Type type;
double numval;
string strval;
ScopeVal *scopeval=nullptr;
+ Assembly *asmval=nullptr;
Value();
Value(double numval);
Value(const string &strval);
Value(ScopeVal *scopeval);
+ Value(Type type,Assembly *asmval); // lazy, function
Value(const Value &other);
Value(Value &&other);
~Value();
@@ -80,6 +85,7 @@ class Assembly{
pushnum, // [ -> this.num]
pushstr, // [ -> this.str]
pushscope, // [ -> this.scope]
+ pushfunc, // [ -> Value(function,this.asmval)]
newscope, // [ -> {}]
pop, // [x -> ]
swap, // [x,y -> y,x]
@@ -102,12 +108,14 @@ class Assembly{
ScopeDef *scope=nullptr;
string name;
int nargs;
+ Assembly *asmval=nullptr;
Instruction(Type type);
Instruction(Type type,double num); // pushnum
Instruction(Type type,const string &str); // pushstr, create, store, load
Instruction(Type type,ScopeDef *scope); // pushscope
Instruction(Type type,int nargs); // call
+ Instruction(Type type,Assembly *asmval); // pushfunc
Instruction(const Instruction &other);
Instruction(Instruction &&other);
~Instruction();
@@ -122,6 +130,8 @@ class Assembly{
void codegen(const Statement &stmt);
void codegen(const Expression &expr);
+ Assembly(const ScopeDef &scopeDef);
+
public:
Assembly(const StatementList &stl);