diff options
Diffstat (limited to 'cpp/024compare')
-rw-r--r-- | cpp/024compare | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/cpp/024compare b/cpp/024compare index c536b23e..3445809c 100644 --- a/cpp/024compare +++ b/cpp/024compare @@ -6,14 +6,14 @@ EQUAL, Recipe_number["equal"] = EQUAL; :(before "End Primitive Recipe Implementations") case EQUAL: { - trace("run") << "ingredient 0 is " << instructions[pc].ingredients[0].name; - vector<int> arg0 = read_memory(instructions[pc].ingredients[0]); - trace("run") << "ingredient 1 is " << instructions[pc].ingredients[1].name; - vector<int> arg1 = read_memory(instructions[pc].ingredients[1]); + trace("run") << "ingredient 0 is " << current_instruction().ingredients[0].name; + vector<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; result.push_back(equal(arg0.begin(), arg0.end(), arg1.begin())); trace("run") << "product 0 is " << result[0]; - write_memory(instructions[pc].products[0], result); + write_memory(current_instruction().products[0], result); break; } @@ -51,16 +51,16 @@ GREATER_THAN, Recipe_number["greater-than"] = GREATER_THAN; :(before "End Primitive Recipe Implementations") case GREATER_THAN: { - trace("run") << "ingredient 0 is " << instructions[pc].ingredients[0].name; - vector<int> arg0 = read_memory(instructions[pc].ingredients[0]); + trace("run") << "ingredient 0 is " << current_instruction().ingredients[0].name; + vector<int> arg0 = read_memory(current_instruction().ingredients[0]); assert(arg0.size() == 1); - trace("run") << "ingredient 1 is " << instructions[pc].ingredients[1].name; - vector<int> arg1 = read_memory(instructions[pc].ingredients[1]); + trace("run") << "ingredient 1 is " << current_instruction().ingredients[1].name; + vector<int> arg1 = read_memory(current_instruction().ingredients[1]); assert(arg1.size() == 1); vector<int> result; result.push_back(arg0[0] > arg1[0]); trace("run") << "product 0 is " << result[0]; - write_memory(instructions[pc].products[0], result); + write_memory(current_instruction().products[0], result); break; } @@ -98,16 +98,16 @@ LESSER_THAN, Recipe_number["lesser-than"] = LESSER_THAN; :(before "End Primitive Recipe Implementations") case LESSER_THAN: { - trace("run") << "ingredient 0 is " << instructions[pc].ingredients[0].name; - vector<int> arg0 = read_memory(instructions[pc].ingredients[0]); + trace("run") << "ingredient 0 is " << current_instruction().ingredients[0].name; + vector<int> arg0 = read_memory(current_instruction().ingredients[0]); assert(arg0.size() == 1); - trace("run") << "ingredient 1 is " << instructions[pc].ingredients[1].name; - vector<int> arg1 = read_memory(instructions[pc].ingredients[1]); + trace("run") << "ingredient 1 is " << current_instruction().ingredients[1].name; + vector<int> arg1 = read_memory(current_instruction().ingredients[1]); assert(arg1.size() == 1); vector<int> result; result.push_back(arg0[0] < arg1[0]); trace("run") << "product 0 is " << result[0]; - write_memory(instructions[pc].products[0], result); + write_memory(current_instruction().products[0], result); break; } @@ -145,16 +145,16 @@ GREATER_OR_EQUAL, Recipe_number["greater-or-equal"] = GREATER_OR_EQUAL; :(before "End Primitive Recipe Implementations") case GREATER_OR_EQUAL: { - trace("run") << "ingredient 0 is " << instructions[pc].ingredients[0].name; - vector<int> arg0 = read_memory(instructions[pc].ingredients[0]); + trace("run") << "ingredient 0 is " << current_instruction().ingredients[0].name; + vector<int> arg0 = read_memory(current_instruction().ingredients[0]); assert(arg0.size() == 1); - trace("run") << "ingredient 1 is " << instructions[pc].ingredients[1].name; - vector<int> arg1 = read_memory(instructions[pc].ingredients[1]); + trace("run") << "ingredient 1 is " << current_instruction().ingredients[1].name; + vector<int> arg1 = read_memory(current_instruction().ingredients[1]); assert(arg1.size() == 1); vector<int> result; result.push_back(arg0[0] >= arg1[0]); trace("run") << "product 0 is " << result[0]; - write_memory(instructions[pc].products[0], result); + write_memory(current_instruction().products[0], result); break; } @@ -206,16 +206,16 @@ LESSER_OR_EQUAL, Recipe_number["lesser-or-equal"] = LESSER_OR_EQUAL; :(before "End Primitive Recipe Implementations") case LESSER_OR_EQUAL: { - trace("run") << "ingredient 0 is " << instructions[pc].ingredients[0].name; - vector<int> arg0 = read_memory(instructions[pc].ingredients[0]); + trace("run") << "ingredient 0 is " << current_instruction().ingredients[0].name; + vector<int> arg0 = read_memory(current_instruction().ingredients[0]); assert(arg0.size() == 1); - trace("run") << "ingredient 1 is " << instructions[pc].ingredients[1].name; - vector<int> arg1 = read_memory(instructions[pc].ingredients[1]); + trace("run") << "ingredient 1 is " << current_instruction().ingredients[1].name; + vector<int> arg1 = read_memory(current_instruction().ingredients[1]); assert(arg1.size() == 1); vector<int> result; result.push_back(arg0[0] <= arg1[0]); trace("run") << "product 0 is " << result[0]; - write_memory(instructions[pc].products[0], result); + write_memory(current_instruction().products[0], result); break; } |