Mercurial > projects > ldc
changeset 18:c05ef76f1c20 trunk
[svn r22] * Forgot to add std.stdio
author | lindquist |
---|---|
date | Thu, 04 Oct 2007 01:47:53 +0200 |
parents | 6c6cd097bcdf |
children | 788401029ecf |
files | gen/toir.c gen/tollvm.c gen/toobj.c lphobos/std/stdio.d test/imports2.d |
diffstat | 5 files changed, 32 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/gen/toir.c Wed Oct 03 06:14:41 2007 +0200 +++ b/gen/toir.c Thu Oct 04 01:47:53 2007 +0200 @@ -760,16 +760,16 @@ elem* e = new elem; elem* fn = e1->toElem(p); LINK dlink = LINKdefault; - + bool delegateCall = false; llvm::Value* zero = llvm::ConstantInt::get(llvm::Type::Int32Ty,0,false); llvm::Value* one = llvm::ConstantInt::get(llvm::Type::Int32Ty,1,false); // hidden struct return parameter handling bool retinptr = false; - + TypeFunction* tf = 0; - + // regular functions if (e1->type->ty == Tfunction) { tf = (TypeFunction*)e1->type; @@ -778,7 +778,7 @@ } dlink = tf->linkage; } - + // delegates else if (e1->type->ty == Tdelegate) { Logger::println("delegateTy = %s\n", e1->type->toChars()); @@ -790,7 +790,7 @@ dlink = tf->linkage; delegateCall = true; } - + // invalid else { assert(tf); @@ -801,10 +801,11 @@ if (retinptr) n++; llvm::Value* funcval = fn->getValue(); + assert(funcval != 0); std::vector<llvm::Value*> llargs(n, 0); const llvm::FunctionType* llfnty = 0; - + // normal function call if (llvm::isa<llvm::FunctionType>(funcval->getType())) { llfnty = llvm::cast<llvm::FunctionType>(funcval->getType()); @@ -816,7 +817,6 @@ if (llvm::isa<llvm::PointerType>(funcval->getType()->getContainedType(0))) { funcval = new llvm::LoadInst(funcval,"tmp",p->scopebb()); } - // function pointer if (llvm::isa<llvm::FunctionType>(funcval->getType()->getContainedType(0))) { //Logger::cout() << "function pointer type:\n" << *funcval << '\n'; @@ -956,7 +956,7 @@ Logger::cout() << *llargs[i] << '\n'; } - Logger::cout() << "Calling: " << *funcval->getType() << '\n'; + //Logger::cout() << "Calling: " << *funcval->getType() << '\n'; // call the function llvm::CallInst* call = new llvm::CallInst(funcval, llargs.begin(), llargs.end(), varname, p->scopebb());
--- a/gen/tollvm.c Wed Oct 03 06:14:41 2007 +0200 +++ b/gen/tollvm.c Thu Oct 04 01:47:53 2007 +0200 @@ -891,12 +891,15 @@ assert(f != 0); if (fdecl->llvmValue != 0) { - assert(llvm::isa<llvm::Function>(fdecl->llvmValue)); + if (!llvm::isa<llvm::Function>(fdecl->llvmValue)) + { + Logger::cout() << *fdecl->llvmValue << '\n'; + assert(0); + } return llvm::cast<llvm::Function>(fdecl->llvmValue); } - static int fdi = 0; - Logger::print("FuncDeclaration::toObjFile(%d,%s): %s\n", fdi++, fdecl->needThis()?"this":"static",fdecl->toChars()); + Logger::print("FuncDeclaration::toObjFile(%s): %s\n", fdecl->needThis()?"this":"static",fdecl->toChars()); LOG_SCOPE; if (fdecl->llvmInternal == LLVMintrinsic && fdecl->fbody) {
--- a/gen/toobj.c Wed Oct 03 06:14:41 2007 +0200 +++ b/gen/toobj.c Thu Oct 04 01:47:53 2007 +0200 @@ -34,6 +34,7 @@ #include "id.h" #include "import.h" #include "template.h" +#include "scope.h" #include "gen/irstate.h" #include "gen/elem.h" @@ -51,7 +52,7 @@ // start by deleting the old object file deleteObjFile(); - // creaet a new ir state + // create a new ir state IRState ir; gIR = &ir; ir.dmodule = this; @@ -85,7 +86,6 @@ LLVM_DtoMain(); } - /* // verify the llvm std::string verifyErr; Logger::println("Verifying module..."); @@ -96,7 +96,6 @@ } else Logger::println("Verification passed!"); - */ // run passes // TODO @@ -608,7 +607,7 @@ void FuncDeclaration::toObjFile() { - if (llvmDModule == gIR->dmodule) { + if (llvmDModule) { assert(llvmValue != 0); return; }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lphobos/std/stdio.d Thu Oct 04 01:47:53 2007 +0200 @@ -0,0 +1,15 @@ +module std.stdio; + +void _writef(T)(T t) { + //static if(is(T: Object)) _writef(t.toString()); else + static if(is(T: char[])) printf("%.*s", t.length, t.ptr); else + static if(is(T==int)) printf("%i", t); else + static assert(false, "Cannot print "~T.stringof); +} + +void writef(T...)(T t) { + foreach (v; t) _writef(v); +} +void writefln(T...)(T t) { + writef(t, "\n"[]); +}