From ced133e40290c30809e6d632cdf1e6f749ea9dd5 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Fri, 16 Sep 2016 16:04:11 -0700 Subject: 3371 --- html/003trace.cc.html | 9 +- html/011load.cc.html | 8 ++ html/014literal_string.cc.html | 4 +- html/020run.cc.html | 4 + html/026call.cc.html | 5 + html/032array.cc.html | 2 +- html/050scenario.cc.html | 2 +- html/059to_text.mu.html | 17 +++ html/061text.mu.html | 99 +++++++------ html/062convert_ingredients_to_text.cc.html | 210 ++++++++++++++++++++++++++++ html/062rewrite_stash.cc.html | 183 ------------------------ html/101run_sandboxed.cc.html | 33 +++-- html/edit/010-sandbox-trace.mu.html | 12 -- 13 files changed, 336 insertions(+), 252 deletions(-) create mode 100644 html/062convert_ingredients_to_text.cc.html delete mode 100644 html/062rewrite_stash.cc.html (limited to 'html') diff --git a/html/003trace.cc.html b/html/003trace.cc.html index 0e35ce97..7a7cb31f 100644 --- a/html/003trace.cc.html +++ b/html/003trace.cc.html @@ -166,10 +166,11 @@ Hide_errors = false;void trace_stream::newline() { if (!curr_stream) return; string curr_contents = curr_stream->str(); - if (curr_contents.empty()) return; - past_lines.push_back(trace_line(curr_depth, trim(curr_label), curr_contents)); // preserve indent in contents - if (!Hide_errors && curr_label == "error") - cerr << curr_label << ": " << curr_contents << '\n'; + if (!curr_contents.empty()) { + past_lines.push_back(trace_line(curr_depth, trim(curr_label), curr_contents)); // preserve indent in contents + if (!Hide_errors && curr_label == "error") + cerr << curr_label << ": " << curr_contents << '\n'; + } delete curr_stream; curr_stream = NULL; curr_label.clear(); diff --git a/html/011load.cc.html b/html/011load.cc.html index 0a232b80..bf642aaf 100644 --- a/html/011load.cc.html +++ b/html/011load.cc.html @@ -263,6 +263,14 @@ Disable_redefine_checks = false(0); } +:(scenario recipe_instead_of_def) +recipe main [ + 1:number <- copy 23 +] ++parse: instruction: copy ++parse: ingredient: {23: "literal"} ++parse: product: {1: "number"} + :(scenario parse_comment_outside_recipe) # this comment will be dropped by the tangler, so we need a dummy recipe to stop that def f1 [ diff --git a/html/014literal_string.cc.html b/html/014literal_string.cc.html index 52a1b264..bb6eba51 100644 --- a/html/014literal_string.cc.html +++ b/html/014literal_string.cc.html @@ -254,8 +254,8 @@ def main [ :(scenario multiple_unfinished_recipes) % Hide_errors = true; -recipe f1 [ -recipe f2 [ +def f1 [ +def f2 [ +error: unbalanced '[' diff --git a/html/020run.cc.html b/html/020run.cc.html index a4ddb087..08909f94 100644 --- a/html/020run.cc.html +++ b/html/020run.cc.html @@ -160,6 +160,10 @@ map<string, int> return get(Recipe, Current_routine->running_recipe).name; } +const recipe& current_recipe() { + return get(Recipe, Current_routine->running_recipe); +} + const instruction& current_instruction() { return get(Recipe, Current_routine->running_recipe).steps.at(Current_routine->running_step_index); } diff --git a/html/026call.cc.html b/html/026call.cc.html index ca151665..687ffbd3 100644 --- a/html/026call.cc.html +++ b/html/026call.cc.html @@ -119,6 +119,11 @@ call& current_call() assert(!Current_routine->calls.empty()); return get(Recipe, current_call().running_recipe).name; } +:(replace{} "const recipe& current_recipe()") +const recipe& current_recipe() { + assert(!Current_routine->calls.empty()); + return get(Recipe, current_call().running_recipe); +} :(replace{} "const instruction& current_instruction()") const instruction& current_instruction() { assert(!Current_routine->calls.empty()); diff --git a/html/032array.cc.html b/html/032array.cc.html index d78f29ab..1a733068 100644 --- a/html/032array.cc.html +++ b/html/032array.cc.html @@ -209,7 +209,7 @@ def main [ container card [ rank:number <- next-ingredient ] -recipe foo [ +def foo [ 1:card <- merge 3 2:number <- get 1:card rank:offset ] diff --git a/html/050scenario.cc.html b/html/050scenario.cc.html index 7554e95a..9dcedc44 100644 --- a/html/050scenario.cc.html +++ b/html/050scenario.cc.html @@ -447,7 +447,7 @@ put(Recipe_ordinal,(9999, "run") << "checking string length at " << address << end(); if (get_or_insert(Memory, address) != SIZE(literal)) { if (Current_scenario && !Scenario_testing_scenario) - raise << "\nF - " << Current_scenario->name << ": expected location '" << address << "' to contain length " << SIZE(literal) << " of string [" << literal << "] but saw " << no_scientific(get_or_insert(Memory, address)) << " (" << read_mu_string(address) << ")\n" << end(); + raise << "\nF - " << Current_scenario->name << ": expected location '" << address << "' to contain length " << SIZE(literal) << " of string [" << literal << "] but saw " << no_scientific(get_or_insert(Memory, address)) << " (" << read_mu_string(address-/*fake refcount*/1) << ")\n" << end(); else raise << "expected location '" << address << "' to contain length " << SIZE(literal) << " of string [" << literal << "] but saw " << no_scientific(get_or_insert(Memory, address)) << '\n' << end(); if (!Scenario_testing_scenario) Passed = false; diff --git a/html/059to_text.mu.html b/html/059to_text.mu.html index deaacdf7..b050f5e9 100644 --- a/html/059to_text.mu.html +++ b/html/059to_text.mu.html @@ -60,6 +60,23 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color x:text <- array-to-text-line n # just ensure there were no errors ] + +# finally, a specialization for single characters +def to-text c:character -> y:text [ + local-scope + load-ingredients + y <- new character:type, 1/capacity + *y <- put-index *y, 0, c +] + +scenario character-to-text [ + 1:character <- copy 111/o + 2:text <- to-text 1:character + 3:array:character <- copy *2:text + memory-should-contain [ + 3:array:character <- [o] + ] +] diff --git a/html/061text.mu.html b/html/061text.mu.html index e1a99fc8..0a0e41bf 100644 --- a/html/061text.mu.html +++ b/html/061text.mu.html @@ -151,15 +151,15 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color return result ] -def grow-buffer in:address:buffer -> in:address:buffer [ +def grow-buffer buf:address:buffer -> buf:address:buffer [ local-scope load-ingredients # double buffer size - olddata:text <- get *in, data:offset + olddata:text <- get *buf, data:offset oldlen:number <- length *olddata newlen:number <- multiply oldlen, 2 newdata:text <- new character:type, newlen - *in <- put *in, data:offset, newdata + *buf <- put *buf, data:offset, newdata # copy old contents i:number <- copy 0 { @@ -198,10 +198,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color } ] -def append in:address:buffer, c:character -> in:address:buffer [ +def append buf:address:buffer, c:character -> buf:address:buffer [ local-scope load-ingredients - len:number <- get *in, length:offset + len:number <- get *buf, length:offset { # backspace? just drop last character if it exists and return backspace?:boolean <- equal c, 8/backspace @@ -209,19 +209,34 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color empty?:boolean <- lesser-or-equal len, 0 return-if empty? len <- subtract len, 1 - *in <- put *in, length:offset, len + *buf <- put *buf, length:offset, len return } { # grow buffer if necessary - full?:boolean <- buffer-full? in + full?:boolean <- buffer-full? buf break-unless full? - in <- grow-buffer in + buf <- grow-buffer buf } - s:text <- get *in, data:offset + s:text <- get *buf, data:offset *s <- put-index *s, len, c len <- add len, 1 - *in <- put *in, length:offset, len + *buf <- put *buf, length:offset, len +] + +def append buf:address:buffer, t:text -> buf:address:buffer [ + local-scope + load-ingredients + len:number <- length *t + i:number <- copy 0 + { + done?:boolean <- greater-or-equal i, len + break-if done? + c:character <- index *t, i + buf <- append buf, c + i <- add i, 1 + loop + } ] scenario buffer-append-works [ @@ -318,44 +333,32 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color } ] -def append a:text, b:text -> result:text [ +# Append any number of texts together. +# A later layer also translates calls to this to implicitly call to-text, so +# append to string becomes effectively dynamically typed. +# +# Beware though: this hack restricts how much 'append' can be overridden. Any +# new variants that match: +# append _:text, ___ +# will never ever get used. +def append first:text -> result:text [ local-scope load-ingredients - # handle null addresses - return-unless a, b - return-unless b, a - # result = new character[a.length + b.length] - a-len:number <- length *a - b-len:number <- length *b - result-len:number <- add a-len, b-len - result <- new character:type, result-len - # copy a into result - result-idx:number <- copy 0 - i:number <- copy 0 + buf:address:buffer <- new-buffer 30 + # append first ingredient { - # while i < a.length - a-done?:boolean <- greater-or-equal i, a-len - break-if a-done? - # result[result-idx] = a[i] - in:character <- index *a, i - *result <- put-index *result, result-idx, in - i <- add i, 1 - result-idx <- add result-idx, 1 - loop + break-unless first + buf <- append buf, first } - # copy b into result - i <- copy 0 + # append remaining ingredients { - # while i < b.length - b-done?:boolean <- greater-or-equal i, b-len - break-if b-done? - # result[result-idx] = a[i] - in:character <- index *b, i - *result <- put-index *result, result-idx, in - i <- add i, 1 - result-idx <- add result-idx, 1 + arg:text, arg-found?:boolean <- next-ingredient + break-unless arg-found? + loop-unless arg + buf <- append buf, arg loop } + result <- buffer-to-array buf ] scenario text-append-1 [ @@ -397,6 +400,20 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] ] +scenario text-append-multiary [ + run [ + local-scope + x:text <- new [hello, ] + y:text <- new [world] + z:text <- new [!] + z:text <- append x, y, z + 10:array:character/raw <- copy *z + ] + memory-should-contain [ + 10:array:character <- [hello, world!] + ] +] + scenario replace-character-in-text [ run [ local-scope diff --git a/html/062convert_ingredients_to_text.cc.html b/html/062convert_ingredients_to_text.cc.html new file mode 100644 index 00000000..34ef34f0 --- /dev/null +++ b/html/062convert_ingredients_to_text.cc.html @@ -0,0 +1,210 @@ + + + + +Mu - 062convert_ingredients_to_text.cc + + + + + + + + + + +
+//: make some functions more friendly by trying to auto-convert their ingredients to text
+
+:(scenarios transform)
+:(scenario rewrite_stashes_to_text)
+def main [
+  local-scope
+  n:number <- copy 34
+  stash n
+]
++transform: {stash_2_0: ("address" "array" "character")} <- to-text-line {n: "number"}
++transform: stash {stash_2_0: ("address" "array" "character")}
+
+:(scenario rewrite_traces_to_text)
+def main [
+  local-scope
+  n:number <- copy 34
+  trace 2, [app], n
+]
++transform: {trace_2_2: ("address" "array" "character")} <- to-text-line {n: "number"}
++transform: trace {2: "literal"}, {"app": "literal-string"}, {trace_2_2: ("address" "array" "character")}
+
+//: special case: rewrite attempts to stash contents of most arrays to avoid
+//: passing addresses around
+
+:(scenario rewrite_stashes_of_arrays)
+def main [
+  local-scope
+  n:address:array:number <- new number:type, 3
+  stash *n
+]
++transform: {stash_2_0: ("address" "array" "character")} <- array-to-text-line {n: ("address" "array" "number")}
++transform: stash {stash_2_0: ("address" "array" "character")}
+
+:(scenario ignore_stashes_of_static_arrays)
+def main [
+  local-scope
+  n:array:number:3 <- create-array
+  stash n
+]
++transform: stash {n: ("array" "number" "3")}
+
+:(scenario rewrite_stashes_of_recipe_header_products)
+container foo [
+  x:number
+]
+def bar -> x:foo [
+  local-scope
+  load-ingredients
+  x <- merge 34
+  stash x
+]
++transform: stash {stash_2_0: ("address" "array" "character")}
+
+//: misplaced; should be in instruction inserting/deleting transforms, but has
+//: prerequisites: deduce_types_from_header and check_or_set_types_by_name
+:(after "Transform.push_back(deduce_types_from_header)")
+Transform.push_back(convert_ingredients_to_text);
+
+:(code)
+void convert_ingredients_to_text(recipe_ordinal r) {
+  recipe& caller = get(Recipe, r);
+  trace(9991, "transform") << "--- convert some ingredients to text in recipe " << caller.name << end();
+//?   cerr << "--- convert some ingredients to text in recipe " << caller.name << '\n';
+  // in recipes without named locations, 'stash' is still not extensible
+  if (contains_numeric_locations(caller)) return;
+  convert_ingredients_to_text(caller);
+}
+
+void convert_ingredients_to_text(recipe& caller) {
+  vector<instruction> new_instructions;
+  for (int i = 0; i < SIZE(caller.steps); ++i) {
+    instruction& inst = caller.steps.at(i);
+    // all these cases are getting hairy. how can we make this extensible?
+    if (inst.name == "stash") {
+      for (int j = 0; j < SIZE(inst.ingredients); ++j) {
+        if (is_literal_string(inst.ingredients.at(j))) continue;
+        ostringstream ingredient_name;
+        ingredient_name << "stash_" << i << '_' << j << ":address:array:character";
+        convert_ingredient_to_text(inst.ingredients.at(j), new_instructions, ingredient_name.str());
+      }
+    }
+    else if (inst.name == "trace") {
+      for (int j = /*skip*/2; j < SIZE(inst.ingredients); ++j) {
+        if (is_literal_string(inst.ingredients.at(j))) continue;
+        ostringstream ingredient_name;
+        ingredient_name << "trace_" << i << '_' << j << ":address:array:character";
+        convert_ingredient_to_text(inst.ingredients.at(j), new_instructions, ingredient_name.str());
+      }
+    }
+    else if (inst.old_name == "append") {
+      // override only variants that try to append to a string
+      // Beware: this hack restricts how much 'append' can be overridden. Any
+      // new variants that match:
+      //   append _:text, ___
+      // will never ever get used.
+      if (is_literal_string(inst.ingredients.at(0)) || is_mu_string(inst.ingredients.at(0))) {
+        for (int j = 0; j < SIZE(inst.ingredients); ++j) {
+          ostringstream ingredient_name;
+          ingredient_name << "append_" << i << '_' << j << ":address:array:character";
+          convert_ingredient_to_text(inst.ingredients.at(j), new_instructions, ingredient_name.str());
+        }
+      }
+    }
+    trace(9993, "transform") << to_string(inst) << end();
+    new_instructions.push_back(inst);
+  }
+  caller.steps.swap(new_instructions);
+}
+
+// add an instruction to convert reagent 'r' to text in list 'out', then
+// replace r with converted text
+void convert_ingredient_to_text(reagent& r, vector<instruction>& out, const string& tmp_var) {
+  if (!r.type) return;  // error; will be handled elsewhere
+  if (is_mu_string(r)) return;
+  // don't try to extend static arrays
+  if (is_static_array(r)) return;
+  instruction def;
+  if (is_lookup_of_address_of_array(r)) {
+    def.name = "array-to-text-line";
+    reagent/*copy*/ tmp = r;
+    drop_one_lookup(tmp);
+    def.ingredients.push_back(tmp);
+  }
+  else {
+    def.name = "to-text-line";
+    def.ingredients.push_back(r);
+  }
+  def.products.push_back(reagent(tmp_var));
+  trace(9993, "transform") << to_string(def) << end();
+  out.push_back(def);
+  r.clear();  // reclaim old memory
+  r = reagent(tmp_var);
+}
+
+bool is_lookup_of_address_of_array(reagent/*copy*/ x) {
+  if (x.type->atom) return false;
+  if (x.type->left->name != "address") return false;
+  if (!canonize_type(x)) return false;
+  return is_mu_array(x);
+}
+
+bool is_static_array(const reagent& x) {
+  // no canonize_type()
+  return !x.type->atom && x.type->left->atom && x.type->left->name == "array";
+}
+
+:(scenarios run)
+:(scenario append_other_types_to_text)
+def main [
+  local-scope
+  n:number <- copy 11
+  c:character <- copy 111/o
+  a:text <- append [abc], 10, n, c
+  expected:text <- new [abc1011o]
+  10:boolean/raw <- equal a, expected
+]
+
+//: Make sure that the new system is strictly better than just the 'stash'
+//: primitive by itself.
+
+:(scenario rewrite_stash_continues_to_fall_back_to_default_implementation)
+# type without a to-text implementation
+container foo [
+  x:number
+  y:number
+]
+def main [
+  local-scope
+  x:foo <- merge 34, 35
+  stash x
+]
++app: 34 35
+
+ + + diff --git a/html/062rewrite_stash.cc.html b/html/062rewrite_stash.cc.html deleted file mode 100644 index 8ed4fa38..00000000 --- a/html/062rewrite_stash.cc.html +++ /dev/null @@ -1,183 +0,0 @@ - - - - -Mu - 062rewrite_stash.cc - - - - - - - - - - -
-//: when encountering other types, try to convert them to strings using
-//: 'to-text'
-
-:(scenarios transform)
-:(scenario rewrite_stashes_to_text)
-recipe main [
-  local-scope
-  n:number <- copy 34
-  stash n
-]
-+transform: {stash_2_0: ("address" "array" "character")} <- to-text-line {n: "number"}
-+transform: stash {stash_2_0: ("address" "array" "character")}
-
-:(scenario rewrite_traces_to_text)
-recipe main [
-  local-scope
-  n:number <- copy 34
-  trace 2, [app], n
-]
-+transform: {trace_2_2: ("address" "array" "character")} <- to-text-line {n: "number"}
-+transform: trace {2: "literal"}, {"app": "literal-string"}, {trace_2_2: ("address" "array" "character")}
-
-//: special case: rewrite attempts to stash contents of most arrays to avoid
-//: passing addresses around
-
-:(scenario rewrite_stashes_of_arrays)
-recipe main [
-  local-scope
-  n:address:array:number <- new number:type, 3
-  stash *n
-]
-+transform: {stash_2_0: ("address" "array" "character")} <- array-to-text-line {n: ("address" "array" "number")}
-+transform: stash {stash_2_0: ("address" "array" "character")}
-
-:(scenario ignore_stashes_of_static_arrays)
-recipe main [
-  local-scope
-  n:array:number:3 <- create-array
-  stash n
-]
-+transform: stash {n: ("array" "number" "3")}
-
-:(scenario rewrite_stashes_of_recipe_header_products)
-container foo [
-  x:number
-]
-recipe bar -> x:foo [
-  local-scope
-  load-ingredients
-  x <- merge 34
-  stash x
-]
-+transform: stash {stash_2_0: ("address" "array" "character")}
-
-//: misplaced; should be in instruction inserting/deleting transforms, but has
-//: prerequisites: deduce_types_from_header and check_or_set_types_by_name
-:(after "Transform.push_back(deduce_types_from_header)")
-Transform.push_back(rewrite_stashes_to_text);
-
-:(code)
-void rewrite_stashes_to_text(recipe_ordinal r) {
-  recipe& caller = get(Recipe, r);
-  trace(9991, "transform") << "--- rewrite 'stash' instructions in recipe " << caller.name << end();
-  // in recipes without named locations, 'stash' is still not extensible
-  if (contains_numeric_locations(caller)) return;
-  rewrite_stashes_to_text(caller);
-}
-
-void rewrite_stashes_to_text(recipe& caller) {
-  vector<instruction> new_instructions;
-  for (int i = 0; i < SIZE(caller.steps); ++i) {
-    instruction& inst = caller.steps.at(i);
-    if (inst.name == "stash") {
-      for (int j = 0; j < SIZE(inst.ingredients); ++j) {
-        ostringstream ingredient_name;
-        ingredient_name << "stash_" << i << '_' << j << ":address:array:character";
-        rewrite_stash_to_text(inst.ingredients.at(j), new_instructions, ingredient_name.str());
-      }
-    }
-    else if (inst.name == "trace") {
-      for (int j = /*skip*/2; j < SIZE(inst.ingredients); ++j) {
-        ostringstream ingredient_name;
-        ingredient_name << "trace_" << i << '_' << j << ":address:array:character";
-        rewrite_stash_to_text(inst.ingredients.at(j), new_instructions, ingredient_name.str());
-      }
-    }
-    trace(9993, "transform") << to_string(inst) << end();
-    new_instructions.push_back(inst);
-  }
-  caller.steps.swap(new_instructions);
-}
-
-// add an instruction to convert reagent 'r' to text in list 'out', then
-// replace r with converted text
-void rewrite_stash_to_text(reagent& r, vector<instruction>& out, const string& tmp_var) {
-  if (!r.type) return;  // error; will be handled elsewhere
-  if (is_literal(r)) return;
-  if (is_mu_string(r)) return;
-  // don't try to extend static arrays
-  if (is_static_array(r)) return;
-  instruction def;
-  if (is_lookup_of_address_of_array(r)) {
-    def.name = "array-to-text-line";
-    reagent/*copy*/ tmp = r;
-    drop_one_lookup(tmp);
-    def.ingredients.push_back(tmp);
-  }
-  else {
-    def.name = "to-text-line";
-    def.ingredients.push_back(r);
-  }
-  def.products.push_back(reagent(tmp_var));
-  trace(9993, "transform") << to_string(def) << end();
-  out.push_back(def);
-  r.clear();  // reclaim old memory
-  r = reagent(tmp_var);
-}
-
-bool is_lookup_of_address_of_array(reagent/*copy*/ x) {
-  if (x.type->atom) return false;
-  if (x.type->left->name != "address") return false;
-  if (!canonize_type(x)) return false;
-  return is_mu_array(x);
-}
-
-bool is_static_array(const reagent& x) {
-  // no canonize_type()
-  return !x.type->atom && x.type->left->atom && x.type->left->name == "array";
-}
-
-//: Make sure that the new system is strictly better than just the 'stash'
-//: primitive by itself.
-
-:(scenarios run)
-:(scenario rewrite_stash_continues_to_fall_back_to_default_implementation)
-# type without a to-text implementation
-container foo [
-  x:number
-  y:number
-]
-recipe main [
-  local-scope
-  x:foo <- merge 34, 35
-  stash x
-]
-+app: 34 35
-
- - - diff --git a/html/101run_sandboxed.cc.html b/html/101run_sandboxed.cc.html index d43b68af..bf39a10e 100644 --- a/html/101run_sandboxed.cc.html +++ b/html/101run_sandboxed.cc.html @@ -21,6 +21,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color .Special { color: #c00000; } .Identifier { color: #fcb165; } .Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } +.CommentedCode { color: #6c6c6c; } --> @@ -102,12 +103,21 @@ put(Recipe_ordinal,} } +//: To show results in the sandbox Mu uses a hack: it saves the products +//: returned by each instruction while Track_most_recent_products is true, and +//: keeps the most recent such result around so that it can be returned as the +//: result of a sandbox. + :(before "End Globals") bool Track_most_recent_products = false; -trace_stream* Save_trace_stream = NULL; -string Save_trace_file; +string Most_recent_products; :(before "End Setup") Track_most_recent_products = false; +Most_recent_products = ""; + +:(before "End Globals") +trace_stream* Save_trace_stream = NULL; +string Save_trace_file; :(code) // reads a string, tries to call it as code (treating it as a test), saving // all errors. @@ -175,6 +185,9 @@ map<string, vector<recipe_ordinal> > void run_code_end() { Hide_errors = false; Disable_redefine_checks = false; +//? ofstream fout("sandbox.log"); +//? fout << Trace_stream->readable_contents(""); +//? fout.close(); delete Trace_stream; Trace_stream = Save_trace_stream; Save_trace_stream = NULL; @@ -382,10 +395,6 @@ def main [ # no errors +mem: storing 0 in location 3 -:(before "End Globals") -string Most_recent_products; -:(before "End Setup") -Most_recent_products = ""; :(before "End Running One Instruction") if (Track_most_recent_products) { track_most_recent_products(current_instruction(), products); @@ -394,14 +403,22 @@ Most_recent_products = ""void track_most_recent_products(const instruction& instruction, const vector<vector<double> >& products) { ostringstream out; for (int i = 0; i < SIZE(products); ++i) { - // string + // A sandbox can print a string result, but only if it is actually saved + // to a variable in the sandbox, because otherwise the results are + // reclaimed before the sandbox sees them. So you get these interactions + // in the sandbox: + // + // new [abc] + // => <address> + // + // x:text <- new [abc] + // => abc if (i < SIZE(instruction.products)) { if (is_mu_string(instruction.products.at(i))) { if (!scalar(products.at(i))) continue; // error handled elsewhere out << read_mu_string(products.at(i).at(0)) << '\n'; continue; } - // End Record Product Special-cases } for (int j = 0; j < SIZE(products.at(i)); ++j) out << no_scientific(products.at(i).at(j)) << ' '; diff --git a/html/edit/010-sandbox-trace.mu.html b/html/edit/010-sandbox-trace.mu.html index 3c4956b7..177fdee1 100644 --- a/html/edit/010-sandbox-trace.mu.html +++ b/html/edit/010-sandbox-trace.mu.html @@ -76,9 +76,6 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color . stash [abc] ┊0 edit copy delete . .] ┊foo . .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊abc . - . ┊8 instructions run . - . ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. - . ┊ . ] screen-should-contain-in-color 245/grey, [ . . @@ -87,9 +84,6 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color . ┊ . . ┊ . .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊abc . - . ┊8 instructions run . - . ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. - . ┊ . ] # click again on the same region assume-console [ @@ -178,9 +172,6 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color . ┊0 edit copy delete . . ┊stash 123456789 . . ┊123456789 . - . ┊6 instructions run . - . ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. - . ┊ . ] # click on the stash under the edit-button region (or any of the other buttons, really) assume-console [ @@ -197,9 +188,6 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color . ┊0 edit copy delete . . ┊stash 123456789 . . ┊123456789 . - . ┊6 instructions run . - . ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. - . ┊ . ] ] -- cgit 1.4.1-2-gfad0