diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-03-17 11:23:29 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-03-17 13:19:20 -0700 |
commit | 3ba6357924e1098a28e43c94a4573a3d2978b5e9 (patch) | |
tree | 9a5a4b181a82a77646b1c9d796bdd8b4159dc337 /cpp/020array | |
parent | 5f0e4762468c412d57fb54236a0ee90e23a2cb14 (diff) | |
download | mu-3ba6357924e1098a28e43c94a4573a3d2978b5e9.tar.gz |
949 - paving the way for jumps to labels
Addresses for reagents are now computed after all transforms.
Diffstat (limited to 'cpp/020array')
-rw-r--r-- | cpp/020array | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/cpp/020array b/cpp/020array index f76342c9..709fd65a 100644 --- a/cpp/020array +++ b/cpp/020array @@ -29,13 +29,10 @@ recipe main [ :(before "End size_of Cases") if (t.is_array) { - assert(!r.name.empty()); - int base = to_int(r.name); + int base = r.value; if (Memory[base] == 0) return 0; - ostringstream out; - out << base+1; - reagent x(out.str()); - x.types.push_back(t.element[0]); + reagent x(t.element[0]); + x.value = base+1; return 1 + Memory[base]*size_of(x); } @@ -50,19 +47,17 @@ Next_recipe_number++; case INDEX: { trace("run") << "ingredient 0 is " << instructions[pc].ingredients[0].name; reagent base = canonize(instructions[pc].ingredients[0]); - int base_address = to_int(base.name); + int base_address = base.value; int base_type = base.types[0]; assert(Type[base_type].is_array); trace("run") << "ingredient 1 is " << instructions[pc].ingredients[1].name; - size_t offset = to_int(instructions[pc].ingredients[1].name); + size_t offset = instructions[pc].ingredients[1].value; int src = base_address + 1 + offset*size_of(reagent(Type[base_type].element[0])); trace("run") << "address to copy is " << src; int src_type = Type[base_type].element[0]; trace("run") << "its type is " << src_type; - ostringstream s; - s << src; - reagent tmp(s.str()); - tmp.types.push_back(src_type); + reagent tmp(src_type); + tmp.value = src; vector<int> result(read_memory(tmp)); trace("run") << "product 0 is " << result[0]; write_memory(instructions[pc].products[0], result); @@ -97,11 +92,11 @@ Next_recipe_number++; case INDEX_ADDRESS: { trace("run") << "ingredient 0 is " << instructions[pc].ingredients[0].name; reagent base = canonize(instructions[pc].ingredients[0]); - int base_address = to_int(base.name); + int base_address = base.value; int base_type = base.types[0]; assert(Type[base_type].is_array); trace("run") << "ingredient 1 is " << instructions[pc].ingredients[1].name; - size_t offset = to_int(instructions[pc].ingredients[1].name); + size_t offset = instructions[pc].ingredients[1].value; int src = base_address + 1 + offset*size_of(reagent(Type[base_type].element[0])); trace("run") << "address to copy is " << src; vector<int> result; |