From 1a6c5a0d489297a3235b7daf18fea8ef71875530 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Thu, 25 Aug 2016 10:26:21 -0700 Subject: 3248 --- 042name.cc | 3 ++- 071recipe.cc | 20 +++++++++++++++++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/042name.cc b/042name.cc index eeebe3da..2711b94d 100644 --- a/042name.cc +++ b/042name.cc @@ -50,6 +50,7 @@ void transform_names(const recipe_ordinal r) { // map names to addresses for (int in = 0; in < SIZE(inst.ingredients); ++in) { reagent& ingredient = inst.ingredients.at(in); + // Begin transform_names Ingredient Special-cases(ingredient, inst, caller) if (is_disqualified(ingredient, inst, caller.name)) continue; if (is_numeric_location(ingredient)) numeric_locations_used = true; if (is_named_location(ingredient)) names_used = true; @@ -70,6 +71,7 @@ void transform_names(const recipe_ordinal r) { } for (int out = 0; out < SIZE(inst.products); ++out) { reagent& product = inst.products.at(out); + // Begin transform_names Product Special-cases(product, inst, caller) if (is_disqualified(product, inst, caller.name)) continue; if (is_numeric_location(product)) numeric_locations_used = true; if (is_named_location(product)) names_used = true; @@ -96,7 +98,6 @@ void transform_names(const recipe_ordinal r) { bool is_disqualified(/*mutable*/ reagent& x, const instruction& inst, const string& recipe_name) { if (!x.type) { - // End Null-type is_disqualified Exceptions raise << maybe(recipe_name) << "missing type for '" << x.original_string << "' in '" << inst.original_string << "'\n" << end(); return true; } diff --git a/071recipe.cc b/071recipe.cc index e41eb494..13c5874e 100644 --- a/071recipe.cc +++ b/071recipe.cc @@ -33,11 +33,25 @@ put(Type_ordinal, "recipe-literal", 0); type_ordinal recipe = put(Type_ordinal, "recipe", Next_type_ordinal++); get_or_insert(Type, recipe).name = "recipe"; -:(before "End Null-type is_disqualified Exceptions") -if (!x.type && contains_key(Recipe_ordinal, x.name)) { +:(after "Begin transform_names Ingredient Special-cases(ingredient, inst, caller)") +if (is_recipe_literal(ingredient)) { + initialize_recipe_literal(ingredient); + continue; +} +:(after "Begin transform_names Product Special-cases(product, inst, caller)") +if (is_recipe_literal(product)) { + initialize_recipe_literal(product); + continue; +} +:(code) +bool is_recipe_literal(const reagent& x) { + if (x.type) return false; + if (!contains_key(Recipe_ordinal, x.name)) return false; + return true; +} +void initialize_recipe_literal(reagent& x) { x.type = new type_tree("recipe-literal"); x.set_value(get(Recipe_ordinal, x.name)); - return true; } :(before "End Primitive Recipe Declarations") -- cgit 1.4.1-2-gfad0