mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-16 12:24:03 +00:00
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
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user