diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2017-11-19 04:18:31 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2017-11-19 04:18:31 -0800 |
commit | 0e1ebc3eb390e29ed31b2b9f2e8781e5824fe95f (patch) | |
tree | 3093afe398aa7015788f6d67a7ae1039c8975966 /076continuation.cc | |
parent | 82f3c320eac140067e1510786fad52c72574348e (diff) | |
download | mu-0e1ebc3eb390e29ed31b2b9f2e8781e5824fe95f.tar.gz |
4130
Diffstat (limited to '076continuation.cc')
-rw-r--r-- | 076continuation.cc | 68 |
1 files changed, 34 insertions, 34 deletions
diff --git a/076continuation.cc b/076continuation.cc index 79ee0dcd..8cfda4a3 100644 --- a/076continuation.cc +++ b/076continuation.cc @@ -222,6 +222,40 @@ if (is_mu_continuation(current_instruction().ingredients.at(0))) { break; // record results of resuming 'return-continuation-until-mark' instruction } +:(scenario continuations_can_return_values) +def main [ + local-scope + k:continuation, 1:num/raw <- call-with-continuation-mark f +] +def f [ + local-scope + g +] +def g [ + local-scope + return-continuation-until-mark 34 + stash [continuation called] +] +# entering main ++mem: new alloc: 1000 ++run: {k: "continuation"}, {1: "number", "raw": ()} <- call-with-continuation-mark {f: "recipe-literal"} +# entering f ++mem: new alloc: 1004 +# entering g ++mem: new alloc: 1007 +# return control to main ++run: return-continuation-until-mark {34: "literal"} +# no allocs abandoned yet ++mem: storing 34 in location 1 +# end of main +# make sure no memory leaks.. ++mem: trying to reclaim local k:continuation ++mem: automatically abandoning 1007 ++mem: automatically abandoning 1004 ++mem: automatically abandoning 1000 +# ..even though we never called the continuation +-app: continuation called + //: Ensure that the presence of a continuation keeps its stack frames from being reclaimed. :(scenario continuations_preserve_local_scopes) @@ -283,37 +317,3 @@ bool is_mu_continuation(reagent/*copy*/ x) { canonize_type(x); return x.type && x.type->atom && x.type->value == get(Type_ordinal, "continuation"); } - -:(scenario continuations_can_return_values) -def main [ - local-scope - k:continuation, 1:num/raw <- call-with-continuation-mark f -] -def f [ - local-scope - g -] -def g [ - local-scope - return-continuation-until-mark 34 - stash [continuation called] -] -# entering main -+mem: new alloc: 1000 -+run: {k: "continuation"}, {1: "number", "raw": ()} <- call-with-continuation-mark {f: "recipe-literal"} -# entering f -+mem: new alloc: 1004 -# entering g -+mem: new alloc: 1007 -# return control to main -+run: return-continuation-until-mark {34: "literal"} -# no allocs abandoned yet -+mem: storing 34 in location 1 -# end of main -# make sure no memory leaks.. -+mem: trying to reclaim local k:continuation -+mem: automatically abandoning 1007 -+mem: automatically abandoning 1004 -+mem: automatically abandoning 1000 -# ..even though we never called the continuation --app: continuation called |