diff options
Diffstat (limited to 'evaluate.h')
-rw-r--r-- | evaluate.h | 21 |
1 files changed, 17 insertions, 4 deletions
@@ -36,12 +36,18 @@ public: Type type; double numval; string strval; - ScopeVal *scopeval; + ScopeVal *scopeval=nullptr; Value(); Value(double numval); Value(const string &strval); Value(ScopeVal *scopeval); + Value(const Value &other); + Value(Value &&other); + ~Value(); + + Value& operator=(const Value &other) = delete; + Value& operator=(Value &&other) = delete; }; class ScopeVal{ @@ -69,11 +75,12 @@ namespace A { class Assembly{ class Instruction{ public: - enum class Type{ // Effect on the value stack is given + enum class Type{ pushnil, // [ -> nil] pushnum, // [ -> this.num] pushstr, // [ -> this.str] pushscope, // [ -> this.scope] + newscope, // [ -> {}] pop, // [x -> ] swap, // [x,y -> y,x] add, // [x,y -> x+y] @@ -84,7 +91,7 @@ class Assembly{ create, // [value -> ] Creates binding this.name in the top scope store, // [value -> ] Stores in the first scope to contain a this.name binding load, // [ -> value] Retrieves from the first scope to contain a this.name binding - enter, // [scope -> ] Pushes the given scope on the scope stack + enter, // [scope -> scope] Copies the given scope to the scope stack leave, // [ -> ] Pops from the scope stack call, // [scope,arg,...,arg -> scope] Pops this.nargs arguments and replaces for names from scope.scopeDef.args }; @@ -92,7 +99,7 @@ class Assembly{ Type type; double num; string str; - ScopeDef *scope; + ScopeDef *scope=nullptr; string name; int nargs; @@ -101,6 +108,12 @@ class Assembly{ Instruction(Type type,const string &str); // pushstr, create, store, load Instruction(Type type,ScopeDef *scope); // pushscope Instruction(Type type,int nargs); // call + Instruction(const Instruction &other); + Instruction(Instruction &&other); + ~Instruction(); + + Instruction& operator=(const Instruction &other) = delete; + Instruction& operator=(Instruction &&other) = delete; }; vector<Instruction> listing; |