summary refs log tree commit diff stats
path: root/request
diff options
context:
space:
mode:
authorAndinus <andinus@nand.sh>2020-03-26 15:31:26 +0530
committerAndinus <andinus@nand.sh>2020-03-26 15:31:26 +0530
commit79bad7258fb6f6b1ffd4b4bb378fefe513de7062 (patch)
tree2219a089ad774b71ca7da32387537b169d60e806 /request
parentafd4130b382c333e746adff49ce5d2c554d3045d (diff)
downloadcetus-79bad7258fb6f6b1ffd4b4bb378fefe513de7062.tar.gz
Fix logical error in fmt.Errorf statement
Diffstat (limited to 'request')
0 files changed, 0 insertions, 0 deletions
a id='n97' href='#n97'>97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
:(before "End Primitive Recipe Declarations")
// Jump ops.
JUMP,
:(before "End Primitive Recipe Numbers")
Recipe_number["jump"] = JUMP;
:(before "End Primitive Recipe Implementations")
case JUMP: {
  trace("run") << "ingredient 0 is " << instructions[pc].ingredients[0].value;
  pc += instructions[pc].ingredients[0].value;
  trace("run") << "pc now " << pc;
  break;
}

:(scenario "jump_can_skip_instructions")
recipe main [
  jump 1:offset
  1:integer <- copy 1:literal
]
+run: instruction main/0
+run: ingredient 0 is 1
-run: instruction main/1
-mem: storing 1 in location 1

:(scenario "jump_backward")
recipe main [
  jump 1:offset  # 0 -+
  jump 1:offset  #    |   +-+ 1
                 #   \/  /\ |
  jump -2:offset #  2 +-->+ |
]                #         \/ 3
+run: instruction main/0
+run: instruction main/2
+run: instruction main/1

:(before "End Primitive Recipe Declarations")
JUMP_IF,
:(before "End Primitive Recipe Numbers")
Recipe_number["jump-if"] = JUMP_IF;
:(before "End Primitive Recipe Implementations")
case JUMP_IF: {
  vector<int> arg0 = read_memory(instructions[pc].ingredients[0]);
  assert(arg0.size() == 1);
  trace("run") << "ingredient 0 is " << arg0[0];
  if (!arg0[0]) {
    trace("run") << "jump-if fell through";
    break;
  }
  trace("run") << "ingredient 1 is " << instructions[pc].ingredients[1].name;
  pc += instructions[pc].ingredients[1].value;
  trace("run") << "jumping to instruction " << pc+1;
  break;
}

:(scenario "jump_if")
recipe main [
  jump-if 999:literal 1:offset
  1:integer <- copy 1:literal
]
+run: instruction main/0
+run: ingredient 1 is 1
+run: jumping to instruction 2
-run: instruction main/1
-mem: storing 1 in location 1

:(scenario "jump_if_fallthrough")
recipe main [
  jump-if 0:literal 1:offset
  123:integer <- copy 1:literal
]
+run: instruction main/0
+run: jump-if fell through
+run: instruction main/1
+mem: storing 1 in location 123

:(before "End Primitive Recipe Declarations")
JUMP_UNLESS,
:(before "End Primitive Recipe Numbers")
Recipe_number["jump-unless"] = JUMP_UNLESS;
:(before "End Primitive Recipe Implementations")
case JUMP_UNLESS: {
  vector<int> arg0 = read_memory(instructions[pc].ingredients[0]);
  assert(arg0.size() == 1);
  trace("run") << "ingredient 0 is " << arg0[0];
  if (arg0[0]) {
    trace("run") << "jump-unless fell through";
    break;
  }
  trace("run") << "ingredient 1 is " << instructions[pc].ingredients[1].name;
  pc += instructions[pc].ingredients[1].value;
  trace("run") << "jumping to instruction " << pc+1;
  break;
}

:(scenario "jump_unless")
recipe main [
  jump-unless 0:literal 1:offset
  1:integer <- copy 1:literal
]
+run: instruction main/0
+run: ingredient 1 is 1
+run: jumping to instruction 2
-run: instruction main/1
-mem: storing 1 in location 1

:(scenario "jump_unless_fallthrough")
recipe main [
  jump-unless 999:literal 1:offset
  123:integer <- copy 1:literal
]
+run: instruction main/0
+run: ingredient 0 is 999
+run: jump-unless fell through
+run: instruction main/1
+mem: storing 1 in location 123