Mercurial > projects > ldc
comparison dmd/declaration.c @ 1587:def7a1d494fd
Merge DMD 1.051
author | Christian Kamm <kamm incasoftware de> |
---|---|
date | Fri, 06 Nov 2009 23:58:01 +0100 |
parents | e4ff2e15cf5f |
children | 207a8a438dea |
comparison
equal
deleted
inserted
replaced
1586:7f728c52e63c | 1587:def7a1d494fd |
---|---|
65 { | 65 { |
66 return FALSE; | 66 return FALSE; |
67 } | 67 } |
68 | 68 |
69 int Declaration::isDataseg() | 69 int Declaration::isDataseg() |
70 { | |
71 return FALSE; | |
72 } | |
73 | |
74 int Declaration::isThreadlocal() | |
70 { | 75 { |
71 return FALSE; | 76 return FALSE; |
72 } | 77 } |
73 | 78 |
74 int Declaration::isCodeseg() | 79 int Declaration::isCodeseg() |
130 else | 135 else |
131 { | 136 { |
132 VarDeclaration *v = isVarDeclaration(); | 137 VarDeclaration *v = isVarDeclaration(); |
133 if (v && v->canassign == 0) | 138 if (v && v->canassign == 0) |
134 { | 139 { |
135 char *p = NULL; | 140 const char *p = NULL; |
136 if (isConst()) | 141 if (isConst()) |
137 p = "const"; | 142 p = "const"; |
138 else if (isInvariant()) | 143 else if (isInvariant()) |
139 p = "invariant"; | 144 p = "immutable"; |
140 else if (storage_class & STCmanifest) | 145 else if (storage_class & STCmanifest) |
141 p = "manifest constant"; | 146 p = "enum"; |
142 else if (!t->isAssignable()) | 147 else if (!t->isAssignable()) |
143 p = "struct with immutable members"; | 148 p = "struct with immutable members"; |
144 if (p) | 149 if (p) |
145 { error(loc, "cannot modify %s", p); | 150 { error(loc, "cannot modify %s", p); |
146 halt(); | |
147 } | 151 } |
148 } | 152 } |
149 } | 153 } |
150 } | 154 } |
151 #endif | 155 #endif |
198 /* We know it's a type tuple, so build the TypeTuple | 202 /* We know it's a type tuple, so build the TypeTuple |
199 */ | 203 */ |
200 Arguments *args = new Arguments(); | 204 Arguments *args = new Arguments(); |
201 args->setDim(objects->dim); | 205 args->setDim(objects->dim); |
202 OutBuffer buf; | 206 OutBuffer buf; |
207 int hasdeco = 1; | |
203 for (size_t i = 0; i < objects->dim; i++) | 208 for (size_t i = 0; i < objects->dim; i++) |
204 { Type *t = (Type *)objects->data[i]; | 209 { Type *t = (Type *)objects->data[i]; |
205 | 210 |
206 //printf("type = %s\n", t->toChars()); | 211 //printf("type = %s\n", t->toChars()); |
207 #if 0 | 212 #if 0 |
211 Argument *arg = new Argument(STCin, t, id, NULL); | 216 Argument *arg = new Argument(STCin, t, id, NULL); |
212 #else | 217 #else |
213 Argument *arg = new Argument(STCin, t, NULL, NULL); | 218 Argument *arg = new Argument(STCin, t, NULL, NULL); |
214 #endif | 219 #endif |
215 args->data[i] = (void *)arg; | 220 args->data[i] = (void *)arg; |
221 if (!t->deco) | |
222 hasdeco = 0; | |
216 } | 223 } |
217 | 224 |
218 tupletype = new TypeTuple(args); | 225 tupletype = new TypeTuple(args); |
226 if (hasdeco) | |
227 return tupletype->semantic(0, NULL); | |
219 } | 228 } |
220 | 229 |
221 return tupletype; | 230 return tupletype; |
222 } | 231 } |
223 | 232 |
454 * const x = 3; | 463 * const x = 3; |
455 * alias x y; | 464 * alias x y; |
456 * try to alias y to 3. | 465 * try to alias y to 3. |
457 */ | 466 */ |
458 s = type->toDsymbol(sc); | 467 s = type->toDsymbol(sc); |
459 if (s) | 468 if (s |
469 #if DMDV2 | |
470 ` && ((s->getType() && type->equals(s->getType())) || s->isEnumMember()) | |
471 #endif | |
472 ) | |
460 goto L2; // it's a symbolic alias | 473 goto L2; // it's a symbolic alias |
461 | 474 |
462 //printf("alias type is %s\n", type->toChars()); | 475 #if DMDV2 |
463 type->resolve(loc, sc, &e, &t, &s); | 476 if (storage_class & (STCref | STCnothrow | STCpure)) |
477 { // For 'ref' to be attached to function types, and picked | |
478 // up by Type::resolve(), it has to go into sc. | |
479 sc = sc->push(); | |
480 sc->stc |= storage_class & (STCref | STCnothrow | STCpure); | |
481 type->resolve(loc, sc, &e, &t, &s); | |
482 sc = sc->pop(); | |
483 } | |
484 else | |
485 #endif | |
486 type->resolve(loc, sc, &e, &t, &s); | |
464 if (s) | 487 if (s) |
465 { | 488 { |
466 goto L2; | 489 goto L2; |
467 } | 490 } |
468 else if (e) | 491 else if (e) |
521 { | 544 { |
522 assert(global.errors); | 545 assert(global.errors); |
523 s = NULL; | 546 s = NULL; |
524 } | 547 } |
525 } | 548 } |
526 aliassym = s; | 549 if (!aliassym) |
550 aliassym = s; | |
527 this->inSemantic = 0; | 551 this->inSemantic = 0; |
528 } | 552 } |
529 | 553 |
530 int AliasDeclaration::overloadInsert(Dsymbol *s) | 554 int AliasDeclaration::overloadInsert(Dsymbol *s) |
531 { | 555 { |
533 * be overloaded and check later for correctness. | 557 * be overloaded and check later for correctness. |
534 */ | 558 */ |
535 | 559 |
536 //printf("AliasDeclaration::overloadInsert('%s')\n", s->toChars()); | 560 //printf("AliasDeclaration::overloadInsert('%s')\n", s->toChars()); |
537 if (overnext == NULL) | 561 if (overnext == NULL) |
538 { overnext = s; | 562 { |
563 if (s == this) | |
564 { | |
565 return TRUE; | |
566 } | |
567 overnext = s; | |
539 return TRUE; | 568 return TRUE; |
540 } | 569 } |
541 else | 570 else |
542 { | 571 { |
543 return overnext->overloadInsert(s); | 572 return overnext->overloadInsert(s); |
549 return "alias"; | 578 return "alias"; |
550 } | 579 } |
551 | 580 |
552 Type *AliasDeclaration::getType() | 581 Type *AliasDeclaration::getType() |
553 { | 582 { |
583 //printf("AliasDeclaration::getType() %s\n", type->toChars()); | |
584 #if 0 | |
585 if (!type->deco && scope) | |
586 semantic(scope); | |
587 if (type && !type->deco) | |
588 error("forward reference to alias %s\n", toChars()); | |
589 #endif | |
554 return type; | 590 return type; |
555 } | 591 } |
556 | 592 |
557 Dsymbol *AliasDeclaration::toAlias() | 593 Dsymbol *AliasDeclaration::toAlias() |
558 { | 594 { |
559 //printf("AliasDeclaration::toAlias('%s', this = %p, aliassym = %p, kind = '%s')\n", toChars(), this, aliassym, aliassym ? aliassym->kind() : ""); | 595 //printf("AliasDeclaration::toAlias('%s', this = %p, aliassym = %p, kind = '%s')\n", toChars(), this, aliassym, aliassym ? aliassym->kind() : ""); |
560 assert(this != aliassym); | 596 assert(this != aliassym); |
561 //static int count; if (++count == 10) *(char*)0=0; | 597 //static int count; if (++count == 75) exit(0); //*(char*)0=0; |
562 if (inSemantic) | 598 if (inSemantic) |
563 { error("recursive alias declaration"); | 599 { error("recursive alias declaration"); |
564 aliassym = new TypedefDeclaration(loc, ident, Type::terror, NULL); | 600 aliassym = new TypedefDeclaration(loc, ident, Type::terror, NULL); |
565 } | 601 } |
566 Dsymbol *s = aliassym ? aliassym->toAlias() : this; | 602 Dsymbol *s = aliassym ? aliassym->toAlias() : this; |
618 this->hinit = NULL; | 654 this->hinit = NULL; |
619 #endif | 655 #endif |
620 this->loc = loc; | 656 this->loc = loc; |
621 offset = 0; | 657 offset = 0; |
622 noscope = 0; | 658 noscope = 0; |
659 #if DMDV1 | |
623 nestedref = 0; | 660 nestedref = 0; |
661 #endif | |
624 ctorinit = 0; | 662 ctorinit = 0; |
625 aliassym = NULL; | 663 aliassym = NULL; |
626 onstack = 0; | 664 onstack = 0; |
627 canassign = 0; | 665 canassign = 0; |
628 value = NULL; | 666 value = NULL; |
682 return sv; | 720 return sv; |
683 } | 721 } |
684 | 722 |
685 void VarDeclaration::semantic(Scope *sc) | 723 void VarDeclaration::semantic(Scope *sc) |
686 { | 724 { |
687 //printf("VarDeclaration::semantic('%s', parent = '%s')\n", toChars(), sc->parent->toChars()); | 725 #if 0 |
688 //printf(" type = %s\n", type ? type->toChars() : "null"); | 726 printf("VarDeclaration::semantic('%s', parent = '%s')\n", toChars(), sc->parent->toChars()); |
689 //printf(" stc = x%x\n", sc->stc); | 727 printf(" type = %s\n", type ? type->toChars() : "null"); |
690 //printf(" storage_class = x%x\n", storage_class); | 728 printf(" stc = x%x\n", sc->stc); |
691 //printf("linkage = %d\n", sc->linkage); | 729 printf(" storage_class = x%x\n", storage_class); |
730 printf("linkage = %d\n", sc->linkage); | |
692 //if (strcmp(toChars(), "mul") == 0) halt(); | 731 //if (strcmp(toChars(), "mul") == 0) halt(); |
732 #endif | |
693 | 733 |
694 storage_class |= sc->stc; | 734 storage_class |= sc->stc; |
695 if (storage_class & STCextern && init) | 735 if (storage_class & STCextern && init) |
696 error("extern symbols cannot have initializers"); | 736 error("extern symbols cannot have initializers"); |
697 | 737 |
722 this->parent = sc->parent; | 762 this->parent = sc->parent; |
723 //printf("this = %p, parent = %p, '%s'\n", this, parent, parent->toChars()); | 763 //printf("this = %p, parent = %p, '%s'\n", this, parent, parent->toChars()); |
724 protection = sc->protection; | 764 protection = sc->protection; |
725 //printf("sc->stc = %x\n", sc->stc); | 765 //printf("sc->stc = %x\n", sc->stc); |
726 //printf("storage_class = x%x\n", storage_class); | 766 //printf("storage_class = x%x\n", storage_class); |
767 | |
768 #if DMDV2 | |
769 if (storage_class & STCgshared && global.params.safe && !sc->module->safe) | |
770 { | |
771 error("__gshared not allowed in safe mode; use shared"); | |
772 } | |
773 #endif | |
727 | 774 |
728 Dsymbol *parent = toParent(); | 775 Dsymbol *parent = toParent(); |
729 FuncDeclaration *fd = parent->isFuncDeclaration(); | 776 FuncDeclaration *fd = parent->isFuncDeclaration(); |
730 | 777 |
731 Type *tb = type->toBasetype(); | 778 Type *tb = type->toBasetype(); |
830 AggregateDeclaration *aad = sc->anonAgg; | 877 AggregateDeclaration *aad = sc->anonAgg; |
831 if (!aad) | 878 if (!aad) |
832 aad = parent->isAggregateDeclaration(); | 879 aad = parent->isAggregateDeclaration(); |
833 if (aad) | 880 if (aad) |
834 { | 881 { |
835 aad->addField(sc, this); | 882 #if DMDV2 |
883 assert(!(storage_class & (STCextern | STCstatic | STCtls | STCgshared))); | |
884 | |
885 if (storage_class & (STCconst | STCimmutable) && init) | |
886 { | |
887 if (!type->toBasetype()->isTypeBasic()) | |
888 storage_class |= STCstatic; | |
889 } | |
890 else | |
891 #endif | |
892 aad->addField(sc, this); | |
836 } | 893 } |
837 | 894 |
838 InterfaceDeclaration *id = parent->isInterfaceDeclaration(); | 895 InterfaceDeclaration *id = parent->isInterfaceDeclaration(); |
839 if (id) | 896 if (id) |
840 { | 897 { |
862 error("cannot use template to add field to aggregate '%s'", ad->toChars()); | 919 error("cannot use template to add field to aggregate '%s'", ad->toChars()); |
863 } | 920 } |
864 } | 921 } |
865 } | 922 } |
866 | 923 |
924 #if DMDV2 | |
925 if ((storage_class & (STCref | STCparameter | STCforeach)) == STCref && | |
926 ident != Id::This) | |
927 { | |
928 error("only parameters or foreach declarations can be ref"); | |
929 } | |
930 #endif | |
931 | |
867 if (type->isscope() && !noscope) | 932 if (type->isscope() && !noscope) |
868 { | 933 { |
869 if (storage_class & (STCfield | STCout | STCref | STCstatic) || !fd) | 934 if (storage_class & (STCfield | STCout | STCref | STCstatic) || !fd) |
870 { | 935 { |
871 error("globals, statics, fields, ref and out parameters cannot be scope"); | 936 error("globals, statics, fields, ref and out parameters cannot be scope"); |
876 if (!(storage_class & STCparameter) && ident != Id::withSym) | 941 if (!(storage_class & STCparameter) && ident != Id::withSym) |
877 error("reference to scope class must be scope"); | 942 error("reference to scope class must be scope"); |
878 } | 943 } |
879 } | 944 } |
880 | 945 |
946 enum TOK op = TOKconstruct; | |
881 if (!init && !sc->inunion && !isStatic() && !isConst() && fd && | 947 if (!init && !sc->inunion && !isStatic() && !isConst() && fd && |
882 !(storage_class & (STCfield | STCin | STCforeach)) && | 948 !(storage_class & (STCfield | STCin | STCforeach)) && |
883 type->size() != 0) | 949 type->size() != 0) |
884 { | 950 { |
885 // Provide a default initializer | 951 // Provide a default initializer |
894 */ | 960 */ |
895 Expression *e = new IntegerExp(loc, 0, Type::tint32); | 961 Expression *e = new IntegerExp(loc, 0, Type::tint32); |
896 Expression *e1; | 962 Expression *e1; |
897 e1 = new VarExp(loc, this); | 963 e1 = new VarExp(loc, this); |
898 e = new AssignExp(loc, e1, e); | 964 e = new AssignExp(loc, e1, e); |
899 e->type = e1->type; | 965 e->op = TOKconstruct; |
900 init = new ExpInitializer(loc, e/*->type->defaultInit()*/); | 966 e->type = e1->type; // don't type check this, it would fail |
967 init = new ExpInitializer(loc, e); | |
901 return; | 968 return; |
902 } | 969 } |
903 else if (type->ty == Ttypedef) | 970 else if (type->ty == Ttypedef) |
904 { TypeTypedef *td = (TypeTypedef *)type; | 971 { TypeTypedef *td = (TypeTypedef *)type; |
905 if (td->sym->init) | 972 if (td->sym->init) |
914 } | 981 } |
915 else | 982 else |
916 { | 983 { |
917 init = getExpInitializer(); | 984 init = getExpInitializer(); |
918 } | 985 } |
986 // Default initializer is always a blit | |
987 op = TOKblit; | |
919 } | 988 } |
920 | 989 |
921 if (init) | 990 if (init) |
922 { | 991 { |
923 sc = sc->push(); | 992 sc = sc->push(); |
924 sc->stc &= ~(STCconst | STCinvariant | STCpure); | 993 sc->stc &= ~(STC_TYPECTOR | STCpure | STCnothrow | STCref); |
925 | 994 |
926 ArrayInitializer *ai = init->isArrayInitializer(); | 995 ArrayInitializer *ai = init->isArrayInitializer(); |
927 if (ai && tb->ty == Taarray) | 996 if (ai && tb->ty == Taarray) |
928 { | 997 { |
929 init = ai->toAssocArrayInitializer(); | 998 init = ai->toAssocArrayInitializer(); |
930 } | 999 } |
931 | 1000 |
932 StructInitializer *si = init->isStructInitializer(); | 1001 StructInitializer *si = init->isStructInitializer(); |
933 ExpInitializer *ei = init->isExpInitializer(); | 1002 ExpInitializer *ei = init->isExpInitializer(); |
934 | 1003 |
935 // See if we can allocate on the stack | 1004 // See if initializer is a NewExp that can be allocated on the stack |
936 if (ei && isScope() && ei->exp->op == TOKnew) | 1005 if (ei && isScope() && ei->exp->op == TOKnew) |
937 { NewExp *ne = (NewExp *)ei->exp; | 1006 { NewExp *ne = (NewExp *)ei->exp; |
938 if (!(ne->newargs && ne->newargs->dim)) | 1007 if (!(ne->newargs && ne->newargs->dim)) |
939 { ne->onstack = 1; | 1008 { ne->onstack = 1; |
940 onstack = 1; | 1009 onstack = 1; |
968 } | 1037 } |
969 | 1038 |
970 Expression *e1 = new VarExp(loc, this); | 1039 Expression *e1 = new VarExp(loc, this); |
971 | 1040 |
972 Type *t = type->toBasetype(); | 1041 Type *t = type->toBasetype(); |
973 if (t->ty == Tsarray) | 1042 if (t->ty == Tsarray && !(storage_class & (STCref | STCout))) |
974 { | 1043 { |
975 ei->exp = ei->exp->semantic(sc); | 1044 ei->exp = ei->exp->semantic(sc); |
976 if (!ei->exp->implicitConvTo(type)) | 1045 if (!ei->exp->implicitConvTo(type)) |
977 { | 1046 { |
978 int dim = ((TypeSArray *)t)->dim->toInteger(); | 1047 int dim = ((TypeSArray *)t)->dim->toInteger(); |
989 e1 = new SliceExp(loc, e1, NULL, NULL); | 1058 e1 = new SliceExp(loc, e1, NULL, NULL); |
990 } | 1059 } |
991 else if (t->ty == Tstruct) | 1060 else if (t->ty == Tstruct) |
992 { | 1061 { |
993 ei->exp = ei->exp->semantic(sc); | 1062 ei->exp = ei->exp->semantic(sc); |
1063 ei->exp = resolveProperties(sc, ei->exp); | |
1064 StructDeclaration *sd = ((TypeStruct *)t)->sym; | |
1065 #if DMDV2 | |
1066 /* Look to see if initializer is a call to the constructor | |
1067 */ | |
1068 if (sd->ctor && // there are constructors | |
1069 ei->exp->type->ty == Tstruct && // rvalue is the same struct | |
1070 ((TypeStruct *)ei->exp->type)->sym == sd && | |
1071 ei->exp->op == TOKstar) | |
1072 { | |
1073 /* Look for form of constructor call which is: | |
1074 * *__ctmp.ctor(arguments...) | |
1075 */ | |
1076 PtrExp *pe = (PtrExp *)ei->exp; | |
1077 if (pe->e1->op == TOKcall) | |
1078 { CallExp *ce = (CallExp *)pe->e1; | |
1079 if (ce->e1->op == TOKdotvar) | |
1080 { DotVarExp *dve = (DotVarExp *)ce->e1; | |
1081 if (dve->var->isCtorDeclaration()) | |
1082 { /* It's a constructor call, currently constructing | |
1083 * a temporary __ctmp. | |
1084 */ | |
1085 /* Before calling the constructor, initialize | |
1086 * variable with a bit copy of the default | |
1087 * initializer | |
1088 */ | |
1089 Expression *e = new AssignExp(loc, new VarExp(loc, this), t->defaultInit(loc)); | |
1090 e->op = TOKblit; | |
1091 e->type = t; | |
1092 ei->exp = new CommaExp(loc, e, ei->exp); | |
1093 | |
1094 /* Replace __ctmp being constructed with e1 | |
1095 */ | |
1096 dve->e1 = e1; | |
1097 return; | |
1098 } | |
1099 } | |
1100 } | |
1101 } | |
1102 #endif | |
994 if (!ei->exp->implicitConvTo(type)) | 1103 if (!ei->exp->implicitConvTo(type)) |
995 ei->exp = new CastExp(loc, ei->exp, type); | 1104 { |
1105 /* Look for opCall | |
1106 * See bugzilla 2702 for more discussion | |
1107 */ | |
1108 Type *ti = ei->exp->type->toBasetype(); | |
1109 // Don't cast away invariant or mutability in initializer | |
1110 if (search_function(sd, Id::call) && | |
1111 /* Initializing with the same type is done differently | |
1112 */ | |
1113 !(ti->ty == Tstruct && t->toDsymbol(sc) == ti->toDsymbol(sc))) | |
1114 { // Rewrite as e1.call(arguments) | |
1115 Expression * eCall = new DotIdExp(loc, e1, Id::call); | |
1116 ei->exp = new CallExp(loc, eCall, ei->exp); | |
1117 } | |
1118 } | |
996 } | 1119 } |
997 ei->exp = new AssignExp(loc, e1, ei->exp); | 1120 ei->exp = new AssignExp(loc, e1, ei->exp); |
998 ei->exp->op = TOKconstruct; | 1121 ei->exp->op = TOKconstruct; |
999 canassign++; | 1122 canassign++; |
1000 ei->exp = ei->exp->semantic(sc); | 1123 ei->exp = ei->exp->semantic(sc); |
1008 { // Make it static | 1131 { // Make it static |
1009 storage_class |= STCstatic; | 1132 storage_class |= STCstatic; |
1010 } | 1133 } |
1011 } | 1134 } |
1012 } | 1135 } |
1013 else if (isConst() || isFinal()) | 1136 else if (isConst() || isFinal() || |
1137 parent->isAggregateDeclaration()) | |
1014 { | 1138 { |
1015 /* Because we may need the results of a const declaration in a | 1139 /* Because we may need the results of a const declaration in a |
1016 * subsequent type, such as an array dimension, before semantic2() | 1140 * subsequent type, such as an array dimension, before semantic2() |
1017 * gets ordinarily run, try to run semantic2() now. | 1141 * gets ordinarily run, try to run semantic2() now. |
1018 * Ignore failure. | 1142 * Ignore failure. |
1041 //printf("-gag\n"); | 1165 //printf("-gag\n"); |
1042 if (errors != global.errors) // if errors happened | 1166 if (errors != global.errors) // if errors happened |
1043 { | 1167 { |
1044 if (global.gag == 0) | 1168 if (global.gag == 0) |
1045 global.errors = errors; // act as if nothing happened | 1169 global.errors = errors; // act as if nothing happened |
1170 #if DMDV2 | |
1171 /* Save scope for later use, to try again | |
1172 */ | |
1173 scope = new Scope(*sc); | |
1174 scope->setNoFree(); | |
1175 #endif | |
1046 } | 1176 } |
1047 else if (ei) | 1177 else if (ei) |
1048 { | 1178 { |
1049 e = e->optimize(WANTvalue | WANTinterpret); | 1179 e = e->optimize(WANTvalue | WANTinterpret); |
1050 if (e->op == TOKint64 || e->op == TOKstring) | 1180 if (e->op == TOKint64 || e->op == TOKstring || e->op == TOKfloat64) |
1051 { | 1181 { |
1052 ei->exp = e; // no errors, keep result | 1182 ei->exp = e; // no errors, keep result |
1053 } | 1183 } |
1184 #if DMDV2 | |
1185 else | |
1186 { | |
1187 /* Save scope for later use, to try again | |
1188 */ | |
1189 scope = new Scope(*sc); | |
1190 scope->setNoFree(); | |
1191 } | |
1192 #endif | |
1054 } | 1193 } |
1055 else | 1194 else |
1056 init = i2; // no errors, keep result | 1195 init = i2; // no errors, keep result |
1057 } | 1196 } |
1058 } | 1197 } |
1129 type->toCBuffer(buf, ident, hgs); | 1268 type->toCBuffer(buf, ident, hgs); |
1130 else | 1269 else |
1131 buf->writestring(ident->toChars()); | 1270 buf->writestring(ident->toChars()); |
1132 if (init) | 1271 if (init) |
1133 { buf->writestring(" = "); | 1272 { buf->writestring(" = "); |
1134 init->toCBuffer(buf, hgs); | 1273 #if DMDV2 |
1274 ExpInitializer *ie = init->isExpInitializer(); | |
1275 if (ie && (ie->exp->op == TOKconstruct || ie->exp->op == TOKblit)) | |
1276 ((AssignExp *)ie->exp)->e2->toCBuffer(buf, hgs); | |
1277 else | |
1278 #endif | |
1279 init->toCBuffer(buf, hgs); | |
1135 } | 1280 } |
1136 buf->writeByte(';'); | 1281 buf->writeByte(';'); |
1137 buf->writenl(); | 1282 buf->writenl(); |
1138 } | 1283 } |
1139 | 1284 |
1208 return (storage_class & (STCstatic | STCconst) || | 1353 return (storage_class & (STCstatic | STCconst) || |
1209 parent->isModule() || | 1354 parent->isModule() || |
1210 parent->isTemplateInstance()); | 1355 parent->isTemplateInstance()); |
1211 } | 1356 } |
1212 | 1357 |
1358 /************************************ | |
1359 * Does symbol go into thread local storage? | |
1360 */ | |
1361 | |
1362 int VarDeclaration::isThreadlocal() | |
1363 { | |
1364 return 0; | |
1365 } | |
1366 | |
1213 int VarDeclaration::hasPointers() | 1367 int VarDeclaration::hasPointers() |
1214 { | 1368 { |
1369 //printf("VarDeclaration::hasPointers() %s, ty = %d\n", toChars(), type->ty); | |
1215 return (!isDataseg() && type->hasPointers()); | 1370 return (!isDataseg() && type->hasPointers()); |
1216 } | 1371 } |
1217 | 1372 |
1218 int VarDeclaration::isSameAsInitializer() | 1373 int VarDeclaration::isSameAsInitializer() |
1219 { | 1374 { |
1226 /****************************************** | 1381 /****************************************** |
1227 * If a variable has an scope destructor call, return call for it. | 1382 * If a variable has an scope destructor call, return call for it. |
1228 * Otherwise, return NULL. | 1383 * Otherwise, return NULL. |
1229 */ | 1384 */ |
1230 | 1385 |
1231 Expression *VarDeclaration::callScopeDtor() | 1386 Expression *VarDeclaration::callScopeDtor(Scope *sc) |
1232 { Expression *e = NULL; | 1387 { Expression *e = NULL; |
1233 | 1388 |
1234 //printf("VarDeclaration::callScopeDtor() %s\n", toChars()); | 1389 //printf("VarDeclaration::callScopeDtor() %s\n", toChars()); |
1235 if (storage_class & STCscope && !noscope) | 1390 if (storage_class & STCscope && !noscope) |
1236 { | 1391 { |
1339 : TypeInfoDeclaration(tinfo, 0) | 1494 : TypeInfoDeclaration(tinfo, 0) |
1340 { | 1495 { |
1341 } | 1496 } |
1342 #endif | 1497 #endif |
1343 | 1498 |
1499 /***************************** TypeInfoSharedDeclaration **********************/ | |
1500 | |
1501 #if DMDV2 | |
1502 TypeInfoSharedDeclaration::TypeInfoSharedDeclaration(Type *tinfo) | |
1503 : TypeInfoDeclaration(tinfo, 0) | |
1504 { | |
1505 } | |
1506 #endif | |
1507 | |
1344 /***************************** TypeInfoStructDeclaration **********************/ | 1508 /***************************** TypeInfoStructDeclaration **********************/ |
1345 | 1509 |
1346 TypeInfoStructDeclaration::TypeInfoStructDeclaration(Type *tinfo) | 1510 TypeInfoStructDeclaration::TypeInfoStructDeclaration(Type *tinfo) |
1347 : TypeInfoDeclaration(tinfo, 0) | 1511 : TypeInfoDeclaration(tinfo, 0) |
1348 { | 1512 { |
1448 { | 1612 { |
1449 this->loc = loc; | 1613 this->loc = loc; |
1450 this->dsym = dsym; | 1614 this->dsym = dsym; |
1451 storage_class |= STCconst; | 1615 storage_class |= STCconst; |
1452 } | 1616 } |
1453 |