about summary refs log tree commit diff stats
path: root/035call_ingredient.cc
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-10-01 17:30:14 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-10-01 17:30:14 -0700
commit166e3c0d407a967d25d793b6a9db56ffd7a03727 (patch)
tree73b18adca78fda2a4b1ef5a65fe3851e77248d93 /035call_ingredient.cc
parent16386f766ec1e347db8a19ebfd9cedaa9b281a5f (diff)
downloadmu-166e3c0d407a967d25d793b6a9db56ffd7a03727.tar.gz
2232
Diffstat (limited to '035call_ingredient.cc')
-rw-r--r--035call_ingredient.cc29
1 files changed, 20 insertions, 9 deletions
diff --git a/035call_ingredient.cc b/035call_ingredient.cc
index 3cfc44ce..3772c644 100644
--- a/035call_ingredient.cc
+++ b/035call_ingredient.cc
@@ -35,12 +35,16 @@ for (long long int i = 0; i < SIZE(ingredients); ++i) {
 NEXT_INGREDIENT,
 :(before "End Primitive Recipe Numbers")
 Recipe_ordinal["next-ingredient"] = NEXT_INGREDIENT;
-:(before "End Primitive Recipe Implementations")
+:(before "End Primitive Recipe Checks")
 case NEXT_INGREDIENT: {
-  if (!ingredients.empty()) {
-    raise << maybe(current_recipe_name()) << "'next-ingredient' didn't expect any ingredients in '" << current_instruction().to_string() << "'\n" << end();
+  if (!inst.ingredients.empty()) {
+    raise << maybe(Recipe[r].name) << "'next-ingredient' didn't expect any ingredients in '" << inst.to_string() << "'\n" << end();
     break;
   }
+  break;
+}
+:(before "End Primitive Recipe Implementations")
+case NEXT_INGREDIENT: {
   assert(!Current_routine->calls.empty());
   if (Current_routine->calls.front().next_ingredient_to_process < SIZE(Current_routine->calls.front().ingredient_atoms)) {
     products.push_back(
@@ -88,6 +92,10 @@ recipe f [
 REWIND_INGREDIENTS,
 :(before "End Primitive Recipe Numbers")
 Recipe_ordinal["rewind-ingredients"] = REWIND_INGREDIENTS;
+:(before "End Primitive Recipe Checks")
+case REWIND_INGREDIENTS: {
+  break;
+}
 :(before "End Primitive Recipe Implementations")
 case REWIND_INGREDIENTS: {
   Current_routine->calls.front().next_ingredient_to_process = 0;
@@ -109,17 +117,20 @@ recipe f [
 INGREDIENT,
 :(before "End Primitive Recipe Numbers")
 Recipe_ordinal["ingredient"] = INGREDIENT;
-:(before "End Primitive Recipe Implementations")
+:(before "End Primitive Recipe Checks")
 case INGREDIENT: {
-  if (SIZE(ingredients) != 1) {
-    raise << maybe(current_recipe_name()) << "'ingredient' expects exactly one ingredient, but got '" << current_instruction().to_string() << "'\n" << end();
+  if (SIZE(inst.ingredients) != 1) {
+    raise << maybe(Recipe[r].name) << "'ingredient' expects exactly one ingredient, but got '" << inst.to_string() << "'\n" << end();
     break;
   }
-  if (!is_literal(current_instruction().ingredients.at(0))) {
-    raise << maybe(current_recipe_name()) << "'ingredient' expects a literal ingredient, but got " << current_instruction().ingredients.at(0).original_string << '\n' << end();
+  if (!is_literal(inst.ingredients.at(0)) && !is_mu_scalar(inst.ingredients.at(0))) {
+    raise << maybe(Recipe[r].name) << "'ingredient' expects a literal ingredient, but got " << inst.ingredients.at(0).original_string << '\n' << end();
     break;
   }
-  assert(scalar(ingredients.at(0)));
+  break;
+}
+:(before "End Primitive Recipe Implementations")
+case INGREDIENT: {
   if (static_cast<long long int>(ingredients.at(0).at(0)) < SIZE(Current_routine->calls.front().ingredient_atoms)) {
     Current_routine->calls.front().next_ingredient_to_process = ingredients.at(0).at(0);
     products.push_back(