From a2372bee56a110e7dfd83c3b52f430c75b2cf0e7 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Tue, 7 Jul 2015 15:55:57 -0700 Subject: 1720 - start adding repl support --- 081run_interactive.cc | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to '081run_interactive.cc') diff --git a/081run_interactive.cc b/081run_interactive.cc index 9ef0f8a9..5e6f3f1a 100644 --- a/081run_interactive.cc +++ b/081run_interactive.cc @@ -73,32 +73,31 @@ case RUN_INTERACTIVE: { bool run_interactive(long long int address, long long int* result) { long long int size = Memory[address]; if (size == 0) { -//? trace(1, "foo") << "AAA\n"; //? 1 +//? trace(1, "foo") << "AAA"; //? 2 *result = 0; return false; } ostringstream tmp; - for (long long int curr = address+1; curr < address+size; ++curr) { + for (long long int curr = address+1; curr <= address+size; ++curr) { // todo: unicode tmp << (char)(int)Memory[curr]; } - assert(Memory[address+size] == 10); // skip the newline if (Recipe_ordinal.find("interactive") == Recipe_ordinal.end()) 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\n"; //? 1 +//? trace(1, "foo") << "BBB"; //? 2 *result = stringified_value_of_location(to_integer(command)); -//? trace(1, "foo") << *result << " " << result << " " << Memory[*result]; //? 1 +//? 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\n"; //? 1 +//? trace(1, "foo") << "CCC"; //? 2 *result = stringified_value_of_location(Name[Recipe_ordinal["interactive"]][command]); return false; } -//? trace(1, "foo") << "DDD\n"; //? 1 +//? trace(1, "foo") << "DDD"; //? 2 Recipe.erase(Recipe_ordinal["interactive"]); // call run(string) but without the scheduling load("recipe interactive [\n"+command+"\n]\n"); @@ -126,7 +125,9 @@ string strip_comments(string in) { long long int stringified_value_of_location(long long int address) { // convert to string ostringstream out; +//? trace(1, "foo") << "a: " << address; //? 1 out << Memory[address]; +//? trace(1, "foo") << "b: " << Memory[address]; //? 1 return new_string(out.str()); } -- cgit 1.4.1-2-gfad0