diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2017-12-10 03:44:49 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2017-12-10 03:44:49 -0800 |
commit | 1cd833619e355c70d5d96a208cd67ba3a3ccb937 (patch) | |
tree | 3bfce5ec1e5efc71aef91220f68f045408117c7b | |
parent | 7847762229f065e07e8a9cc80a41e0ab2359c587 (diff) | |
download | mu-1cd833619e355c70d5d96a208cd67ba3a3ccb937.tar.gz |
4159
Many continuation examples were failing since commit 4151. Include one of them as a test.
-rw-r--r-- | 076continuation.cc | 29 | ||||
-rw-r--r-- | continuation2.mu | 4 |
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 ] |