From 3322999a97f4170e1476fc4bff431f5ca8909333 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 7 Mar 2009 04:55:14 +0000 Subject: Consistent external forms. git-svn-id: http://svn.drobilla.net/resp/tuplr@76 ad02d1e2-f140-0410-9f75-f8b11f17cedd --- llvm.cpp | 4 ++-- write.cpp | 21 ++++++++++++--------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/llvm.cpp b/llvm.cpp index 3ccb1d7..ecfb735 100644 --- a/llvm.cpp +++ b/llvm.cpp @@ -493,9 +493,9 @@ call(AType* retT, void* fp) if (lltype(retT) == Type::Int32Ty) ss << ((int32_t (*)())fp)(); else if (lltype(retT) == Type::FloatTy) - ss << ((float (*)())fp)(); + ss << showpoint << ((float (*)())fp)(); else if (lltype(retT) == Type::Int1Ty) - ss << ((bool (*)())fp)(); + ss << (((bool (*)())fp)() ? "#t" : "#f"); else ss << ((void* (*)())fp)(); return ss.str(); diff --git a/write.cpp b/write.cpp index b5784ab..7cad2c5 100644 --- a/write.cpp +++ b/write.cpp @@ -20,14 +20,17 @@ ostream& operator<<(ostream& out, const AST* ast) { -#define TRY_WRITE_LITERAL(T) \ - const ASTLiteral* lit ## T = dynamic_cast*>(ast); \ - if (lit ## T) \ - return out << (lit ## T)->val; - - TRY_WRITE_LITERAL(int32_t); - TRY_WRITE_LITERAL(float); - TRY_WRITE_LITERAL(bool); + const ASTLiteral* flit = dynamic_cast*>(ast); + if (flit) + return out << showpoint << flit->val; + + const ASTLiteral* ilit = dynamic_cast*>(ast); + if (ilit) + return out << ilit->val; + + const ASTLiteral* blit = dynamic_cast*>(ast); + if (blit) + return out << (blit->val ? "#t" : "#f"); const ASTSymbol* sym = dynamic_cast(ast); if (sym) @@ -40,7 +43,7 @@ operator<<(ostream& out, const AST* ast) case AType::PRIM: return out << type->at(0); case AType::EXPR: break; // will catch Tuple case below } - } + } const ASTTuple* tup = dynamic_cast(ast); if (tup) { -- cgit v1.2.1