From 3eb60f8775941422a7f04c0e16bd3a7fac9b73f5 Mon Sep 17 00:00:00 2001 From: "Vikram S. Adve" Date: Sun, 28 Oct 2001 20:52:27 +0000 Subject: [PATCH] Add methods print for String, Pointer, and each primitive type. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@994 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../Interpreter/ExternalFunctions.cpp | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp b/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp index 662abc22919..7c60126aaef 100644 --- a/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp +++ b/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp @@ -142,6 +142,37 @@ GenericValue lle_X_printVal(MethodType *M, const vector &ArgVal) { return GenericValue(); } +// Implement 'void printString(X)' +// Argument must be [ubyte {x N} ] * or sbyte * +GenericValue lle_X_printString(MethodType *M, const vector &ArgVal) { + assert(ArgVal.size() == 1 && "generic print only takes one argument!"); + return lle_VP_printstr(M, ArgVal); +} + +// Implement 'void print(X)' for each primitive type or pointer type +#define PRINT_TYPE_FUNC(TYPENAME,TYPEID) \ + GenericValue lle_X_print##TYPENAME##(MethodType *M,\ + const vector &ArgVal) {\ + assert(ArgVal.size() == 1 && "generic print only takes one argument!");\ + assert(M->getParamTypes()[0].get()->getPrimitiveID()\ + == Type::##TYPEID##);\ + Interpreter::printValue(M->getParamTypes()[0], ArgVal[0]);\ + return GenericValue();\ + } + +PRINT_TYPE_FUNC(Byte, SByteTyID) +PRINT_TYPE_FUNC(UByte, UByteTyID) +PRINT_TYPE_FUNC(Short, ShortTyID) +PRINT_TYPE_FUNC(UShort, UShortTyID) +PRINT_TYPE_FUNC(Int, IntTyID) +PRINT_TYPE_FUNC(UInt, UIntTyID) +PRINT_TYPE_FUNC(Long, LongTyID) +PRINT_TYPE_FUNC(ULong, ULongTyID) +PRINT_TYPE_FUNC(Float, FloatTyID) +PRINT_TYPE_FUNC(Double, DoubleTyID) +PRINT_TYPE_FUNC(Pointer, PointerTyID) + + // void "putchar"(sbyte) GenericValue lle_Vb_putchar(MethodType *M, const vector &Args) { cout << Args[0].SByteVal;