diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2016-01-30 22:30:08 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2016-01-30 22:30:08 -0800 |
commit | d215081d872f776a3d49ab54abf450f20d39572c (patch) | |
tree | 4a83a69405ae9d59acb10046b5d8776d47c3540c | |
parent | 4d238fd71e675d9fa060c03841cac9c356389b97 (diff) | |
download | mu-d215081d872f776a3d49ab54abf450f20d39572c.tar.gz |
2621 - bugfix: empty shape-shifting recipes
My transform pipeline ignores empty recipes, but when I specialized shape-shifting ones I forgot that check.
-rw-r--r-- | 059shape_shifting_recipe.cc | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/059shape_shifting_recipe.cc b/059shape_shifting_recipe.cc index 5b423e9a..dcd041ac 100644 --- a/059shape_shifting_recipe.cc +++ b/059shape_shifting_recipe.cc @@ -77,14 +77,16 @@ if (best_score == -1) { recipe_ordinal new_recipe_ordinal = new_variant(exemplar, inst, caller_recipe); if (new_recipe_ordinal == 0) goto done_constructing_variant; variants.push_back(new_recipe_ordinal); + recipe& variant = get(Recipe, new_recipe_ordinal); // perform all transforms on the new specialization - const string& new_name = get(Recipe, variants.back()).name; - trace(9992, "transform") << "transforming new specialization: " << new_name << end(); - for (long long int t = 0; t < SIZE(Transform); ++t) { - (*Transform.at(t))(new_recipe_ordinal); + if (!variant.steps.empty()) { + trace(9992, "transform") << "transforming new specialization: " << variant.name << end(); + for (long long int t = 0; t < SIZE(Transform); ++t) { + (*Transform.at(t))(new_recipe_ordinal); + } } - get(Recipe, new_recipe_ordinal).transformed_until = SIZE(Transform)-1; - inst.name = get(Recipe, variants.back()).name; + variant.transformed_until = SIZE(Transform)-1; + inst.name = variant.name; trace(9992, "transform") << "new specialization: " << inst.name << end(); } done_constructing_variant:; @@ -533,6 +535,15 @@ container foo:_t [ +mem: storing 14 in location 20 +mem: storing 15 in location 21 +:(scenario shape_shifting_recipe_empty) +recipe main [ + foo 1 +] +# shape-shifting recipe with no body +recipe foo a:_t [ +] +# shouldn't crash + :(scenario shape_shifting_recipe_handles_shape_shifting_new_ingredient) recipe main [ 1:address:shared:foo:point <- bar 3 |