diff options
author | Chris Lattner <sabre@nondot.org> | 2001-10-15 05:51:48 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2001-10-15 05:51:48 +0000 |
commit | 2e42d3a3060ff0c3d4c419f17493bc6a7683e9d0 (patch) | |
tree | d796bc523341806373c120a3bfe45776b2642fa3 /lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp | |
parent | 8d2de8a82cce67513debee7a3fa5aca0189b4105 (diff) | |
download | external_llvm-2e42d3a3060ff0c3d4c419f17493bc6a7683e9d0.zip external_llvm-2e42d3a3060ff0c3d4c419f17493bc6a7683e9d0.tar.gz external_llvm-2e42d3a3060ff0c3d4c419f17493bc6a7683e9d0.tar.bz2 |
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/ExternalFunctions.cpp')
-rw-r--r-- | lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp b/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp index 4c2039d..7be3336 100644 --- a/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp +++ b/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp @@ -91,10 +91,32 @@ void Interpreter::callExternalMethod(Method *M, // extern "C" { // Don't add C++ manglings to llvm mangling :) +// Implement void printstr([ubyte {x N}] *) +GenericValue lle_VP_printstr(MethodType *M, const vector<GenericValue> &ArgVal){ + assert(ArgVal.size() == 1 && "printstr only takes one argument!"); + cout << (char*)ArgVal[0].PointerVal; + return GenericValue(); +} + // Implement 'void print(X)' for every type... GenericValue lle_X_print(MethodType *M, const vector<GenericValue> &ArgVals) { assert(ArgVals.size() == 1 && "generic print only takes one argument!"); - Interpreter::printValue(M->getParamTypes()[0], ArgVals[0]); + + Interpreter::print(M->getParamTypes()[0], ArgVals[0]); + return GenericValue(); +} + +// Implement 'void printVal(X)' for every type... +GenericValue lle_X_printVal(MethodType *M, const vector<GenericValue> &ArgVal) { + assert(ArgVal.size() == 1 && "generic print only takes one argument!"); + + // Specialize print([ubyte {x N} ] *) + if (PointerType *PTy = dyn_cast<PointerType>(M->getParamTypes()[0].get())) + if (const ArrayType *ATy = dyn_cast<ArrayType>(PTy->getValueType())) { + return lle_VP_printstr(M, ArgVal); + } + + Interpreter::printValue(M->getParamTypes()[0], ArgVal[0]); return GenericValue(); } @@ -104,4 +126,10 @@ GenericValue lle_Vb_putchar(MethodType *M, const vector<GenericValue> &Args) { return GenericValue(); } +// void "putchar"(ubyte) +GenericValue lle_VB_putchar(MethodType *M, const vector<GenericValue> &Args) { + cout << Args[0].UByteVal; + return GenericValue(); +} + } // End extern "C" |