From 850822ffbfd441d05161452be28b54f882b1b378 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Wed, 1 Nov 2017 03:41:16 -0700 Subject: 4102 --- html/035lookup.cc.html | 124 ++++++++++++++++++++++++------------------------- 1 file changed, 62 insertions(+), 62 deletions(-) (limited to 'html/035lookup.cc.html') diff --git a/html/035lookup.cc.html b/html/035lookup.cc.html index a4ee9480..175b0ad5 100644 --- a/html/035lookup.cc.html +++ b/html/035lookup.cc.html @@ -99,10 +99,10 @@ if ('onhashchange' in window) { 34 35 :(scenario copy_indirect) 36 def main [ - 37 1:address:num <- copy 10/unsafe + 37 1:address:num <- copy 10/unsafe 38 11:num <- copy 34 39 # This loads location 1 as an address and looks up *that* location. - 40 2:num <- copy 1:address:num/lookup + 40 2:num <- copy 1:address:num/lookup 41 ] 42 # 1 contains 10. Skip refcount and lookup location 11. 43 +mem: storing 34 in location 2 @@ -114,8 +114,8 @@ if ('onhashchange' in window) { 49 //: 'lookup' property 50 :(scenario store_indirect) 51 def main [ - 52 1:address:num <- copy 10/unsafe - 53 1:address:num/lookup <- copy 34 + 52 1:address:num <- copy 10/unsafe + 53 1:address:num/lookup <- copy 34 54 ] 55 +mem: storing 34 in location 11 56 @@ -126,37 +126,37 @@ if ('onhashchange' in window) { 61 :(scenario store_to_0_fails) 62 % Hide_errors = true; 63 def main [ - 64 1:address:num <- copy 0 - 65 1:address:num/lookup <- copy 34 + 64 1:address:num <- copy 0 + 65 1:address:num/lookup <- copy 34 66 ] 67 -mem: storing 34 in location 0 - 68 +error: can't write to location 0 in '1:address:num/lookup <- copy 34' + 68 +error: can't write to location 0 in '1:address:num/lookup <- copy 34' 69 70 //: attempts to /lookup address 0 always loudly fail 71 :(scenario lookup_0_fails) 72 % Hide_errors = true; 73 def main [ - 74 1:address:num <- copy 0 - 75 2:num <- copy 1:address:num/lookup + 74 1:address:num <- copy 0 + 75 2:num <- copy 1:address:num/lookup 76 ] 77 +error: main: tried to /lookup 0 in '2:num <- copy 1:address:num/lookup' 78 79 :(code) 80 void canonize(reagent& x) { 81 if (is_literal(x)) return; - 82 // End canonize(x) Special-cases + 82 // Begin canonize(x) Lookups 83 while (has_property(x, "lookup")) 84 ¦ lookup_memory(x); 85 } 86 87 void lookup_memory(reagent& x) { 88 if (!x.type || x.type->atom || x.type->left->value != get(Type_ordinal, "address")) { - 89 ¦ raise << maybe(current_recipe_name()) << "tried to /lookup '" << x.original_string << "' but it isn't an address\n" << end(); + 89 ¦ raise << maybe(current_recipe_name()) << "tried to /lookup '" << x.original_string << "' but it isn't an address\n" << end(); 90 ¦ return; 91 } 92 // compute value 93 if (x.value == 0) { - 94 ¦ raise << maybe(current_recipe_name()) << "tried to /lookup 0\n" << end(); + 94 ¦ raise << maybe(current_recipe_name()) << "tried to /lookup 0\n" << end(); 95 ¦ return; 96 } 97 lookup_memory_core(x, /*check_for_null*/true); @@ -173,7 +173,7 @@ if ('onhashchange' in window) { 108 } 109 else if (check_for_null) { 110 ¦ if (Current_routine) -111 ¦ ¦ raise << maybe(current_recipe_name()) << "tried to /lookup 0 in '" << to_original_string(current_instruction()) << "'\n" << end(); +111 ¦ ¦ raise << maybe(current_recipe_name()) << "tried to /lookup 0 in '" << to_original_string(current_instruction()) << "'\n" << end(); 112 ¦ else 113 ¦ ¦ raise << "tried to /lookup 0\n" << end(); 114 } @@ -181,7 +181,7 @@ if ('onhashchange' in window) { 116 } 117 118 void test_lookup_address_skips_refcount() { -119 reagent x("*x:address:num"); +119 reagent x("*x:address:num"); 120 x.set_value(34); // unsafe 121 put(Memory, 34, 1000); 122 lookup_memory(x); @@ -191,7 +191,7 @@ if ('onhashchange' in window) { 126 127 void test_lookup_zero_address_does_not_skip_refcount() { 128 Hide_errors = true; -129 reagent x("*x:address:num"); +129 reagent x("*x:address:num"); 130 x.set_value(34); // unsafe 131 put(Memory, 34, 0); 132 lookup_memory(x); @@ -239,7 +239,7 @@ if ('onhashchange' in window) { 174 bool canonize_type(reagent& r) { 175 while (has_property(r, "lookup")) { 176 ¦ if (!r.type || r.type->atom || !r.type->left || !r.type->left->atom || r.type->left->value != get(Type_ordinal, "address")) { -177 ¦ ¦ raise << "cannot perform lookup on '" << r.name << "' because it has non-address type " << to_string(r.type) << '\n' << end(); +177 ¦ ¦ raise << "cannot perform lookup on '" << r.name << "' because it has non-address type " << to_string(r.type) << '\n' << end(); 178 ¦ ¦ return false; 179 ¦ } 180 ¦ drop_from_type(r, "address"); @@ -264,32 +264,32 @@ if ('onhashchange' in window) { 199 200 :(scenario get_indirect) 201 def main [ -202 1:address:point <- copy 10/unsafe +202 1:address:point <- copy 10/unsafe 203 # 10 reserved for refcount 204 11:num <- copy 34 205 12:num <- copy 35 -206 2:num <- get 1:address:point/lookup, 0:offset +206 2:num <- get 1:address:point/lookup, 0:offset 207 ] 208 +mem: storing 34 in location 2 209 210 :(scenario get_indirect2) 211 def main [ -212 1:address:point <- copy 10/unsafe +212 1:address:point <- copy 10/unsafe 213 # 10 reserved for refcount 214 11:num <- copy 34 215 12:num <- copy 35 -216 2:address:num <- copy 20/unsafe -217 2:address:num/lookup <- get 1:address:point/lookup, 0:offset +216 2:address:num <- copy 20/unsafe +217 2:address:num/lookup <- get 1:address:point/lookup, 0:offset 218 ] 219 +mem: storing 34 in location 21 220 221 :(scenario include_nonlookup_properties) 222 def main [ -223 1:address:point <- copy 10/unsafe +223 1:address:point <- copy 10/unsafe 224 # 10 reserved for refcount 225 11:num <- copy 34 226 12:num <- copy 35 -227 2:num <- get 1:address:point/lookup/foo, 0:offset +227 2:num <- get 1:address:point/lookup/foo, 0:offset 228 ] 229 +mem: storing 34 in location 2 230 @@ -302,11 +302,11 @@ if ('onhashchange' in window) { 237 238 :(scenario put_indirect) 239 def main [ -240 1:address:point <- copy 10/unsafe +240 1:address:point <- copy 10/unsafe 241 # 10 reserved for refcount 242 11:num <- copy 34 243 12:num <- copy 35 -244 1:address:point/lookup <- put 1:address:point/lookup, 0:offset, 36 +244 1:address:point/lookup <- put 1:address:point/lookup, 0:offset, 36 245 ] 246 +mem: storing 36 in location 11 247 @@ -320,11 +320,11 @@ if ('onhashchange' in window) { 255 :(scenario put_product_error_with_lookup) 256 % Hide_errors = true; 257 def main [ -258 1:address:point <- copy 10/unsafe +258 1:address:point <- copy 10/unsafe 259 # 10 reserved for refcount 260 11:num <- copy 34 261 12:num <- copy 35 -262 1:address:point <- put 1:address:point/lookup, x:offset, 36 +262 1:address:point <- put 1:address:point/lookup, x:offset, 36 263 ] 264 +error: main: product of 'put' must be first ingredient '1:address:point/lookup', but got '1:address:point' 265 @@ -355,8 +355,8 @@ if ('onhashchange' in window) { 290 12:num <- copy 14 291 13:num <- copy 15 292 14:num <- copy 16 -293 1:address:array:num <- copy 10/unsafe -294 2:array:num <- copy 1:address:array:num/lookup +293 1:address:array:num <- copy 10/unsafe +294 2:array:num <- copy 1:address:array:num/lookup 295 ] 296 +mem: storing 3 in location 2 297 +mem: storing 14 in location 3 @@ -366,8 +366,8 @@ if ('onhashchange' in window) { 301 :(scenario create_array_indirect) 302 def main [ 303 1000:num/raw <- copy 1 # pretend refcount -304 1:address:array:num:3 <- copy 1000/unsafe # pretend allocation -305 1:address:array:num:3/lookup <- create-array +304 1:address:array:num:3 <- copy 1000/unsafe # pretend allocation +305 1:address:array:num:3/lookup <- create-array 306 ] 307 +mem: storing 3 in location 1001 308 @@ -383,8 +383,8 @@ if ('onhashchange' in window) { 318 12:num <- copy 14 319 13:num <- copy 15 320 14:num <- copy 16 -321 1:address:array:num <- copy 10/unsafe -322 2:num <- index 1:address:array:num/lookup, 1 +321 1:address:array:num <- copy 10/unsafe +322 2:num <- index 1:address:array:num/lookup, 1 323 ] 324 +mem: storing 15 in location 2 325 @@ -407,8 +407,8 @@ if ('onhashchange' in window) { 342 12:num <- copy 14 343 13:num <- copy 15 344 14:num <- copy 16 -345 1:address:array:num <- copy 10/unsafe -346 1:address:array:num/lookup <- put-index 1:address:array:num/lookup, 1, 34 +345 1:address:array:num <- copy 10/unsafe +346 1:address:array:num/lookup <- put-index 1:address:array:num/lookup, 1, 34 347 ] 348 +mem: storing 34 in location 13 349 @@ -418,10 +418,10 @@ if ('onhashchange' in window) { 353 2:num <- copy 14 354 3:num <- copy 15 355 4:num <- copy 16 -356 5:address:num <- copy 10/unsafe +356 5:address:num <- copy 10/unsafe 357 # 10 reserved for refcount 358 11:num <- copy 1 -359 1:array:num:3 <- put-index 1:array:num:3, 5:address:num/lookup, 34 +359 1:array:num:3 <- put-index 1:array:num:3, 5:address:num/lookup, 34 360 ] 361 +mem: storing 34 in location 3 362 @@ -433,8 +433,8 @@ if ('onhashchange' in window) { 368 12:num <- copy 14 369 13:num <- copy 15 370 14:num <- copy 16 -371 1:address:array:num <- copy 10/unsafe -372 1:address:array:num <- put-index 1:address:array:num/lookup, 1, 34 +371 1:address:array:num <- copy 10/unsafe +372 1:address:array:num <- put-index 1:address:array:num/lookup, 1, 34 373 ] 374 +error: main: product of 'put-index' must be first ingredient '1:address:array:num/lookup', but got '1:address:array:num' 375 @@ -450,11 +450,11 @@ if ('onhashchange' in window) { 385 386 :(scenario dilated_reagent_in_static_array) 387 def main [ -388 {1: (array (address number) 3)} <- create-array -389 5:address:num <- new number:type -390 {1: (array (address number) 3)} <- put-index {1: (array (address number) 3)}, 0, 5:address:num -391 *5:address:num <- copy 34 -392 6:num <- copy *5:address:num +388 {1: (array (address number) 3)} <- create-array +389 5:address:num <- new number:type +390 {1: (array (address number) 3)} <- put-index {1: (array (address number) 3)}, 0, 5:address:num +391 *5:address:num <- copy 34 +392 6:num <- copy *5:address:num 393 ] 394 +run: creating array of size 4 395 +mem: storing 34 in location 6 @@ -478,8 +478,8 @@ if ('onhashchange' in window) { 413 12:num <- copy 14 414 13:num <- copy 15 415 14:num <- copy 16 -416 1:address:array:num <- copy 10/unsafe -417 2:num <- length 1:address:array:num/lookup +416 1:address:array:num <- copy 10/unsafe +417 2:num <- length 1:address:array:num/lookup 418 ] 419 +mem: storing 3 in location 2 420 @@ -492,8 +492,8 @@ if ('onhashchange' in window) { 427 def main [ 428 # 10 reserved for refcount 429 11:number-or-point <- merge 0/number, 34 -430 1:address:number-or-point <- copy 10/unsafe -431 2:num, 3:bool <- maybe-convert 1:address:number-or-point/lookup, i:variant +430 1:address:number-or-point <- copy 10/unsafe +431 2:num, 3:bool <- maybe-convert 1:address:number-or-point/lookup, i:variant 432 ] 433 +mem: storing 1 in location 3 434 +mem: storing 34 in location 2 @@ -502,9 +502,9 @@ if ('onhashchange' in window) { 437 def main [ 438 # 10 reserved for refcount 439 11:number-or-point <- merge 0/number, 34 -440 1:address:number-or-point <- copy 10/unsafe -441 2:address:num <- copy 20/unsafe -442 2:address:num/lookup, 3:bool <- maybe-convert 1:address:number-or-point/lookup, i:variant +440 1:address:number-or-point <- copy 10/unsafe +441 2:address:num <- copy 20/unsafe +442 2:address:num/lookup, 3:bool <- maybe-convert 1:address:number-or-point/lookup, i:variant 443 ] 444 +mem: storing 1 in location 3 445 +mem: storing 34 in location 21 @@ -513,9 +513,9 @@ if ('onhashchange' in window) { 448 def main [ 449 # 10 reserved for refcount 450 11:number-or-point <- merge 0/number, 34 -451 1:address:number-or-point <- copy 10/unsafe -452 2:address:bool <- copy 20/unsafe -453 3:num, 2:address:bool/lookup <- maybe-convert 1:address:number-or-point/lookup, i:variant +451 1:address:number-or-point <- copy 10/unsafe +452 2:address:bool <- copy 20/unsafe +453 3:num, 2:address:bool/lookup <- maybe-convert 1:address:number-or-point/lookup, i:variant 454 ] 455 +mem: storing 1 in location 21 456 +mem: storing 34 in location 3 @@ -536,8 +536,8 @@ if ('onhashchange' in window) { 471 472 :(scenario merge_exclusive_container_indirect) 473 def main [ -474 1:address:number-or-point <- copy 10/unsafe -475 1:address:number-or-point/lookup <- merge 0/number, 34 +474 1:address:number-or-point <- copy 10/unsafe +475 1:address:number-or-point/lookup <- merge 0/number, 34 476 ] 477 # skip 10 for refcount 478 +mem: storing 0 in location 11 @@ -550,10 +550,10 @@ if ('onhashchange' in window) { 485 486 :(scenario lookup_abbreviation) 487 def main [ -488 1:address:number <- copy 10/unsafe +488 1:address:number <- copy 10/unsafe 489 # 10 reserved for refcount 490 11:number <- copy 34 -491 3:number <- copy *1:address:number +491 3:number <- copy *1:address:number 492 ] 493 +parse: ingredient: {1: ("address" "number"), "lookup": ()} 494 +mem: storing 34 in location 3 @@ -576,9 +576,9 @@ if ('onhashchange' in window) { 511 put(Recipe_ordinal, "$dump", _DUMP); 512 :(before "End Primitive Recipe Implementations") 513 case _DUMP: { -514 reagent/*copy*/ after_canonize = current_instruction().ingredients.at(0); +514 reagent/*copy*/ after_canonize = current_instruction().ingredients.at(0); 515 canonize(after_canonize); -516 cerr << maybe(current_recipe_name()) << current_instruction().ingredients.at(0).name << ' ' << no_scientific(current_instruction().ingredients.at(0).value) << " => " << no_scientific(after_canonize.value) << " => " << no_scientific(get_or_insert(Memory, after_canonize.value)) << '\n'; +516 cerr << maybe(current_recipe_name()) << current_instruction().ingredients.at(0).name << ' ' << no_scientific(current_instruction().ingredients.at(0).value) << " => " << no_scientific(after_canonize.value) << " => " << no_scientific(get_or_insert(Memory, after_canonize.value)) << '\n'; 517 break; 518 } 519 @@ -592,12 +592,12 @@ if ('onhashchange' in window) { 527 put(Recipe_ordinal, "$bar", _BAR); 528 :(before "End Primitive Recipe Implementations") 529 case _BAR: { -530 if (current_instruction().ingredients.empty()) { +530 if (current_instruction().ingredients.empty()) { 531 ¦ if (Bar != -1) cerr << Bar << ": " << no_scientific(get_or_insert(Memory, Bar)) << '\n'; 532 ¦ else cerr << '\n'; 533 } 534 else { -535 ¦ reagent/*copy*/ tmp = current_instruction().ingredients.at(0); +535 ¦ reagent/*copy*/ tmp = current_instruction().ingredients.at(0); 536 ¦ canonize(tmp); 537 ¦ Bar = tmp.value; 538 } -- cgit 1.4.1-2-gfad0