about summary refs log tree commit diff stats
path: root/059shape_shifting_recipe.cc
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-11-14 22:59:09 -0800
committerKartik K. Agaram <vc@akkartik.com>2015-11-14 22:59:09 -0800
commit5bbd91a06eb2e315682a77fb4845c3321a0b3920 (patch)
tree676e45c0f0d50f4f2e7d92c33bd12787389cabdd /059shape_shifting_recipe.cc
parent687f871a932cefbb66b8eb189d312058f4e02a99 (diff)
downloadmu-5bbd91a06eb2e315682a77fb4845c3321a0b3920.tar.gz
2438 - specialize inside header-less recipes
What was I thinking with 2366?

Thanks Caleb Couch. It turned out we couldn't call shape-shifting
recipes inside the edit/ or sandbox/ apps.
Diffstat (limited to '059shape_shifting_recipe.cc')
-rw-r--r--059shape_shifting_recipe.cc27
1 files changed, 26 insertions, 1 deletions
diff --git a/059shape_shifting_recipe.cc b/059shape_shifting_recipe.cc
index e308be3a..bc63d616 100644
--- a/059shape_shifting_recipe.cc
+++ b/059shape_shifting_recipe.cc
@@ -20,11 +20,20 @@ recipe foo a:_t -> result:_t [
 +mem: storing 14 in location 11
 +mem: storing 15 in location 12
 
-//: Before anything else, disable transforms for shape-shifting recipes.
+//: Before anything else, disable transforms for shape-shifting recipes and
+//: make sure we never try to actually run a shape-shifting recipe. We should
+//: be rewriting such instructions to *specializations* with the type
+//: ingredients filled in.
 
 :(before "End Transform Checks")
 if (any_type_ingredient_in_header(/*recipe_ordinal*/p->first)) continue;
 
+:(after "Running One Instruction")
+if (Current_routine->calls.front().running_step_index == 0
+    && any_type_ingredient_in_header(Current_routine->calls.front().running_recipe)) {
+  raise_error << "ran into unspecialized shape-shifting recipe " << current_recipe_name() << '\n' << end();
+}
+
 //: We'll be creating recipes without loading them from anywhere by
 //: *specializing* existing recipes, so make sure we don't clear any of those
 //: when we start running tests.
@@ -442,3 +451,19 @@ recipe foo a:_t -> b:_t [
   b <- copy a
 ]
 +error: main: no call found for 'b:address:number <- foo a'
+
+:(scenario specialize_inside_recipe_without_header)
+recipe main [
+  foo 3
+]
+recipe foo [
+  local-scope
+  x:number <- next-ingredient  # ensure no header
+  1:number/raw <- bar x  # call a shape-shifting recipe
+]
+recipe bar x:_elem -> y:_elem [
+  local-scope
+  load-ingredients
+  y <- add x, 1
+]
++mem: storing 4 in location 1