From 2c678a4e1d7f97c862342ee19cf2d6ee6e901d85 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Mon, 29 May 2017 14:21:32 -0700 Subject: 3897 - various updates to documentation --- html/030container.cc.html | 78 +++++++++++++++++++++++------------------------ 1 file changed, 39 insertions(+), 39 deletions(-) (limited to 'html/030container.cc.html') diff --git a/html/030container.cc.html b/html/030container.cc.html index a2a94c28..8d2fcc44 100644 --- a/html/030container.cc.html +++ b/html/030container.cc.html @@ -69,8 +69,8 @@ if ('onhashchange' in window) { 2 3 :(before "End Mu Types Initialization") 4 //: We'll use this container as a running example in scenarios below. - 5 type_ordinal point = put(Type_ordinal, "point", Next_type_ordinal++); - 6 get_or_insert(Type, point); // initialize + 5 type_ordinal point = put(Type_ordinal, "point", Next_type_ordinal++); + 6 get_or_insert(Type, point); // initialize 7 get(Type, point).kind = CONTAINER; 8 get(Type, point).name = "point"; 9 get(Type, point).elements.push_back(reagent("x:number")); @@ -102,8 +102,8 @@ if ('onhashchange' in window) { 35 :(before "End Mu Types Initialization") 36 // A more complex example container, containing another container as one of 37 // its elements. - 38 type_ordinal point_number = put(Type_ordinal, "point-number", Next_type_ordinal++); - 39 get_or_insert(Type, point_number); // initialize + 38 type_ordinal point_number = put(Type_ordinal, "point-number", Next_type_ordinal++); + 39 get_or_insert(Type, point_number); // initialize 40 get(Type, point_number).kind = CONTAINER; 41 get(Type, point_number).name = "point-number"; 42 get(Type, point_number).elements.push_back(reagent("xy:point")); @@ -189,20 +189,20 @@ if ('onhashchange' in window) { 122 :(code) 123 // invariant: Container_metadata always contains a superset of Container_metadata_snapshot 124 void restore_container_metadata() { -125 for (int i = 0; i < SIZE(Container_metadata); ++i) { +125 for (int i = 0; i < SIZE(Container_metadata); ++i) { 126 ¦ assert(Container_metadata.at(i).first); -127 ¦ if (i < SIZE(Container_metadata_snapshot)) { +127 ¦ if (i < SIZE(Container_metadata_snapshot)) { 128 ¦ ¦ assert(Container_metadata.at(i).first == Container_metadata_snapshot.at(i).first); 129 ¦ ¦ continue; 130 ¦ } 131 ¦ delete Container_metadata.at(i).first; 132 ¦ Container_metadata.at(i).first = NULL; 133 } -134 Container_metadata.resize(SIZE(Container_metadata_snapshot)); +134 Container_metadata.resize(SIZE(Container_metadata_snapshot)); 135 } 136 void clear_container_metadata() { 137 Container_metadata_snapshot.clear(); -138 for (int i = 0; i < SIZE(Container_metadata); ++i) { +138 for (int i = 0; i < SIZE(Container_metadata); ++i) { 139 ¦ delete Container_metadata.at(i).first; 140 ¦ Container_metadata.at(i).first = NULL; 141 } @@ -241,12 +241,12 @@ if ('onhashchange' in window) { 174 void compute_container_sizes(const recipe_ordinal r) { 175 recipe& caller = get(Recipe, r); 176 trace(9992, "transform") << "--- compute container sizes for " << caller.name << end(); -177 for (int i = 0; i < SIZE(caller.steps); ++i) { +177 for (int i = 0; i < SIZE(caller.steps); ++i) { 178 ¦ instruction& inst = caller.steps.at(i); 179 ¦ trace(9993, "transform") << "- compute container sizes for " << to_string(inst) << end(); -180 ¦ for (int i = 0; i < SIZE(inst.ingredients); ++i) +180 ¦ for (int i = 0; i < SIZE(inst.ingredients); ++i) 181 ¦ ¦ compute_container_sizes(inst.ingredients.at(i), " in '"+to_original_string(inst)+"'"); -182 ¦ for (int i = 0; i < SIZE(inst.products); ++i) +182 ¦ for (int i = 0; i < SIZE(inst.products); ++i) 183 ¦ ¦ compute_container_sizes(inst.products.at(i), " in '"+to_original_string(inst)+"'"); 184 } 185 } @@ -292,7 +292,7 @@ if ('onhashchange' in window) { 225 // (So it can only contain arrays if they're static and include their 226 // length in the type.) 227 container_metadata metadata; -228 for (int i = 0; i < SIZE(container_info.elements); ++i) { +228 for (int i = 0; i < SIZE(container_info.elements); ++i) { 229 ¦ reagent/*copy*/ element = container_info.elements.at(i); 230 ¦ // Compute Container Size(element, full_type) 231 ¦ compute_container_sizes(element.type, pending_metadata, location_for_error_messages); @@ -311,7 +311,7 @@ if ('onhashchange' in window) { 244 } 245 246 container_metadata& get(vector<pair<type_tree*, container_metadata> >& all, const type_tree* key) { -247 for (int i = 0; i < SIZE(all); ++i) { +247 for (int i = 0; i < SIZE(all); ++i) { 248 ¦ if (matches(all.at(i).first, key)) 249 ¦ ¦ return all.at(i).second; 250 } @@ -321,7 +321,7 @@ if ('onhashchange' in window) { 254 } 255 256 bool contains_key(const vector<pair<type_tree*, container_metadata> >& all, const type_tree* key) { -257 for (int i = 0; i < SIZE(all); ++i) { +257 for (int i = 0; i < SIZE(all); ++i) { 258 ¦ if (matches(all.at(i).first, key)) 259 ¦ ¦ return true; 260 } @@ -363,7 +363,7 @@ if ('onhashchange' in window) { 296 297 void test_container_sizes_through_aliases() { 298 // a new alias for a container -299 put(Type_abbreviations, "pt", new_type_tree("point")); +299 put(Type_abbreviations, "pt", new_type_tree("point")); 300 reagent r("x:pt"); 301 // scan 302 compute_container_sizes(r, ""); @@ -424,10 +424,10 @@ if ('onhashchange' in window) { 357 :(before "End Primitive Recipe Declarations") 358 GET, 359 :(before "End Primitive Recipe Numbers") -360 put(Recipe_ordinal, "get", GET); +360 put(Recipe_ordinal, "get", GET); 361 :(before "End Primitive Recipe Checks") 362 case GET: { -363 if (SIZE(inst.ingredients) != 2) { +363 if (SIZE(inst.ingredients) != 2) { 364 ¦ raise << maybe(get(Recipe, r).name) << "'get' expects exactly 2 ingredients in '" << to_original_string(inst) << "'\n" << end(); 365 ¦ break; 366 } @@ -453,7 +453,7 @@ if ('onhashchange' in window) { 386 ¦ offset_value = to_integer(offset.name); 387 } 388 // End update GET offset_value in Check -389 if (offset_value < 0 || offset_value >= SIZE(get(Type, base_type->value).elements)) { +389 if (offset_value < 0 || offset_value >= SIZE(get(Type, base_type->value).elements)) { 390 ¦ raise << maybe(get(Recipe, r).name) << "invalid offset '" << offset_value << "' for '" << get(Type, base_type->value).name << "'\n" << end(); 391 ¦ break; 392 } @@ -480,7 +480,7 @@ if ('onhashchange' in window) { 413 const type_tree* base_type = base.type; 414 // Update GET base_type in Run 415 int offset = ingredients.at(1).at(0); -416 if (offset < 0 || offset >= SIZE(get(Type, base_type->value).elements)) break; // copied from Check above +416 if (offset < 0 || offset >= SIZE(get(Type, base_type->value).elements)) break; // copied from Check above 417 assert(base.metadata.size); 418 int src = base_address + base.metadata.offset.at(offset); 419 trace(9998, "run") << "address to copy is " << src << end(); @@ -502,7 +502,7 @@ if ('onhashchange' in window) { 435 assert(!get(Type, base_type->value).name.empty()); 436 const type_info& info = get(Type, base_type->value); 437 assert(info.kind == CONTAINER); -438 if (offset_value >= SIZE(info.elements)) return reagent(); // error handled elsewhere +438 if (offset_value >= SIZE(info.elements)) return reagent(); // error handled elsewhere 439 reagent/*copy*/ element = info.elements.at(offset_value); 440 // End element_type Special-cases 441 return element; @@ -564,7 +564,7 @@ if ('onhashchange' in window) { 497 12:num <- copy 34 498 13:num <- copy 35 499 $clear-trace -500 12:point <- put 12:point, 1:offset, 36 +500 12:point <- put 12:point, 1:offset, 36 501 ] 502 +mem: storing 36 in location 13 503 -mem: storing 34 in location 12 @@ -572,10 +572,10 @@ if ('onhashchange' in window) { 505 :(before "End Primitive Recipe Declarations") 506 PUT, 507 :(before "End Primitive Recipe Numbers") -508 put(Recipe_ordinal, "put", PUT); +508 put(Recipe_ordinal, "put", PUT); 509 :(before "End Primitive Recipe Checks") 510 case PUT: { -511 if (SIZE(inst.ingredients) != 3) { +511 if (SIZE(inst.ingredients) != 3) { 512 ¦ raise << maybe(get(Recipe, r).name) << "'put' expects exactly 3 ingredients in '" << to_original_string(inst) << "'\n" << end(); 513 ¦ break; 514 } @@ -601,7 +601,7 @@ if ('onhashchange' in window) { 534 //: later layers will permit non-integer offsets 535 if (is_integer(offset.name)) { 536 ¦ offset_value = to_integer(offset.name); -537 ¦ if (offset_value < 0 || offset_value >= SIZE(get(Type, base_type->value).elements)) { +537 ¦ if (offset_value < 0 || offset_value >= SIZE(get(Type, base_type->value).elements)) { 538 ¦ ¦ raise << maybe(get(Recipe, r).name) << "invalid offset '" << offset_value << "' for '" << get(Type, base_type->value).name << "'\n" << end(); 539 ¦ ¦ break; 540 ¦ } @@ -636,16 +636,16 @@ if ('onhashchange' in window) { 569 const type_tree* base_type = base.type; 570 // Update PUT base_type in Run 571 int offset = ingredients.at(1).at(0); -572 if (offset < 0 || offset >= SIZE(get(Type, base_type->value).elements)) break; // copied from Check above +572 if (offset < 0 || offset >= SIZE(get(Type, base_type->value).elements)) break; // copied from Check above 573 int address = base_address + base.metadata.offset.at(offset); 574 trace(9998, "run") << "address to copy to is " << address << end(); 575 // optimization: directly write the element rather than updating 'product' 576 // and writing the entire container 577 // Write Memory in PUT in Run 578 write_products = false; -579 for (int i = 0; i < SIZE(ingredients.at(2)); ++i) { +579 for (int i = 0; i < SIZE(ingredients.at(2)); ++i) { 580 ¦ trace(9999, "mem") << "storing " << no_scientific(ingredients.at(2).at(i)) << " in location " << address+i << end(); -581 ¦ put(Memory, address+i, ingredients.at(2).at(i)); +581 ¦ put(Memory, address+i, ingredients.at(2).at(i)); 582 } 583 break; 584 } @@ -656,7 +656,7 @@ if ('onhashchange' in window) { 589 local-scope 590 load-ingredients 591 1:point <- merge 34, 35 -592 3:point <- put 1:point, x:offset, 36 +592 3:point <- put 1:point, x:offset, 36 593 ] 594 +error: main: product of 'put' must be first ingredient '1:point', but got '3:point' 595 @@ -738,11 +738,11 @@ if ('onhashchange' in window) { 671 trace(9991, "parse") << "--- defining " << command << ' ' << name << end(); 672 if (!contains_key(Type_ordinal, name) 673 ¦ ¦ || get(Type_ordinal, name) == 0) { -674 ¦ put(Type_ordinal, name, Next_type_ordinal++); +674 ¦ put(Type_ordinal, name, Next_type_ordinal++); 675 } 676 trace(9999, "parse") << "type number: " << get(Type_ordinal, name) << end(); 677 skip_bracket(in, "'"+command+"' must begin with '['"); -678 type_info& info = get_or_insert(Type, get(Type_ordinal, name)); +678 type_info& info = get_or_insert(Type, get(Type_ordinal, name)); 679 if (info.Num_calls_to_transform_all_at_first_definition == -1) { 680 ¦ // initial definition of this container 681 ¦ info.Num_calls_to_transform_all_at_first_definition = Num_calls_to_transform_all; @@ -754,7 +754,7 @@ if ('onhashchange' in window) { 687 } 688 info.name = name; 689 info.kind = kind; -690 while (has_data(in)) { +690 while (has_data(in)) { 691 ¦ skip_whitespace_and_comments(in); 692 ¦ string element = next_word(in); 693 ¦ if (element.empty()) { @@ -766,7 +766,7 @@ if ('onhashchange' in window) { 699 ¦ if (in.peek() != '\n') { 700 ¦ ¦ raise << command << " '" << name << "' contains multiple elements on a single line. Containers and exclusive containers must only contain elements, one to a line, no code.\n" << end(); 701 ¦ ¦ // skip rest of container declaration -702 ¦ ¦ while (has_data(in)) { +702 ¦ ¦ while (has_data(in)) { 703 ¦ ¦ ¦ skip_whitespace_and_comments(in); 704 ¦ ¦ ¦ if (next_word(in) == "]") break; 705 ¦ ¦ } @@ -793,7 +793,7 @@ if ('onhashchange' in window) { 726 } 727 // End insert_container Special-cases 728 else if (type->name != "->") { // used in recipe types -729 ¦ put(Type_ordinal, type->name, Next_type_ordinal++); +729 ¦ put(Type_ordinal, type->name, Next_type_ordinal++); 730 ¦ type->value = get(Type_ordinal, type->name); 731 } 732 } @@ -829,9 +829,9 @@ if ('onhashchange' in window) { 762 :(code) 763 // extremely inefficient; we process all types over and over again, once for every single recipe 764 // but it doesn't seem to cause any noticeable slowdown -765 void expand_type_abbreviations_in_containers(unused const recipe_ordinal r) { +765 void expand_type_abbreviations_in_containers(unused const recipe_ordinal r) { 766 for (map<type_ordinal, type_info>::iterator p = Type.begin(); p != Type.end(); ++p) { -767 ¦ for (int i = 0; i < SIZE(p->second.elements); ++i) +767 ¦ for (int i = 0; i < SIZE(p->second.elements); ++i) 768 ¦ ¦ expand_type_abbreviations(p->second.elements.at(i).type); 769 } 770 } @@ -886,11 +886,11 @@ if ('onhashchange' in window) { 819 void check_or_set_invalid_types(const recipe_ordinal r) { 820 recipe& caller = get(Recipe, r); 821 trace(9991, "transform") << "--- check for invalid types in recipe " << caller.name << end(); -822 for (int index = 0; index < SIZE(caller.steps); ++index) { +822 for (int index = 0; index < SIZE(caller.steps); ++index) { 823 ¦ instruction& inst = caller.steps.at(index); -824 ¦ for (int i = 0; i < SIZE(inst.ingredients); ++i) +824 ¦ for (int i = 0; i < SIZE(inst.ingredients); ++i) 825 ¦ ¦ check_or_set_invalid_types(inst.ingredients.at(i), caller, inst); -826 ¦ for (int i = 0; i < SIZE(inst.products); ++i) +826 ¦ for (int i = 0; i < SIZE(inst.products); ++i) 827 ¦ ¦ check_or_set_invalid_types(inst.products.at(i), caller, inst); 828 } 829 // End check_or_set_invalid_types @@ -951,7 +951,7 @@ if ('onhashchange' in window) { 884 for (map<type_ordinal, type_info>::iterator p = Type.begin(); p != Type.end(); ++p) { 885 ¦ const type_info& info = p->second; 886 ¦ // Check Container Field Types(info) -887 ¦ for (int i = 0; i < SIZE(info.elements); ++i) +887 ¦ for (int i = 0; i < SIZE(info.elements); ++i) 888 ¦ ¦ check_invalid_types(info.elements.at(i).type, maybe(info.name), info.elements.at(i).name); 889 } 890 } -- cgit 1.4.1-2-gfad0