diff options
-rw-r--r-- | cpp/002main.cc | 37 | ||||
-rw-r--r-- | cpp/002main.test.cc | 7 |
2 files changed, 38 insertions, 6 deletions
diff --git a/cpp/002main.cc b/cpp/002main.cc index 7aac3d6b..c2baea50 100644 --- a/cpp/002main.cc +++ b/cpp/002main.cc @@ -101,7 +101,10 @@ struct type_info { vector<vector<type_number> > elements; // only if is_record or is_array }; -unordered_map<type_number, type_info> type; +typedef int type_number; +unordered_map<string, type_number> Type_name; +unordered_map<type_number, type_info> Type; +unordered_map<int, int> Memory; struct reagent { string name; @@ -110,15 +113,35 @@ struct reagent { }; struct instruction { - recipe_number op; - vector<reagent> ingredients; - vector<reagent> products; + bool is_label; + string label; // only if is_label + recipe_number operation; // only if !is_label + vector<reagent> ingredients; // only if !is_label + vector<reagent> products; // only if !is_label +}; + +struct recipe { + vector<instruction> step; }; -void load(const char* filename) { +unordered_map<int, recipe> Recipe; + +void load(string filename) { +} + +void run(string function_name) { +} + +void setup_memory() { + Memory.clear(); +} + +void setup_types() { + Type_name["integer"] = 1; + Type[1].size = 1; } -void run(const char* function_name) { +void compile(string form) { } @@ -148,6 +171,8 @@ void verify() { } void setup() { + setup_memory(); + setup_types(); Passed = true; } diff --git a/cpp/002main.test.cc b/cpp/002main.test.cc new file mode 100644 index 00000000..b622828b --- /dev/null +++ b/cpp/002main.test.cc @@ -0,0 +1,7 @@ +void test_literal() { + compile("function main [\n" + " 1:integer <- copy 23:literal\n" + "]\n"); + run("main"); + CHECK_EQ(Memory[1], 23); +} |