From 201458e3bd2f1d79a0ea0b853552e9df267e92b1 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Mon, 26 Dec 2016 20:44:10 -0800 Subject: 3713 - cross-link calls with definitions in html --- html/033exclusive_container.cc.html | 130 ++++++++++++++++++------------------ 1 file changed, 65 insertions(+), 65 deletions(-) (limited to 'html/033exclusive_container.cc.html') diff --git a/html/033exclusive_container.cc.html b/html/033exclusive_container.cc.html index 5f32f852..3ee83490 100644 --- a/html/033exclusive_container.cc.html +++ b/html/033exclusive_container.cc.html @@ -68,9 +68,9 @@ if ('onhashchange' in window) { 7 :(before "End Mu Types Initialization") 8 //: We'll use this container as a running example, with two number elements. 9 { - 10 type_ordinal tmp = put(Type_ordinal, "number-or-point", Next_type_ordinal++); - 11 get_or_insert(Type, tmp); // initialize - 12 get(Type, tmp).kind = EXCLUSIVE_CONTAINER; + 10 type_ordinal tmp = put(Type_ordinal, "number-or-point", Next_type_ordinal++); + 11 get_or_insert(Type, tmp); // initialize + 12 get(Type, tmp).kind = EXCLUSIVE_CONTAINER; 13 get(Type, tmp).name = "number-or-point"; 14 get(Type, tmp).elements.push_back(reagent("i:number")); 15 get(Type, tmp).elements.push_back(reagent("p:point")); @@ -81,7 +81,7 @@ if ('onhashchange' in window) { 20 //: checks in future layers from flagging them. 21 :(scenario copy_exclusive_container) 22 # Copying exclusive containers copies all their contents and an extra location for the tag. - 23 def main [ + 23 def main [ 24 1:num <- copy 1 # 'point' variant 25 2:num <- copy 34 26 3:num <- copy 35 @@ -92,22 +92,22 @@ if ('onhashchange' in window) { 31 +mem: storing 35 in location 6 32 33 :(before "End size_of(type) Special-cases") - 34 if (t.kind == EXCLUSIVE_CONTAINER) { + 34 if (t.kind == EXCLUSIVE_CONTAINER) { 35 // Compute size_of Exclusive Container 36 return get(Container_metadata, type).size; 37 } 38 :(before "End compute_container_sizes Atom Special-cases") - 39 if (info.kind == EXCLUSIVE_CONTAINER) { - 40 compute_exclusive_container_sizes(info, type, pending_metadata, location_for_error_messages); + 39 if (info.kind == EXCLUSIVE_CONTAINER) { + 40 compute_exclusive_container_sizes(info, type, pending_metadata, location_for_error_messages); 41 } 42 43 :(code) - 44 void compute_exclusive_container_sizes(const type_info& exclusive_container_info, const type_tree* full_type, set<type_tree>& pending_metadata, const string& location_for_error_messages) { + 44 void compute_exclusive_container_sizes(const type_info& exclusive_container_info, const type_tree* full_type, set<type_tree>& pending_metadata, const string& location_for_error_messages) { 45 // size of an exclusive container is the size of its largest variant 46 // (So, like containers, it can only contain arrays if they're static and 47 // include their length in the type.) 48 container_metadata metadata; - 49 for (int i = 0; i < SIZE(exclusive_container_info.elements); ++i) { + 49 for (int i = 0; i < SIZE(exclusive_container_info.elements); ++i) { 50 reagent/*copy*/ element = exclusive_container_info.elements.at(i); 51 // Compute Exclusive Container Size(element, full_type) 52 compute_container_sizes(element.type, pending_metadata, location_for_error_messages); @@ -127,10 +127,10 @@ if ('onhashchange' in window) { 66 //: 'maybe-convert' requires a literal in ingredient 1. We'll use a synonym 67 //: called 'variant'. 68 :(before "End Mu Types Initialization") - 69 put(Type_ordinal, "variant", 0); + 69 put(Type_ordinal, "variant", 0); 70 71 :(scenario maybe_convert) - 72 def main [ + 72 def main [ 73 12:num <- copy 1 74 13:num <- copy 35 75 14:num <- copy 36 @@ -143,7 +143,7 @@ if ('onhashchange' in window) { 82 +mem: storing 36 in location 21 83 84 :(scenario maybe_convert_fail) - 85 def main [ + 85 def main [ 86 12:num <- copy 1 87 13:num <- copy 35 88 14:num <- copy 36 @@ -156,52 +156,52 @@ if ('onhashchange' in window) { 95 :(before "End Primitive Recipe Declarations") 96 MAYBE_CONVERT, 97 :(before "End Primitive Recipe Numbers") - 98 put(Recipe_ordinal, "maybe-convert", MAYBE_CONVERT); + 98 put(Recipe_ordinal, "maybe-convert", MAYBE_CONVERT); 99 :(before "End Primitive Recipe Checks") 100 case MAYBE_CONVERT: { 101 const recipe& caller = get(Recipe, r); -102 if (SIZE(inst.ingredients) != 2) { -103 raise << maybe(caller.name) << "'maybe-convert' expects exactly 2 ingredients in '" << inst.original_string << "'\n" << end(); +102 if (SIZE(inst.ingredients) != 2) { +103 raise << maybe(caller.name) << "'maybe-convert' expects exactly 2 ingredients in '" << inst.original_string << "'\n" << end(); 104 break; 105 } 106 reagent/*copy*/ base = inst.ingredients.at(0); 107 // Update MAYBE_CONVERT base in Check 108 if (!base.type) { -109 raise << maybe(caller.name) << "first ingredient of 'maybe-convert' should be an exclusive-container, but got '" << base.original_string << "'\n" << end(); +109 raise << maybe(caller.name) << "first ingredient of 'maybe-convert' should be an exclusive-container, but got '" << base.original_string << "'\n" << end(); 110 break; 111 } 112 const type_tree* base_type = base.type; 113 // Update MAYBE_CONVERT base_type in Check -114 if (!base_type->atom || base_type->value == 0 || !contains_key(Type, base_type->value) || get(Type, base_type->value).kind != EXCLUSIVE_CONTAINER) { -115 raise << maybe(caller.name) << "first ingredient of 'maybe-convert' should be an exclusive-container, but got '" << base.original_string << "'\n" << end(); +114 if (!base_type->atom || base_type->value == 0 || !contains_key(Type, base_type->value) || get(Type, base_type->value).kind != EXCLUSIVE_CONTAINER) { +115 raise << maybe(caller.name) << "first ingredient of 'maybe-convert' should be an exclusive-container, but got '" << base.original_string << "'\n" << end(); 116 break; 117 } 118 if (!is_literal(inst.ingredients.at(1))) { -119 raise << maybe(caller.name) << "second ingredient of 'maybe-convert' should have type 'variant', but got '" << inst.ingredients.at(1).original_string << "'\n" << end(); +119 raise << maybe(caller.name) << "second ingredient of 'maybe-convert' should have type 'variant', but got '" << inst.ingredients.at(1).original_string << "'\n" << end(); 120 break; 121 } 122 if (inst.products.empty()) break; -123 if (SIZE(inst.products) != 2) { -124 raise << maybe(caller.name) << "'maybe-convert' expects exactly 2 products in '" << inst.original_string << "'\n" << end(); +123 if (SIZE(inst.products) != 2) { +124 raise << maybe(caller.name) << "'maybe-convert' expects exactly 2 products in '" << inst.original_string << "'\n" << end(); 125 break; 126 } 127 reagent/*copy*/ product = inst.products.at(0); 128 // Update MAYBE_CONVERT product in Check 129 reagent& offset = inst.ingredients.at(1); -130 populate_value(offset); -131 if (offset.value >= SIZE(get(Type, base_type->value).elements)) { -132 raise << maybe(caller.name) << "invalid tag " << offset.value << " in '" << inst.original_string << '\n' << end(); +130 populate_value(offset); +131 if (offset.value >= SIZE(get(Type, base_type->value).elements)) { +132 raise << maybe(caller.name) << "invalid tag " << offset.value << " in '" << inst.original_string << '\n' << end(); 133 break; 134 } 135 const reagent& variant = variant_type(base, offset.value); 136 if (!types_coercible(product, variant)) { -137 raise << maybe(caller.name) << "'maybe-convert " << base.original_string << ", " << inst.ingredients.at(1).original_string << "' should write to " << to_string(variant.type) << " but '" << product.name << "' has type " << to_string(product.type) << '\n' << end(); +137 raise << maybe(caller.name) << "'maybe-convert " << base.original_string << ", " << inst.ingredients.at(1).original_string << "' should write to " << to_string(variant.type) << " but '" << product.name << "' has type " << to_string(product.type) << '\n' << end(); 138 break; 139 } 140 reagent/*copy*/ status = inst.products.at(1); 141 // Update MAYBE_CONVERT status in Check 142 if (!is_mu_boolean(status)) { -143 raise << maybe(get(Recipe, r).name) << "second product yielded by 'maybe-convert' should be a boolean, but tried to write to '" << inst.products.at(1).original_string << "'\n" << end(); +143 raise << maybe(get(Recipe, r).name) << "second product yielded by 'maybe-convert' should be a boolean, but tried to write to '" << inst.products.at(1).original_string << "'\n" << end(); 144 break; 145 } 146 break; @@ -212,7 +212,7 @@ if ('onhashchange' in window) { 151 // Update MAYBE_CONVERT base in Run 152 int base_address = base.value; 153 if (base_address == 0) { -154 raise << maybe(current_recipe_name()) << "tried to access location 0 in '" << to_original_string(current_instruction()) << "'\n" << end(); +154 raise << maybe(current_recipe_name()) << "tried to access location 0 in '" << to_original_string(current_instruction()) << "'\n" << end(); 155 break; 156 } 157 int tag = current_instruction().ingredients.at(1).value; @@ -221,22 +221,22 @@ if ('onhashchange' in window) { 160 reagent/*copy*/ status = current_instruction().products.at(1); 161 // Update MAYBE_CONVERT status in Run 162 // optimization: directly write results to only update first product when necessary -163 if (tag == static_cast<int>(get_or_insert(Memory, base_address))) { +163 if (tag == static_cast<int>(get_or_insert(Memory, base_address))) { 164 const reagent& variant = variant_type(base, tag); -165 trace(9999, "mem") << "storing 1 in location " << status.value << end(); -166 put(Memory, status.value, 1); +165 trace(9999, "mem") << "storing 1 in location " << status.value << end(); +166 put(Memory, status.value, 1); 167 if (!is_dummy(product)) { 168 // Write Memory in Successful MAYBE_CONVERT in Run 169 for (int i = 0; i < size_of(variant); ++i) { -170 double val = get_or_insert(Memory, base_address+/*skip tag*/1+i); -171 trace(9999, "mem") << "storing " << no_scientific(val) << " in location " << product.value+i << end(); -172 put(Memory, product.value+i, val); +170 double val = get_or_insert(Memory, base_address+/*skip tag*/1+i); +171 trace(9999, "mem") << "storing " << no_scientific(val) << " in location " << product.value+i << end(); +172 put(Memory, product.value+i, val); 173 } 174 } 175 } 176 else { -177 trace(9999, "mem") << "storing 0 in location " << status.value << end(); -178 put(Memory, status.value, 0); +177 trace(9999, "mem") << "storing 0 in location " << status.value << end(); +178 put(Memory, status.value, 0); 179 } 180 goto finish_instruction; 181 } @@ -252,7 +252,7 @@ if ('onhashchange' in window) { 191 assert(contains_key(Type, root_type->value)); 192 assert(!get(Type, root_type->value).name.empty()); 193 const type_info& info = get(Type, root_type->value); -194 assert(info.kind == EXCLUSIVE_CONTAINER); +194 assert(info.kind == EXCLUSIVE_CONTAINER); 195 reagent/*copy*/ element = info.elements.at(tag); 196 // End variant_type Special-cases 197 return element; @@ -260,16 +260,16 @@ if ('onhashchange' in window) { 199 200 :(scenario maybe_convert_product_type_mismatch) 201 % Hide_errors = true; -202 def main [ +202 def main [ 203 12:num <- copy 1 204 13:num <- copy 35 205 14:num <- copy 36 206 20:num, 21:bool <- maybe-convert 12:number-or-point/unsafe, 1:variant 207 ] -208 +error: main: 'maybe-convert 12:number-or-point/unsafe, 1:variant' should write to point but '20' has type number +208 +error: main: 'maybe-convert 12:number-or-point/unsafe, 1:variant' should write to point but '20' has type number 209 210 :(scenario maybe_convert_dummy_product) -211 def main [ +211 def main [ 212 12:num <- copy 1 213 13:num <- copy 35 214 14:num <- copy 36 @@ -290,7 +290,7 @@ if ('onhashchange' in window) { 229 230 :(before "End Command Handlers") 231 else if (command == "exclusive-container") { -232 insert_container(command, EXCLUSIVE_CONTAINER, in); +232 insert_container(command, EXCLUSIVE_CONTAINER, in); 233 } 234 235 //: arrays are disallowed inside exclusive containers unless their length is @@ -315,7 +315,7 @@ if ('onhashchange' in window) { 254 x:num 255 y:num 256 ] -257 def main [ +257 def main [ 258 1:num <- copy 34 259 2:foo <- merge 0/x, 1:num # tag must be a literal when merging exclusive containers 260 4:foo <- merge 1/y, 1:num @@ -335,7 +335,7 @@ if ('onhashchange' in window) { 274 container bar [ 275 z:num 276 ] -277 def main [ +277 def main [ 278 1:foo <- merge 0/x, 34 279 ] 280 +mem: storing 0 in location 1 @@ -351,11 +351,11 @@ if ('onhashchange' in window) { 290 container bar [ 291 z:num 292 ] -293 def main [ +293 def main [ 294 1:num <- copy 0 295 2:foo <- merge 1:num, 34 296 ] -297 +error: main: ingredient 0 of 'merge' should be a literal, for the tag of exclusive-container 'foo' in '2:foo <- merge 1:num, 34' +297 +error: main: ingredient 0 of 'merge' should be a literal, for the tag of exclusive-container 'foo' in '2:foo <- merge 1:num, 34' 298 299 :(scenario merge_handles_exclusive_container_inside_exclusive_container) 300 exclusive-container foo [ @@ -366,7 +366,7 @@ if ('onhashchange' in window) { 305 a:num 306 b:num 307 ] -308 def main [ +308 def main [ 309 1:num <- copy 0 310 2:bar <- merge 0/a, 34 311 4:foo <- merge 1/y, 2:bar @@ -375,25 +375,25 @@ if ('onhashchange' in window) { 314 +mem: storing 34 in location 6 315 $error: 0 316 -317 :(before "End check_merge_call Special-cases") -318 case EXCLUSIVE_CONTAINER: { +317 :(before "End check_merge_call Special-cases") +318 case EXCLUSIVE_CONTAINER: { 319 assert(state.data.top().container_element_index == 0); -320 trace(9999, "transform") << "checking exclusive container " << to_string(container) << " vs ingredient " << ingredient_index << end(); +320 trace(9999, "transform") << "checking exclusive container " << to_string(container) << " vs ingredient " << ingredient_index << end(); 321 // easy case: exact match 322 if (types_strictly_match(container, inst.ingredients.at(ingredient_index))) 323 return; 324 if (!is_literal(ingredients.at(ingredient_index))) { -325 raise << maybe(caller.name) << "ingredient " << ingredient_index << " of 'merge' should be a literal, for the tag of exclusive-container '" << container_info.name << "' in '" << inst.original_string << "'\n" << end(); +325 raise << maybe(caller.name) << "ingredient " << ingredient_index << " of 'merge' should be a literal, for the tag of exclusive-container '" << container_info.name << "' in '" << inst.original_string << "'\n" << end(); 326 return; 327 } 328 reagent/*copy*/ ingredient = ingredients.at(ingredient_index); // unnecessary copy just to keep this function from modifying caller -329 populate_value(ingredient); -330 if (ingredient.value >= SIZE(container_info.elements)) { -331 raise << maybe(caller.name) << "invalid tag at " << ingredient_index << " for '" << container_info.name << "' in '" << inst.original_string << "'\n" << end(); +329 populate_value(ingredient); +330 if (ingredient.value >= SIZE(container_info.elements)) { +331 raise << maybe(caller.name) << "invalid tag at " << ingredient_index << " for '" << container_info.name << "' in '" << inst.original_string << "'\n" << end(); 332 return; 333 } 334 const reagent& variant = variant_type(container, ingredient.value); -335 trace(9999, "transform") << "tag: " << ingredient.value << end(); +335 trace(9999, "transform") << "tag: " << ingredient.value << end(); 336 // replace union with its variant 337 state.data.pop(); 338 state.data.push(merge_check_point(variant, 0)); @@ -410,7 +410,7 @@ if ('onhashchange' in window) { 349 x:num 350 y:num 351 ] -352 def main [ +352 def main [ 353 1:foo <- merge 23, 1/y, 34 354 ] 355 +mem: storing 23 in location 1 @@ -428,10 +428,10 @@ if ('onhashchange' in window) { 367 x:num 368 y:num 369 ] -370 def main [ +370 def main [ 371 1:foo <- merge 23, 1/y, 34, 35 372 ] -373 +error: main: too many ingredients in '1:foo <- merge 23, 1/y, 34, 35' +373 +error: main: too many ingredients in '1:foo <- merge 23, 1/y, 34, 35' 374 375 :(scenario merge_check_exclusive_container_containing_container) 376 exclusive-container foo [ @@ -442,7 +442,7 @@ if ('onhashchange' in window) { 381 x:num 382 y:num 383 ] -384 def main [ +384 def main [ 385 1:foo <- merge 1/y, 23, 34 386 ] 387 +mem: storing 1 in location 1 @@ -459,7 +459,7 @@ if ('onhashchange' in window) { 398 x:num 399 y:num 400 ] -401 def main [ +401 def main [ 402 1:foo <- merge 0/x, 23 403 ] 404 $error: 0 @@ -474,10 +474,10 @@ if ('onhashchange' in window) { 413 x:num 414 y:num 415 ] -416 def main [ +416 def main [ 417 1:foo <- merge 1/y, 23 418 ] -419 +error: main: too few ingredients in '1:foo <- merge 1/y, 23' +419 +error: main: too few ingredients in '1:foo <- merge 1/y, 23' 420 421 :(scenario merge_check_exclusive_container_containing_container_4) 422 exclusive-container foo [ @@ -488,7 +488,7 @@ if ('onhashchange' in window) { 427 a:num 428 b:num 429 ] -430 def main [ +430 def main [ 431 1:bar <- merge 23, 24 432 3:foo <- merge 1/y, 1:bar 433 ] @@ -497,7 +497,7 @@ if ('onhashchange' in window) { 436 //: Since the different variants of an exclusive-container might have 437 //: different sizes, relax the size mismatch check for 'merge' instructions. 438 :(before "End size_mismatch(x) Special-cases") -439 if (current_step_index() < SIZE(Current_routine->steps()) +439 if (current_step_index() < SIZE(Current_routine->steps()) 440 && current_instruction().operation == MERGE 441 && !current_instruction().products.empty() 442 && current_instruction().products.at(0).type) { @@ -505,8 +505,8 @@ if ('onhashchange' in window) { 444 // Update size_mismatch Check for MERGE(x) 445 const type_tree* root_type = x.type->atom ? x.type : x.type->left; 446 assert(root_type->atom); -447 if (get(Type, root_type->value).kind == EXCLUSIVE_CONTAINER) -448 return size_of(x) < SIZE(data); +447 if (get(Type, root_type->value).kind == EXCLUSIVE_CONTAINER) +448 return size_of(x) < SIZE(data); 449 } 450 451 :(scenario merge_exclusive_container_with_mismatched_sizes) @@ -518,7 +518,7 @@ if ('onhashchange' in window) { 457 x:num 458 y:foo 459 ] -460 def main [ +460 def main [ 461 1:num <- copy 34 462 2:num <- copy 35 463 3:bar <- merge 0/x, 1:num -- cgit 1.4.1-2-gfad0