about summary refs log tree commit diff stats
path: root/081run_interactive.cc
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-07-08 12:54:06 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-07-08 13:21:26 -0700
commit6dc1379b5ab74bbd081a4e059cd04257ba7272c3 (patch)
treefdc209d1dca5f71351415ffa0bc011cb545595c2 /081run_interactive.cc
parent260c3de2bfad49c0587547b8af1be5bc3e2dacd5 (diff)
downloadmu-6dc1379b5ab74bbd081a4e059cd04257ba7272c3.tar.gz
1722 - drop support for querying locations
Also added another failing test showing what behavior we want in the
programming environment. But there's no way to make use of querying
locations, since we're not planning any interaction with individual
sandboxes at the moment.

Instead of interacting with one sandbox at a time, which is the current
approach, we want to create dashboards out of multiple sandboxes at
once. Start with them non-interactive, that'll demonstrate 80% of the
new benefits. We'll add interactivity down the road.
Diffstat (limited to '081run_interactive.cc')
-rw-r--r--081run_interactive.cc63
1 files changed, 6 insertions, 57 deletions
diff --git a/081run_interactive.cc b/081run_interactive.cc
index abb67b17..fd076c06 100644
--- a/081run_interactive.cc
+++ b/081run_interactive.cc
@@ -1,22 +1,6 @@
 //: Helper for various programming environments: run arbitrary mu code and
 //: return some result in string form.
 
-:(scenario run_interactive_location)
-recipe main [
-  1:number <- copy 34:literal
-  2:address:array:character <- new [1
-]
-  3:address:array:character <- run-interactive 2:address:array:character
-  4:array:character <- copy 3:address:array:character/deref
-]
-#? ?
-# size of string
-+mem: storing 2 in location 4
-# unicode '3'
-+mem: storing 51 in location 5
-# unicode '4'
-+mem: storing 52 in location 6
-
 :(scenario run_interactive_code)
 recipe main [
   2:address:array:character <- new [1:number <- copy 34:literal
@@ -25,21 +9,6 @@ recipe main [
 ]
 +mem: storing 34 in location 1
 
-:(scenario run_interactive_name)
-recipe main [
-  2:address:array:character <- new [x:number <- copy 34:literal
-]
-  run-interactive 2:address:array:character
-  3:address:array:character <- new [x
-]
-  4:address:array:character <- run-interactive 3:address:array:character
-  5:array:character <- copy 4:address:array:character/deref
-]
-# result is string "34"
-+mem: storing 2 in location 5
-+mem: storing 51 in location 6
-+mem: storing 52 in location 7
-
 :(scenario run_interactive_empty)
 recipe main [
   1:address:array:character <- run-interactive 0:literal
@@ -56,11 +25,10 @@ Recipe_ordinal["run-interactive"] = RUN_INTERACTIVE;
 case RUN_INTERACTIVE: {
   assert(scalar(ingredients.at(0)));
   products.resize(1);
-  long long int result = 0;
-  bool new_code_pushed_to_stack = run_interactive(ingredients.at(0).at(0), &result);
+  bool new_code_pushed_to_stack = run_interactive(ingredients.at(0).at(0));
   if (!new_code_pushed_to_stack) {
-    products.at(0).push_back(result);
-    break;
+    products.at(0).push_back(0);
+    break;  // done with this instruction
   }
   else {
     continue;  // not done with caller; don't increment current_step_index()
@@ -68,14 +36,11 @@ case RUN_INTERACTIVE: {
 }
 
 :(code)
-// reads a string. if it's a variable, stores its value as a string and returns false.
-// if it's lines of code, calls them and returns true (no result available yet to be stored)
-bool run_interactive(long long int address, long long int* result) {
-//?   cerr << "run interactive\n"; //? 1
+// reads a string, tries to call it as code.
+// returns true if successfully called (no errors found during load and transform)
+bool run_interactive(long long int address) {
   long long int size = Memory[address];
   if (size == 0) {
-//?     trace(1, "foo") << "AAA"; //? 2
-    *result = 0;
     return false;
   }
   ostringstream tmp;
@@ -87,32 +52,16 @@ bool run_interactive(long long int address, long long int* result) {
     Recipe_ordinal["interactive"] = Next_recipe_ordinal++;
   string command = trim(strip_comments(tmp.str()));
   if (command.empty()) return false;
-  if (is_integer(command)) {
-//?     trace(1, "foo") << "BBB"; //? 2
-    *result = stringified_value_of_location(to_integer(command));
-//?     trace(1, "foo") << *result << " " << result << " " << Memory[*result]; //? 2
-    return false;
-  }
-  if (Name[Recipe_ordinal["interactive"]].find(command) != Name[Recipe_ordinal["interactive"]].end()) {
-//?     trace(1, "foo") << "CCC"; //? 2
-    *result = stringified_value_of_location(Name[Recipe_ordinal["interactive"]][command]);
-    return false;
-  }
-//?   trace(1, "foo") << "DDD"; //? 2
   Recipe.erase(Recipe_ordinal["interactive"]);
-//?   trace("foo") << "hiding warnings\n"; //? 2
   Hide_warnings = true;
   // call run(string) but without the scheduling
   load("recipe interactive [\n"+command+"\n]\n");
   transform_all();
   if (trace_count("warn") > 0) {
     Hide_warnings = false;
-    *result = 0;
     return false;
   }
-//?   cerr << "call interactive: " << Current_routine->calls.size() << '\n'; //? 1
   Current_routine->calls.push_front(call(Recipe_ordinal["interactive"]));
-  *result = 0;
   return true;
 }