aboutsummaryrefslogtreecommitdiff
path: root/lib/ExecutionEngine/Interpreter/UserInput.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2001-10-15 05:51:48 +0000
committerChris Lattner <sabre@nondot.org>2001-10-15 05:51:48 +0000
commit2e42d3a3060ff0c3d4c419f17493bc6a7683e9d0 (patch)
treed796bc523341806373c120a3bfe45776b2642fa3 /lib/ExecutionEngine/Interpreter/UserInput.cpp
parent8d2de8a82cce67513debee7a3fa5aca0189b4105 (diff)
Implement global variables. Struct and Pointer initializers are not implemented yet though
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@818 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/ExecutionEngine/Interpreter/UserInput.cpp')
-rw-r--r--lib/ExecutionEngine/Interpreter/UserInput.cpp45
1 files changed, 44 insertions, 1 deletions
diff --git a/lib/ExecutionEngine/Interpreter/UserInput.cpp b/lib/ExecutionEngine/Interpreter/UserInput.cpp
index e9fc9db343..4c2faf6ca1 100644
--- a/lib/ExecutionEngine/Interpreter/UserInput.cpp
+++ b/lib/ExecutionEngine/Interpreter/UserInput.cpp
@@ -5,6 +5,7 @@
//===----------------------------------------------------------------------===//
#include "Interpreter.h"
+#include "llvm/Bytecode/Reader.h"
#include "llvm/Assembly/Writer.h"
#include <algorithm>
@@ -81,9 +82,14 @@ void Interpreter::handleUserInput() {
switch (E->CID) {
case Quit: UserQuit = true; break;
+ case Load:
+ cin >> Command;
+ loadModule(Command);
+ break;
+ case Flush: flushModule(); break;
case Print:
cin >> Command;
- printValue(Command);
+ print(Command);
break;
case Info:
cin >> Command;
@@ -118,6 +124,43 @@ void Interpreter::handleUserInput() {
} while (!UserQuit);
}
+//===----------------------------------------------------------------------===//
+// loadModule - Load a new module to execute...
+//
+void Interpreter::loadModule(const string &Filename) {
+ if (CurMod && !flushModule()) return; // Kill current execution
+
+ CurMod = ParseBytecodeFile(Filename);
+ if (CurMod == 0) {
+ cout << "Error parsing '" << Filename << "': No module loaded.\n";
+ return;
+ }
+
+ // TODO: link in support library...
+}
+
+
+//===----------------------------------------------------------------------===//
+// flushModule - Return true if the current program has been unloaded.
+//
+bool Interpreter::flushModule() {
+ if (CurMod == 0) {
+ cout << "Error flushing: No module loaded!\n";
+ return false;
+ }
+
+ if (!ECStack.empty()) {
+ // TODO: if use is not sure, return false
+ cout << "Killing current execution!\n";
+ ECStack.clear();
+ CurFrame = -1;
+ }
+
+ delete CurMod;
+ CurMod = 0;
+ ExitCode = 0;
+ return true;
+}
//===----------------------------------------------------------------------===//
// setBreakpoint - Enable a breakpoint at the specified location