about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--011load.cc2
-rw-r--r--014literal_string.cc3
-rw-r--r--056recipe_header.cc26
-rw-r--r--057static_dispatch.cc4
4 files changed, 31 insertions, 4 deletions
diff --git a/011load.cc b/011load.cc
index 36b45214..10fe3817 100644
--- a/011load.cc
+++ b/011load.cc
@@ -57,6 +57,7 @@ long long int slurp_recipe(istream& in) {
     Recipe.erase(Recipe_ordinal[result.name]);
   }
   slurp_body(in, result);
+  // End recipe Body(result)
   Recipe[Recipe_ordinal[result.name]] = result;
   // track added recipes because we may need to undo them in tests; see below
   recently_added_recipes.push_back(Recipe_ordinal[result.name]);
@@ -142,6 +143,7 @@ bool next_instruction(istream& in, instruction* curr) {
   }
 
   trace(9993, "parse") << "instruction: " << curr->name << end();
+  trace(9993, "parse") << "  number of ingredients: " << SIZE(curr->ingredients) << end();
   for (vector<reagent>::iterator p = curr->ingredients.begin(); p != curr->ingredients.end(); ++p) {
     trace(9993, "parse") << "  ingredient: " << p->to_string() << end();
   }
diff --git a/014literal_string.cc b/014literal_string.cc
index 785aa822..99e7c097 100644
--- a/014literal_string.cc
+++ b/014literal_string.cc
@@ -171,10 +171,9 @@ recipe main [
 ]
 +parse: --- defining main
 +parse: instruction: copy
++parse:   number of ingredients: 1
 +parse:   ingredient: {"abc": "literal-string"}
 +parse:   product: {"1": <"address" : <"array" : <"character" : <>>>>}
-# no other ingredients
-$parse: 4
 
 :(scenario string_literal_escapes_newlines_in_trace)
 recipe main [
diff --git a/056recipe_header.cc b/056recipe_header.cc
index 79284ce5..477fafcd 100644
--- a/056recipe_header.cc
+++ b/056recipe_header.cc
@@ -48,6 +48,32 @@ void load_recipe_header(istream& in, recipe& result) {
   // End Load Recipe Header(result)
 }
 
+//: If a recipe never mentions any ingredients or products, assume it has a header.
+
+:(scenario recipe_without_ingredients_or_products_has_header)
+recipe test [
+  1:number <- copy 34
+]
++parse: recipe test has a header
+
+:(before "End recipe Body(result)")
+if (!result.has_header) {
+  result.has_header = true;
+  for (long long int i = 0; i < SIZE(result.steps); ++i) {
+    const instruction& inst = result.steps.at(i);
+    if ((inst.name == "reply" && !inst.ingredients.empty())
+        || inst.name == "next-ingredient"
+        || inst.name == "ingredient"
+        || inst.name == "rewind-ingredients") {
+      result.has_header = false;
+      break;
+    }
+  }
+}
+if (result.has_header) {
+  trace(9999, "parse") << "recipe " << result.name << " has a header" << end();
+}
+
 //: Now rewrite 'load-ingredients' to instructions to create all reagents in
 //: the header.
 
diff --git a/057static_dispatch.cc b/057static_dispatch.cc
index 5401c775..cc99f5ed 100644
--- a/057static_dispatch.cc
+++ b/057static_dispatch.cc
@@ -151,14 +151,14 @@ recipe test a:number -> z:number [
   z <- copy 1
 ]
 recipe test [
-  z:number <- copy 1
+  reply 34
 ]
 +warn: redefining recipe test
 
 :(scenario static_dispatch_disabled_on_headerless_definition_2)
 % Hide_warnings = true;
 recipe test [
-  z:number <- copy 1
+  reply 34
 ]
 recipe test a:number -> z:number [
   z <- copy 1