Mercurial > projects > ldc
comparison dmd2/mtype.c @ 847:356e65836fb5
Merged DMD 2.021 frontend.
Removed generated files from dmd/dmd2 dirs.
author | Tomas Lindquist Olsen <tomas.l.olsen@gmail.com> |
---|---|
date | Sat, 13 Dec 2008 16:14:37 +0100 |
parents | 43178a913a28 |
children | eb936607f071 |
comparison
equal
deleted
inserted
replaced
846:bc982f1ad106 | 847:356e65836fb5 |
---|---|
2800 return e; | 2800 return e; |
2801 } | 2801 } |
2802 | 2802 |
2803 int TypeAArray::isZeroInit() | 2803 int TypeAArray::isZeroInit() |
2804 { | 2804 { |
2805 return 1; | 2805 return TRUE; |
2806 } | 2806 } |
2807 | 2807 |
2808 int TypeAArray::checkBoolean() | 2808 int TypeAArray::checkBoolean() |
2809 { | 2809 { |
2810 return TRUE; | 2810 return TRUE; |
3143 { Argument *arg1 = Argument::getNth(t1->parameters, i); | 3143 { Argument *arg1 = Argument::getNth(t1->parameters, i); |
3144 Argument *arg2 = Argument::getNth(t2->parameters, i); | 3144 Argument *arg2 = Argument::getNth(t2->parameters, i); |
3145 | 3145 |
3146 if (!arg1->type->equals(arg2->type)) | 3146 if (!arg1->type->equals(arg2->type)) |
3147 goto Ldistinct; | 3147 goto Ldistinct; |
3148 if (arg1->storageClass != arg2->storageClass) | 3148 if ((arg1->storageClass & ~STCscope) != (arg2->storageClass & ~STCscope)) |
3149 inoutmismatch = 1; | |
3150 // We can add scope, but not subtract it | |
3151 if (!(arg1->storageClass & STCscope) && (arg2->storageClass & STCscope)) | |
3149 inoutmismatch = 1; | 3152 inoutmismatch = 1; |
3150 } | 3153 } |
3151 } | 3154 } |
3152 else if (t1->parameters != t2->parameters) | 3155 else if (t1->parameters != t2->parameters) |
3153 goto Ldistinct; | 3156 goto Ldistinct; |
3648 } | 3651 } |
3649 } | 3652 } |
3650 return next->reliesOnTident(); | 3653 return next->reliesOnTident(); |
3651 } | 3654 } |
3652 | 3655 |
3656 /*************************** | |
3657 * Examine function signature for parameter p and see if | |
3658 * p can 'escape' the scope of the function. | |
3659 */ | |
3660 | |
3661 bool TypeFunction::parameterEscapes(Argument *p) | |
3662 { | |
3663 | |
3664 /* Scope parameters do not escape. | |
3665 * Allow 'lazy' to imply 'scope' - | |
3666 * lazy parameters can be passed along | |
3667 * as lazy parameters to the next function, but that isn't | |
3668 * escaping. | |
3669 */ | |
3670 if (p->storageClass & (STCscope | STClazy)) | |
3671 return FALSE; | |
3672 | |
3673 if (ispure) | |
3674 { /* With pure functions, we need only be concerned if p escapes | |
3675 * via any return statement. | |
3676 */ | |
3677 Type* tret = nextOf()->toBasetype(); | |
3678 if (!isref && !tret->hasPointers()) | |
3679 { /* The result has no references, so p could not be escaping | |
3680 * that way. | |
3681 */ | |
3682 return FALSE; | |
3683 } | |
3684 } | |
3685 | |
3686 /* Assume it escapes in the absence of better information. | |
3687 */ | |
3688 return TRUE; | |
3689 } | |
3690 | |
3653 /***************************** TypeDelegate *****************************/ | 3691 /***************************** TypeDelegate *****************************/ |
3654 | 3692 |
3655 TypeDelegate::TypeDelegate(Type *t) | 3693 TypeDelegate::TypeDelegate(Type *t) |
3656 : TypeNext(Tfunction, t) | 3694 : TypeNext(Tfunction, t) |
3657 { | 3695 { |
4596 } | 4634 } |
4597 else if (ident == Id::init) | 4635 else if (ident == Id::init) |
4598 { | 4636 { |
4599 e = defaultInit(loc); | 4637 e = defaultInit(loc); |
4600 } | 4638 } |
4639 else if (ident == Id::stringof) | |
4640 { char *s = toChars(); | |
4641 e = new StringExp(loc, s, strlen(s), 'c'); | |
4642 Scope sc; | |
4643 e = e->semantic(&sc); | |
4644 } | |
4601 else | 4645 else |
4602 { | 4646 { |
4603 e = toBasetype()->getProperty(loc, ident); | 4647 e = toBasetype()->getProperty(loc, ident); |
4604 } | 4648 } |
4605 return e; | 4649 return e; |
6190 else if (arg->storageClass & STCalias) | 6234 else if (arg->storageClass & STCalias) |
6191 buf->writestring("alias "); | 6235 buf->writestring("alias "); |
6192 else if (arg->storageClass & STCauto) | 6236 else if (arg->storageClass & STCauto) |
6193 buf->writestring("auto "); | 6237 buf->writestring("auto "); |
6194 | 6238 |
6239 if (arg->storageClass & STCscope) | |
6240 buf->writestring("scope "); | |
6241 | |
6195 if (arg->storageClass & STCconst) | 6242 if (arg->storageClass & STCconst) |
6196 buf->writestring("const "); | 6243 buf->writestring("const "); |
6197 if (arg->storageClass & STCinvariant) | 6244 if (arg->storageClass & STCinvariant) |
6198 buf->writestring("invariant "); | 6245 buf->writestring("invariant "); |
6246 if (arg->storageClass & STCshared) | |
6247 buf->writestring("shared "); | |
6199 | 6248 |
6200 argbuf.reset(); | 6249 argbuf.reset(); |
6201 if (arg->storageClass & STCalias) | 6250 if (arg->storageClass & STCalias) |
6202 { if (arg->ident) | 6251 { if (arg->ident) |
6203 argbuf.writestring(arg->ident->toChars()); | 6252 argbuf.writestring(arg->ident->toChars()); |
6290 return NULL; | 6339 return NULL; |
6291 } | 6340 } |
6292 | 6341 |
6293 void Argument::toDecoBuffer(OutBuffer *buf) | 6342 void Argument::toDecoBuffer(OutBuffer *buf) |
6294 { | 6343 { |
6344 if (storageClass & STCscope) | |
6345 buf->writeByte('M'); | |
6295 switch (storageClass & (STCin | STCout | STCref | STClazy)) | 6346 switch (storageClass & (STCin | STCout | STCref | STClazy)) |
6296 { case 0: | 6347 { case 0: |
6297 case STCin: | 6348 case STCin: |
6298 break; | 6349 break; |
6299 case STCout: | 6350 case STCout: |