diff options
-rw-r--r-- | cpp/002test.cc | 4 | ||||
-rw-r--r-- | cpp/010vm.cc | 6 | ||||
-rw-r--r-- | cpp/020run.cc | 12 | ||||
-rw-r--r-- | cpp/021arithmetic.cc | 32 | ||||
-rw-r--r-- | cpp/022boolean.cc | 16 | ||||
-rw-r--r-- | cpp/023jump.cc | 4 | ||||
-rw-r--r-- | cpp/024compare.cc | 30 | ||||
-rw-r--r-- | cpp/026assert.cc | 2 | ||||
-rw-r--r-- | cpp/027debug.cc | 2 | ||||
-rw-r--r-- | cpp/030container.cc | 18 | ||||
-rw-r--r-- | cpp/031address.cc | 8 | ||||
-rw-r--r-- | cpp/032array.cc | 18 | ||||
-rw-r--r-- | cpp/033length.cc | 2 | ||||
-rw-r--r-- | cpp/034exclusive_container.cc | 6 | ||||
-rw-r--r-- | cpp/036call_ingredient.cc | 10 | ||||
-rw-r--r-- | cpp/037call_reply.cc | 6 | ||||
-rw-r--r-- | cpp/042new.cc | 6 | ||||
-rw-r--r-- | cpp/043space.cc | 12 | ||||
-rw-r--r-- | cpp/044space_surround.cc | 10 | ||||
-rw-r--r-- | cpp/070display.cc | 16 |
20 files changed, 110 insertions, 110 deletions
diff --git a/cpp/002test.cc b/cpp/002test.cc index af56ae97..488bbff4 100644 --- a/cpp/002test.cc +++ b/cpp/002test.cc @@ -82,9 +82,9 @@ bool is_number(const string& s) { return s.find_first_not_of("0123456789-.") == string::npos; } -int to_int(string n) { +long long int to_int(string n) { char* end = NULL; - int result = strtol(n.c_str(), &end, /*any base*/0); + long long int result = strtoll(n.c_str(), &end, /*any base*/0); assert(*end == '\0'); return result; } diff --git a/cpp/010vm.cc b/cpp/010vm.cc index 12558073..38fc582c 100644 --- a/cpp/010vm.cc +++ b/cpp/010vm.cc @@ -41,12 +41,12 @@ struct instruction { struct reagent { vector<pair<string, vector<string> > > properties; string name; - int value; + long long int value; bool initialized; vector<type_number> types; reagent(string s); reagent(); - void set_value(int v) { value = v; initialized = true; } + void set_value(long long int v) { value = v; initialized = true; } string to_string() const; }; @@ -57,7 +57,7 @@ struct property { :(before "End Globals") // Locations refer to a common 'memory'. Each location can store a number. -map<index_t, int> Memory; +map<index_t, long long int> Memory; :(before "End Setup") Memory.clear(); diff --git a/cpp/020run.cc b/cpp/020run.cc index 9fc1f624..10e463b6 100644 --- a/cpp/020run.cc +++ b/cpp/020run.cc @@ -60,7 +60,7 @@ void run_current_routine() // Primitive Recipe Implementations case COPY: { trace("run") << "ingredient 0 is " << current_instruction().ingredients[0].name; - vector<int> data = read_memory(current_instruction().ingredients[0]); + vector<long long int> data = read_memory(current_instruction().ingredients[0]); write_memory(current_instruction().products[0], data); break; } @@ -144,14 +144,14 @@ void run(string form) { //:: Reading from memory, writing to memory. -vector<int> read_memory(reagent x) { +vector<long long int> read_memory(reagent x) { //? cout << "read_memory: " << x.to_string() << '\n'; //? 1 - vector<int> result; + vector<long long int> result; if (isa_literal(x)) { result.push_back(x.value); return result; } - int base = x.value; + index_t base = x.value; size_t size = size_of(x); for (index_t offset = 0; offset < size; ++offset) { int val = Memory[base+offset]; @@ -161,9 +161,9 @@ vector<int> read_memory(reagent x) { return result; } -void write_memory(reagent x, vector<int> data) { +void write_memory(reagent x, vector<long long int> data) { if (is_dummy(x)) return; - int base = x.value; + index_t base = x.value; if (size_of(x) != data.size()) raise << "size mismatch in storing to " << x.to_string() << '\n'; for (index_t offset = 0; offset < data.size(); ++offset) { diff --git a/cpp/021arithmetic.cc b/cpp/021arithmetic.cc index 7f7ab0f0..e9496248 100644 --- a/cpp/021arithmetic.cc +++ b/cpp/021arithmetic.cc @@ -7,12 +7,12 @@ Recipe_number["add"] = ADD; :(before "End Primitive Recipe Implementations") case ADD: { trace("run") << "ingredient 0 is " << current_instruction().ingredients[0].name; - vector<int> arg0 = read_memory(current_instruction().ingredients[0]); + vector<long long int> arg0 = read_memory(current_instruction().ingredients[0]); assert(arg0.size() == 1); trace("run") << "ingredient 1 is " << current_instruction().ingredients[1].name; - vector<int> arg1 = read_memory(current_instruction().ingredients[1]); + vector<long long int> arg1 = read_memory(current_instruction().ingredients[1]); assert(arg1.size() == 1); - vector<int> result; + vector<long long int> result; result.push_back(arg0[0] + arg1[0]); trace("run") << "product 0 is " << result[0]; write_memory(current_instruction().products[0], result); @@ -50,12 +50,12 @@ Recipe_number["subtract"] = SUBTRACT; :(before "End Primitive Recipe Implementations") case SUBTRACT: { trace("run") << "ingredient 0 is " << current_instruction().ingredients[0].name; - vector<int> arg0 = read_memory(current_instruction().ingredients[0]); + vector<long long int> arg0 = read_memory(current_instruction().ingredients[0]); assert(arg0.size() == 1); trace("run") << "ingredient 1 is " << current_instruction().ingredients[1].name; - vector<int> arg1 = read_memory(current_instruction().ingredients[1]); + vector<long long int> arg1 = read_memory(current_instruction().ingredients[1]); assert(arg1.size() == 1); - vector<int> result; + vector<long long int> result; result.push_back(arg0[0] - arg1[0]); trace("run") << "product 0 is " << result[0]; write_memory(current_instruction().products[0], result); @@ -93,13 +93,13 @@ Recipe_number["multiply"] = MULTIPLY; :(before "End Primitive Recipe Implementations") case MULTIPLY: { trace("run") << "ingredient 0 is " << current_instruction().ingredients[0].name; - vector<int> arg0 = read_memory(current_instruction().ingredients[0]); + vector<long long int> arg0 = read_memory(current_instruction().ingredients[0]); assert(arg0.size() == 1); trace("run") << "ingredient 1 is " << current_instruction().ingredients[1].name; - vector<int> arg1 = read_memory(current_instruction().ingredients[1]); + vector<long long int> arg1 = read_memory(current_instruction().ingredients[1]); assert(arg1.size() == 1); trace("run") << "ingredient 1 is " << arg1[0]; - vector<int> result; + vector<long long int> result; result.push_back(arg0[0] * arg1[0]); trace("run") << "product 0 is " << result[0]; write_memory(current_instruction().products[0], result); @@ -137,13 +137,13 @@ Recipe_number["divide"] = DIVIDE; :(before "End Primitive Recipe Implementations") case DIVIDE: { trace("run") << "ingredient 0 is " << current_instruction().ingredients[0].name; - vector<int> arg0 = read_memory(current_instruction().ingredients[0]); + vector<long long int> arg0 = read_memory(current_instruction().ingredients[0]); assert(arg0.size() == 1); trace("run") << "ingredient 1 is " << current_instruction().ingredients[1].name; - vector<int> arg1 = read_memory(current_instruction().ingredients[1]); + vector<long long int> arg1 = read_memory(current_instruction().ingredients[1]); assert(arg1.size() == 1); trace("run") << "ingredient 1 is " << arg1[0]; - vector<int> result; + vector<long long int> result; result.push_back(arg0[0] / arg1[0]); trace("run") << "product 0 is " << result[0]; write_memory(current_instruction().products[0], result); @@ -181,16 +181,16 @@ Recipe_number["divide-with-remainder"] = DIVIDE_WITH_REMAINDER; :(before "End Primitive Recipe Implementations") case DIVIDE_WITH_REMAINDER: { trace("run") << "ingredient 0 is " << current_instruction().ingredients[0].name; - vector<int> arg0 = read_memory(current_instruction().ingredients[0]); + vector<long long int> arg0 = read_memory(current_instruction().ingredients[0]); assert(arg0.size() == 1); trace("run") << "ingredient 1 is " << current_instruction().ingredients[1].name; - vector<int> arg1 = read_memory(current_instruction().ingredients[1]); + vector<long long int> arg1 = read_memory(current_instruction().ingredients[1]); assert(arg1.size() == 1); - vector<int> result0; + vector<long long int> result0; result0.push_back(arg0[0] / arg1[0]); trace("run") << "product 0 is " << result0[0]; write_memory(current_instruction().products[0], result0); - vector<int> result1; + vector<long long int> result1; result1.push_back(arg0[0] % arg1[0]); trace("run") << "product 1 is " << result1[0]; write_memory(current_instruction().products[1], result1); diff --git a/cpp/022boolean.cc b/cpp/022boolean.cc index 014774db..013519fd 100644 --- a/cpp/022boolean.cc +++ b/cpp/022boolean.cc @@ -7,12 +7,12 @@ Recipe_number["and"] = AND; :(before "End Primitive Recipe Implementations") case AND: { trace("run") << "ingredient 0 is " << current_instruction().ingredients[0].name; - vector<int> arg0 = read_memory(current_instruction().ingredients[0]); + vector<long long int> arg0 = read_memory(current_instruction().ingredients[0]); assert(arg0.size() == 1); trace("run") << "ingredient 1 is " << current_instruction().ingredients[1].name; - vector<int> arg1 = read_memory(current_instruction().ingredients[1]); + vector<long long int> arg1 = read_memory(current_instruction().ingredients[1]); assert(arg1.size() == 1); - vector<int> result; + vector<long long int> result; result.push_back(arg0[0] && arg1[0]); trace("run") << "product 0 is " << result[0]; write_memory(current_instruction().products[0], result); @@ -40,12 +40,12 @@ Recipe_number["or"] = OR; :(before "End Primitive Recipe Implementations") case OR: { trace("run") << "ingredient 0 is " << current_instruction().ingredients[0].name; - vector<int> arg0 = read_memory(current_instruction().ingredients[0]); + vector<long long int> arg0 = read_memory(current_instruction().ingredients[0]); assert(arg0.size() == 1); trace("run") << "ingredient 1 is " << current_instruction().ingredients[1].name; - vector<int> arg1 = read_memory(current_instruction().ingredients[1]); + vector<long long int> arg1 = read_memory(current_instruction().ingredients[1]); assert(arg1.size() == 1); - vector<int> result; + vector<long long int> result; result.push_back(arg0[0] || arg1[0]); trace("run") << "product 0 is " << result[0]; write_memory(current_instruction().products[0], result); @@ -73,9 +73,9 @@ Recipe_number["not"] = NOT; :(before "End Primitive Recipe Implementations") case NOT: { trace("run") << "ingredient 0 is " << current_instruction().ingredients[0].name; - vector<int> arg0 = read_memory(current_instruction().ingredients[0]); + vector<long long int> arg0 = read_memory(current_instruction().ingredients[0]); assert(arg0.size() == 1); - vector<int> result; + vector<long long int> result; result.push_back(!arg0[0]); trace("run") << "product 0 is " << result[0]; write_memory(current_instruction().products[0], result); diff --git a/cpp/023jump.cc b/cpp/023jump.cc index 932d0da8..7e649ddd 100644 --- a/cpp/023jump.cc +++ b/cpp/023jump.cc @@ -39,7 +39,7 @@ JUMP_IF, Recipe_number["jump-if"] = JUMP_IF; :(before "End Primitive Recipe Implementations") case JUMP_IF: { - vector<int> arg0 = read_memory(current_instruction().ingredients[0]); + vector<long long int> arg0 = read_memory(current_instruction().ingredients[0]); assert(arg0.size() == 1); trace("run") << "ingredient 0 is " << arg0[0]; if (!arg0[0]) { @@ -79,7 +79,7 @@ JUMP_UNLESS, Recipe_number["jump-unless"] = JUMP_UNLESS; :(before "End Primitive Recipe Implementations") case JUMP_UNLESS: { - vector<int> arg0 = read_memory(current_instruction().ingredients[0]); + vector<long long int> arg0 = read_memory(current_instruction().ingredients[0]); assert(arg0.size() == 1); trace("run") << "ingredient 0 is " << arg0[0]; if (arg0[0]) { diff --git a/cpp/024compare.cc b/cpp/024compare.cc index 3445809c..91cea1e6 100644 --- a/cpp/024compare.cc +++ b/cpp/024compare.cc @@ -7,10 +7,10 @@ Recipe_number["equal"] = EQUAL; :(before "End Primitive Recipe Implementations") case EQUAL: { trace("run") << "ingredient 0 is " << current_instruction().ingredients[0].name; - vector<int> arg0 = read_memory(current_instruction().ingredients[0]); + vector<long long int> arg0 = read_memory(current_instruction().ingredients[0]); trace("run") << "ingredient 1 is " << current_instruction().ingredients[1].name; - vector<int> arg1 = read_memory(current_instruction().ingredients[1]); - vector<int> result; + vector<long long int> arg1 = read_memory(current_instruction().ingredients[1]); + vector<long long int> result; result.push_back(equal(arg0.begin(), arg0.end(), arg1.begin())); trace("run") << "product 0 is " << result[0]; write_memory(current_instruction().products[0], result); @@ -52,12 +52,12 @@ Recipe_number["greater-than"] = GREATER_THAN; :(before "End Primitive Recipe Implementations") case GREATER_THAN: { trace("run") << "ingredient 0 is " << current_instruction().ingredients[0].name; - vector<int> arg0 = read_memory(current_instruction().ingredients[0]); + vector<long long int> arg0 = read_memory(current_instruction().ingredients[0]); assert(arg0.size() == 1); trace("run") << "ingredient 1 is " << current_instruction().ingredients[1].name; - vector<int> arg1 = read_memory(current_instruction().ingredients[1]); + vector<long long int> arg1 = read_memory(current_instruction().ingredients[1]); assert(arg1.size() == 1); - vector<int> result; + vector<long long int> result; result.push_back(arg0[0] > arg1[0]); trace("run") << "product 0 is " << result[0]; write_memory(current_instruction().products[0], result); @@ -99,12 +99,12 @@ Recipe_number["lesser-than"] = LESSER_THAN; :(before "End Primitive Recipe Implementations") case LESSER_THAN: { trace("run") << "ingredient 0 is " << current_instruction().ingredients[0].name; - vector<int> arg0 = read_memory(current_instruction().ingredients[0]); + vector<long long int> arg0 = read_memory(current_instruction().ingredients[0]); assert(arg0.size() == 1); trace("run") << "ingredient 1 is " << current_instruction().ingredients[1].name; - vector<int> arg1 = read_memory(current_instruction().ingredients[1]); + vector<long long int> arg1 = read_memory(current_instruction().ingredients[1]); assert(arg1.size() == 1); - vector<int> result; + vector<long long int> result; result.push_back(arg0[0] < arg1[0]); trace("run") << "product 0 is " << result[0]; write_memory(current_instruction().products[0], result); @@ -146,12 +146,12 @@ Recipe_number["greater-or-equal"] = GREATER_OR_EQUAL; :(before "End Primitive Recipe Implementations") case GREATER_OR_EQUAL: { trace("run") << "ingredient 0 is " << current_instruction().ingredients[0].name; - vector<int> arg0 = read_memory(current_instruction().ingredients[0]); + vector<long long int> arg0 = read_memory(current_instruction().ingredients[0]); assert(arg0.size() == 1); trace("run") << "ingredient 1 is " << current_instruction().ingredients[1].name; - vector<int> arg1 = read_memory(current_instruction().ingredients[1]); + vector<long long int> arg1 = read_memory(current_instruction().ingredients[1]); assert(arg1.size() == 1); - vector<int> result; + vector<long long int> result; result.push_back(arg0[0] >= arg1[0]); trace("run") << "product 0 is " << result[0]; write_memory(current_instruction().products[0], result); @@ -207,12 +207,12 @@ Recipe_number["lesser-or-equal"] = LESSER_OR_EQUAL; :(before "End Primitive Recipe Implementations") case LESSER_OR_EQUAL: { trace("run") << "ingredient 0 is " << current_instruction().ingredients[0].name; - vector<int> arg0 = read_memory(current_instruction().ingredients[0]); + vector<long long int> arg0 = read_memory(current_instruction().ingredients[0]); assert(arg0.size() == 1); trace("run") << "ingredient 1 is " << current_instruction().ingredients[1].name; - vector<int> arg1 = read_memory(current_instruction().ingredients[1]); + vector<long long int> arg1 = read_memory(current_instruction().ingredients[1]); assert(arg1.size() == 1); - vector<int> result; + vector<long long int> result; result.push_back(arg0[0] <= arg1[0]); trace("run") << "product 0 is " << result[0]; write_memory(current_instruction().products[0], result); diff --git a/cpp/026assert.cc b/cpp/026assert.cc index 785db1f5..6ab49db2 100644 --- a/cpp/026assert.cc +++ b/cpp/026assert.cc @@ -12,7 +12,7 @@ Recipe_number["assert"] = ASSERT; :(before "End Primitive Recipe Implementations") case ASSERT: { trace("run") << "ingredient 0 is " << current_instruction().ingredients[0].name; - vector<int> arg0 = read_memory(current_instruction().ingredients[0]); + vector<long long int> arg0 = read_memory(current_instruction().ingredients[0]); assert(arg0.size() == 1); if (arg0[0] == 0) raise << current_instruction().ingredients[1].name << '\n'; diff --git a/cpp/027debug.cc b/cpp/027debug.cc index 167e896b..27ac8ce6 100644 --- a/cpp/027debug.cc +++ b/cpp/027debug.cc @@ -11,7 +11,7 @@ case _PRINT: { cout << current_instruction().ingredients[0].name; break; } - vector<int> result(read_memory(current_instruction().ingredients[0])); + vector<long long int> result(read_memory(current_instruction().ingredients[0])); for (index_t i = 0; i < result.size(); ++i) { trace("run") << "$print: " << result[i]; if (i > 0) cout << " "; diff --git a/cpp/030container.cc b/cpp/030container.cc index 0572b693..9de3aad7 100644 --- a/cpp/030container.cc +++ b/cpp/030container.cc @@ -83,25 +83,25 @@ Recipe_number["get"] = GET; case GET: { trace("run") << "ingredient 0 is " << current_instruction().ingredients[0].name; reagent base = current_instruction().ingredients[0]; - int base_address = base.value; - int base_type = base.types[0]; + index_t base_address = base.value; + type_number base_type = base.types[0]; assert(Type[base_type].kind == container); trace("run") << "ingredient 1 is " << current_instruction().ingredients[1].name; assert(isa_literal(current_instruction().ingredients[1])); index_t offset = current_instruction().ingredients[1].value; - int src = base_address; + index_t src = base_address; for (index_t i = 0; i < offset; ++i) { src += size_of(Type[base_type].elements[i]); } trace("run") << "address to copy is " << src; assert(Type[base_type].kind == container); assert(Type[base_type].elements.size() > offset); - int src_type = Type[base_type].elements[offset][0]; + type_number src_type = Type[base_type].elements[offset][0]; trace("run") << "its type is " << src_type; reagent tmp; tmp.set_value(src); tmp.types.push_back(src_type); - vector<int> result(read_memory(tmp)); + vector<long long int> result(read_memory(tmp)); trace("run") << "product 0 is " << result[0]; write_memory(current_instruction().products[0], result); break; @@ -150,18 +150,18 @@ Recipe_number["get-address"] = GET_ADDRESS; case GET_ADDRESS: { trace("run") << "ingredient 0 is " << current_instruction().ingredients[0].name; reagent base = current_instruction().ingredients[0]; - int base_address = base.value; - int base_type = base.types[0]; + index_t base_address = base.value; + type_number base_type = base.types[0]; assert(Type[base_type].kind == container); trace("run") << "ingredient 1 is " << current_instruction().ingredients[1].name; assert(isa_literal(current_instruction().ingredients[1])); index_t offset = current_instruction().ingredients[1].value; - int src = base_address; + index_t src = base_address; for (index_t i = 0; i < offset; ++i) { src += size_of(Type[base_type].elements[i]); } trace("run") << "address to copy is " << src; - vector<int> result; + vector<long long int> result; result.push_back(src); trace("run") << "product 0 is " << result[0]; write_memory(current_instruction().products[0], result); diff --git a/cpp/031address.cc b/cpp/031address.cc index ddb9ba64..1c830c74 100644 --- a/cpp/031address.cc +++ b/cpp/031address.cc @@ -13,7 +13,7 @@ recipe main [ +mem: location 2 is 34 +mem: storing 34 in location 3 -:(before "int base = x.value" following "vector<int> read_memory(reagent x)") +:(before "index_t base = x.value" following "vector<long long int> read_memory(reagent x)") x = canonize(x); //: similarly, write to addresses pointing at other locations using the @@ -27,7 +27,7 @@ recipe main [ +mem: location 1 is 2 +mem: storing 34 in location 2 -:(before "int base = x.value" following "void write_memory(reagent x, vector<int> data)") +:(before "index_t base = x.value" following "void write_memory(reagent x, vector<long long int> data)") x = canonize(x); :(code) @@ -55,8 +55,8 @@ reagent deref(reagent x) { copy(++x.types.begin(), x.types.end(), inserter(result.types, result.types.begin())); // drop-one 'deref' - int i = 0; - int len = x.properties.size(); + index_t i = 0; + size_t len = x.properties.size(); for (i = 0; i < len; ++i) { if (x.properties[i].first == "deref") break; result.properties.push_back(x.properties[i]); diff --git a/cpp/032array.cc b/cpp/032array.cc index 6c3eb6da..de19b719 100644 --- a/cpp/032array.cc +++ b/cpp/032array.cc @@ -47,7 +47,7 @@ recipe main [ +mem: storing 16 in location 9 //: disable the size mismatch check since the destination array need not be initialized -:(replace "if (size_of(x) != data.size())" following "void write_memory(reagent x, vector<int> data)") +:(replace "if (size_of(x) != data.size())" following "void write_memory(reagent x, vector<long long int> data)") if (x.types[0] != Type_number["array"] && size_of(x) != data.size()) :(after "size_t size_of(const reagent& r)") static const type_number ARRAY = Type_number["array"]; @@ -101,23 +101,23 @@ case INDEX: { trace("run") << "ingredient 0 is " << current_instruction().ingredients[0].to_string(); reagent base = canonize(current_instruction().ingredients[0]); //? trace("run") << "ingredient 0 after canonize: " << base.to_string(); //? 1 - int base_address = base.value; + index_t base_address = base.value; assert(base.types[0] == ARRAY); trace("run") << "ingredient 1 is " << current_instruction().ingredients[1].to_string(); reagent offset = canonize(current_instruction().ingredients[1]); //? trace("run") << "ingredient 1 after canonize: " << offset.to_string(); //? 1 - vector<int> offset_val(read_memory(offset)); + vector<long long int> offset_val(read_memory(offset)); vector<type_number> element_type = array_element(base.types); //? trace("run") << "offset: " << offset_val[0]; //? 1 //? trace("run") << "size of elements: " << size_of(element_type); //? 1 - int src = base_address + 1 + offset_val[0]*size_of(element_type); + index_t src = base_address + 1 + offset_val[0]*size_of(element_type); trace("run") << "address to copy is " << src; trace("run") << "its type is " << element_type[0]; reagent tmp; tmp.set_value(src); copy(element_type.begin(), element_type.end(), inserter(tmp.types, tmp.types.begin())); //? trace("run") << "AAA: " << tmp.to_string() << '\n'; //? 3 - vector<int> result(read_memory(tmp)); + vector<long long int> result(read_memory(tmp)); trace("run") << "product 0 is " << result[0]; write_memory(current_instruction().products[0], result); //? if (Trace_stream) Trace_stream->dump_layer = ""; //? 1 @@ -164,15 +164,15 @@ case INDEX_ADDRESS: { static const type_number ARRAY = Type_number["array"]; trace("run") << "ingredient 0 is " << current_instruction().ingredients[0].name; reagent base = canonize(current_instruction().ingredients[0]); - int base_address = base.value; + index_t base_address = base.value; assert(base.types[0] == ARRAY); trace("run") << "ingredient 1 is " << current_instruction().ingredients[1].to_string(); reagent offset = canonize(current_instruction().ingredients[1]); - vector<int> offset_val(read_memory(offset)); + vector<long long int> offset_val(read_memory(offset)); vector<type_number> element_type = array_element(base.types); - int src = base_address + 1 + offset_val[0]*size_of(element_type); + index_t src = base_address + 1 + offset_val[0]*size_of(element_type); trace("run") << "address to copy is " << src; - vector<int> result; + vector<long long int> result; result.push_back(src); trace("run") << "product 0 is " << result[0]; write_memory(current_instruction().products[0], result); diff --git a/cpp/033length.cc b/cpp/033length.cc index 5281287d..126a14e7 100644 --- a/cpp/033length.cc +++ b/cpp/033length.cc @@ -22,7 +22,7 @@ case LENGTH: { raise << "tried to calculate length of non-array " << x.to_string() << '\n'; break; } - vector<int> result; + vector<long long int> result; //? cout << "length: " << x.value << '\n'; //? 1 result.push_back(Memory[x.value]); write_memory(current_instruction().products[0], result); diff --git a/cpp/034exclusive_container.cc b/cpp/034exclusive_container.cc index 9b8c4b7f..45164c35 100644 --- a/cpp/034exclusive_container.cc +++ b/cpp/034exclusive_container.cc @@ -90,13 +90,13 @@ Recipe_number["maybe-convert"] = MAYBE_CONVERT; case MAYBE_CONVERT: { trace("run") << "ingredient 0 is " << current_instruction().ingredients[0].name; reagent base = canonize(current_instruction().ingredients[0]); - int base_address = base.value; - int base_type = base.types[0]; + index_t base_address = base.value; + type_number base_type = base.types[0]; assert(Type[base_type].kind == exclusive_container); trace("run") << "ingredient 1 is " << current_instruction().ingredients[1].name; assert(isa_literal(current_instruction().ingredients[1])); index_t tag = current_instruction().ingredients[1].value; - vector<int> result; + vector<long long int> result; if (tag == static_cast<index_t>(Memory[base_address])) { result.push_back(base_address+1); } diff --git a/cpp/036call_ingredient.cc b/cpp/036call_ingredient.cc index 87abe5ef..bbbe3483 100644 --- a/cpp/036call_ingredient.cc +++ b/cpp/036call_ingredient.cc @@ -23,7 +23,7 @@ recipe f [ +mem: storing 0 in location 12 :(before "End call Fields") -vector<vector<int> > ingredient_atoms; +vector<vector<long long int> > ingredient_atoms; index_t next_ingredient_to_process; :(replace{} "call(recipe_number r)") call(recipe_number r) :running_recipe(r), running_step_index(0), next_ingredient_to_process(0) {} @@ -47,7 +47,7 @@ case NEXT_INGREDIENT: { write_memory(current_instruction().products[0], Current_routine->calls.top().ingredient_atoms[Current_routine->calls.top().next_ingredient_to_process]); if (current_instruction().products.size() > 1) { - vector<int> ingredient_exists; + vector<long long int> ingredient_exists; ingredient_exists.push_back(1); write_memory(current_instruction().products[1], ingredient_exists); } @@ -55,7 +55,7 @@ case NEXT_INGREDIENT: { } else { if (current_instruction().products.size() > 1) { - vector<int> no_ingredient; + vector<long long int> no_ingredient; no_ingredient.push_back(0); write_memory(current_instruction().products[1], no_ingredient); } @@ -112,7 +112,7 @@ case INGREDIENT: { write_memory(current_instruction().products[0], Current_routine->calls.top().ingredient_atoms[Current_routine->calls.top().next_ingredient_to_process]); if (current_instruction().products.size() > 1) { - vector<int> ingredient_exists; + vector<long long int> ingredient_exists; ingredient_exists.push_back(1); write_memory(current_instruction().products[1], ingredient_exists); } @@ -120,7 +120,7 @@ case INGREDIENT: { } else { if (current_instruction().products.size() > 1) { - vector<int> no_ingredient; + vector<long long int> no_ingredient; no_ingredient.push_back(0); write_memory(current_instruction().products[1], no_ingredient); } diff --git a/cpp/037call_reply.cc b/cpp/037call_reply.cc index 39fb1606..697c6b84 100644 --- a/cpp/037call_reply.cc +++ b/cpp/037call_reply.cc @@ -21,7 +21,7 @@ REPLY, Recipe_number["reply"] = REPLY; :(before "End Primitive Recipe Implementations") case REPLY: { - vector<vector<int> > callee_results; + vector<vector<long long int> > callee_results; for (index_t i = 0; i < current_instruction().ingredients.size(); ++i) { callee_results.push_back(read_memory(current_instruction().ingredients[i])); } @@ -37,7 +37,7 @@ case REPLY: { if (has_property(reply_inst.ingredients[i], "same-as-ingredient")) { vector<string> tmp = property(reply_inst.ingredients[i], "same-as-ingredient"); assert(tmp.size() == 1); - int ingredient_index = to_int(tmp[0]); + long long int ingredient_index = to_int(tmp[0]); if (caller_instruction.products[i].value != caller_instruction.ingredients[ingredient_index].value) raise << "'same-as-ingredient' result " << caller_instruction.products[i].value << " must be location " << caller_instruction.ingredients[ingredient_index].value << '\n'; } @@ -78,7 +78,7 @@ recipe test1 [ +warn: 'same-as-ingredient' result 2 must be location 1 :(code) -string to_string(const vector<int>& in) { +string to_string(const vector<long long int>& in) { if (in.empty()) return "[]"; ostringstream out; if (in.size() == 1) { diff --git a/cpp/042new.cc b/cpp/042new.cc index 9b50d84d..81a4528a 100644 --- a/cpp/042new.cc +++ b/cpp/042new.cc @@ -58,7 +58,7 @@ case NEW: { type.push_back(current_instruction().ingredients[0].value); if (current_instruction().ingredients.size() > 1) { // array - vector<int> capacity = read_memory(current_instruction().ingredients[1]); + vector<long long int> capacity = read_memory(current_instruction().ingredients[1]); array_length = capacity[0]; trace("mem") << "array size is " << array_length; size = array_length*size_of(type) + /*space for length*/1; @@ -85,7 +85,7 @@ case NEW: { Memory[result] = array_length; } // write result to memory - vector<int> tmp; + vector<long long int> tmp; tmp.push_back(Current_routine->alloc); write_memory(current_instruction().products[0], tmp); // bump @@ -143,7 +143,7 @@ recipe main [ :(after "case NEW" following "Primitive Recipe Implementations") if (current_instruction().ingredients[0].properties[0].second[0] == "literal-string") { // allocate an array just large enough for it - vector<int> result; + vector<long long int> result; result.push_back(Current_routine->alloc); write_memory(current_instruction().products[0], result); // assume that all characters fit in a single location diff --git a/cpp/043space.cc b/cpp/043space.cc index 82b9115a..4230468f 100644 --- a/cpp/043space.cc +++ b/cpp/043space.cc @@ -93,21 +93,21 @@ tmp.properties.push_back(pair<string, vector<string> >("raw", vector<string>())) //:: helpers :(code) -int space_base(const reagent& x) { +index_t space_base(const reagent& x) { return Current_routine->calls.top().default_space; } -int address(int offset, int base) { +index_t address(index_t offset, index_t base) { if (base == 0) return offset; // raw //? cout << base << '\n'; //? 2 - if (offset >= Memory[base]) { + if (offset >= static_cast<index_t>(Memory[base])) { // todo: test raise << "location " << offset << " is out of bounds " << Memory[base] << '\n'; } return base+1 + offset; } -:(after "void write_memory(reagent x, vector<int> data)") +:(after "void write_memory(reagent x, vector<long long int> data)") if (x.name == "default-space") { assert(data.size() == 1); Current_routine->calls.top().default_space = data[0]; @@ -122,9 +122,9 @@ recipe main [ ] +mem: storing 10 in location 1 -:(after "vector<int> read_memory(reagent x)") +:(after "vector<long long int> read_memory(reagent x)") if (x.name == "default-space") { - vector<int> result; + vector<long long int> result; result.push_back(Current_routine->calls.top().default_space); return result; } diff --git a/cpp/044space_surround.cc b/cpp/044space_surround.cc index bfc73eee..dfa6c9ef 100644 --- a/cpp/044space_surround.cc +++ b/cpp/044space_surround.cc @@ -25,23 +25,23 @@ recipe main [ //: lifetime, surrounding allows managing shorter lifetimes inside a longer //: one. -:(replace{} "int space_base(const reagent& x)") -int space_base(const reagent& x) { +:(replace{} "index_t space_base(const reagent& x)") +index_t space_base(const reagent& x) { return space_base(x, space_index(x), Current_routine->calls.top().default_space); } -int space_base(const reagent& x, int space_index, int base) { +index_t space_base(const reagent& x, index_t space_index, index_t base) { //? trace("foo") << "base of space " << space_index << '\n'; //? 1 if (space_index == 0) { //? trace("foo") << "base of space " << space_index << " is " << base << '\n'; //? 1 return base; } //? trace("foo") << "base of space " << space_index << " is " << Memory[base+1] << '\n'; //? 1 - int result = space_base(x, space_index-1, Memory[base+1]); + index_t result = space_base(x, space_index-1, Memory[base+1]); return result; } -int space_index(const reagent& x) { +index_t space_index(const reagent& x) { for (index_t i = 0; i < x.properties.size(); ++i) { if (x.properties[i].first == "space") return to_int(x.properties[i].second[0]); diff --git a/cpp/070display.cc b/cpp/070display.cc index 922b1e4b..350b9c4d 100644 --- a/cpp/070display.cc +++ b/cpp/070display.cc @@ -58,7 +58,7 @@ PRINT_CHARACTER_TO_DISPLAY, Recipe_number["print-character-to-display"] = PRINT_CHARACTER_TO_DISPLAY; :(before "End Primitive Recipe Implementations") case PRINT_CHARACTER_TO_DISPLAY: { - vector<int> arg = read_memory(current_instruction().ingredients[0]); + vector<long long int> arg = read_memory(current_instruction().ingredients[0]); int h=tb_height(), w=tb_width(); size_t height = (h >= 0) ? h : 0; size_t width = (w >= 0) ? w : 0; @@ -86,10 +86,10 @@ CURSOR_POSITION_ON_DISPLAY, Recipe_number["cursor-position-on-display"] = CURSOR_POSITION_ON_DISPLAY; :(before "End Primitive Recipe Implementations") case CURSOR_POSITION_ON_DISPLAY: { - vector<int> row; + vector<long long int> row; row.push_back(Display_row); write_memory(current_instruction().products[0], row); - vector<int> column; + vector<long long int> column; column.push_back(Display_column); write_memory(current_instruction().products[1], column); break; @@ -101,8 +101,8 @@ MOVE_CURSOR_ON_DISPLAY, Recipe_number["move-cursor-on-display"] = MOVE_CURSOR_ON_DISPLAY; :(before "End Primitive Recipe Implementations") case MOVE_CURSOR_ON_DISPLAY: { - vector<int> row = read_memory(current_instruction().ingredients[0]); - vector<int> column = read_memory(current_instruction().ingredients[1]); + vector<long long int> row = read_memory(current_instruction().ingredients[0]); + vector<long long int> column = read_memory(current_instruction().ingredients[1]); Display_row = row[0]; Display_column = column[0]; tb_set_cursor(Display_column, Display_row); @@ -170,7 +170,7 @@ case WAIT_FOR_KEY_FROM_KEYBOARD: { do { tb_poll_event(&event); } while (event.type != TB_EVENT_KEY); - vector<int> result; + vector<long long int> result; result.push_back(event.ch); write_memory(current_instruction().products[0], result); break; @@ -184,8 +184,8 @@ Recipe_number["read-key-from-keyboard"] = READ_KEY_FROM_KEYBOARD; case READ_KEY_FROM_KEYBOARD: { struct tb_event event; int event_type = tb_peek_event(&event, 5/*ms*/); - vector<int> result; - vector<int> found; + vector<long long int> result; + vector<long long int> found; if (event_type != TB_EVENT_KEY) { result.push_back(0); found.push_back(false); |