From 7afe09fbfeb88e3be98dfe4f0db43f66724d4abf Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Wed, 7 Oct 2015 00:22:49 -0700 Subject: 2262 - strengthen some type checks --- 053continuation.cc | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to '053continuation.cc') 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; -- cgit 1.4.1-2-gfad0