From e43db88b2d12f2aebbe62aca8465a46c92292fce Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sat, 27 Oct 2001 04:15:57 +0000 Subject: * Implement exit() builtin function * Implement linked in runtime library with puts(char*) in it * implement builtin putchar(int) function git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@985 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/ExecutionEngine/Interpreter/UserInput.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'lib/ExecutionEngine/Interpreter/UserInput.cpp') diff --git a/lib/ExecutionEngine/Interpreter/UserInput.cpp b/lib/ExecutionEngine/Interpreter/UserInput.cpp index f579ef1a9b..2989ae95e8 100644 --- a/lib/ExecutionEngine/Interpreter/UserInput.cpp +++ b/lib/ExecutionEngine/Interpreter/UserInput.cpp @@ -8,6 +8,7 @@ #include "llvm/Bytecode/Reader.h" #include "llvm/Assembly/Writer.h" #include "llvm/DerivedTypes.h" +#include "llvm/Transforms/Linker.h" #include enum CommandID { @@ -129,15 +130,25 @@ void Interpreter::handleUserInput() { // loadModule - Load a new module to execute... // void Interpreter::loadModule(const string &Filename) { + string ErrorMsg; if (CurMod && !flushModule()) return; // Kill current execution - CurMod = ParseBytecodeFile(Filename); + CurMod = ParseBytecodeFile(Filename, &ErrorMsg); if (CurMod == 0) { - cout << "Error parsing '" << Filename << "': No module loaded.\n"; + cout << "Error parsing '" << Filename << "': No module loaded: " + << ErrorMsg << "\n"; return; } - // TODO: link in support library... + string RuntimeLib = getCurrentExecutablePath() + "/RuntimeLib.bc"; + if (Module *SupportLib = ParseBytecodeFile(RuntimeLib, &ErrorMsg)) { + if (LinkModules(CurMod, SupportLib, &ErrorMsg)) + cerr << "Error Linking runtime library into current module: " + << ErrorMsg << endl; + } else { + cerr << "Error loading runtime library '"+RuntimeLib+"': " + << ErrorMsg << "\n"; + } } -- cgit v1.2.3-18-g5258