Mercurial > projects > ldc
comparison dmd2/inline.c @ 1577:e4f7b5d9c68a
DMD 2.032 Merge.
author | Robert Clipsham <robert@octarineparrot.com> |
---|---|
date | Tue, 08 Sep 2009 10:07:56 +0100 |
parents | f62347c22d81 |
children |
comparison
equal
deleted
inserted
replaced
1576:4551475bc6b6 | 1577:e4f7b5d9c68a |
---|---|
1 | 1 |
2 // Copyright (c) 1999-2008 by Digital Mars | 2 // Copyright (c) 1999-2009 by Digital Mars |
3 // All Rights Reserved | 3 // All Rights Reserved |
4 // written by Walter Bright | 4 // written by Walter Bright |
5 // http://www.digitalmars.com | 5 // http://www.digitalmars.com |
6 // License for redistribution is by either the Artistic License | 6 // License for redistribution is by either the Artistic License |
7 // in artistic.txt, or the GNU General Public License in gnu.txt. | 7 // in artistic.txt, or the GNU General Public License in gnu.txt. |
868 init = init->inlineScan(iss); | 868 init = init->inlineScan(iss); |
869 if (condition) | 869 if (condition) |
870 condition = condition->inlineScan(iss); | 870 condition = condition->inlineScan(iss); |
871 if (increment) | 871 if (increment) |
872 increment = increment->inlineScan(iss); | 872 increment = increment->inlineScan(iss); |
873 body = body->inlineScan(iss); | 873 if (body) |
874 body = body->inlineScan(iss); | |
874 return this; | 875 return this; |
875 } | 876 } |
876 | 877 |
877 | 878 |
878 Statement *ForeachStatement::inlineScan(InlineScanState *iss) | 879 Statement *ForeachStatement::inlineScan(InlineScanState *iss) |
1070 { | 1071 { |
1071 ExpInitializer *ie = vd->init->isExpInitializer(); | 1072 ExpInitializer *ie = vd->init->isExpInitializer(); |
1072 | 1073 |
1073 if (ie) | 1074 if (ie) |
1074 { | 1075 { |
1076 #if DMDV2 | |
1077 if (vd->type) | |
1078 { Type *tb = vd->type->toBasetype(); | |
1079 if (tb->ty == Tstruct) | |
1080 { StructDeclaration *sd = ((TypeStruct *)tb)->sym; | |
1081 if (sd->cpctor) | |
1082 { /* The problem here is that if the initializer is a | |
1083 * function call that returns a struct S with a cpctor: | |
1084 * S s = foo(); | |
1085 * the postblit is done by the return statement in foo() | |
1086 * in s2ir.c, the intermediate code generator. | |
1087 * But, if foo() is inlined and now the code looks like: | |
1088 * S s = x; | |
1089 * the postblit is not there, because such assignments | |
1090 * are rewritten as s.cpctor(&x) by the front end. | |
1091 * So, the inlining won't get the postblit called. | |
1092 * Work around by not inlining these cases. | |
1093 * A proper fix would be to move all the postblit | |
1094 * additions to the front end. | |
1095 */ | |
1096 return; | |
1097 } | |
1098 } | |
1099 } | |
1100 #endif | |
1075 ie->exp = ie->exp->inlineScan(iss); | 1101 ie->exp = ie->exp->inlineScan(iss); |
1076 } | 1102 } |
1077 } | 1103 } |
1078 } | 1104 } |
1079 } | 1105 } |
1497 } | 1523 } |
1498 | 1524 |
1499 inlineNest++; | 1525 inlineNest++; |
1500 Expression *eb = fbody->doInline(&ids); | 1526 Expression *eb = fbody->doInline(&ids); |
1501 inlineNest--; | 1527 inlineNest--; |
1528 //eb->type->print(); | |
1529 //eb->print(); | |
1530 //eb->dump(0); | |
1502 return Expression::combine(e, eb); | 1531 return Expression::combine(e, eb); |
1503 } | 1532 } |
1504 | 1533 |
1505 | 1534 |
1506 | 1535 |