about summary refs log tree commit diff stats
path: root/024jump.cc
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2018-06-24 09:16:17 -0700
committerKartik Agaram <vc@akkartik.com>2018-06-24 09:18:20 -0700
commit23d3a02226973f80188e84fa5dcedb14413c5b7f (patch)
tree3c73284cb795e74d78e53b72df470cafca4c70cf /024jump.cc
parent377b00b045289a3fa8e88d4b2f129d797c687e2f (diff)
downloadmu-23d3a02226973f80188e84fa5dcedb14413c5b7f.tar.gz
4266 - space for alloc-id in heap allocations
This has taken me almost 6 weeks :(
Diffstat (limited to '024jump.cc')
-rw-r--r--024jump.cc21
1 files changed, 16 insertions, 5 deletions
diff --git a/024jump.cc b/024jump.cc
index 37011290..14c14297 100644
--- a/024jump.cc
+++ b/024jump.cc
@@ -72,7 +72,7 @@ case JUMP_IF: {
     raise << maybe(get(Recipe, r).name) << "'" << to_original_string(inst) << "' should get exactly two ingredients\n" << end();
     break;
   }
-  if (!is_mu_scalar(inst.ingredients.at(0))) {
+  if (!is_mu_address(inst.ingredients.at(0)) && !is_mu_scalar(inst.ingredients.at(0))) {
     raise << maybe(get(Recipe, r).name) << "'" << to_original_string(inst) << "' requires a boolean for its first ingredient, but '" << inst.ingredients.at(0).name << "' has type '" << names_to_string_without_quotes(inst.ingredients.at(0).type) << "'\n" << end();
     break;
   }
@@ -90,7 +90,7 @@ case JUMP_IF: {
 :(before "End Primitive Recipe Implementations")
 case JUMP_IF: {
   assert(current_instruction().ingredients.at(1).initialized);
-  if (!ingredients.at(0).at(0)) {
+  if (!scalar_ingredient(ingredients, 0)) {
     trace(9998, "run") << "jump-if fell through" << end();
     break;
   }
@@ -109,7 +109,7 @@ def main [
 ]
 +run: jump-if {999: "literal"}, {1: "offset"}
 +run: jumping to instruction 2
--run: {1: "number"} <- copy {1: "literal"}
+-run: {123: "number"} <- copy {1: "literal"}
 -mem: storing 1 in location 123
 
 :(scenario jump_if_fallthrough)
@@ -122,6 +122,17 @@ def main [
 +run: {123: "number"} <- copy {1: "literal"}
 +mem: storing 1 in location 123
 
+:(scenario jump_if_on_address)
+def main [
+  10:num/alloc-id, 11:num <- copy 0, 999
+  jump-if 10:&:number, 1:offset
+  123:num <- copy 1
+]
++run: jump-if {10: ("address" "number")}, {1: "offset"}
++run: jumping to instruction 3
+-run: {123: "number"} <- copy {1: "literal"}
+-mem: storing 1 in location 123
+
 :(before "End Primitive Recipe Declarations")
 JUMP_UNLESS,
 :(before "End Primitive Recipe Numbers")
@@ -132,7 +143,7 @@ case JUMP_UNLESS: {
     raise << maybe(get(Recipe, r).name) << "'" << to_original_string(inst) << "' should get exactly two ingredients\n" << end();
     break;
   }
-  if (!is_mu_scalar(inst.ingredients.at(0))) {
+  if (!is_mu_address(inst.ingredients.at(0)) && !is_mu_scalar(inst.ingredients.at(0))) {
     raise << maybe(get(Recipe, r).name) << "'" << to_original_string(inst) << "' requires a boolean for its first ingredient, but '" << inst.ingredients.at(0).name << "' has type '" << names_to_string_without_quotes(inst.ingredients.at(0).type) << "'\n" << end();
     break;
   }
@@ -150,7 +161,7 @@ case JUMP_UNLESS: {
 :(before "End Primitive Recipe Implementations")
 case JUMP_UNLESS: {
   assert(current_instruction().ingredients.at(1).initialized);
-  if (ingredients.at(0).at(0)) {
+  if (scalar_ingredient(ingredients, 0)) {
     trace(9998, "run") << "jump-unless fell through" << end();
     break;
   }