about summary refs log tree commit diff stats
path: root/cpp/025name
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-03-27 10:20:17 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-03-27 10:20:17 -0700
commit06b3eb967a289b96fba29e61c015e7a5f11cb570 (patch)
tree6343be66a5b61c2310b13ea842b91725768f4cf3 /cpp/025name
parent81760e2951cbe5683269ab007df4fa3104b8f5e7 (diff)
downloadmu-06b3eb967a289b96fba29e61c015e7a5f11cb570.tar.gz
985
Diffstat (limited to 'cpp/025name')
-rw-r--r--cpp/025name29
1 files changed, 16 insertions, 13 deletions
diff --git a/cpp/025name b/cpp/025name
index 7296881b..2514714f 100644
--- a/cpp/025name
+++ b/cpp/025name
@@ -28,19 +28,8 @@ void transform_names(const recipe_number r) {
   for (size_t i = 0; i < Recipe[r].steps.size(); ++i) {
 //?     cout << "instruction " << i << '\n'; //? 2
     instruction& inst = Recipe[r].steps[i];
-    // 1: replace element names of records with offsets
-    if (inst.operation == Recipe_number["get"]
-        || inst.operation == Recipe_number["get-address"]) {
-      // at least 2 args, and second arg is offset
-      assert(inst.ingredients.size() >= 2);
-      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;
-    }
-    // 2: map names to addresses if necessary
+    // Per-recipe Transforms Go Here
+    // map names to addresses
     for (size_t in = 0; in < inst.ingredients.size(); ++in) {
       if (is_raw(inst.ingredients[in])) continue;
 //?       cout << "ingredient " << inst.ingredients[in].name << '\n'; //? 1
@@ -137,6 +126,20 @@ recipe main [
 +name: field y of type point is at offset 1
 +name: field x of type point is at offset 0
 
+:(after "Per-recipe Transforms")
+// replace element names of records with offsets
+if (inst.operation == Recipe_number["get"]
+    || inst.operation == Recipe_number["get-address"]) {
+  // at least 2 args, and second arg is offset
+  assert(inst.ingredients.size() >= 2);
+  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;
+}
+
 //: this test is actually illegal so can't call run
 :(scenarios transform_test)
 :(scenario "convert_names_handles_records")