From e46306432ddb75a89f69d92ccc175a23f0b72072 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sat, 25 Jul 2015 14:19:28 -0700 Subject: 1848 - core instructions now check for ingredients Also standardized warnings. --- 041jump_label.cc | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to '041jump_label.cc') diff --git a/041jump_label.cc b/041jump_label.cc index 2527e813..a24970d5 100644 --- a/041jump_label.cc +++ b/041jump_label.cc @@ -26,7 +26,6 @@ void transform_labels(const recipe_ordinal r) { for (long long int i = 0; i < SIZE(Recipe[r].steps); ++i) { instruction& inst = Recipe[r].steps.at(i); if (inst.operation == Recipe_ordinal["jump"]) { -//? cerr << inst.to_string() << '\n'; //? 1 replace_offset(inst.ingredients.at(0), offset, i, r); } if (inst.operation == Recipe_ordinal["jump-if"] || inst.operation == Recipe_ordinal["jump-unless"]) { @@ -46,15 +45,14 @@ void transform_labels(const recipe_ordinal r) { :(code) void replace_offset(reagent& x, /*const*/ map& offset, const long long int current_offset, const recipe_ordinal r) { -//? cerr << "AAA " << x.to_string() << '\n'; //? 1 - assert(is_literal(x)); -//? cerr << "BBB " << x.to_string() << '\n'; //? 1 + if (!is_literal(x)) { + raise << Recipe[r].name << ": jump target must be offset or label but is " << x.original_string << '\n' << end(); + return; + } assert(!x.initialized); -//? cerr << "CCC " << x.to_string() << '\n'; //? 1 if (is_integer(x.name)) return; // non-labels will be handled like other number operands -//? cerr << "DDD " << x.to_string() << '\n'; //? 1 if (offset.find(x.name) == offset.end()) - raise << "can't find label " << x.name << " in routine " << Recipe[r].name << '\n' << end(); + raise << Recipe[r].name << ": can't find label " << x.name << '\n' << end(); x.set_value(offset[x.name]-current_offset); } -- cgit 1.4.1-2-gfad0