Mercurial > projects > ldc
comparison gen/tocall.cpp @ 758:f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
author | Tomas Lindquist Olsen <tomas.l.olsen@gmail.com> |
---|---|
date | Tue, 11 Nov 2008 01:38:48 +0100 |
parents | 55f6c2e454d7 |
children | 29f0e5847123 |
comparison
equal
deleted
inserted
replaced
757:2c730d530c98 | 758:f04dde6e882c |
---|---|
20 { | 20 { |
21 return (TypeFunction*)type; | 21 return (TypeFunction*)type; |
22 } | 22 } |
23 else if (type->ty == Tdelegate) | 23 else if (type->ty == Tdelegate) |
24 { | 24 { |
25 assert(type->next->ty == Tfunction); | 25 Type* next = type->nextOf(); |
26 return (TypeFunction*)type->next; | 26 assert(next->ty == Tfunction); |
27 return (TypeFunction*)next; | |
27 } | 28 } |
28 | 29 |
29 assert(0 && "cant get TypeFunction* from non lazy/function/delegate"); | 30 assert(0 && "cant get TypeFunction* from non lazy/function/delegate"); |
30 return 0; | 31 return 0; |
31 } | 32 } |
424 args.push_back(arg); | 425 args.push_back(arg); |
425 } | 426 } |
426 } | 427 } |
427 } | 428 } |
428 | 429 |
429 #if 0 | 430 #if 1 |
430 Logger::println("%d params passed", n); | 431 Logger::println("%lu params passed", args.size()); |
431 for (int i=0; i<args.size(); ++i) { | 432 for (int i=0; i<args.size(); ++i) { |
432 assert(args[i]); | 433 assert(args[i]); |
433 Logger::cout() << "arg["<<i<<"] = " << *args[i] << '\n'; | 434 Logger::cout() << "arg["<<i<<"] = " << *args[i] << '\n'; |
434 } | 435 } |
435 #endif | 436 #endif |
437 // void returns cannot not be named | 438 // void returns cannot not be named |
438 const char* varname = ""; | 439 const char* varname = ""; |
439 if (callableTy->getReturnType() != LLType::VoidTy) | 440 if (callableTy->getReturnType() != LLType::VoidTy) |
440 varname = "tmp"; | 441 varname = "tmp"; |
441 | 442 |
442 //Logger::cout() << "Calling: " << *funcval << '\n'; | 443 Logger::cout() << "Calling: " << *callable << '\n'; |
443 | 444 |
444 // call the function | 445 // call the function |
445 CallOrInvoke* call = gIR->CreateCallOrInvoke(callable, args.begin(), args.end(), varname); | 446 CallOrInvoke* call = gIR->CreateCallOrInvoke(callable, args.begin(), args.end(), varname); |
446 | 447 |
447 // get return value | 448 // get return value |
449 | 450 |
450 // repaint the type if necessary | 451 // repaint the type if necessary |
451 if (resulttype) | 452 if (resulttype) |
452 { | 453 { |
453 Type* rbase = resulttype->toBasetype(); | 454 Type* rbase = resulttype->toBasetype(); |
454 Type* nextbase = tf->next->toBasetype(); | 455 Type* nextbase = tf->nextOf()->toBasetype(); |
456 #if DMDV2 | |
457 rbase = rbase->mutableOf(); | |
458 nextbase = nextbase->mutableOf(); | |
459 #endif | |
455 if (!rbase->equals(nextbase)) | 460 if (!rbase->equals(nextbase)) |
456 { | 461 { |
457 Logger::println("repainting return value from '%s' to '%s'", tf->next->toChars(), rbase->toChars()); | 462 Logger::println("repainting return value from '%s' to '%s'", tf->nextOf()->toChars(), rbase->toChars()); |
458 switch(rbase->ty) | 463 switch(rbase->ty) |
459 { | 464 { |
460 case Tarray: | 465 case Tarray: |
461 retllval = DtoAggrPaint(retllval, DtoType(rbase)); | 466 retllval = DtoAggrPaint(retllval, DtoType(rbase)); |
462 break; | 467 break; |