Mercurial > projects > ldc
comparison gen/llvmhelpers.cpp @ 1504:855f188aab7a
Added a stripModifiers() function to remove shared|const|immutable storage classes in D2 (should eventually be moved to a dhelpers file rather than llvm helpers).
Replaced a few occurances of STCinvariant with STCimmutable.
author | Robert Clipsham <robert@octarineparrot.com> |
---|---|
date | Thu, 18 Jun 2009 15:44:04 +0100 |
parents | c3c46399bcf1 |
children | e07f15c4ab4d |
comparison
equal
deleted
inserted
replaced
1501:8b9f236dd051 | 1504:855f188aab7a |
---|---|
1478 // ok, we're good, llvm will align properly! | 1478 // ok, we're good, llvm will align properly! |
1479 return alignedoffset; | 1479 return alignedoffset; |
1480 } | 1480 } |
1481 | 1481 |
1482 ////////////////////////////////////////////////////////////////////////////////////////// | 1482 ////////////////////////////////////////////////////////////////////////////////////////// |
1483 | |
1484 Type * stripModifiers( Type * type ) | |
1485 { | |
1486 #if DMDV2 | |
1487 Type *t = type; | |
1488 while (t->mod) | |
1489 { | |
1490 switch (t->mod) | |
1491 { | |
1492 case MODconst: | |
1493 t = type->cto; | |
1494 break; | |
1495 case MODshared: | |
1496 t = type->sto; | |
1497 break; | |
1498 case MODinvariant: | |
1499 t = type->ito; | |
1500 break; | |
1501 case MODshared | MODconst: | |
1502 t = type->scto; | |
1503 break; | |
1504 default: | |
1505 assert(0 && "Unhandled type modifier"); | |
1506 } | |
1507 | |
1508 if (!t) | |
1509 { | |
1510 unsigned sz = type->sizeTy[type->ty]; | |
1511 t = (Type *)malloc(sz); | |
1512 memcpy(t, type, sz); | |
1513 t->mod = 0; | |
1514 t->deco = NULL; | |
1515 t->arrayof = NULL; | |
1516 t->pto = NULL; | |
1517 t->rto = NULL; | |
1518 t->cto = NULL; | |
1519 t->ito = NULL; | |
1520 t->sto = NULL; | |
1521 t->scto = NULL; | |
1522 t->vtinfo = NULL; | |
1523 t = t->merge(); | |
1524 | |
1525 t->fixTo(type); | |
1526 switch (type->mod) | |
1527 { | |
1528 case MODconst: | |
1529 t->cto = type; | |
1530 break; | |
1531 | |
1532 case MODinvariant: | |
1533 t->ito = type; | |
1534 break; | |
1535 | |
1536 case MODshared: | |
1537 t->sto = type; | |
1538 break; | |
1539 | |
1540 case MODshared | MODconst: | |
1541 t->scto = type; | |
1542 break; | |
1543 | |
1544 default: | |
1545 assert(0); | |
1546 } | |
1547 } | |
1548 } | |
1549 return t; | |
1550 #else | |
1551 return type; | |
1552 #endif | |
1553 } | |
1554 | |
1555 ////////////////////////////////////////////////////////////////////////////////////////// |