diff options
Diffstat (limited to '024jump.cc')
-rw-r--r-- | 024jump.cc | 50 |
1 files changed, 31 insertions, 19 deletions
diff --git a/024jump.cc b/024jump.cc index 925906de..dabe33bb 100644 --- a/024jump.cc +++ b/024jump.cc @@ -13,16 +13,20 @@ recipe main [ JUMP, :(before "End Primitive Recipe Numbers") Recipe_ordinal["jump"] = JUMP; -:(before "End Primitive Recipe Implementations") +:(before "End Primitive Recipe Checks") case JUMP: { - if (SIZE(ingredients) != 1) { - raise << current_recipe_name() << ": 'jump' requires exactly one ingredient, but got " << current_instruction().to_string() << '\n' << end(); + if (SIZE(inst.ingredients) != 1) { + raise << Recipe[r].name << ": 'jump' requires exactly one ingredient, but got " << inst.to_string() << '\n' << end(); break; } - if (!scalar(ingredients.at(0))) { - raise << current_recipe_name() << ": first ingredient of 'jump' should be a label or offset, but got " << current_instruction().ingredients.at(0).original_string << '\n' << end(); + if (!is_mu_scalar(inst.ingredients.at(0))) { + raise << Recipe[r].name << ": first ingredient of 'jump' should be a label or offset, but got " << inst.ingredients.at(0).original_string << '\n' << end(); break; } + break; +} +:(before "End Primitive Recipe Implementations") +case JUMP: { assert(current_instruction().ingredients.at(0).initialized); current_step_index() += ingredients.at(0).at(0)+1; trace(Primitive_recipe_depth, "run") << "jumping to instruction " << current_step_index() << end(); @@ -48,20 +52,24 @@ recipe main [ JUMP_IF, :(before "End Primitive Recipe Numbers") Recipe_ordinal["jump-if"] = JUMP_IF; -:(before "End Primitive Recipe Implementations") +:(before "End Primitive Recipe Checks") case JUMP_IF: { - if (SIZE(ingredients) != 2) { - raise << current_recipe_name() << ": 'jump-if' requires exactly two ingredients, but got " << current_instruction().to_string() << '\n' << end(); + if (SIZE(inst.ingredients) != 2) { + raise << Recipe[r].name << ": 'jump-if' requires exactly two ingredients, but got " << inst.to_string() << '\n' << end(); break; } - if (!scalar(ingredients.at(0))) { - raise << current_recipe_name() << ": 'jump-if' requires a boolean for its first ingredient, but got " << current_instruction().ingredients.at(0).original_string << '\n' << end(); + if (!is_mu_scalar(inst.ingredients.at(0))) { + raise << Recipe[r].name << ": 'jump-if' requires a boolean for its first ingredient, but got " << inst.ingredients.at(0).original_string << '\n' << end(); break; } - if (!scalar(ingredients.at(1))) { - raise << current_recipe_name() << ": 'jump-if' requires a label or offset for its second ingredient, but got " << current_instruction().ingredients.at(0).original_string << '\n' << end(); + if (!is_mu_scalar(inst.ingredients.at(1))) { + raise << Recipe[r].name << ": 'jump-if' requires a label or offset for its second ingredient, but got " << inst.ingredients.at(0).original_string << '\n' << end(); break; } + break; +} +:(before "End Primitive Recipe Implementations") +case JUMP_IF: { assert(current_instruction().ingredients.at(1).initialized); if (!ingredients.at(0).at(0)) { trace(Primitive_recipe_depth, "run") << "jump-if fell through" << end(); @@ -96,20 +104,24 @@ recipe main [ JUMP_UNLESS, :(before "End Primitive Recipe Numbers") Recipe_ordinal["jump-unless"] = JUMP_UNLESS; -:(before "End Primitive Recipe Implementations") +:(before "End Primitive Recipe Checks") case JUMP_UNLESS: { - if (SIZE(ingredients) != 2) { - raise << current_recipe_name() << ": 'jump-unless' requires exactly two ingredients, but got " << current_instruction().to_string() << '\n' << end(); + if (SIZE(inst.ingredients) != 2) { + raise << Recipe[r].name << ": 'jump-unless' requires exactly two ingredients, but got " << inst.to_string() << '\n' << end(); break; } - if (!scalar(ingredients.at(0))) { - raise << current_recipe_name() << ": 'jump-unless' requires a boolean for its first ingredient, but got " << current_instruction().ingredients.at(0).original_string << '\n' << end(); + if (!is_mu_scalar(inst.ingredients.at(0))) { + raise << Recipe[r].name << ": 'jump-unless' requires a boolean for its first ingredient, but got " << inst.ingredients.at(0).original_string << '\n' << end(); break; } - if (!scalar(ingredients.at(1))) { - raise << current_recipe_name() << ": 'jump-unless' requires a label or offset for its second ingredient, but got " << current_instruction().ingredients.at(0).original_string << '\n' << end(); + if (!is_mu_scalar(inst.ingredients.at(1))) { + raise << Recipe[r].name << ": 'jump-unless' requires a label or offset for its second ingredient, but got " << inst.ingredients.at(0).original_string << '\n' << end(); break; } + break; +} +:(before "End Primitive Recipe Implementations") +case JUMP_UNLESS: { assert(current_instruction().ingredients.at(1).initialized); if (ingredients.at(0).at(0)) { trace(Primitive_recipe_depth, "run") << "jump-unless fell through" << end(); |