diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-10-07 00:22:49 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-10-07 00:22:49 -0700 |
commit | 7afe09fbfeb88e3be98dfe4f0db43f66724d4abf (patch) | |
tree | 0592cc6cf3e98aa25ec9c35b638a56baeff1d5e3 /053continuation.cc | |
parent | 857adbc496dca7d41e46cbece815a24d32c735fe (diff) | |
download | mu-7afe09fbfeb88e3be98dfe4f0db43f66724d4abf.tar.gz |
2262 - strengthen some type checks
Diffstat (limited to '053continuation.cc')
-rw-r--r-- | 053continuation.cc | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/053continuation.cc b/053continuation.cc index c9a6a5cb..9ccd6311 100644 --- a/053continuation.cc +++ b/053continuation.cc @@ -44,8 +44,8 @@ CONTINUE_FROM, Recipe_ordinal["continue-from"] = CONTINUE_FROM; :(before "End Primitive Recipe Checks") case CONTINUE_FROM: { - if (!is_mu_scalar(inst.ingredients.at(0))) { - raise_error << maybe(Recipe[r].name) << "first ingredient of 'continue-from' should be a continuation id generated by 'current-continuation', but got " << inst.ingredients.at(0).original_string << '\n' << end(); + if (!is_mu_continuation(inst.ingredients.at(0))) { + raise_error << maybe(Recipe[r].name) << "first ingredient of 'continue-from' should be a continuation generated by 'current-continuation', but got " << inst.ingredients.at(0).original_string << '\n' << end(); break; } break; @@ -57,6 +57,12 @@ case CONTINUE_FROM: { continue; // skip rest of this instruction } +:(code) +bool is_mu_continuation(const reagent& x) { + if (x.types.empty()) return false; + return x.types.at(0) == Type_ordinal["continuation"]; +} + :(scenario continuation) # simulate a loop using continuations recipe main [ @@ -253,3 +259,6 @@ call_stack::iterator find_reset(call_stack& c) { ingredients.erase(ingredients.begin()); // drop the callee goto call_housekeeping; } + +:(before "End is_mu_recipe Cases") +if (r.types.at(0) == Type_ordinal["continuation"]) return true; |