From e4ac3c9e6e5464a0fc0f8fd3763a572e0e180c04 Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Sat, 1 Dec 2018 14:13:33 -0800 Subject: 4814 --- html/031merge.cc.html | 60 ++++++++++++++++++++++++++------------------------- 1 file changed, 31 insertions(+), 29 deletions(-) (limited to 'html/031merge.cc.html') diff --git a/html/031merge.cc.html b/html/031merge.cc.html index 2650b295..a2e757bd 100644 --- a/html/031merge.cc.html +++ b/html/031merge.cc.html @@ -11,21 +11,22 @@ @@ -60,6 +61,7 @@ if ('onhashchange' in window) { +https://github.com/akkartik/mu/blob/master/031merge.cc
   1 //: Construct types out of their constituent fields.
   2 
@@ -77,7 +79,7 @@ if ('onhashchange' in window) {
  14 :(before "End Primitive Recipe Declarations")
  15 MERGE,
  16 :(before "End Primitive Recipe Numbers")
- 17 put(Recipe_ordinal, "merge", MERGE);
+ 17 put(Recipe_ordinal, "merge", MERGE);
  18 :(before "End Primitive Recipe Checks")
  19 case MERGE: {
  20   // type-checking in a separate transform below
@@ -173,29 +175,29 @@ if ('onhashchange' in window) {
 110 };
 111 
 112 :(before "End Checks")
-113 Transform.push_back(check_merge_calls);  // idempotent
+113 Transform.push_back(check_merge_calls);  // idempotent
 114 :(code)
 115 void check_merge_calls(const recipe_ordinal r) {
-116   const recipe& caller = get(Recipe, r);
+116   const recipe& caller = get(Recipe, r);
 117   trace(9991, "transform") << "--- type-check merge instructions in recipe " << caller.name << end();
 118   for (int i = 0;  i < SIZE(caller.steps);  ++i) {
 119     const instruction& inst = caller.steps.at(i);
 120     if (inst.name != "merge") continue;
 121     if (SIZE(inst.products) != 1) {
-122       raise << maybe(caller.name) << "'merge' should yield a single product in '" << to_original_string(inst) << "'\n" << end();
+122       raise << maybe(caller.name) << "'merge' should yield a single product in '" << to_original_string(inst) << "'\n" << end();
 123       continue;
 124     }
 125     reagent/*copy*/ product = inst.products.at(0);
 126     // Update product While Type-checking Merge
 127     const type_tree* product_base_type = product.type->atom ? product.type : product.type->left;
 128     assert(product_base_type->atom);
-129     if (product_base_type->value == 0 || !contains_key(Type, product_base_type->value)) {
-130       raise << maybe(caller.name) << "'merge' should yield a container in '" << to_original_string(inst) << "'\n" << end();
+129     if (product_base_type->value == 0 || !contains_key(Type, product_base_type->value)) {
+130       raise << maybe(caller.name) << "'merge' should yield a container in '" << to_original_string(inst) << "'\n" << end();
 131       continue;
 132     }
-133     const type_info& info = get(Type, product_base_type->value);
+133     const type_info& info = get(Type, product_base_type->value);
 134     if (info.kind != CONTAINER && info.kind != EXCLUSIVE_CONTAINER) {
-135       raise << maybe(caller.name) << "'merge' should yield a container in '" << to_original_string(inst) << "'\n" << end();
+135       raise << maybe(caller.name) << "'merge' should yield a container in '" << to_original_string(inst) << "'\n" << end();
 136       continue;
 137     }
 138     check_merge_call(inst.ingredients, product, caller, inst);
@@ -210,14 +212,14 @@ if ('onhashchange' in window) {
 147     assert(!state.data.empty());
 148     trace("transform") << ingredient_index << " vs " << SIZE(ingredients) << end();
 149     if (ingredient_index >= SIZE(ingredients)) {
-150       raise << maybe(caller.name) << "too few ingredients in '" << to_original_string(inst) << "'\n" << end();
+150       raise << maybe(caller.name) << "too few ingredients in '" << to_original_string(inst) << "'\n" << end();
 151       return;
 152     }
 153     reagent& container = state.data.top().container;
 154     if (!container.type) return;  // error handled elsewhere
 155     const type_tree* top_root_type = container.type->atom ? container.type : container.type->left;
 156     assert(top_root_type->atom);
-157     type_info& container_info = get(Type, top_root_type->value);
+157     type_info& container_info = get(Type, top_root_type->value);
 158     switch (container_info.kind) {
 159       case CONTAINER: {
 160         // degenerate case: merge with the same type always succeeds
@@ -229,11 +231,11 @@ if ('onhashchange' in window) {
 166         if (types_coercible(expected_ingredient, ingredients.at(ingredient_index))) {
 167           ++ingredient_index;
 168           ++state.data.top().container_element_index;
-169           while (state.data.top().container_element_index >= SIZE(get(Type, get_base_type(state.data.top().container.type)->value).elements)) {
+169           while (state.data.top().container_element_index >= SIZE(get(Type, get_base_type(state.data.top().container.type)->value).elements)) {
 170             state.data.pop();
 171             if (state.data.empty()) {
 172               if (ingredient_index < SIZE(ingredients))
-173                 raise << maybe(caller.name) << "too many ingredients in '" << to_original_string(inst) << "'\n" << end();
+173                 raise << maybe(caller.name) << "too many ingredients in '" << to_original_string(inst) << "'\n" << end();
 174               return;
 175             }
 176             ++state.data.top().container_element_index;
@@ -249,9 +251,9 @@ if ('onhashchange' in window) {
 186       // End check_merge_call Special-cases
 187       default: {
 188         if (!types_coercible(container, ingredients.at(ingredient_index))) {
-189           raise << maybe(caller.name) << "incorrect type of ingredient " << ingredient_index << " in '" << to_original_string(inst) << "'\n" << end();
-190           raise << "  (expected '" << debug_string(container) << "')\n" << end();
-191           raise << "  (got '" << debug_string(ingredients.at(ingredient_index)) << "')\n" << end();
+189           raise << maybe(caller.name) << "incorrect type of ingredient " << ingredient_index << " in '" << to_original_string(inst) << "'\n" << end();
+190           raise << "  (expected '" << debug_string(container) << "')\n" << end();
+191           raise << "  (got '" << debug_string(ingredients.at(ingredient_index)) << "')\n" << end();
 192           return;
 193         }
 194         ++ingredient_index;
@@ -260,11 +262,11 @@ if ('onhashchange' in window) {
 197           state.data.pop();
 198           if (state.data.empty()) {
 199             if (ingredient_index < SIZE(ingredients))
-200               raise << maybe(caller.name) << "too many ingredients in '" << to_original_string(inst) << "'\n" << end();
+200               raise << maybe(caller.name) << "too many ingredients in '" << to_original_string(inst) << "'\n" << end();
 201             return;
 202           }
 203           ++state.data.top().container_element_index;
-204         } while (state.data.top().container_element_index >= SIZE(get(Type, get_base_type(state.data.top().container.type)->value).elements));
+204         } while (state.data.top().container_element_index >= SIZE(get(Type, get_base_type(state.data.top().container.type)->value).elements));
 205       }
 206     }
 207   }
-- 
cgit 1.4.1-2-gfad0