about summary refs log tree commit diff stats
path: root/024jump.cc
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-04-28 13:20:12 -0700
committerKartik K. Agaram <vc@akkartik.com>2016-04-28 13:24:52 -0700
commit4f5bb5b6b199b9ccf1bf12082436d9f841559b2c (patch)
tree0210618f47baf3c8a2d9129183776af0442b0230 /024jump.cc
parent5b22547bb352f6e5a98ddd8ff42f37861a8e16ea (diff)
downloadmu-4f5bb5b6b199b9ccf1bf12082436d9f841559b2c.tar.gz
2881 - disallow recipe literals in conditional jumps
If you accidentally use a recipe name in an ingredient you usually get
an error because types don't match. But jumps need to be flexible enough
to support both addresses and booleans, so they were accepting recipe
literals as well. Now a useful error results.
Diffstat (limited to '024jump.cc')
-rw-r--r--024jump.cc8
1 files changed, 5 insertions, 3 deletions
diff --git a/024jump.cc b/024jump.cc
index 7a1d938a..4503ade3 100644
--- a/024jump.cc
+++ b/024jump.cc
@@ -19,7 +19,7 @@ case JUMP: {
     raise << maybe(get(Recipe, r).name) << "'jump' requires exactly one ingredient, but got " << to_original_string(inst) << '\n' << end();
     break;
   }
-  if (!is_mu_scalar(inst.ingredients.at(0))) {
+  if (!is_literal(inst.ingredients.at(0))) {
     raise << maybe(get(Recipe, r).name) << "first ingredient of 'jump' should be a label or offset, but got " << inst.ingredients.at(0).original_string << '\n' << end();
     break;
   }
@@ -62,10 +62,11 @@ case JUMP_IF: {
     raise << maybe(get(Recipe, r).name) << "'jump-if' requires a boolean for its first ingredient, but got " << inst.ingredients.at(0).original_string << '\n' << end();
     break;
   }
-  if (!is_mu_scalar(inst.ingredients.at(1))) {
+  if (!is_literal(inst.ingredients.at(1))) {
     raise << maybe(get(Recipe, r).name) << "'jump-if' requires a label or offset for its second ingredient, but got " << inst.ingredients.at(0).original_string << '\n' << end();
     break;
   }
+  // End JUMP_IF Checks
   break;
 }
 :(before "End Primitive Recipe Implementations")
@@ -114,10 +115,11 @@ case JUMP_UNLESS: {
     raise << maybe(get(Recipe, r).name) << "'jump-unless' requires a boolean for its first ingredient, but got " << inst.ingredients.at(0).original_string << '\n' << end();
     break;
   }
-  if (!is_mu_scalar(inst.ingredients.at(1))) {
+  if (!is_literal(inst.ingredients.at(1))) {
     raise << maybe(get(Recipe, r).name) << "'jump-unless' requires a label or offset for its second ingredient, but got " << inst.ingredients.at(0).original_string << '\n' << end();
     break;
   }
+  // End JUMP_UNLESS Checks
   break;
 }
 :(before "End Primitive Recipe Implementations")