diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2016-01-19 19:03:20 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2016-01-19 19:03:20 -0800 |
commit | ff9d5f43cfcc18e853de8d92ade1f962961fa516 (patch) | |
tree | e2732cbe6e58b9bb42efff3cd0829d639946ae35 | |
parent | bb33c5e89993338f6e554210e87b27a5220ead98 (diff) | |
download | mu-ff9d5f43cfcc18e853de8d92ade1f962961fa516.tar.gz |
2574
-rw-r--r-- | 031address.cc | 12 | ||||
-rw-r--r-- | 038new.cc | 15 |
2 files changed, 12 insertions, 15 deletions
diff --git a/031address.cc b/031address.cc index 8efd5cd8..7f2937e5 100644 --- a/031address.cc +++ b/031address.cc @@ -57,7 +57,7 @@ void lookup_memory(reagent& x) { } trace(9999, "mem") << "location " << x.value << " is " << no_scientific(get_or_insert(Memory, x.value)) << end(); x.set_value(get_or_insert(Memory, x.value)); - drop_address_from_type(x); + drop_from_type(x, "address"); drop_one_lookup(x); } @@ -88,15 +88,19 @@ bool canonize_type(reagent& r) { raise_error << "can't lookup non-address: " << r.to_string() << ": " << debug_string(r.type) << '\n' << end(); return false; } - drop_address_from_type(r); + drop_from_type(r, "address"); drop_one_lookup(r); } return true; } -void drop_address_from_type(reagent& r) { +void drop_from_type(reagent& r, string expected_type) { if (!r.type) { - raise_error << "can't drop address from " << debug_string(r) << '\n' << end(); + raise_error << "can't drop " << expected_type << " from " << debug_string(r) << '\n' << end(); + return; + } + if (r.properties.at(0).second->value != expected_type) { + raise_error << "can't drop " << expected_type << " from " << debug_string(r) << '\n' << end(); return; } type_tree* tmp = r.type; diff --git a/038new.cc b/038new.cc index 21273cfa..2d7337a3 100644 --- a/038new.cc +++ b/038new.cc @@ -52,17 +52,10 @@ case NEW: { } reagent product(inst.products.at(0)); canonize_type(product); - drop_address_from_type(product); + drop_from_type(product, "address"); if (SIZE(inst.ingredients) > 1) { - // array allocation, so drop an 'array' as well from product.type - type_tree* tmp = product.type; - if (tmp->value != get(Type_ordinal, "array")) { - raise_error << maybe(caller.name) << "result of 'new' should start with 'address:array:...' in " << inst.to_string() << '\n' << end(); - break; - } - product.type = tmp->right; - tmp->right = NULL; - delete tmp; + // array allocation + drop_from_type(product, "array"); } reagent expected_product("x:"+type.name); // End Post-processing(expected_product) When Checking 'new' @@ -260,7 +253,7 @@ case ABANDON: { canonize(types); // lookup_memory without drop_one_lookup { types.set_value(get_or_insert(Memory, types.value)); - drop_address_from_type(types); + drop_from_type(types, "address"); // } abandon(address, size_of(types)); break; |