+const string PRINT_FUNC_NAME = "printVal";
+
+static const char*
+PrintMethodNameForType(const Type* type)
+{
+ if (PointerType* pty = dyn_cast<PointerType>(type))
+ {
+ const Type* elemTy;
+ if (ArrayType* aty = dyn_cast<ArrayType>(pty->getValueType()))
+ elemTy = aty->getElementType();
+ else
+ elemTy = pty->getValueType();
+ if (elemTy == Type::SByteTy || elemTy == Type::UByteTy)
+ return "printString";
+ }
+
+ switch (type->getPrimitiveID())
+ {
+ case Type::BoolTyID: return "printBool";
+ case Type::UByteTyID: return "printUByte";
+ case Type::SByteTyID: return "printSByte";
+ case Type::UShortTyID: return "printUShort";
+ case Type::ShortTyID: return "printShort";
+ case Type::UIntTyID: return "printUInt";
+ case Type::IntTyID: return "printInt";
+ case Type::ULongTyID: return "printULong";
+ case Type::LongTyID: return "printLong";
+ case Type::FloatTyID: return "printFloat";
+ case Type::DoubleTyID: return "printDouble";
+ case Type::PointerTyID: return "printPointer";
+ case Type::MethodTyID: return "printPointer";
+ default:
+ assert(0 && "Unsupported type for printing");
+ return NULL;
+ }
+}
+