about summary refs log tree commit diff stats
path: root/024jump.cc
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2018-05-25 12:25:13 -0700
committerKartik Agaram <vc@akkartik.com>2018-05-25 12:25:13 -0700
commitf7d3dc0eea180a6e5c233fdc493ad8f6cf1022e4 (patch)
tree4f5052737ae77e17087c3a41f64e979ccb0c232e /024jump.cc
parentc9cf358c0e34525efbb283f01dcb79816677f056 (diff)
downloadmu-f7d3dc0eea180a6e5c233fdc493ad8f6cf1022e4.tar.gz
4247
Diffstat (limited to '024jump.cc')
-rw-r--r--024jump.cc19
1 files changed, 19 insertions, 0 deletions
diff --git a/024jump.cc b/024jump.cc
index 748b2405..37011290 100644
--- a/024jump.cc
+++ b/024jump.cc
@@ -23,6 +23,10 @@ case JUMP: {
     raise << maybe(get(Recipe, r).name) << "first ingredient of '" << to_original_string(inst) << "' should be a label or offset, but '" << inst.ingredients.at(0).name << "' has type '" << names_to_string_without_quotes(inst.ingredients.at(0).type) << "'\n" << end();
     break;
   }
+  if (!inst.products.empty()) {
+    raise << maybe(get(Recipe, r).name) << "'jump' instructions write no products\n" << end();
+    break;
+  }
   break;
 }
 :(before "End Primitive Recipe Implementations")
@@ -51,6 +55,13 @@ def main [
 +run: jump {-2: "offset"}
 +run: jump {3: "offset"}
 
+:(scenario jump_takes_no_products)
+% Hide_errors = true;
+def main [
+  1:num <- jump 1
+]
++error: main: 'jump' instructions write no products
+
 :(before "End Primitive Recipe Declarations")
 JUMP_IF,
 :(before "End Primitive Recipe Numbers")
@@ -69,6 +80,10 @@ case JUMP_IF: {
     raise << maybe(get(Recipe, r).name) << "'" << to_original_string(inst) << "' requires a label or offset for its second ingredient, but '" << inst.ingredients.at(1).name << "' has type '" << names_to_string_without_quotes(inst.ingredients.at(1).type) << "'\n" << end();
     break;
   }
+  if (!inst.products.empty()) {
+    raise << maybe(get(Recipe, r).name) << "'jump-if' instructions write no products\n" << end();
+    break;
+  }
   // End JUMP_IF Checks
   break;
 }
@@ -125,6 +140,10 @@ case JUMP_UNLESS: {
     raise << maybe(get(Recipe, r).name) << "'" << to_original_string(inst) << "' requires a label or offset for its second ingredient, but '" << inst.ingredients.at(1).name << "' has type '" << names_to_string_without_quotes(inst.ingredients.at(1).type) << "'\n" << end();
     break;
   }
+  if (!inst.products.empty()) {
+    raise << maybe(get(Recipe, r).name) << "'jump' instructions write no products\n" << end();
+    break;
+  }
   // End JUMP_UNLESS Checks
   break;
 }