aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/ExecutionEngine/Interpreter/Interpreter.cpp
diff options
context:
space:
mode:
authorBrian Gaeke <gaeke@uiuc.edu>2003-09-05 04:46:26 +0000
committerBrian Gaeke <gaeke@uiuc.edu>2003-09-05 04:46:26 +0000
commit8421765778da9df4fce1886556be916e9f3a95e3 (patch)
treee67c851c226b2a2d7b525de09b59775f2f7f5fce /llvm/lib/ExecutionEngine/Interpreter/Interpreter.cpp
parentd15598bfe05351f4ce07174520bb49d322b338cb (diff)
downloadllvm-8421765778da9df4fce1886556be916e9f3a95e3.zip
llvm-8421765778da9df4fce1886556be916e9f3a95e3.tar.gz
llvm-8421765778da9df4fce1886556be916e9f3a95e3.tar.bz2
Remove support for interactive (step finish next) instructions.
Remove printCurrentInstruction, printStackFrame and infoValue (only used interactively) and other unused methods of Interpreter. Fold UserInput.cpp containing only callMainFunction() into Interpreter.cpp. Remove unused Profile flag. llvm-svn: 8359
Diffstat (limited to 'llvm/lib/ExecutionEngine/Interpreter/Interpreter.cpp')
-rw-r--r--llvm/lib/ExecutionEngine/Interpreter/Interpreter.cpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/llvm/lib/ExecutionEngine/Interpreter/Interpreter.cpp b/llvm/lib/ExecutionEngine/Interpreter/Interpreter.cpp
index 4f8c407..6b82dad 100644
--- a/llvm/lib/ExecutionEngine/Interpreter/Interpreter.cpp
+++ b/llvm/lib/ExecutionEngine/Interpreter/Interpreter.cpp
@@ -8,6 +8,8 @@
#include "Interpreter.h"
#include "llvm/Module.h"
+#include "llvm/DerivedTypes.h"
+#include "llvm/Function.h"
/// create - Create a new interpreter object. This can never fail.
///
@@ -76,3 +78,45 @@ int Interpreter::run(const std::string &MainFunction,
return ExitCode;
}
+
+// callMainFunction - Construct call to typical C main() function and
+// call it using callFunction().
+//
+bool Interpreter::callMainFunction(const std::string &Name,
+ const std::vector<std::string> &InputArgv) {
+ Function *M = getModule().getNamedFunction(Name);
+ if (M == 0) {
+ std::cerr << "Could not find function '" << Name << "' in module!\n";
+ return 1;
+ }
+ const FunctionType *MT = M->getFunctionType();
+
+ std::vector<GenericValue> Args;
+ if (MT->getParamTypes().size() >= 2) {
+ PointerType *SPP = PointerType::get(PointerType::get(Type::SByteTy));
+ if (MT->getParamTypes()[1] != SPP) {
+ CW << "Second argument of '" << Name << "' should have type: '"
+ << SPP << "'!\n";
+ return true;
+ }
+ Args.push_back(PTOGV(CreateArgv(InputArgv)));
+ }
+
+ if (MT->getParamTypes().size() >= 1) {
+ if (!MT->getParamTypes()[0]->isInteger()) {
+ std::cout << "First argument of '" << Name
+ << "' should be an integer!\n";
+ return true;
+ } else {
+ GenericValue GV; GV.UIntVal = InputArgv.size();
+ Args.insert(Args.begin(), GV);
+ }
+ }
+
+ callFunction(M, Args); // Start executing it...
+
+ // Reset the current frame location to the top of stack
+ CurFrame = ECStack.size()-1;
+
+ return false;
+}