From 46026f62877a1c6c218f9d551ce2e261298f2540 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Fri, 24 Jul 2015 01:14:49 -0700 Subject: 1835 --- 032array.cc | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/032array.cc b/032array.cc index 1231eb8b..9dad84ac 100644 --- a/032array.cc +++ b/032array.cc @@ -42,7 +42,10 @@ recipe main [ if (x.types.at(0) == Type_ordinal["array"]) return false; :(before "End size_of(reagent) Cases") if (r.types.at(0) == Type_ordinal["array"]) { - assert(SIZE(r.types) > 1); + if (SIZE(r.types) == 1) { + raise << current_recipe_name() << ": '" << r.original_string << "' is an array of what?\n"; + return 1; + } // skip the 'array' type to get at the element type return 1 + Memory[r.value]*size_of(array_element(r.types)); } @@ -80,7 +83,10 @@ case INDEX: { reagent base = canonize(current_instruction().ingredients.at(0)); //? trace(Primitive_recipe_depth, "run") << "ingredient 0 after canonize: " << base.to_string(); //? 1 long long int base_address = base.value; - assert(base.types.at(0) == Type_ordinal["array"]); + if (base.types.at(0) != Type_ordinal["array"]) { + raise << current_recipe_name () << ": 'index' on a non-array " << base.original_string << '\n'; + break; + } reagent offset = canonize(current_instruction().ingredients.at(1)); //? trace(Primitive_recipe_depth, "run") << "ingredient 1 after canonize: " << offset.to_string(); //? 1 vector offset_val(read_memory(offset)); @@ -168,7 +174,10 @@ Recipe_ordinal["index-address"] = INDEX_ADDRESS; case INDEX_ADDRESS: { reagent base = canonize(current_instruction().ingredients.at(0)); long long int base_address = base.value; - assert(base.types.at(0) == Type_ordinal["array"]); + if (base.types.at(0) != Type_ordinal["array"]) { + raise << current_recipe_name () << ": 'index-address' on a non-array " << base.original_string << '\n'; + break; + } reagent offset = canonize(current_instruction().ingredients.at(1)); vector offset_val(read_memory(offset)); vector element_type = array_element(base.types); -- cgit 1.4.1-2-gfad0