diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-11-06 15:25:40 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-11-06 15:25:40 -0800 |
commit | 3bcc53bcd6345dc5aa6ddeca949ab59dba6e7590 (patch) | |
tree | cfb294ed9bcc75d88afd45eb09383a4bfca9bbeb | |
parent | c157066cab02f91b2d5e53dbec09151936538578 (diff) | |
download | mu-3bcc53bcd6345dc5aa6ddeca949ab59dba6e7590.tar.gz |
2381
-rw-r--r-- | 010vm.cc | 2 | ||||
-rw-r--r-- | 030container.cc | 16 |
2 files changed, 14 insertions, 4 deletions
diff --git a/010vm.cc b/010vm.cc index b4ba23f1..cf46bc65 100644 --- a/010vm.cc +++ b/010vm.cc @@ -275,6 +275,8 @@ type_tree* new_type_tree(const string_tree* properties) { const string& type_name = properties->value; if (contains_key(Type_ordinal, type_name)) result->value = get(Type_ordinal, type_name); + else + result->value = -1; } result->left = new_type_tree(properties->left); result->right = new_type_tree(properties->right); diff --git a/030container.cc b/030container.cc index ae6f590c..5c19c4c8 100644 --- a/030container.cc +++ b/030container.cc @@ -83,6 +83,10 @@ recipe main [ +mem: storing 0 in location 7 :(before "End size_of(type) Cases") +if (type->value == -1) { + // error value, but we'll raise it elsewhere + return 1; +} if (type->value == 0) { assert(!type->left && !type->right); return 1; @@ -458,6 +462,7 @@ vector<type_ordinal> recently_added_types; recently_added_types.clear(); :(before "End Setup") //: for tests for (long long int i = 0; i < SIZE(recently_added_types); ++i) { + if (!contains_key(Type, recently_added_types.at(i))) continue; Type_ordinal.erase(get(Type, recently_added_types.at(i)).name); // todo: why do I explicitly need to provide this? for (long long int j = 0; j < SIZE(Type.at(recently_added_types.at(i)).elements); ++j) { @@ -530,11 +535,14 @@ void check_invalid_types(const recipe_ordinal r) { void check_invalid_types(const type_tree* type, const string& block, const string& name) { if (!type) return; // will throw a more precise error elsewhere // End Container Type Checks - if (type->value && (!contains_key(Type, type->value) || get(Type, type->value).name.empty())) { - raise_error << block << "unknown type in " << name << '\n' << end(); + if (type->value == 0) { + assert(!type->left && !type->right); + return; } - if (type->left) check_invalid_types(type->left, block, name); - if (type->right) check_invalid_types(type->right, block, name); + if (!contains_key(Type, type->value)) + raise_error << block << "unknown type in " << name << '\n' << end(); + check_invalid_types(type->left, block, name); + check_invalid_types(type->right, block, name); } :(scenario container_unknown_field) |