about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--030container.cc7
-rw-r--r--034call.cc15
2 files changed, 14 insertions, 8 deletions
diff --git a/030container.cc b/030container.cc
index 89ba58de..8071ff4c 100644
--- a/030container.cc
+++ b/030container.cc
@@ -160,7 +160,7 @@ case GET: {
   }
   type_ordinal base_type = base.types.at(0);
   long long int offset = ingredients.at(1).at(0);
-  if (offset < 0 || offset >= SIZE(Type[base_type].elements)) break;
+  if (offset < 0 || offset >= SIZE(Type[base_type].elements)) break;  // copied from Check above
   long long int src = base_address;
   for (long long int i = 0; i < offset; ++i) {
     src += size_of(Type[base_type].elements.at(i));
@@ -256,6 +256,7 @@ case GET_ADDRESS: {
   }
   type_ordinal base_type = base.types.at(0);
   long long int offset = ingredients.at(1).at(0);
+  if (offset < 0 || offset >= SIZE(Type[base_type].elements)) break;  // copied from Check above
   long long int result = base_address;
   for (long long int i = 0; i < offset; ++i) {
     result += size_of(Type[base_type].elements.at(i));
@@ -505,6 +506,10 @@ void check_container_field_types() {
 MERGE,
 :(before "End Primitive Recipe Numbers")
 Recipe_ordinal["merge"] = MERGE;
+:(before "End Primitive Recipe Checks")
+case MERGE: {
+  break;
+}
 :(before "End Primitive Recipe Implementations")
 case MERGE: {
   products.resize(1);
diff --git a/034call.cc b/034call.cc
index f1c82f7f..43c9061f 100644
--- a/034call.cc
+++ b/034call.cc
@@ -77,15 +77,16 @@ inline const instruction& current_instruction() {
   return Recipe[Current_routine->calls.front().running_recipe].steps.at(Current_routine->calls.front().running_step_index);
 }
 
+:(after "Defined Recipe Checks")
+// not a primitive; check that it's present in the book of recipes
+if (Recipe.find(inst.operation) == Recipe.end()) {
+  raise << maybe(Recipe[r].name) << "undefined operation in '" << inst.to_string() << "'\n" << end();
+  break;
+}
 :(replace{} "default:" following "End Primitive Recipe Implementations")
 default: {
-  // not a primitive; try to look up the book of recipes
-  if (Recipe.find(current_instruction().operation) == Recipe.end()) {
-    raise << maybe(current_recipe_name()) << "undefined operation in '" << current_instruction().to_string() << "'\n" << end();
-    // stop running this instruction immediately
-    ++current_step_index();
-    continue;
-  }
+  if (Recipe.find(current_instruction().operation) == Recipe.end()) break;  // duplicate from Checks
+  // not a primitive; look up the book of recipes
   Current_routine->calls.push_front(call(current_instruction().operation));
   call_housekeeping:
   ++Callstack_depth;