From 5fe060d582d4a82444243a28b18085c971a85628 Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Fri, 27 Jul 2018 17:07:52 -0700 Subject: 4447 --- html/053recipe_header.cc.html | 102 +++++++++++++++++++++--------------------- 1 file changed, 51 insertions(+), 51 deletions(-) (limited to 'html/053recipe_header.cc.html') diff --git a/html/053recipe_header.cc.html b/html/053recipe_header.cc.html index 7ef683cd..348e473d 100644 --- a/html/053recipe_header.cc.html +++ b/html/053recipe_header.cc.html @@ -85,40 +85,40 @@ if ('onhashchange' in window) { 20 vector<reagent> ingredients; 21 vector<reagent> products; 22 :(before "End recipe Constructor") - 23 has_header = false; + 23 has_header = false; 24 25 :(before "End Recipe Refinements") 26 if (in.peek() != '[') { - 27 trace("parse") << "recipe has a header; parsing" << end(); + 27 trace("parse") << "recipe has a header; parsing" << end(); 28 load_recipe_header(in, result); 29 } 30 31 :(code) 32 void load_recipe_header(istream& in, recipe& result) { - 33 result.has_header = true; + 33 result.has_header = true; 34 while (has_data(in) && in.peek() != '[' && in.peek() != '\n') { - 35 string s = next_word(in); + 35 string s = next_word(in); 36 if (s.empty()) { 37 assert(!has_data(in)); - 38 raise << "incomplete recipe header at end of file (0)\n" << end(); + 38 raise << "incomplete recipe header at end of file (0)\n" << end(); 39 return; 40 } 41 if (s == "<-") - 42 raise << "recipe " << result.name << " should say '->' and not '<-'\n" << end(); + 42 raise << "recipe " << result.name << " should say '->' and not '<-'\n" << end(); 43 if (s == "->") break; 44 result.ingredients.push_back(reagent(s)); - 45 trace("parse") << "header ingredient: " << result.ingredients.back().original_string << end(); + 45 trace("parse") << "header ingredient: " << result.ingredients.back().original_string << end(); 46 skip_whitespace_but_not_newline(in); 47 } 48 while (has_data(in) && in.peek() != '[' && in.peek() != '\n') { - 49 string s = next_word(in); + 49 string s = next_word(in); 50 if (s.empty()) { 51 assert(!has_data(in)); - 52 raise << "incomplete recipe header at end of file (1)\n" << end(); + 52 raise << "incomplete recipe header at end of file (1)\n" << end(); 53 return; 54 } 55 result.products.push_back(reagent(s)); - 56 trace("parse") << "header product: " << result.products.back().original_string << end(); + 56 trace("parse") << "header product: " << result.products.back().original_string << end(); 57 skip_whitespace_but_not_newline(in); 58 } 59 // End Load Recipe Header(result) @@ -200,7 +200,7 @@ if ('onhashchange' in window) { 135 136 :(before "End Recipe Body(result)") 137 if (!result.has_header) { -138 result.has_header = true; +138 result.has_header = true; 139 for (int i = 0; i < SIZE(result.steps); ++i) { 140 const instruction& inst = result.steps.at(i); 141 if ((inst.name == "reply" && !inst.ingredients.empty()) @@ -208,13 +208,13 @@ if ('onhashchange' in window) { 143 || inst.name == "next-ingredient" 144 || inst.name == "ingredient" 145 || inst.name == "rewind-ingredients") { -146 result.has_header = false; +146 result.has_header = false; 147 break; 148 } 149 } 150 } 151 if (result.has_header) { -152 trace("parse") << "recipe " << result.name << " has a header" << end(); +152 trace("parse") << "recipe " << result.name << " has a header" << end(); 153 } 154 155 //: Support type abbreviations in headers. @@ -253,7 +253,7 @@ if ('onhashchange' in window) { 188 } 189 } 190 if (curr.name == "next-ingredient-without-typechecking") { -191 raise << maybe(result.name) << "never call 'next-ingredient-without-typechecking' directly\n" << end(); +191 raise << maybe(result.name) << "never call 'next-ingredient-without-typechecking' directly\n" << end(); 192 curr.clear(); 193 } 194 @@ -298,7 +298,7 @@ if ('onhashchange' in window) { 233 234 :(after "use-before-set Error") 235 if (is_present_in_ingredients(caller, ingredient.name)) -236 raise << " did you forget 'load-ingredients'?\n" << end(); +236 raise << " did you forget 'load-ingredients'?\n" << end(); 237 238 :(scenario load_ingredients_missing_error_2) 239 % Hide_errors = true; @@ -311,15 +311,15 @@ if ('onhashchange' in window) { 246 247 :(after "missing-type Error 1") 248 if (is_present_in_ingredients(get(Recipe, get(Recipe_ordinal, recipe_name)), x.name)) -249 raise << " did you forget 'load-ingredients'?\n" << end(); +249 raise << " did you forget 'load-ingredients'?\n" << end(); 250 251 :(code) 252 bool is_present_in_ingredients(const recipe& callee, const string& ingredient_name) { 253 for (int i = 0; i < SIZE(callee.ingredients); ++i) { 254 if (callee.ingredients.at(i).name == ingredient_name) -255 return true; +255 return true; 256 } -257 return false; +257 return false; 258 } 259 260 //:: Check all calls against headers. @@ -353,7 +353,7 @@ if ('onhashchange' in window) { 288 :(code) 289 void check_calls_against_header(const recipe_ordinal r) { 290 const recipe& caller = get(Recipe, r); -291 trace(9991, "transform") << "--- type-check calls inside recipe " << caller.name << end(); +291 trace(9991, "transform") << "--- type-check calls inside recipe " << caller.name << end(); 292 for (int i = 0; i < SIZE(caller.steps); ++i) { 293 const instruction& inst = caller.steps.at(i); 294 if (is_primitive(inst.operation)) continue; @@ -362,16 +362,16 @@ if ('onhashchange' in window) { 297 for (long int i = 0; i < min(SIZE(inst.ingredients), SIZE(callee.ingredients)); ++i) { 298 // ingredients coerced from call to callee 299 if (!types_coercible(callee.ingredients.at(i), inst.ingredients.at(i))) { -300 raise << maybe(caller.name) << "ingredient " << i << " has the wrong type at '" << to_original_string(inst) << "'\n" << end(); -301 raise << " ['" << to_string(callee.ingredients.at(i).type) << "' vs '" << to_string(inst.ingredients.at(i).type) << "']\n" << end(); +300 raise << maybe(caller.name) << "ingredient " << i << " has the wrong type at '" << to_original_string(inst) << "'\n" << end(); +301 raise << " ['" << to_string(callee.ingredients.at(i).type) << "' vs '" << to_string(inst.ingredients.at(i).type) << "']\n" << end(); 302 } 303 } 304 for (long int i = 0; i < min(SIZE(inst.products), SIZE(callee.products)); ++i) { 305 if (is_dummy(inst.products.at(i))) continue; 306 // products coerced from callee to call 307 if (!types_coercible(inst.products.at(i), callee.products.at(i))) { -308 raise << maybe(caller.name) << "product " << i << " has the wrong type at '" << to_original_string(inst) << "'\n" << end(); -309 raise << " ['" << to_string(inst.products.at(i).type) << "' vs '" << to_string(callee.products.at(i).type) << "']\n" << end(); +308 raise << maybe(caller.name) << "product " << i << " has the wrong type at '" << to_original_string(inst) << "'\n" << end(); +309 raise << " ['" << to_string(inst.products.at(i).type) << "' vs '" << to_string(callee.products.at(i).type) << "']\n" << end(); 310 } 311 } 312 } @@ -397,17 +397,17 @@ if ('onhashchange' in window) { 332 void check_return_instructions_against_header(const recipe_ordinal r) { 333 const recipe& caller_recipe = get(Recipe, r); 334 if (!caller_recipe.has_header) return; -335 trace(9991, "transform") << "--- checking return instructions against header for " << caller_recipe.name << end(); +335 trace(9991, "transform") << "--- checking return instructions against header for " << caller_recipe.name << end(); 336 for (int i = 0; i < SIZE(caller_recipe.steps); ++i) { 337 const instruction& inst = caller_recipe.steps.at(i); 338 if (inst.name != "reply" && inst.name != "return") continue; 339 if (SIZE(caller_recipe.products) != SIZE(inst.ingredients)) { -340 raise << maybe(caller_recipe.name) << "replied with the wrong number of products at '" << to_original_string(inst) << "'\n" << end(); +340 raise << maybe(caller_recipe.name) << "replied with the wrong number of products at '" << to_original_string(inst) << "'\n" << end(); 341 continue; 342 } 343 for (int i = 0; i < SIZE(caller_recipe.products); ++i) { 344 if (!types_match(caller_recipe.products.at(i), inst.ingredients.at(i))) -345 raise << maybe(caller_recipe.name) << "replied with the wrong type at '" << to_original_string(inst) << "'\n" << end(); +345 raise << maybe(caller_recipe.name) << "replied with the wrong type at '" << to_original_string(inst) << "'\n" << end(); 346 } 347 } 348 } @@ -427,7 +427,7 @@ if ('onhashchange' in window) { 362 def foo -> x:num [ 363 local-scope 364 x:num <- copy 0 -365 z:bool <- copy 0/false +365 z:bool <- copy false 366 return-if z, z 367 ] 368 +error: foo: replied with the wrong type at 'return-if z, z' @@ -468,12 +468,12 @@ if ('onhashchange' in window) { 403 void check_header_ingredients(const recipe_ordinal r) { 404 recipe& caller_recipe = get(Recipe, r); 405 caller_recipe.ingredient_index.clear(); -406 trace(9991, "transform") << "--- checking return instructions against header for " << caller_recipe.name << end(); +406 trace(9991, "transform") << "--- checking return instructions against header for " << caller_recipe.name << end(); 407 for (int i = 0; i < SIZE(caller_recipe.ingredients); ++i) { 408 if (caller_recipe.ingredients.at(i).type == NULL) -409 raise << maybe(caller_recipe.name) << "ingredient '" << caller_recipe.ingredients.at(i).name << "' has no type\n" << end(); -410 if (contains_key(caller_recipe.ingredient_index, caller_recipe.ingredients.at(i).name)) -411 raise << maybe(caller_recipe.name) << "'" << caller_recipe.ingredients.at(i).name << "' can't repeat in the ingredients\n" << end(); +409 raise << maybe(caller_recipe.name) << "ingredient '" << caller_recipe.ingredients.at(i).name << "' has no type\n" << end(); +410 if (contains_key(caller_recipe.ingredient_index, caller_recipe.ingredients.at(i).name)) +411 raise << maybe(caller_recipe.name) << "'" << caller_recipe.ingredients.at(i).name << "' can't repeat in the ingredients\n" << end(); 412 put(caller_recipe.ingredient_index, caller_recipe.ingredients.at(i).name, i); 413 } 414 } @@ -500,37 +500,37 @@ if ('onhashchange' in window) { 435 void deduce_types_from_header(const recipe_ordinal r) { 436 recipe& caller_recipe = get(Recipe, r); 437 if (caller_recipe.products.empty()) return; -438 trace(9991, "transform") << "--- deduce types from header for " << caller_recipe.name << end(); +438 trace(9991, "transform") << "--- deduce types from header for " << caller_recipe.name << end(); 439 map<string, const type_tree*> header_type; 440 for (int i = 0; i < SIZE(caller_recipe.ingredients); ++i) { 441 if (!caller_recipe.ingredients.at(i).type) continue; // error handled elsewhere 442 put(header_type, caller_recipe.ingredients.at(i).name, caller_recipe.ingredients.at(i).type); -443 trace(9993, "transform") << "type of " << caller_recipe.ingredients.at(i).name << " is " << names_to_string(caller_recipe.ingredients.at(i).type) << end(); +443 trace(9993, "transform") << "type of " << caller_recipe.ingredients.at(i).name << " is " << names_to_string(caller_recipe.ingredients.at(i).type) << end(); 444 } 445 for (int i = 0; i < SIZE(caller_recipe.products); ++i) { 446 if (!caller_recipe.products.at(i).type) continue; // error handled elsewhere 447 put(header_type, caller_recipe.products.at(i).name, caller_recipe.products.at(i).type); -448 trace(9993, "transform") << "type of " << caller_recipe.products.at(i).name << " is " << names_to_string(caller_recipe.products.at(i).type) << end(); +448 trace(9993, "transform") << "type of " << caller_recipe.products.at(i).name << " is " << names_to_string(caller_recipe.products.at(i).type) << end(); 449 } 450 for (int i = 0; i < SIZE(caller_recipe.steps); ++i) { 451 instruction& inst = caller_recipe.steps.at(i); -452 trace(9992, "transform") << "instruction: " << to_string(inst) << end(); +452 trace(9992, "transform") << "instruction: " << to_string(inst) << end(); 453 for (int i = 0; i < SIZE(inst.ingredients); ++i) { 454 if (inst.ingredients.at(i).type) continue; -455 if (header_type.find(inst.ingredients.at(i).name) == header_type.end()) +455 if (header_type.find(inst.ingredients.at(i).name) == header_type.end()) 456 continue; 457 if (!contains_key(header_type, inst.ingredients.at(i).name)) continue; // error handled elsewhere 458 inst.ingredients.at(i).type = new type_tree(*get(header_type, inst.ingredients.at(i).name)); -459 trace(9993, "transform") << "type of " << inst.ingredients.at(i).name << " is " << names_to_string(inst.ingredients.at(i).type) << end(); +459 trace(9993, "transform") << "type of " << inst.ingredients.at(i).name << " is " << names_to_string(inst.ingredients.at(i).type) << end(); 460 } 461 for (int i = 0; i < SIZE(inst.products); ++i) { -462 trace(9993, "transform") << " product: " << to_string(inst.products.at(i)) << end(); +462 trace(9993, "transform") << " product: " << to_string(inst.products.at(i)) << end(); 463 if (inst.products.at(i).type) continue; -464 if (header_type.find(inst.products.at(i).name) == header_type.end()) +464 if (header_type.find(inst.products.at(i).name) == header_type.end()) 465 continue; 466 if (!contains_key(header_type, inst.products.at(i).name)) continue; // error handled elsewhere 467 inst.products.at(i).type = new type_tree(*get(header_type, inst.products.at(i).name)); -468 trace(9993, "transform") << "type of " << inst.products.at(i).name << " is " << names_to_string(inst.products.at(i).type) << end(); +468 trace(9993, "transform") << "type of " << inst.products.at(i).name << " is " << names_to_string(inst.products.at(i).type) << end(); 469 } 470 } 471 } @@ -556,7 +556,7 @@ if ('onhashchange' in window) { 491 :(code) 492 void fill_in_return_ingredients(const recipe_ordinal r) { 493 recipe& caller_recipe = get(Recipe, r); -494 trace(9991, "transform") << "--- fill in return ingredients from header for recipe " << caller_recipe.name << end(); +494 trace(9991, "transform") << "--- fill in return ingredients from header for recipe " << caller_recipe.name << end(); 495 if (!caller_recipe.has_header) return; 496 for (int i = 0; i < SIZE(caller_recipe.steps); ++i) { 497 instruction& inst = caller_recipe.steps.at(i); @@ -569,7 +569,7 @@ if ('onhashchange' in window) { 504 if (final_instruction.name == "reply" || final_instruction.name == "return") 505 return; 506 } -507 instruction inst; +507 instruction inst; 508 inst.name = "return"; 509 add_header_products(inst, caller_recipe); 510 caller_recipe.steps.push_back(inst); @@ -583,7 +583,7 @@ if ('onhashchange' in window) { 518 if (SIZE(inst.ingredients) == i) 519 inst.ingredients.push_back(caller_recipe.products.at(i)); 520 // if it's missing /same_as_ingredient, try to fill it in -521 if (contains_key(caller_recipe.ingredient_index, caller_recipe.products.at(i).name) && !has_property(inst.ingredients.at(i), "same_as_ingredient")) { +521 if (contains_key(caller_recipe.ingredient_index, caller_recipe.products.at(i).name) && !has_property(inst.ingredients.at(i), "same_as_ingredient")) { 522 ostringstream same_as_ingredient; 523 same_as_ingredient << get(caller_recipe.ingredient_index, caller_recipe.products.at(i).name); 524 inst.ingredients.at(i).properties.push_back(pair<string, string_tree*>("same-as-ingredient", new string_tree(same_as_ingredient.str()))); @@ -614,7 +614,7 @@ if ('onhashchange' in window) { 549 load-ingredients 550 z <- add x, y 551 ] -552 +transform: instruction: return {z: "number"} +552 +transform: instruction: return {z: "number"} 553 +mem: storing 8 in location 1 554 555 :(scenario return_on_fallthrough_already_exists) @@ -627,8 +627,8 @@ if ('onhashchange' in window) { 562 z <- add x, y # no type for z 563 return z 564 ] -565 +transform: instruction: return {z: ()} -566 -transform: instruction: return z:num +565 +transform: instruction: return {z: ()} +566 -transform: instruction: return z:num 567 +mem: storing 8 in location 1 568 569 :(scenario return_causes_error_in_empty_recipe) @@ -645,7 +645,7 @@ if ('onhashchange' in window) { 580 local-scope 581 load-ingredients 582 z <- add x, y # no type for z -583 return-if 0/false, 34 +583 return-if false, 34 584 ] 585 +mem: storing 8 in location 1 586 @@ -689,12 +689,12 @@ if ('onhashchange' in window) { 624 void check_recipe_header_constraints(const recipe_ordinal r) { 625 const recipe& caller = get(Recipe, r); 626 if (caller.name != "main") return; -627 trace(9992, "transform") << "check recipe header constraints for recipe " << caller.name << end(); +627 trace(9992, "transform") << "check recipe header constraints for recipe " << caller.name << end(); 628 if (!caller.has_header) return; -629 reagent/*local*/ expected_ingredient("x:address:array:character"); +629 reagent/*local*/ expected_ingredient("x:address:array:character"); 630 for (int i = 0; i < SIZE(caller.ingredients); ++i) { 631 if (!types_strictly_match(expected_ingredient, caller.ingredients.at(i))) { -632 raise << "ingredients of recipe 'main' must all be text (address:array:character)\n" << end(); +632 raise << "ingredients of recipe 'main' must all be text (address:array:character)\n" << end(); 633 break; 634 } 635 } @@ -702,7 +702,7 @@ if ('onhashchange' in window) { 637 reagent/*local*/ expected_product("x:number"); 638 if (nprod > 1 639 || (nprod == 1 && !types_strictly_match(expected_product, caller.products.at(0)))) { -640 raise << "recipe 'main' must return at most a single product, a number\n" << end(); +640 raise << "recipe 'main' must return at most a single product, a number\n" << end(); 641 } 642 } -- cgit 1.4.1-2-gfad0