diff options
Diffstat (limited to 'cpp/025name')
-rw-r--r-- | cpp/025name | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/cpp/025name b/cpp/025name index 1c73b16a..375f9854 100644 --- a/cpp/025name +++ b/cpp/025name @@ -90,17 +90,17 @@ type_number skip_addresses(const vector<type_number>& types) { for (size_t i = 0; i < types.size(); ++i) { if (types[i] != Type_number["address"]) return types[i]; } - raise << "expected a record" << '\n' << die(); + raise << "expected a container" << '\n' << die(); return -1; } int find_element_name(const type_number t, const string& name) { - const type_info& record = Type[t]; -//? cout << "looking for field " << name << " in type " << record.name << " with " << record.element_names.size() << " fields\n"; //? 1 - for (size_t i = 0; i < record.element_names.size(); ++i) { - if (record.element_names[i] == name) return i; + const type_info& container = Type[t]; +//? cout << "looking for element " << name << " in type " << container.name << " with " << container.element_names.size() << " elements\n"; //? 1 + for (size_t i = 0; i < container.element_names.size(); ++i) { + if (container.element_names[i] == name) return i; } - raise << "unknown element " << name << " in record " << t << '\n' << die(); + raise << "unknown element " << name << " in container " << t << '\n' << die(); return -1; } @@ -134,20 +134,20 @@ recipe main [ ] -name: assign x 1 -//: update our running example record for the next test +//: update our running example container for the next test :(before "End Mu Types Initialization") Type[point].element_names.push_back("x"); Type[point].element_names.push_back("y"); -:(scenario "convert_names_transforms_record_elements") +:(scenario "convert_names_transforms_container_elements") recipe main [ a:integer <- get 0:point, y:offset b:integer <- get 0:point, x:offset ] -+name: field y of type point is at offset 1 -+name: field x of type point is at offset 0 ++name: element y of type point is at offset 1 ++name: element x of type point is at offset 0 :(after "Per-recipe Transforms") -// replace element names of records with offsets +// replace element names of containers with offsets if (inst.operation == Recipe_number["get"] || inst.operation == Recipe_number["get-address"]) { // at least 2 args, and second arg is offset @@ -155,15 +155,15 @@ if (inst.operation == Recipe_number["get"] //? cout << inst.ingredients[1].to_string() << '\n'; //? 1 assert(isa_literal(inst.ingredients[1])); if (inst.ingredients[1].name.find_first_not_of("0123456789") == string::npos) continue; - // since first non-address in base type must be a record, we don't have to canonize - type_number record = skip_addresses(inst.ingredients[0].types); - inst.ingredients[1].set_value(find_element_name(record, inst.ingredients[1].name)); - trace("name") << "field " << inst.ingredients[1].name << " of type " << Type[record].name << " is at offset " << inst.ingredients[1].value; + // since first non-address in base type must be a container, we don't have to canonize + type_number container = skip_addresses(inst.ingredients[0].types); + inst.ingredients[1].set_value(find_element_name(container, inst.ingredients[1].name)); + trace("name") << "element " << inst.ingredients[1].name << " of type " << Type[container].name << " is at offset " << inst.ingredients[1].value; } //: this test is actually illegal so can't call run :(scenarios transform_test) -:(scenario "convert_names_handles_records") +:(scenario "convert_names_handles_containers") recipe main [ a:point <- copy 0:literal b:integer <- copy 0:literal |