diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2016-03-21 02:53:34 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2016-03-21 02:53:34 -0700 |
commit | d57bf669c20f1936af8674d549bfb01c01f68f4f (patch) | |
tree | 0d10ba2f55f1d7725c193871900ffb3152564d66 /042name.cc | |
parent | acc4792d2f7c787aad064876a1eb2d00bdf076b2 (diff) | |
download | mu-d57bf669c20f1936af8674d549bfb01c01f68f4f.tar.gz |
2804 - support stashing arrays
Now to extend 'stash' for arrays, just extend array-to-text-line instead and perform the lookup inside it.
Diffstat (limited to '042name.cc')
-rw-r--r-- | 042name.cc | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/042name.cc b/042name.cc index 6a9858a6..8cd6cd4f 100644 --- a/042name.cc +++ b/042name.cc @@ -110,14 +110,13 @@ int lookup_name(const reagent& r, const recipe_ordinal default_recipe) { return Name[default_recipe][r.name]; } -type_ordinal skip_addresses(type_tree* type, const string& recipe_name) { +type_ordinal skip_addresses(type_tree* type) { type_ordinal address = get(Type_ordinal, "address"); type_ordinal shared = get(Type_ordinal, "shared"); for (; type; type = type->right) { if (type->value != address && type->value != shared) return type->value; } - raise << maybe(recipe_name) << "expected a container" << '\n' << end(); return -1; } @@ -220,7 +219,9 @@ if (inst.name == "get" || inst.name == "get-address") { raise << maybe(get(Recipe, r).name) << "expected ingredient 1 of " << (inst.name == "get" ? "'get'" : "'get-address'") << " to have type 'offset'; got " << inst.ingredients.at(1).original_string << '\n' << end(); if (inst.ingredients.at(1).name.find_first_not_of("0123456789") != string::npos) { // since first non-address in base type must be a container, we don't have to canonize - type_ordinal base_type = skip_addresses(inst.ingredients.at(0).type, get(Recipe, r).name); + type_ordinal base_type = skip_addresses(inst.ingredients.at(0).type); + if (base_type == -1) + raise << maybe(get(Recipe, r).name) << "expected a container in '" << to_original_string(inst) << "'\n" << end(); if (contains_key(Type, base_type)) { // otherwise we'll raise an error elsewhere inst.ingredients.at(1).set_value(find_element_name(base_type, inst.ingredients.at(1).name, get(Recipe, r).name)); trace(9993, "name") << "element " << inst.ingredients.at(1).name << " of type " << get(Type, base_type).name << " is at offset " << no_scientific(inst.ingredients.at(1).value) << end(); @@ -261,7 +262,9 @@ if (inst.name == "maybe-convert") { assert(is_literal(inst.ingredients.at(1))); if (inst.ingredients.at(1).name.find_first_not_of("0123456789") != string::npos) { // since first non-address in base type must be an exclusive container, we don't have to canonize - type_ordinal base_type = skip_addresses(inst.ingredients.at(0).type, get(Recipe, r).name); + type_ordinal base_type = skip_addresses(inst.ingredients.at(0).type); + if (base_type == -1) + raise << maybe(get(Recipe, r).name) << "expected an exclusive-container in '" << to_original_string(inst) << "'\n" << end(); if (contains_key(Type, base_type)) { // otherwise we'll raise an error elsewhere inst.ingredients.at(1).set_value(find_element_name(base_type, inst.ingredients.at(1).name, get(Recipe, r).name)); trace(9993, "name") << "variant " << inst.ingredients.at(1).name << " of type " << get(Type, base_type).name << " has tag " << no_scientific(inst.ingredients.at(1).value) << end(); |