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/057immutable.cc.html | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'html/057immutable.cc.html') diff --git a/html/057immutable.cc.html b/html/057immutable.cc.html index 215d3398..e1109712 100644 --- a/html/057immutable.cc.html +++ b/html/057immutable.cc.html @@ -78,7 +78,7 @@ if ('onhashchange' in window) { 14 def foo p:point -> p:point [ 15 local-scope 16 load-ingredients - 17 p <- put p, x:offset, 34 + 17 p <- put p, x:offset, 34 18 ] 19 $error: 0 20 @@ -92,7 +92,7 @@ if ('onhashchange' in window) { 28 def foo p:&:point -> p:&:point [ 29 local-scope 30 load-ingredients - 31 *p <- put *p, x:offset, 34 + 31 *p <- put *p, x:offset, 34 32 ] 33 $error: 0 34 @@ -120,7 +120,7 @@ if ('onhashchange' in window) { 56 local-scope 57 load-ingredients 58 x:&:d1 <- new d1:type - 59 *x <- put *x, p:offset, 34 # ignore this 'p' + 59 *x <- put *x, p:offset, 34 # ignore this 'p' 60 return 36 61 ] 62 container d1 [ @@ -160,7 +160,7 @@ if ('onhashchange' in window) { 96 # modify the element: boom 97 # This could be ok if y contains no addresses, but we're not going to try to be that smart. 98 # It also makes the rules easier to reason about. If it's just an ingredient, just don't try to change it. - 99 y <- put y, x:offset, 37 + 99 y <- put y, x:offset, 37 100 ] 101 +error: foo: cannot modify 'y' in instruction 'y <- put y, x:offset, 37' because that would modify 'x' which is an ingredient of recipe foo but not also a product 102 @@ -227,7 +227,7 @@ if ('onhashchange' in window) { 163 local-scope 164 load-ingredients 165 q:&:point <- copy p -166 *q <- put *q, x:offset, 34 +166 *q <- put *q, x:offset, 34 167 ] 168 +error: foo: cannot modify 'q' in instruction '*q <- put *q, x:offset, 34' because that would modify p which is an ingredient of recipe foo but not also a product 169 @@ -241,7 +241,7 @@ if ('onhashchange' in window) { 177 local-scope 178 load-ingredients 179 q:&:point <- copy p -180 *q <- put *q, x:offset, 34 +180 *q <- put *q, x:offset, 34 181 ] 182 $error: 0 183 @@ -410,16 +410,16 @@ if ('onhashchange' in window) { 346 const recipe& caller = get(Recipe, r); 347 trace(9991, "transform") << "--- check mutability of ingredients in recipe " << caller.name << end(); 348 if (!caller.has_header) return; // skip check for old-style recipes calling next-ingredient directly -349 for (int i = 0; i < SIZE(caller.ingredients); ++i) { +349 for (int i = 0; i < SIZE(caller.ingredients); ++i) { 350 ¦ const reagent& current_ingredient = caller.ingredients.at(i); 351 ¦ if (is_present_in_products(caller, current_ingredient.name)) continue; // not expected to be immutable 352 ¦ // End Immutable Ingredients Special-cases 353 ¦ set<reagent> immutable_vars; 354 ¦ immutable_vars.insert(current_ingredient); -355 ¦ for (int i = 0; i < SIZE(caller.steps); ++i) { +355 ¦ for (int i = 0; i < SIZE(caller.steps); ++i) { 356 ¦ ¦ const instruction& inst = caller.steps.at(i); 357 ¦ ¦ check_immutable_ingredient_in_instruction(inst, immutable_vars, current_ingredient.name, caller); -358 ¦ ¦ if (inst.operation == INDEX && SIZE(inst.ingredients) > 1 && inst.ingredients.at(1).name == current_ingredient.name) continue; +358 ¦ ¦ if (inst.operation == INDEX && SIZE(inst.ingredients) > 1 && inst.ingredients.at(1).name == current_ingredient.name) continue; 359 ¦ ¦ update_aliases(inst, immutable_vars); 360 ¦ } 361 } @@ -450,7 +450,7 @@ if ('onhashchange' in window) { 386 ¦ // defined recipe 387 ¦ set<int> contained_in_product_indices = scan_contained_in_product_indices(inst, current_ingredient_indices); 388 ¦ for (set<int>::iterator p = contained_in_product_indices.begin(); p != contained_in_product_indices.end(); ++p) { -389 ¦ ¦ if (*p < SIZE(inst.products)) +389 ¦ ¦ if (*p < SIZE(inst.products)) 390 ¦ ¦ ¦ current_ingredient_and_aliases.insert(inst.products.at(*p)); 391 ¦ } 392 } @@ -460,11 +460,11 @@ if ('onhashchange' in window) { 396 set<reagent> selected_ingredients; 397 const recipe& callee = get(Recipe, inst.operation); 398 for (set<int>::iterator p = ingredient_indices.begin(); p != ingredient_indices.end(); ++p) { -399 ¦ if (*p >= SIZE(callee.ingredients)) continue; // optional immutable ingredient +399 ¦ if (*p >= SIZE(callee.ingredients)) continue; // optional immutable ingredient 400 ¦ selected_ingredients.insert(callee.ingredients.at(*p)); 401 } 402 set<int> result; -403 for (int i = 0; i < SIZE(callee.products); ++i) { +403 for (int i = 0; i < SIZE(callee.products); ++i) { 404 ¦ const reagent& current_product = callee.products.at(i); 405 ¦ const string_tree* contained_in_name = property(current_product, "contained-in"); 406 ¦ if (contained_in_name && selected_ingredients.find(contained_in_name->value) != selected_ingredients.end()) @@ -489,7 +489,7 @@ if ('onhashchange' in window) { 425 local-scope 426 load-ingredients 427 p2:&:test-list <- test-next p # p2 is immutable -428 *p2 <- put *p2, value:offset, 34 +428 *p2 <- put *p2, value:offset, 34 429 ] 430 def test-next x:&:test-list -> y:&:test-list/contained-in:x [ 431 local-scope @@ -501,7 +501,7 @@ if ('onhashchange' in window) { 437 :(code) 438 void check_immutable_ingredient_in_instruction(const instruction& inst, const set<reagent>& current_ingredient_and_aliases, const string& original_ingredient_name, const recipe& caller) { 439 // first check if the instruction is directly modifying something it shouldn't -440 for (int i = 0; i < SIZE(inst.products); ++i) { +440 for (int i = 0; i < SIZE(inst.products); ++i) { 441 ¦ if (has_property(inst.products.at(i), "lookup") 442 ¦ ¦ ¦ && current_ingredient_and_aliases.find(inst.products.at(i)) != current_ingredient_and_aliases.end()) { 443 ¦ ¦ string current_product_name = inst.products.at(i).name; @@ -553,12 +553,12 @@ if ('onhashchange' in window) { 489 ¦ raise << maybe(caller.name) << "can't check mutability of ingredients in recipe " << callee.name << " because it uses 'next-ingredient' directly, rather than a recipe header.\n" << end(); 490 ¦ return true; 491 } -492 if (ingredient_index >= SIZE(callee.ingredients)) return false; // optional immutable ingredient +492 if (ingredient_index >= SIZE(callee.ingredients)) return false; // optional immutable ingredient 493 return is_present_in_products(callee, callee.ingredients.at(ingredient_index).name); 494 } 495 496 bool is_present_in_products(const recipe& callee, const string& ingredient_name) { -497 for (int i = 0; i < SIZE(callee.products); ++i) { +497 for (int i = 0; i < SIZE(callee.products); ++i) { 498 ¦ if (callee.products.at(i).name == ingredient_name) 499 ¦ ¦ return true; 500 } @@ -567,7 +567,7 @@ if ('onhashchange' in window) { 503 504 set<int> ingredient_indices(const instruction& inst, const set<reagent>& ingredient_names) { 505 set<int> result; -506 for (int i = 0; i < SIZE(inst.ingredients); ++i) { +506 for (int i = 0; i < SIZE(inst.ingredients); ++i) { 507 ¦ if (is_literal(inst.ingredients.at(i))) continue; 508 ¦ if (ingredient_names.find(inst.ingredients.at(i)) != ingredient_names.end()) 509 ¦ ¦ result.insert(i); @@ -611,7 +611,7 @@ if ('onhashchange' in window) { 547 def test-remove x:&:test-list/contained-in:from, from:&:test-list -> from:&:test-list [ 548 local-scope 549 load-ingredients -550 *x <- put *x, value:offset, 34 # can modify x +550 *x <- put *x, value:offset, 34 # can modify x 551 ] 552 $error: 0 553 -- cgit 1.4.1-2-gfad0