Mercurial > projects > ldc
comparison gen/toir.c @ 51:61bc1b4ad3c4 trunk
[svn r55] Foreach was always generating code as if the value variable was 'ref'
Other not-so-major improvements
author | lindquist |
---|---|
date | Mon, 22 Oct 2007 17:25:44 +0200 |
parents | 6fcc08a4d406 |
children | 0c77619e803b |
comparison
equal
deleted
inserted
replaced
50:6fcc08a4d406 | 51:61bc1b4ad3c4 |
---|---|
497 e->mem = l->mem; | 497 e->mem = l->mem; |
498 // struct + struct | 498 // struct + struct |
499 if (e2ty == Tstruct) { | 499 if (e2ty == Tstruct) { |
500 // struct literals do the assignment themselvs (in place) | 500 // struct literals do the assignment themselvs (in place) |
501 if (!r->inplace) { | 501 if (!r->inplace) { |
502 TypeStruct* ts = (TypeStruct*)e2type; | 502 LLVM_DtoStructCopy(l->mem,r->getValue()); |
503 LLVM_DtoStructCopy(ts,l->mem,r->getValue()); | |
504 } | 503 } |
505 else { | 504 else { |
506 e->inplace = true; | 505 e->inplace = true; |
507 } | 506 } |
508 } | 507 } |
509 // struct + const int | 508 // struct + const int |
510 else if (e2type->isintegral()){ | 509 else if (e2type->isintegral()){ |
511 IntegerExp* iexp = (IntegerExp*)e2; | 510 IntegerExp* iexp = (IntegerExp*)e2; |
512 assert(iexp->value == 0 && "Only integral struct initializer allowed is zero"); | 511 assert(iexp->value == 0 && "Only integral struct initializer allowed is zero"); |
513 TypeStruct* st = (TypeStruct*)e1type; | 512 LLVM_DtoStructZeroInit(l->mem); |
514 LLVM_DtoStructZeroInit(st, l->mem); | |
515 } | 513 } |
516 // :x | 514 // :x |
517 else | 515 else |
518 assert(0 && "struct = unknown"); | 516 assert(0 && "struct = unknown"); |
519 } | 517 } |
1548 if (!ve->inplace) { | 1546 if (!ve->inplace) { |
1549 llvm::Value* val = ve->getValue(); | 1547 llvm::Value* val = ve->getValue(); |
1550 Logger::cout() << *val << " | " << *arrptr << '\n'; | 1548 Logger::cout() << *val << " | " << *arrptr << '\n'; |
1551 | 1549 |
1552 Type* vxtype = LLVM_DtoDType(vx->type); | 1550 Type* vxtype = LLVM_DtoDType(vx->type); |
1553 if (vxtype->ty == Tstruct) { | 1551 LLVM_DtoAssign(vxtype, arrptr, val); |
1554 TypeStruct* ts = (TypeStruct*)vxtype; | |
1555 LLVM_DtoStructCopy(ts,arrptr,val); | |
1556 } | |
1557 else if (vxtype->ty == Tarray) { | |
1558 LLVM_DtoArrayAssign(arrptr,val); | |
1559 } | |
1560 else if (vxtype->ty == Tsarray) { | |
1561 LLVM_DtoStaticArrayCopy(arrptr,val); | |
1562 } | |
1563 else | |
1564 new llvm::StoreInst(val, arrptr, p->scopebb()); | |
1565 } | 1552 } |
1566 delete ve; | 1553 delete ve; |
1567 } | 1554 } |
1568 else { | 1555 else { |
1569 assert(0); | 1556 assert(0); |
2056 } | 2043 } |
2057 } | 2044 } |
2058 else if (ntype->ty == Tstruct) { | 2045 else if (ntype->ty == Tstruct) { |
2059 TypeStruct* ts = (TypeStruct*)ntype; | 2046 TypeStruct* ts = (TypeStruct*)ntype; |
2060 if (ts->isZeroInit()) { | 2047 if (ts->isZeroInit()) { |
2061 LLVM_DtoStructZeroInit(ts,e->mem); | 2048 LLVM_DtoStructZeroInit(e->mem); |
2062 } | 2049 } |
2063 else { | 2050 else { |
2064 LLVM_DtoStructCopy(ts,e->mem,ts->llvmInit); | 2051 LLVM_DtoStructCopy(e->mem,ts->llvmInit); |
2065 } | 2052 } |
2066 } | 2053 } |
2067 | 2054 |
2068 e->inplace = true; | 2055 e->inplace = true; |
2069 e->type = elem::VAR; | 2056 e->type = elem::VAR; |