From 6992b1689e5848d6f882c461bea722b6f734bb46 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 25 Jan 2009 19:57:37 +0000 Subject: Execute and print REPL code with type safety (i.e. print int and bool correctly). git-svn-id: http://svn.drobilla.net/resp/llvm-lisp@13 ad02d1e2-f140-0410-9f75-f8b11f17cedd --- ll.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ll.cpp b/ll.cpp index f3082e1..0b81628 100644 --- a/ll.cpp +++ b/ll.cpp @@ -765,8 +765,14 @@ main() } void* fp = engine->getPointerToFunction(f); - double (*cfunc)() = (double (*)())fp; - std::cout << cfunc(); + if (bodyT->ctype == Type::Int32Ty) + std::cout << ((int32_t (*)())fp)(); + else if (bodyT->ctype == Type::FloatTy) + std::cout << ((float (*)())fp)(); + else if (bodyT->ctype == Type::Int1Ty) + std::cout << ((bool (*)())fp)(); + else + std::cout << "?"; } else { Value* val = body->compile(cenv); -- cgit v1.2.1