about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-07-11 22:58:04 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-07-11 22:58:04 -0700
commitc60e18850cc3207fb6b52f72c5400cc88da923cc (patch)
tree9bf5b3653637df699046c0a4ce243c55edc3f370
parent4c879fa1bcd407b0212a13d18851365015a4e406 (diff)
downloadmu-c60e18850cc3207fb6b52f72c5400cc88da923cc.tar.gz
1764 - editor now updates all sandboxes
Finally, albeit too late for my demo.
-rw-r--r--021arithmetic.cc1
-rw-r--r--081run_interactive.cc14
-rw-r--r--edit.mu61
3 files changed, 61 insertions, 15 deletions
diff --git a/021arithmetic.cc b/021arithmetic.cc
index 01202f33..0701e82a 100644
--- a/021arithmetic.cc
+++ b/021arithmetic.cc
@@ -7,6 +7,7 @@ Recipe_ordinal["add"] = ADD;
 :(before "End Primitive Recipe Implementations")
 case ADD: {
   double result = 0;
+//?   if (!tb_is_active()) cerr << ingredients.at(1).at(0) << '\n'; //? 1
   for (long long int i = 0; i < SIZE(ingredients); ++i) {
     assert(scalar(ingredients.at(i)));
     result += ingredients.at(i).at(0);
diff --git a/081run_interactive.cc b/081run_interactive.cc
index 179ab218..3f68a514 100644
--- a/081run_interactive.cc
+++ b/081run_interactive.cc
@@ -49,6 +49,8 @@ bool run_interactive(long long int address) {
     Recipe_ordinal["interactive"] = Next_recipe_ordinal++;
   string command = trim(strip_comments(to_string(address)));
   if (command.empty()) return false;
+//?   tb_shutdown(); //? 1
+//?   cerr << command << '\n'; //? 2
   Recipe.erase(Recipe_ordinal["interactive"]);
   Hide_warnings = true;
   if (!Trace_stream) {
@@ -73,8 +75,11 @@ if (current_recipe_name() == "interactive") clean_up_interactive();
 if (current_recipe_name() == "interactive") clean_up_interactive();
 :(code)
 void clean_up_interactive() {
+//?   static int foo = 0; //? 1
   Hide_warnings = false;
   Running_interactive = false;
+//?   ++foo; //? 1
+//?   if (foo == 1) tb_init(); //? 1
 }
 
 :(scenario "run_interactive_returns_stringified_result")
@@ -188,6 +193,8 @@ string to_string(long long int address) {
     // todo: unicode
     tmp << (char)(int)Memory[curr];
   }
+//?   tb_shutdown(); //? 1
+//?   cerr << tmp.str() << '\n'; //? 1
   return tmp.str();
 }
 
@@ -236,6 +243,13 @@ case RELOAD: {
   Loading_interactive = true;
   Hide_warnings = true;
   load(to_string(ingredients.at(0).at(0)));
+//?   static int foo = 0;
+//?   if (++foo == 2) {
+//?     tb_shutdown();
+//?     cerr << Recipe_ordinal["new-add"] << '\n';
+//?     cerr << Recipe[Recipe_ordinal["new-add"]].steps[2].to_string() << '\n';
+//?     exit(0);
+//?   }
   transform_all();
   Hide_warnings = false;
   Loading_interactive = false;
diff --git a/edit.mu b/edit.mu
index 0bbe5ca9..5042313f 100644
--- a/edit.mu
+++ b/edit.mu
@@ -1949,21 +1949,51 @@ recipe run-sandboxes [
   in:address:array:character <- editor-contents recipes:address:editor-data
   recipe-warnings:address:address:array:character <- get-address env:address:programming-environment-data/deref, recipe-warnings:offset
   recipe-warnings:address:address:array:character/deref <- reload in:address:array:character
-  # run contents of right editor (sandbox), turn into a new sandbox-data
-  new-sandbox:address:sandbox-data <- new sandbox-data:type
-  data:address:address:array:character <- get-address new-sandbox:address:sandbox-data/deref, data:offset
-  data:address:address:array:character/deref <- editor-contents current-sandbox:address:editor-data
-  response:address:address:array:character <- get-address new-sandbox:address:sandbox-data/deref, response:offset
-  warnings:address:address:array:character <- get-address new-sandbox:address:sandbox-data/deref, warnings:offset
-  response:address:address:array:character/deref, warnings:address:address:array:character/deref <- run-interactive data:address:address:array:character/deref
-  next:address:address:sandbox-data <- get-address new-sandbox:address:sandbox-data/deref, next-sandbox:offset
-  # push to head of sandbox list
-  dest:address:address:sandbox-data <- get-address env:address:programming-environment-data/deref, sandbox:offset
-  next:address:address:sandbox-data/deref <- copy dest:address:address:sandbox-data/deref
-  dest:address:address:sandbox-data/deref <- copy new-sandbox:address:sandbox-data
-  # clear sandbox editor
-  init:address:address:duplex-list <- get-address current-sandbox:address:editor-data/deref, data:offset
-  init:address:address:duplex-list/deref <- push-duplex 167:literal/§, 0:literal/tail
+  # check contents of right editor (sandbox)
+  {
+    sandbox-contents:address:array:character <- editor-contents current-sandbox:address:editor-data
+    break-unless sandbox-contents:address:array:character
+    # if contents exist, run them and turn them into a new sandbox-data
+    new-sandbox:address:sandbox-data <- new sandbox-data:type
+    data:address:address:array:character <- get-address new-sandbox:address:sandbox-data/deref, data:offset
+    data:address:address:array:character/deref <- copy sandbox-contents:address:array:character
+    # push to head of sandbox list
+    dest:address:address:sandbox-data <- get-address env:address:programming-environment-data/deref, sandbox:offset
+    next:address:address:sandbox-data <- get-address new-sandbox:address:sandbox-data/deref, next-sandbox:offset
+    next:address:address:sandbox-data/deref <- copy dest:address:address:sandbox-data/deref
+    dest:address:address:sandbox-data/deref <- copy new-sandbox:address:sandbox-data
+    # clear sandbox editor
+    init:address:address:duplex-list <- get-address current-sandbox:address:editor-data/deref, data:offset
+    init:address:address:duplex-list/deref <- push-duplex 167:literal/§, 0:literal/tail
+  }
+  # rerun other sandboxes
+  curr:address:sandbox-data <- get env:address:programming-environment-data/deref, sandbox:offset
+  {
+    break-unless curr:address:sandbox-data
+#?     clear-screen 0:literal #? 1
+#?     show-screen 0:literal #? 1
+#?     wait-for-some-interaction #? 1
+    data:address:address:array:character <- get-address curr:address:sandbox-data/deref, data:offset
+#?     print-string 0:literal, data:address:address:array:character/deref #? 1
+#?     show-screen 0:literal #? 1
+#?     wait-for-some-interaction #? 1
+    response:address:address:array:character <- get-address curr:address:sandbox-data/deref, response:offset
+    warnings:address:address:array:character <- get-address curr:address:sandbox-data/deref, warnings:offset
+    response:address:address:array:character/deref, warnings:address:address:array:character/deref <- run-interactive data:address:address:array:character/deref
+#?     show-screen 0:literal #? 1
+#?     wait-for-some-interaction #? 1
+#?     print-string 0:literal, response:address:address:array:character/deref #? 1
+#?     $print response:address:address:array:character/deref #? 1
+#?     show-screen 0:literal #? 1
+#?     wait-for-some-interaction #? 1
+#?     # $ mu test edit.mu run-instruction-and-print-warnings #? 1
+#?     open-console #? 1
+#?     print-string 0:literal, warnings:address:address:array:character/deref #? 1
+#?     wait-for-some-interaction #? 1
+#?     close-console #? 1
+    curr:address:sandbox-data <- get curr:address:sandbox-data/deref, next-sandbox:offset
+    loop
+  }
 ]
 
 scenario run-instruction-and-print-warnings [
@@ -2027,6 +2057,7 @@ recipe editor-contents [
   # skip § sentinel
   assert curr:address:duplex-list, [editor without data is illegal; must have at least a sentinel]
   curr:address:duplex-list <- next-duplex curr:address:duplex-list
+  reply-unless curr:address:duplex-list, 0:literal
   {
     break-unless curr:address:duplex-list
     c:character <- get curr:address:duplex-list/deref, value:offset