diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2016-01-17 23:15:03 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2016-01-17 23:15:03 -0800 |
commit | 83d8299d2d966c39b4970828ff5743a5b05e3287 (patch) | |
tree | d2b0203d068b1c5651c58928c0f2fdf98d558789 /061recipe.cc | |
parent | 94fed2020040cf469bd47c8890ed4e609e3ed561 (diff) | |
download | mu-83d8299d2d966c39b4970828ff5743a5b05e3287.tar.gz |
2562
We want to use the type 'recipe' for recipe *variables*, because it seems nicer to say `recipe number -> number` rather than recipe-ordinal, etc. To support this we'll allow recipe names to be mentioned without any type. This might make a couple of places in this commit more brittle. I'm dropping error messages, causing them to not happen in some situations. Maybe I should just bite the bullet and require an explicit :recipe-literal. We'll see.
Diffstat (limited to '061recipe.cc')
-rw-r--r-- | 061recipe.cc | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/061recipe.cc b/061recipe.cc index 42cc2279..3d7c0eaa 100644 --- a/061recipe.cc +++ b/061recipe.cc @@ -3,23 +3,24 @@ //: recipes, return recipes from recipes and so on. :(before "End Mu Types Initialization") -// 'recipe' is a literal -put(Type_ordinal, "recipe", 0); -// 'recipe-ordinal' is the literal that can store recipe literals -type_ordinal recipe_ordinal = put(Type_ordinal, "recipe-ordinal", Next_type_ordinal++); -get_or_insert(Type, recipe_ordinal).name = "recipe-ordinal"; +put(Type_ordinal, "recipe-literal", 0); +// 'recipe' variables can store recipe-literal +type_ordinal recipe = put(Type_ordinal, "recipe", Next_type_ordinal++); +get_or_insert(Type, recipe).name = "recipe"; -:(before "End Reagent-parsing Exceptions") -if (r.properties.at(0).second && r.properties.at(0).second->value == "recipe") { - r.set_value(get(Recipe_ordinal, r.name)); - return; +:(before "End transform_names Exceptions") +if (!x.properties.at(0).second && contains_key(Recipe_ordinal, x.name)) { + x.properties.at(0).second = new string_tree("recipe-literal"); + x.type = new type_tree(get(Type_ordinal, "recipe-literal")); + x.set_value(get(Recipe_ordinal, x.name)); + return true; } :(code) bool is_mu_recipe(reagent r) { if (!r.type) return false; - if (r.type->value == get(Type_ordinal, "recipe")) return true; - if (r.type->value == get(Type_ordinal, "recipe-ordinal")) return true; + if (r.properties.at(0).second->value == "recipe") return true; + if (r.properties.at(0).second->value == "recipe-literal") return true; // End is_mu_recipe Cases return false; } |