about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--076continuation.cc29
-rw-r--r--continuation2.mu4
2 files changed, 30 insertions, 3 deletions
diff --git a/076continuation.cc b/076continuation.cc
index d6059c22..98cd70ee 100644
--- a/076continuation.cc
+++ b/076continuation.cc
@@ -276,9 +276,21 @@ def f x:_elem -> y:_elem [
 
 :(before "End resolve_ambiguous_call(r, index, inst, caller_recipe) Special-cases")
 if (inst.name == "call-with-continuation-mark" && first_ingredient_is_recipe_literal(inst)) {
-  resolve_indirect_ambiguous_call(r, index, inst, caller_recipe);
+  resolve_indirect_continuation_call(r, index, inst, caller_recipe);
   return;
 }
+:(code)
+void resolve_indirect_continuation_call(const recipe_ordinal r, int index, instruction& inst, const recipe& caller_recipe) {
+  instruction inst2;
+  inst2.name = inst.ingredients.at(0).name;
+  for (int i = /*skip recipe*/1;  i < SIZE(inst.ingredients);  ++i)
+    inst2.ingredients.push_back(inst.ingredients.at(i));
+  for (int i = /*skip continuation*/1;  i < SIZE(inst.products);  ++i)
+    inst2.products.push_back(inst.products.at(i));
+  resolve_ambiguous_call(r, index, inst2, caller_recipe);
+  inst.ingredients.at(0).name = inst2.name;
+  inst.ingredients.at(0).set_value(get(Recipe_ordinal, inst2.name));
+}
 
 :(scenario call_shape_shifting_recipe_with_continuation_mark_and_no_outputs)
 def main [
@@ -291,6 +303,21 @@ def f x:_elem [
 ]
 $error: 0
 
+:(scenario continuation1)
+def main [
+  local-scope
+  k:continuation <- call-with-continuation-mark create-yielder
+  10:num/raw <- call k
+]
+def create-yielder -> n:num [
+  local-scope
+  load-inputs
+  return-continuation-until-mark
+  return 1
+]
++mem: storing 1 in location 10
+$error: 0
+
 //: Ensure that the presence of a continuation keeps its stack frames from being reclaimed.
 
 :(scenario continuations_preserve_local_scopes)
diff --git a/continuation2.mu b/continuation2.mu
index def83867..6906a385 100644
--- a/continuation2.mu
+++ b/continuation2.mu
@@ -30,8 +30,8 @@ def create-yielder l:&:list:num -> n:num, done?:bool [
   local-scope
   load-inputs
   return-continuation-until-mark
-  done? <- equal l, 0
-  return-if done?, 0
+  done? <- equal l, 0/nil
+  return-if done?, 0/false
   n <- first l
   l <- rest l
 ]