From 1c2d788b454670bf8fa1cb65c6251a8ff6ddcaf7 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Mon, 19 Jun 2017 11:29:20 -0700 Subject: 3927 --- html/032array.cc.html | 58 +++++++++++++++++++++++++-------------------------- 1 file changed, 29 insertions(+), 29 deletions(-) (limited to 'html/032array.cc.html') diff --git a/html/032array.cc.html b/html/032array.cc.html index cf144ab1..abe96768 100644 --- a/html/032array.cc.html +++ b/html/032array.cc.html @@ -91,23 +91,23 @@ if ('onhashchange' in window) { 26 reagent/*copy*/ product = inst.products.at(0); 27 // Update CREATE_ARRAY product in Check 28 if (!is_mu_array(product)) { - 29 ¦ raise << maybe(get(Recipe, r).name) << "'create-array' cannot create non-array '" << product.original_string << "'\n" << end(); + 29 ¦ raise << maybe(get(Recipe, r).name) << "'create-array' cannot create non-array '" << product.original_string << "'\n" << end(); 30 ¦ break; 31 } 32 if (!product.type->right) { - 33 ¦ raise << maybe(get(Recipe, r).name) << "create array of what? '" << to_original_string(inst) << "'\n" << end(); + 33 ¦ raise << maybe(get(Recipe, r).name) << "create array of what? '" << to_original_string(inst) << "'\n" << end(); 34 ¦ break; 35 } 36 // 'create-array' will need to check properties rather than types 37 type_tree* array_length_from_type = product.type->right->right; 38 if (!array_length_from_type) { - 39 ¦ raise << maybe(get(Recipe, r).name) << "create array of what size? '" << to_original_string(inst) << "'\n" << end(); + 39 ¦ raise << maybe(get(Recipe, r).name) << "create array of what size? '" << to_original_string(inst) << "'\n" << end(); 40 ¦ break; 41 } 42 if (!product.type->right->right->atom) 43 ¦ array_length_from_type = array_length_from_type->left; 44 if (!is_integer(array_length_from_type->name)) { - 45 ¦ raise << maybe(get(Recipe, r).name) << "'create-array' product should specify size of array after its element type, but got '" << product.type->right->right->name << "'\n" << end(); + 45 ¦ raise << maybe(get(Recipe, r).name) << "'create-array' product should specify size of array after its element type, but got '" << product.type->right->right->name << "'\n" << end(); 46 ¦ break; 47 } 48 break; @@ -122,10 +122,10 @@ if ('onhashchange' in window) { 57 ¦ array_length_from_type = array_length_from_type->left; 58 int array_length = to_integer(array_length_from_type->name); 59 // initialize array length, so that size_of will work - 60 trace(9999, "mem") << "storing " << array_length << " in location " << base_address << end(); + 60 trace(9999, "mem") << "storing " << array_length << " in location " << base_address << end(); 61 put(Memory, base_address, array_length); // in array elements 62 int size = size_of(product); // in locations - 63 trace(9998, "run") << "creating array of size " << size << end(); + 63 trace(9998, "run") << "creating array of size " << size << end(); 64 // initialize array 65 for (int i = 1; i <= size_of(product); ++i) { 66 ¦ put(Memory, base_address+i, 0); @@ -171,7 +171,7 @@ if ('onhashchange' in window) { 106 :(before "End size_of(reagent r) Special-cases") 107 if (!r.type->atom && r.type->left->atom && r.type->left->value == get(Type_ordinal, "array")) { 108 if (!r.type->right) { -109 ¦ raise << maybe(current_recipe_name()) << "'" << r.original_string << "' is an array of what?\n" << end(); +109 ¦ raise << maybe(current_recipe_name()) << "'" << r.original_string << "' is an array of what?\n" << end(); 110 ¦ return 1; 111 } 112 return /*space for length*/1 + array_length(r)*size_of(array_element(r.type)); @@ -205,7 +205,7 @@ if ('onhashchange' in window) { 140 ] 141 $error: 0 142 -143 :(before "End insert_container Special-cases") +143 :(before "End insert_container Special-cases") 144 else if (is_integer(type->name)) { // sometimes types will contain non-type tags, like numbers for the size of an array 145 type->value = 0; 146 } @@ -230,7 +230,7 @@ if ('onhashchange' in window) { 165 ¦ ¦ continue; 166 ¦ } 167 ¦ if (!type->right->right || !is_integer(type->right->right->left->name)) { // array has no length -168 ¦ ¦ raise << "container '" << name << "' cannot determine size of element '" << info.elements.back().name << "'\n" << end(); +168 ¦ ¦ raise << "container '" << name << "' cannot determine size of element '" << info.elements.back().name << "'\n" << end(); 169 ¦ ¦ continue; 170 ¦ } 171 } @@ -386,19 +386,19 @@ if ('onhashchange' in window) { 321 :(before "End Primitive Recipe Checks") 322 case INDEX: { 323 if (SIZE(inst.ingredients) != 2) { -324 ¦ raise << maybe(get(Recipe, r).name) << "'index' expects exactly 2 ingredients in '" << to_original_string(inst) << "'\n" << end(); +324 ¦ raise << maybe(get(Recipe, r).name) << "'index' expects exactly 2 ingredients in '" << to_original_string(inst) << "'\n" << end(); 325 ¦ break; 326 } 327 reagent/*copy*/ base = inst.ingredients.at(0); 328 // Update INDEX base in Check 329 if (!is_mu_array(base)) { -330 ¦ raise << maybe(get(Recipe, r).name) << "'index' on a non-array '" << base.original_string << "'\n" << end(); +330 ¦ raise << maybe(get(Recipe, r).name) << "'index' on a non-array '" << base.original_string << "'\n" << end(); 331 ¦ break; 332 } 333 reagent/*copy*/ index = inst.ingredients.at(1); 334 // Update INDEX index in Check 335 if (!is_mu_number(index)) { -336 ¦ raise << maybe(get(Recipe, r).name) << "second ingredient of 'index' should be a number, but got '" << index.original_string << "'\n" << end(); +336 ¦ raise << maybe(get(Recipe, r).name) << "second ingredient of 'index' should be a number, but got '" << index.original_string << "'\n" << end(); 337 ¦ break; 338 } 339 if (inst.products.empty()) break; @@ -417,23 +417,23 @@ if ('onhashchange' in window) { 352 reagent/*copy*/ base = current_instruction().ingredients.at(0); 353 // Update INDEX base in Run 354 int base_address = base.value; -355 trace(9998, "run") << "base address is " << base_address << end(); +355 trace(9998, "run") << "base address is " << base_address << end(); 356 if (base_address == 0) { -357 ¦ raise << maybe(current_recipe_name()) << "tried to access location 0 in '" << to_original_string(current_instruction()) << "'\n" << end(); +357 ¦ raise << maybe(current_recipe_name()) << "tried to access location 0 in '" << to_original_string(current_instruction()) << "'\n" << end(); 358 ¦ break; 359 } 360 reagent/*copy*/ index = current_instruction().ingredients.at(1); 361 // Update INDEX index in Run 362 vector<double> index_val(read_memory(index)); 363 if (index_val.at(0) < 0 || index_val.at(0) >= get_or_insert(Memory, base_address)) { -364 ¦ raise << maybe(current_recipe_name()) << "invalid index " << no_scientific(index_val.at(0)) << " in '" << to_original_string(current_instruction()) << "'\n" << end(); +364 ¦ raise << maybe(current_recipe_name()) << "invalid index " << no_scientific(index_val.at(0)) << " in '" << to_original_string(current_instruction()) << "'\n" << end(); 365 ¦ break; 366 } 367 reagent/*local*/ element; 368 element.type = copy_array_element(base.type); 369 element.set_value(base_address + /*skip length*/1 + index_val.at(0)*size_of(element.type)); -370 trace(9998, "run") << "address to copy is " << element.value << end(); -371 trace(9998, "run") << "its type is " << to_string(element.type) << end(); +370 trace(9998, "run") << "address to copy is " << element.value << end(); +371 trace(9998, "run") << "its type is " << to_string(element.type) << end(); 372 // Read element 373 products.push_back(read_memory(element)); 374 break; @@ -572,19 +572,19 @@ if ('onhashchange' in window) { 507 :(before "End Primitive Recipe Checks") 508 case PUT_INDEX: { 509 if (SIZE(inst.ingredients) != 3) { -510 ¦ raise << maybe(get(Recipe, r).name) << "'put-index' expects exactly 3 ingredients in '" << to_original_string(inst) << "'\n" << end(); +510 ¦ raise << maybe(get(Recipe, r).name) << "'put-index' expects exactly 3 ingredients in '" << to_original_string(inst) << "'\n" << end(); 511 ¦ break; 512 } 513 reagent/*copy*/ base = inst.ingredients.at(0); 514 // Update PUT_INDEX base in Check 515 if (!is_mu_array(base)) { -516 ¦ raise << maybe(get(Recipe, r).name) << "'put-index' on a non-array '" << base.original_string << "'\n" << end(); +516 ¦ raise << maybe(get(Recipe, r).name) << "'put-index' on a non-array '" << base.original_string << "'\n" << end(); 517 ¦ break; 518 } 519 reagent/*copy*/ index = inst.ingredients.at(1); 520 // Update PUT_INDEX index in Check 521 if (!is_mu_number(index)) { -522 ¦ raise << maybe(get(Recipe, r).name) << "second ingredient of 'put-index' should have type 'number', but got '" << inst.ingredients.at(1).original_string << "'\n" << end(); +522 ¦ raise << maybe(get(Recipe, r).name) << "second ingredient of 'put-index' should have type 'number', but got '" << inst.ingredients.at(1).original_string << "'\n" << end(); 523 ¦ break; 524 } 525 reagent/*copy*/ value = inst.ingredients.at(2); @@ -592,12 +592,12 @@ if ('onhashchange' in window) { 527 reagent/*local*/ element; 528 element.type = copy_array_element(base.type); 529 if (!types_coercible(element, value)) { -530 ¦ raise << maybe(get(Recipe, r).name) << "'put-index " << base.original_string << ", " << inst.ingredients.at(1).original_string << "' should store " << names_to_string_without_quotes(element.type) << " but '" << value.name << "' has type " << names_to_string_without_quotes(value.type) << '\n' << end(); +530 ¦ raise << maybe(get(Recipe, r).name) << "'put-index " << base.original_string << ", " << inst.ingredients.at(1).original_string << "' should store " << names_to_string_without_quotes(element.type) << " but '" << value.name << "' has type " << names_to_string_without_quotes(value.type) << '\n' << end(); 531 ¦ break; 532 } 533 if (inst.products.empty()) break; // no more checks necessary 534 if (inst.products.at(0).name != inst.ingredients.at(0).name) { -535 ¦ raise << maybe(get(Recipe, r).name) << "product of 'put-index' must be first ingredient '" << inst.ingredients.at(0).original_string << "', but got '" << inst.products.at(0).original_string << "'\n" << end(); +535 ¦ raise << maybe(get(Recipe, r).name) << "product of 'put-index' must be first ingredient '" << inst.ingredients.at(0).original_string << "', but got '" << inst.products.at(0).original_string << "'\n" << end(); 536 ¦ break; 537 } 538 // End PUT_INDEX Product Checks @@ -609,25 +609,25 @@ if ('onhashchange' in window) { 544 // Update PUT_INDEX base in Run 545 int base_address = base.value; 546 if (base_address == 0) { -547 ¦ raise << maybe(current_recipe_name()) << "tried to access location 0 in '" << to_original_string(current_instruction()) << "'\n" << end(); +547 ¦ raise << maybe(current_recipe_name()) << "tried to access location 0 in '" << to_original_string(current_instruction()) << "'\n" << end(); 548 ¦ break; 549 } 550 reagent/*copy*/ index = current_instruction().ingredients.at(1); 551 // Update PUT_INDEX index in Run 552 vector<double> index_val(read_memory(index)); 553 if (index_val.at(0) < 0 || index_val.at(0) >= get_or_insert(Memory, base_address)) { -554 ¦ raise << maybe(current_recipe_name()) << "invalid index " << no_scientific(index_val.at(0)) << " in '" << to_original_string(current_instruction()) << "'\n" << end(); +554 ¦ raise << maybe(current_recipe_name()) << "invalid index " << no_scientific(index_val.at(0)) << " in '" << to_original_string(current_instruction()) << "'\n" << end(); 555 ¦ break; 556 } 557 int address = base_address + /*skip length*/1 + index_val.at(0)*size_of(array_element(base.type)); -558 trace(9998, "run") << "address to copy to is " << address << end(); +558 trace(9998, "run") << "address to copy to is " << address << end(); 559 // optimization: directly write the element rather than updating 'product' 560 // and writing the entire array 561 write_products = false; 562 vector<double> value = read_memory(current_instruction().ingredients.at(2)); 563 // Write Memory in PUT_INDEX in Run 564 for (int i = 0; i < SIZE(value); ++i) { -565 ¦ trace(9999, "mem") << "storing " << no_scientific(value.at(i)) << " in location " << address+i << end(); +565 ¦ trace(9999, "mem") << "storing " << no_scientific(value.at(i)) << " in location " << address+i << end(); 566 ¦ put(Memory, address+i, value.at(i)); 567 } 568 break; @@ -692,13 +692,13 @@ if ('onhashchange' in window) { 627 :(before "End Primitive Recipe Checks") 628 case LENGTH: { 629 if (SIZE(inst.ingredients) != 1) { -630 ¦ raise << maybe(get(Recipe, r).name) << "'length' expects exactly 2 ingredients in '" << to_original_string(inst) << "'\n" << end(); +630 ¦ raise << maybe(get(Recipe, r).name) << "'length' expects exactly 2 ingredients in '" << to_original_string(inst) << "'\n" << end(); 631 ¦ break; 632 } 633 reagent/*copy*/ array = inst.ingredients.at(0); 634 // Update LENGTH array in Check 635 if (!is_mu_array(array)) { -636 ¦ raise << "tried to calculate length of non-array '" << array.original_string << "'\n" << end(); +636 ¦ raise << "tried to calculate length of non-array '" << array.original_string << "'\n" << end(); 637 ¦ break; 638 } 639 break; @@ -708,7 +708,7 @@ if ('onhashchange' in window) { 643 reagent/*copy*/ array = current_instruction().ingredients.at(0); 644 // Update LENGTH array in Run 645 if (array.value == 0) { -646 ¦ raise << maybe(current_recipe_name()) << "tried to access location 0 in '" << to_original_string(current_instruction()) << "'\n" << end(); +646 ¦ raise << maybe(current_recipe_name()) << "tried to access location 0 in '" << to_original_string(current_instruction()) << "'\n" << end(); 647 ¦ break; 648 } 649 products.resize(1); -- cgit 1.4.1-2-gfad0