From 2142ccfc37db49b59ff7e4da47a59adb3a043615 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Thu, 1 Oct 2015 23:44:17 -0700 Subject: 2233 - basic checks for non-primitive recipes This came last because we had to ensure all primitives are covered. --- 030container.cc | 7 ++++++- 034call.cc | 15 ++++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/030container.cc b/030container.cc index 89ba58de..8071ff4c 100644 --- a/030container.cc +++ b/030container.cc @@ -160,7 +160,7 @@ case GET: { } type_ordinal base_type = base.types.at(0); long long int offset = ingredients.at(1).at(0); - if (offset < 0 || offset >= SIZE(Type[base_type].elements)) break; + if (offset < 0 || offset >= SIZE(Type[base_type].elements)) break; // copied from Check above long long int src = base_address; for (long long int i = 0; i < offset; ++i) { src += size_of(Type[base_type].elements.at(i)); @@ -256,6 +256,7 @@ case GET_ADDRESS: { } type_ordinal base_type = base.types.at(0); long long int offset = ingredients.at(1).at(0); + if (offset < 0 || offset >= SIZE(Type[base_type].elements)) break; // copied from Check above long long int result = base_address; for (long long int i = 0; i < offset; ++i) { result += size_of(Type[base_type].elements.at(i)); @@ -505,6 +506,10 @@ void check_container_field_types() { MERGE, :(before "End Primitive Recipe Numbers") Recipe_ordinal["merge"] = MERGE; +:(before "End Primitive Recipe Checks") +case MERGE: { + break; +} :(before "End Primitive Recipe Implementations") case MERGE: { products.resize(1); diff --git a/034call.cc b/034call.cc index f1c82f7f..43c9061f 100644 --- a/034call.cc +++ b/034call.cc @@ -77,15 +77,16 @@ inline const instruction& current_instruction() { return Recipe[Current_routine->calls.front().running_recipe].steps.at(Current_routine->calls.front().running_step_index); } +:(after "Defined Recipe Checks") +// not a primitive; check that it's present in the book of recipes +if (Recipe.find(inst.operation) == Recipe.end()) { + raise << maybe(Recipe[r].name) << "undefined operation in '" << inst.to_string() << "'\n" << end(); + break; +} :(replace{} "default:" following "End Primitive Recipe Implementations") default: { - // not a primitive; try to look up the book of recipes - if (Recipe.find(current_instruction().operation) == Recipe.end()) { - raise << maybe(current_recipe_name()) << "undefined operation in '" << current_instruction().to_string() << "'\n" << end(); - // stop running this instruction immediately - ++current_step_index(); - continue; - } + if (Recipe.find(current_instruction().operation) == Recipe.end()) break; // duplicate from Checks + // not a primitive; look up the book of recipes Current_routine->calls.push_front(call(current_instruction().operation)); call_housekeeping: ++Callstack_depth; -- cgit 1.4.1-2-gfad0 ref='/akkartik/mu/blame/arc/Readme?h=hlt&id=6152ef13a865eb1795fd5547f4d307a6f5690558'>blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14