about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-09-30 02:18:05 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-09-30 02:18:05 -0700
commitd855b0a0a5012c583a35dee57d03b66de895e164 (patch)
tree5189d2162033503fff2a3f3d2cc98693e2e19f27
parente236973be09620daec70d83f7a5846e8f6fff680 (diff)
downloadmu-d855b0a0a5012c583a35dee57d03b66de895e164.tar.gz
2223
-rw-r--r--021check_instruction.cc2
-rw-r--r--024jump.cc50
2 files changed, 32 insertions, 20 deletions
diff --git a/021check_instruction.cc b/021check_instruction.cc
index a9ed55b2..8f12b7ca 100644
--- a/021check_instruction.cc
+++ b/021check_instruction.cc
@@ -109,7 +109,7 @@ bool is_mu_number(reagent r) {
 
 bool is_mu_scalar(reagent r) {
   if (is_literal(r))
-    return r.properties.at(0).second.at(0) != "literal-string";
+    return r.properties.at(0).second.empty() || r.properties.at(0).second.at(0) != "literal-string";
   if (is_mu_array(r)) return false;
   return size_of(r) == 1;
 }
diff --git a/024jump.cc b/024jump.cc
index 925906de..dabe33bb 100644
--- a/024jump.cc
+++ b/024jump.cc
@@ -13,16 +13,20 @@ recipe main [
 JUMP,
 :(before "End Primitive Recipe Numbers")
 Recipe_ordinal["jump"] = JUMP;
-:(before "End Primitive Recipe Implementations")
+:(before "End Primitive Recipe Checks")
 case JUMP: {
-  if (SIZE(ingredients) != 1) {
-    raise << current_recipe_name() << ": 'jump' requires exactly one ingredient, but got " << current_instruction().to_string() << '\n' << end();
+  if (SIZE(inst.ingredients) != 1) {
+    raise << Recipe[r].name << ": 'jump' requires exactly one ingredient, but got " << inst.to_string() << '\n' << end();
     break;
   }
-  if (!scalar(ingredients.at(0))) {
-    raise << current_recipe_name() << ": first ingredient of 'jump' should be a label or offset, but got " << current_instruction().ingredients.at(0).original_string << '\n' << end();
+  if (!is_mu_scalar(inst.ingredients.at(0))) {
+    raise << Recipe[r].name << ": first ingredient of 'jump' should be a label or offset, but got " << inst.ingredients.at(0).original_string << '\n' << end();
     break;
   }
+  break;
+}
+:(before "End Primitive Recipe Implementations")
+case JUMP: {
   assert(current_instruction().ingredients.at(0).initialized);
   current_step_index() += ingredients.at(0).at(0)+1;
   trace(Primitive_recipe_depth, "run") << "jumping to instruction " << current_step_index() << end();
@@ -48,20 +52,24 @@ recipe main [
 JUMP_IF,
 :(before "End Primitive Recipe Numbers")
 Recipe_ordinal["jump-if"] = JUMP_IF;
-:(before "End Primitive Recipe Implementations")
+:(before "End Primitive Recipe Checks")
 case JUMP_IF: {
-  if (SIZE(ingredients) != 2) {
-    raise << current_recipe_name() << ": 'jump-if' requires exactly two ingredients, but got " << current_instruction().to_string() << '\n' << end();
+  if (SIZE(inst.ingredients) != 2) {
+    raise << Recipe[r].name << ": 'jump-if' requires exactly two ingredients, but got " << inst.to_string() << '\n' << end();
     break;
   }
-  if (!scalar(ingredients.at(0))) {
-    raise << current_recipe_name() << ": 'jump-if' requires a boolean for its first ingredient, but got " << current_instruction().ingredients.at(0).original_string << '\n' << end();
+  if (!is_mu_scalar(inst.ingredients.at(0))) {
+    raise << Recipe[r].name << ": 'jump-if' requires a boolean for its first ingredient, but got " << inst.ingredients.at(0).original_string << '\n' << end();
     break;
   }
-  if (!scalar(ingredients.at(1))) {
-    raise << current_recipe_name() << ": 'jump-if' requires a label or offset for its second ingredient, but got " << current_instruction().ingredients.at(0).original_string << '\n' << end();
+  if (!is_mu_scalar(inst.ingredients.at(1))) {
+    raise << 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;
   }
+  break;
+}
+:(before "End Primitive Recipe Implementations")
+case JUMP_IF: {
   assert(current_instruction().ingredients.at(1).initialized);
   if (!ingredients.at(0).at(0)) {
     trace(Primitive_recipe_depth, "run") << "jump-if fell through" << end();
@@ -96,20 +104,24 @@ recipe main [
 JUMP_UNLESS,
 :(before "End Primitive Recipe Numbers")
 Recipe_ordinal["jump-unless"] = JUMP_UNLESS;
-:(before "End Primitive Recipe Implementations")
+:(before "End Primitive Recipe Checks")
 case JUMP_UNLESS: {
-  if (SIZE(ingredients) != 2) {
-    raise << current_recipe_name() << ": 'jump-unless' requires exactly two ingredients, but got " << current_instruction().to_string() << '\n' << end();
+  if (SIZE(inst.ingredients) != 2) {
+    raise << Recipe[r].name << ": 'jump-unless' requires exactly two ingredients, but got " << inst.to_string() << '\n' << end();
     break;
   }
-  if (!scalar(ingredients.at(0))) {
-    raise << current_recipe_name() << ": 'jump-unless' requires a boolean for its first ingredient, but got " << current_instruction().ingredients.at(0).original_string << '\n' << end();
+  if (!is_mu_scalar(inst.ingredients.at(0))) {
+    raise << Recipe[r].name << ": 'jump-unless' requires a boolean for its first ingredient, but got " << inst.ingredients.at(0).original_string << '\n' << end();
     break;
   }
-  if (!scalar(ingredients.at(1))) {
-    raise << current_recipe_name() << ": 'jump-unless' requires a label or offset for its second ingredient, but got " << current_instruction().ingredients.at(0).original_string << '\n' << end();
+  if (!is_mu_scalar(inst.ingredients.at(1))) {
+    raise << 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;
   }
+  break;
+}
+:(before "End Primitive Recipe Implementations")
+case JUMP_UNLESS: {
   assert(current_instruction().ingredients.at(1).initialized);
   if (ingredients.at(0).at(0)) {
     trace(Primitive_recipe_depth, "run") << "jump-unless fell through" << end();