mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-01-11 18:33:14 +01:00
[svn r22] * Forgot to add std.stdio
This commit is contained in:
16
gen/toir.c
16
gen/toir.c
@@ -760,16 +760,16 @@ elem* CallExp::toElem(IRState* p)
|
||||
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 @@ elem* CallExp::toElem(IRState* p)
|
||||
}
|
||||
dlink = tf->linkage;
|
||||
}
|
||||
|
||||
|
||||
// delegates
|
||||
else if (e1->type->ty == Tdelegate) {
|
||||
Logger::println("delegateTy = %s\n", e1->type->toChars());
|
||||
@@ -790,7 +790,7 @@ elem* CallExp::toElem(IRState* p)
|
||||
dlink = tf->linkage;
|
||||
delegateCall = true;
|
||||
}
|
||||
|
||||
|
||||
// invalid
|
||||
else {
|
||||
assert(tf);
|
||||
@@ -801,10 +801,11 @@ elem* CallExp::toElem(IRState* p)
|
||||
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 @@ elem* CallExp::toElem(IRState* p)
|
||||
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 @@ elem* CallExp::toElem(IRState* p)
|
||||
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());
|
||||
|
||||
@@ -891,12 +891,15 @@ llvm::Function* LLVM_DtoDeclareFunction(FuncDeclaration* fdecl)
|
||||
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) {
|
||||
|
||||
@@ -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 @@ Module::genobjfile()
|
||||
// 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 @@ Module::genobjfile()
|
||||
LLVM_DtoMain();
|
||||
}
|
||||
|
||||
/*
|
||||
// verify the llvm
|
||||
std::string verifyErr;
|
||||
Logger::println("Verifying module...");
|
||||
@@ -96,7 +96,6 @@ Module::genobjfile()
|
||||
}
|
||||
else
|
||||
Logger::println("Verification passed!");
|
||||
*/
|
||||
|
||||
// run passes
|
||||
// TODO
|
||||
@@ -608,7 +607,7 @@ void EnumDeclaration::toObjFile()
|
||||
|
||||
void FuncDeclaration::toObjFile()
|
||||
{
|
||||
if (llvmDModule == gIR->dmodule) {
|
||||
if (llvmDModule) {
|
||||
assert(llvmValue != 0);
|
||||
return;
|
||||
}
|
||||
|
||||
15
lphobos/std/stdio.d
Normal file
15
lphobos/std/stdio.d
Normal file
@@ -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"[]);
|
||||
}
|
||||
@@ -3,6 +3,4 @@ import std.stdio;
|
||||
|
||||
void main() {
|
||||
writefln("Hello world!"[]);
|
||||
print(42);
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user