Changeset 842
- Timestamp:
- 01/03/11 08:32:46 (14 years ago)
- Files:
-
- branches/dmd-1.x/src/backend/cgen.c (modified) (1 diff)
- branches/dmd-1.x/src/expression.c (modified) (2 diffs)
- branches/dmd-1.x/src/linux.mak (modified) (2 diffs)
- branches/dmd-1.x/src/mtype.c (modified) (3 diffs)
- branches/dmd-1.x/src/mtype.h (modified) (1 diff)
- trunk/src/backend/cgen.c (modified) (1 diff)
- trunk/src/expression.c (modified) (2 diffs)
- trunk/src/linux.mak (modified) (2 diffs)
- trunk/src/mtype.c (modified) (3 diffs)
- trunk/src/mtype.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/dmd-1.x/src/backend/cgen.c
r827 r842 15 15 #include <stdio.h> 16 16 #include <string.h> 17 17 #include <time.h> 18 18 #include "cc.h" 19 19 #include "el.h" 20 20 #include "oper.h" 21 21 #include "code.h" 22 22 #include "type.h" 23 23 #include "global.h" 24 24 25 25 static char __file__[] = __FILE__; /* for tassert.h */ 26 26 #include "tassert.h" 27 27 28 28 /************************************* 29 29 * Handy function to answer the question: who the heck is generating this piece of code? 30 30 */ 31 31 inline void ccheck(code *cs) 32 32 { 33 33 // if (cs->Iop == LEA && (cs->Irm & 0x3F) == 0x34 && cs->Isib == 7) *(char*)0=0; 34 34 // if (cs->Iop == 0x31) *(char*)0=0; 35 // if (cs->Iop == 0xF6 && cs->Irm == 0xD6) *(char*)0=0; 35 36 } 36 37 37 38 /***************************** 38 39 * Find last code in list. 39 40 */ 40 41 41 42 code *code_last(code *c) 42 43 { 43 44 if (c) 44 45 { while (c->next) 45 46 c = c->next; 46 47 } 47 48 return c; 48 49 } 49 50 50 51 /***************************** 51 52 * Set flag bits on last code in list. 52 53 */ 53 54 54 55 void code_orflag(code *c,unsigned flag) branches/dmd-1.x/src/expression.c
r798 r842 3935 3935 return 0; 3936 3936 } 3937 3937 3938 3938 Expression *VarExp::semantic(Scope *sc) 3939 3939 { FuncLiteralDeclaration *fd; 3940 3940 3941 3941 #if LOGSEMANTIC 3942 3942 printf("VarExp::semantic(%s)\n", toChars()); 3943 3943 #endif 3944 3944 if (!type) 3945 3945 { type = var->type; 3946 3946 #if 0 3947 3947 if (var->storage_class & STClazy) 3948 3948 { 3949 3949 TypeFunction *tf = new TypeFunction(NULL, type, 0, LINKd); 3950 3950 type = new TypeDelegate(tf); 3951 3951 type = type->semantic(loc, sc); 3952 3952 } 3953 3953 #endif 3954 3954 } 3955 3956 if (type && !type->deco) 3957 type = type->semantic(loc, sc); 3955 3958 3956 3959 /* Fix for 1161 doesn't work because it causes protection 3957 3960 * problems when instantiating imported templates passing private 3958 3961 * variables as alias template parameters. 3959 3962 */ 3960 3963 //accessCheck(loc, sc, NULL, var); 3961 3964 3962 3965 VarDeclaration *v = var->isVarDeclaration(); 3963 3966 if (v) 3964 3967 { 3965 3968 if (v->isConst() && v->type && type->toBasetype()->ty != Tsarray && v->init) 3966 3969 { 3967 3970 ExpInitializer *ei = v->init->isExpInitializer(); 3968 3971 if (ei && ei->exp->type) 3969 3972 { 3970 3973 //ei->exp->implicitCastTo(sc, type)->print(); 3971 3974 return ei->exp->implicitCastTo(sc, type); 3972 3975 } 3973 3976 } 3974 3977 v->checkNestedReference(sc, loc); … … 5515 5518 e = type->defaultInit(); 5516 5519 e->loc = loc; 5517 5520 return e; 5518 5521 } 5519 5522 } 5520 5523 if (v->needThis()) 5521 5524 { 5522 5525 if (!eleft) 5523 5526 eleft = new ThisExp(loc); 5524 5527 e = new DotVarExp(loc, eleft, v); 5525 5528 e = e->semantic(sc); 5526 5529 } 5527 5530 else 5528 5531 { 5529 5532 e = new VarExp(loc, v); 5530 5533 if (eleft) 5531 5534 { e = new CommaExp(loc, eleft, e); 5532 5535 e->type = v->type; 5533 5536 } 5534 5537 } 5535 return e->deref(); 5538 e = e->deref(); 5539 return e->semantic(sc); 5536 5540 } 5537 5541 5538 5542 FuncDeclaration *f = s->isFuncDeclaration(); 5539 5543 if (f) 5540 5544 { 5541 5545 //printf("it's a function\n"); 5542 5546 if (f->needThis()) 5543 5547 { 5544 5548 if (!eleft) 5545 5549 eleft = new ThisExp(loc); 5546 5550 e = new DotVarExp(loc, eleft, f); 5547 5551 e = e->semantic(sc); 5548 5552 } 5549 5553 else 5550 5554 { 5551 5555 e = new VarExp(loc, f); 5552 5556 if (eleft) 5553 5557 { e = new CommaExp(loc, eleft, e); 5554 5558 e->type = f->type; 5555 5559 } branches/dmd-1.x/src/linux.mak
r840 r842 77 77 $C/type.c $C/melf.h $C/mach.h $C/bcomplex.h \ 78 78 $C/cdeflnx.h $C/outbuf.h $C/token.h $C/tassert.h \ 79 79 $C/elfobj.c $C/cv4.h $C/dwarf2.h $C/cpp.h $C/exh.h $C/go.h \ 80 80 $C/dwarf.c $C/dwarf.h $C/aa.h $C/aa.c $C/tinfo.h $C/ti_achar.c \ 81 81 $C/machobj.c \ 82 82 $(TK)/filespec.h $(TK)/mem.h $(TK)/list.h $(TK)/vec.h \ 83 83 $(TK)/filespec.c $(TK)/mem.c $(TK)/vec.c $(TK)/list.c \ 84 84 $(ROOT)/dchar.h $(ROOT)/dchar.c $(ROOT)/lstring.h \ 85 85 $(ROOT)/lstring.c $(ROOT)/root.h $(ROOT)/root.c $(ROOT)/array.c \ 86 86 $(ROOT)/rmem.h $(ROOT)/rmem.c $(ROOT)/port.h $(ROOT)/port.c \ 87 87 $(ROOT)/gnuc.h $(ROOT)/gnuc.c $(ROOT)/man.c \ 88 88 $(ROOT)/stringtable.h $(ROOT)/stringtable.c \ 89 89 $(ROOT)/response.c $(ROOT)/async.h $(ROOT)/async.c \ 90 90 $(ROOT)/aav.h $(ROOT)/aav.c \ 91 91 $(ROOT)/speller.h $(ROOT)/speller.c 92 92 93 93 94 94 all: dmd 95 95 96 96 dmd: $(DMD_OBJS) 97 $(CC) -lstdc++ -lpthread $(COV) $(DMD_OBJS) -o dmd97 gcc $(MODEL) -lstdc++ -lpthread $(COV) $(DMD_OBJS) -o dmd 98 98 99 99 clean: 100 100 rm -f $(DMD_OBJS) dmd optab.o id.o impcnvgen idgen id.c id.h \ 101 101 impcnvtab.c optabgen debtab.c optab.c cdxxx.c elxxx.c fltables.c \ 102 102 tytab.c core \ 103 103 *.cov *.gcda *.gcno 104 104 105 105 ######## optabgen generates some source 106 106 107 107 optabgen: $C/optabgen.c $C/cc.h $C/oper.h 108 108 $(CC) $(MFLAGS) $< -o optabgen 109 109 ./optabgen 110 110 111 111 optabgen_output = debtab.c optab.c cdxxx.c elxxx.c fltables.c tytab.c 112 112 $(optabgen_output) : optabgen 113 113 114 114 ######## idgen generates some source 115 115 116 116 idgen_output = id.h id.c 117 117 $(idgen_output) : idgen … … 450 450 451 451 s2ir.o : $C/rtlsym.h statement.h s2ir.c 452 452 $(CC) -c -I$(ROOT) $(MFLAGS) s2ir.c 453 453 454 454 scope.o: scope.c 455 455 $(CC) -c $(CFLAGS) $< 456 456 457 457 speller.o: $(ROOT)/speller.c 458 458 $(CC) -c $(GFLAGS) -I$(ROOT) $< 459 459 460 460 statement.o: statement.c 461 461 $(CC) -c $(CFLAGS) $< 462 462 463 463 staticassert.o: staticassert.h staticassert.c 464 464 $(CC) -c $(CFLAGS) staticassert.c 465 465 466 466 stringtable.o: $(ROOT)/stringtable.c 467 467 $(CC) -c $(GFLAGS) -I$(ROOT) $< 468 468 469 469 strtold.o: $C/strtold.c 470 $(CC) -c $C/strtold.c470 gcc $(MODEL) -c $C/strtold.c 471 471 472 472 struct.o: struct.c 473 473 $(CC) -c $(CFLAGS) $< 474 474 475 475 template.o: template.c 476 476 $(CC) -c $(CFLAGS) $< 477 477 478 478 ti_achar.o: $C/tinfo.h $C/ti_achar.c 479 479 $(CC) -c $(MFLAGS) -I. $C/ti_achar.c 480 480 481 481 tk.o: tk.c 482 482 $(CC) -c $(MFLAGS) tk.c 483 483 484 484 tocsym.o: $(CH) $(TOTALH) mars.h module.h tocsym.c 485 485 $(CC) -c $(MFLAGS) -I$(ROOT) tocsym.c 486 486 487 487 toctype.o: $(CH) $(TOTALH) $C/rtlsym.h mars.h module.h toctype.c 488 488 $(CC) -c $(MFLAGS) -I$(ROOT) toctype.c 489 489 490 490 todt.o : mtype.h expression.h $C/dt.h todt.c branches/dmd-1.x/src/mtype.c
r828 r842 3735 3735 global.gag--; 3736 3736 if (errors != global.errors) 3737 3737 { if (global.gag == 0) 3738 3738 global.errors = errors; 3739 3739 return NULL; 3740 3740 } 3741 3741 } 3742 3742 else 3743 3743 resolve(loc, sc, &e, &t, &s); 3744 3744 3745 3745 return s; 3746 3746 } 3747 3747 3748 3748 3749 3749 /***************************** TypeTypeof *****************************/ 3750 3750 3751 3751 TypeTypeof::TypeTypeof(Loc loc, Expression *exp) 3752 3752 : TypeQualified(Ttypeof, loc) 3753 3753 { 3754 3754 this->exp = exp; 3755 inuse = 0; 3755 3756 } 3756 3757 3757 3758 Type *TypeTypeof::syntaxCopy() 3758 3759 { 3759 3760 //printf("TypeTypeof::syntaxCopy() %s\n", toChars()); 3760 3761 TypeTypeof *t; 3761 3762 3762 3763 t = new TypeTypeof(loc, exp->syntaxCopy()); 3763 3764 t->syntaxCopyHelper(this); 3764 3765 return t; 3765 3766 } 3766 3767 3767 3768 Dsymbol *TypeTypeof::toDsymbol(Scope *sc) 3768 3769 { 3769 3770 Type *t; 3770 3771 3771 3772 t = semantic(loc, sc); 3772 3773 if (t == this) 3773 3774 return NULL; 3774 3775 return t->toDsymbol(sc); … … 3781 3782 return; 3782 3783 } 3783 3784 buf->writestring("typeof("); 3784 3785 exp->toCBuffer(buf, hgs); 3785 3786 buf->writeByte(')'); 3786 3787 toCBuffer2Helper(buf, hgs); 3787 3788 } 3788 3789 3789 3790 void TypeTypeof::toDecoBuffer(OutBuffer *buf) 3790 3791 { 3791 3792 assert(0); 3792 3793 } 3793 3794 3794 3795 Type *TypeTypeof::semantic(Loc loc, Scope *sc) 3795 3796 { Expression *e; 3796 3797 Type *t; 3797 3798 3798 3799 //printf("TypeTypeof::semantic() %p\n", this); 3799 3800 3800 3801 //static int nest; if (++nest == 50) *(char*)0=0; 3802 if (inuse) 3803 { 3804 inuse = 2; 3805 error(loc, "circular typeof definition"); 3806 return Type::terror; 3807 } 3808 inuse++; 3801 3809 3802 3810 #if 0 3803 3811 /* Special case for typeof(this) and typeof(super) since both 3804 3812 * should work even if they are not inside a non-static member function 3805 3813 */ 3806 3814 if (exp->op == TOKthis || exp->op == TOKsuper) 3807 3815 { 3808 3816 // Find enclosing struct or class 3809 3817 for (Dsymbol *s = sc->parent; 1; s = s->parent) 3810 3818 { 3811 3819 ClassDeclaration *cd; 3812 3820 StructDeclaration *sd; 3813 3821 3814 3822 if (!s) 3815 3823 { 3816 3824 error(loc, "%s is not in a struct or class scope", exp->toChars()); 3817 3825 goto Lerr; 3818 3826 } 3819 3827 cd = s->isClassDeclaration(); 3820 3828 if (cd) … … 3877 3885 for (size_t i = 0; i < idents.dim; i++) 3878 3886 { 3879 3887 if (!s) 3880 3888 break; 3881 3889 Identifier *id = (Identifier *)idents.data[i]; 3882 3890 s = s->searchX(loc, sc, id); 3883 3891 } 3884 3892 if (s) 3885 3893 { 3886 3894 t = s->getType(); 3887 3895 if (!t) 3888 3896 { error(loc, "%s is not a type", s->toChars()); 3889 3897 goto Lerr; 3890 3898 } 3891 3899 } 3892 3900 else 3893 3901 { error(loc, "cannot resolve .property for %s", toChars()); 3894 3902 goto Lerr; 3895 3903 } 3896 3904 } 3905 inuse--; 3897 3906 return t; 3898 3907 3899 3908 Lerr: 3909 inuse--; 3900 3910 return terror; 3901 3911 } 3902 3912 3903 3913 d_uns64 TypeTypeof::size(Loc loc) 3904 3914 { 3905 3915 if (exp->type) 3906 3916 return exp->type->size(loc); 3907 3917 else 3908 3918 return TypeQualified::size(loc); 3909 3919 } 3910 3920 3911 3921 3912 3922 3913 3923 /***************************** TypeEnum *****************************/ 3914 3924 3915 3925 TypeEnum::TypeEnum(EnumDeclaration *sym) 3916 3926 : Type(Tenum, NULL) 3917 3927 { 3918 3928 this->sym = sym; 3919 3929 } branches/dmd-1.x/src/mtype.h
r768 r842 540 540 /* Similar to TypeIdentifier, but with a TemplateInstance as the root 541 541 */ 542 542 struct TypeInstance : TypeQualified 543 543 { 544 544 TemplateInstance *tempinst; 545 545 546 546 TypeInstance(Loc loc, TemplateInstance *tempinst); 547 547 Type *syntaxCopy(); 548 548 //char *toChars(); 549 549 //void toDecoBuffer(OutBuffer *buf); 550 550 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod); 551 551 void resolve(Loc loc, Scope *sc, Expression **pe, Type **pt, Dsymbol **ps); 552 552 Type *semantic(Loc loc, Scope *sc); 553 553 Dsymbol *toDsymbol(Scope *sc); 554 554 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes); 555 555 }; 556 556 557 557 struct TypeTypeof : TypeQualified 558 558 { 559 559 Expression *exp; 560 int inuse; 560 561 561 562 TypeTypeof(Loc loc, Expression *exp); 562 563 Type *syntaxCopy(); 563 564 Dsymbol *toDsymbol(Scope *sc); 564 565 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod); 565 566 void toDecoBuffer(OutBuffer *buf); 566 567 Type *semantic(Loc loc, Scope *sc); 567 568 d_uns64 size(Loc loc); 568 569 }; 569 570 570 571 struct TypeStruct : Type 571 572 { 572 573 StructDeclaration *sym; 573 574 574 575 TypeStruct(StructDeclaration *sym); 575 576 d_uns64 size(Loc loc); 576 577 unsigned alignsize(); 577 578 char *toChars(); 578 579 Type *syntaxCopy(); 579 580 Type *semantic(Loc loc, Scope *sc); trunk/src/backend/cgen.c
r827 r842 15 15 #include <stdio.h> 16 16 #include <string.h> 17 17 #include <time.h> 18 18 #include "cc.h" 19 19 #include "el.h" 20 20 #include "oper.h" 21 21 #include "code.h" 22 22 #include "type.h" 23 23 #include "global.h" 24 24 25 25 static char __file__[] = __FILE__; /* for tassert.h */ 26 26 #include "tassert.h" 27 27 28 28 /************************************* 29 29 * Handy function to answer the question: who the heck is generating this piece of code? 30 30 */ 31 31 inline void ccheck(code *cs) 32 32 { 33 33 // if (cs->Iop == LEA && (cs->Irm & 0x3F) == 0x34 && cs->Isib == 7) *(char*)0=0; 34 34 // if (cs->Iop == 0x31) *(char*)0=0; 35 // if (cs->Iop == 0xF6 && cs->Irm == 0xD6) *(char*)0=0; 35 36 } 36 37 37 38 /***************************** 38 39 * Find last code in list. 39 40 */ 40 41 41 42 code *code_last(code *c) 42 43 { 43 44 if (c) 44 45 { while (c->next) 45 46 c = c->next; 46 47 } 47 48 return c; 48 49 } 49 50 50 51 /***************************** 51 52 * Set flag bits on last code in list. 52 53 */ 53 54 54 55 void code_orflag(code *c,unsigned flag) trunk/src/expression.c
r812 r842 4216 4216 Expression *VarExp::semantic(Scope *sc) 4217 4217 { FuncLiteralDeclaration *fd; 4218 4218 4219 4219 #if LOGSEMANTIC 4220 4220 printf("VarExp::semantic(%s)\n", toChars()); 4221 4221 #endif 4222 4222 // if (var->sem == SemanticStart && var->scope) // if forward referenced 4223 4223 // var->semantic(sc); 4224 4224 if (!type) 4225 4225 { type = var->type; 4226 4226 #if 0 4227 4227 if (var->storage_class & STClazy) 4228 4228 { 4229 4229 TypeFunction *tf = new TypeFunction(NULL, type, 0, LINKd); 4230 4230 type = new TypeDelegate(tf); 4231 4231 type = type->semantic(loc, sc); 4232 4232 } 4233 4233 #endif 4234 4234 } 4235 4235 4236 if (type && !type->deco) 4237 type = type->semantic(loc, sc); 4238 4236 4239 /* Fix for 1161 doesn't work because it causes protection 4237 4240 * problems when instantiating imported templates passing private 4238 4241 * variables as alias template parameters. 4239 4242 */ 4240 4243 //accessCheck(loc, sc, NULL, var); 4241 4244 4242 4245 VarDeclaration *v = var->isVarDeclaration(); 4243 4246 if (v) 4244 4247 { 4245 4248 #if 0 4246 4249 if ((v->isConst() || v->isImmutable()) && 4247 4250 type->toBasetype()->ty != Tsarray && v->init) 4248 4251 { 4249 4252 ExpInitializer *ei = v->init->isExpInitializer(); 4250 4253 if (ei) 4251 4254 { 4252 4255 //ei->exp->implicitCastTo(sc, type)->print(); 4253 4256 return ei->exp->implicitCastTo(sc, type); 4254 4257 } 4255 4258 } … … 5940 5943 { 5941 5944 error("circular reference to '%s'", v->toChars()); 5942 5945 return new ErrorExp(); 5943 5946 } 5944 5947 type = v->type; 5945 5948 if (v->needThis()) 5946 5949 { 5947 5950 if (!eleft) 5948 5951 eleft = new ThisExp(loc); 5949 5952 e = new DotVarExp(loc, eleft, v); 5950 5953 e = e->semantic(sc); 5951 5954 } 5952 5955 else 5953 5956 { 5954 5957 e = new VarExp(loc, v); 5955 5958 if (eleft) 5956 5959 { e = new CommaExp(loc, eleft, e); 5957 5960 e->type = v->type; 5958 5961 } 5959 5962 } 5960 return e->deref(); 5963 e = e->deref(); 5964 return e->semantic(sc); 5961 5965 } 5962 5966 5963 5967 FuncDeclaration *f = s->isFuncDeclaration(); 5964 5968 if (f) 5965 5969 { 5966 5970 //printf("it's a function\n"); 5967 5971 if (f->needThis()) 5968 5972 { 5969 5973 if (!eleft) 5970 5974 eleft = new ThisExp(loc); 5971 5975 e = new DotVarExp(loc, eleft, f); 5972 5976 e = e->semantic(sc); 5973 5977 } 5974 5978 else 5975 5979 { 5976 5980 e = new VarExp(loc, f, 1); 5977 5981 if (eleft) 5978 5982 { e = new CommaExp(loc, eleft, e); 5979 5983 e->type = f->type; 5980 5984 } trunk/src/linux.mak
r840 r842 77 77 $C/type.c $C/melf.h $C/mach.h $C/bcomplex.h \ 78 78 $C/cdeflnx.h $C/outbuf.h $C/token.h $C/tassert.h \ 79 79 $C/elfobj.c $C/cv4.h $C/dwarf2.h $C/cpp.h $C/exh.h $C/go.h \ 80 80 $C/dwarf.c $C/dwarf.h $C/aa.h $C/aa.c $C/tinfo.h $C/ti_achar.c \ 81 81 $C/machobj.c \ 82 82 $(TK)/filespec.h $(TK)/mem.h $(TK)/list.h $(TK)/vec.h \ 83 83 $(TK)/filespec.c $(TK)/mem.c $(TK)/vec.c $(TK)/list.c \ 84 84 $(ROOT)/dchar.h $(ROOT)/dchar.c $(ROOT)/lstring.h \ 85 85 $(ROOT)/lstring.c $(ROOT)/root.h $(ROOT)/root.c $(ROOT)/array.c \ 86 86 $(ROOT)/rmem.h $(ROOT)/rmem.c $(ROOT)/port.h $(ROOT)/port.c \ 87 87 $(ROOT)/gnuc.h $(ROOT)/gnuc.c $(ROOT)/man.c \ 88 88 $(ROOT)/stringtable.h $(ROOT)/stringtable.c \ 89 89 $(ROOT)/response.c $(ROOT)/async.h $(ROOT)/async.c \ 90 90 $(ROOT)/aav.h $(ROOT)/aav.c \ 91 91 $(ROOT)/speller.h $(ROOT)/speller.c 92 92 93 93 94 94 all: dmd 95 95 96 96 dmd: $(DMD_OBJS) 97 $(CC) -lstdc++ -lpthread $(COV) $(DMD_OBJS) -o dmd97 gcc $(MODEL) -lstdc++ -lpthread $(COV) $(DMD_OBJS) -o dmd 98 98 99 99 clean: 100 100 rm -f $(DMD_OBJS) dmd optab.o id.o impcnvgen idgen id.c id.h \ 101 101 impcnvtab.c optabgen debtab.c optab.c cdxxx.c elxxx.c fltables.c \ 102 102 tytab.c core \ 103 103 *.cov *.gcda *.gcno 104 104 105 105 ######## optabgen generates some source 106 106 107 107 optabgen: $C/optabgen.c $C/cc.h $C/oper.h 108 108 $(CC) $(MFLAGS) $< -o optabgen 109 109 ./optabgen 110 110 111 111 optabgen_output = debtab.c optab.c cdxxx.c elxxx.c fltables.c tytab.c 112 112 $(optabgen_output) : optabgen 113 113 114 114 ######## idgen generates some source 115 115 116 116 idgen_output = id.h id.c 117 117 $(idgen_output) : idgen … … 450 450 451 451 s2ir.o : $C/rtlsym.h statement.h s2ir.c 452 452 $(CC) -c -I$(ROOT) $(MFLAGS) s2ir.c 453 453 454 454 scope.o: scope.c 455 455 $(CC) -c $(CFLAGS) $< 456 456 457 457 speller.o: $(ROOT)/speller.c 458 458 $(CC) -c $(GFLAGS) -I$(ROOT) $< 459 459 460 460 statement.o: statement.c 461 461 $(CC) -c $(CFLAGS) $< 462 462 463 463 staticassert.o: staticassert.h staticassert.c 464 464 $(CC) -c $(CFLAGS) staticassert.c 465 465 466 466 stringtable.o: $(ROOT)/stringtable.c 467 467 $(CC) -c $(GFLAGS) -I$(ROOT) $< 468 468 469 469 strtold.o: $C/strtold.c 470 $(CC) -c $C/strtold.c470 gcc $(MODEL) -c $C/strtold.c 471 471 472 472 struct.o: struct.c 473 473 $(CC) -c $(CFLAGS) $< 474 474 475 475 template.o: template.c 476 476 $(CC) -c $(CFLAGS) $< 477 477 478 478 ti_achar.o: $C/tinfo.h $C/ti_achar.c 479 479 $(CC) -c $(MFLAGS) -I. $C/ti_achar.c 480 480 481 481 tk.o: tk.c 482 482 $(CC) -c $(MFLAGS) tk.c 483 483 484 484 tocsym.o: $(CH) $(TOTALH) mars.h module.h tocsym.c 485 485 $(CC) -c $(MFLAGS) -I$(ROOT) tocsym.c 486 486 487 487 toctype.o: $(CH) $(TOTALH) $C/rtlsym.h mars.h module.h toctype.c 488 488 $(CC) -c $(MFLAGS) -I$(ROOT) toctype.c 489 489 490 490 todt.o : mtype.h expression.h $C/dt.h todt.c trunk/src/mtype.c
r818 r842 5963 5963 global.gag--; 5964 5964 if (errors != global.errors) 5965 5965 { if (global.gag == 0) 5966 5966 global.errors = errors; 5967 5967 return NULL; 5968 5968 } 5969 5969 } 5970 5970 else 5971 5971 resolve(loc, sc, &e, &t, &s); 5972 5972 5973 5973 return s; 5974 5974 } 5975 5975 5976 5976 5977 5977 /***************************** TypeTypeof *****************************/ 5978 5978 5979 5979 TypeTypeof::TypeTypeof(Loc loc, Expression *exp) 5980 5980 : TypeQualified(Ttypeof, loc) 5981 5981 { 5982 5982 this->exp = exp; 5983 inuse = 0; 5983 5984 } 5984 5985 5985 5986 Type *TypeTypeof::syntaxCopy() 5986 5987 { 5987 5988 //printf("TypeTypeof::syntaxCopy() %s\n", toChars()); 5988 5989 TypeTypeof *t; 5989 5990 5990 5991 t = new TypeTypeof(loc, exp->syntaxCopy()); 5991 5992 t->syntaxCopyHelper(this); 5992 5993 t->mod = mod; 5993 5994 return t; 5994 5995 } 5995 5996 5996 5997 Dsymbol *TypeTypeof::toDsymbol(Scope *sc) 5997 5998 { 5998 5999 Type *t; 5999 6000 6000 6001 t = semantic(loc, sc); 6001 6002 if (t == this) 6002 6003 return NULL; … … 6005 6006 6006 6007 void TypeTypeof::toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod) 6007 6008 { 6008 6009 if (mod != this->mod) 6009 6010 { toCBuffer3(buf, hgs, mod); 6010 6011 return; 6011 6012 } 6012 6013 buf->writestring("typeof("); 6013 6014 exp->toCBuffer(buf, hgs); 6014 6015 buf->writeByte(')'); 6015 6016 toCBuffer2Helper(buf, hgs); 6016 6017 } 6017 6018 6018 6019 Type *TypeTypeof::semantic(Loc loc, Scope *sc) 6019 6020 { Expression *e; 6020 6021 Type *t; 6021 6022 6022 6023 //printf("TypeTypeof::semantic() %s\n", toChars()); 6023 6024 6024 6025 //static int nest; if (++nest == 50) *(char*)0=0; 6026 if (inuse) 6027 { 6028 inuse = 2; 6029 error(loc, "circular typeof definition"); 6030 return Type::terror; 6031 } 6032 inuse++; 6025 6033 6026 6034 #if 0 6027 6035 /* Special case for typeof(this) and typeof(super) since both 6028 6036 * should work even if they are not inside a non-static member function 6029 6037 */ 6030 6038 if (exp->op == TOKthis || exp->op == TOKsuper) 6031 6039 { 6032 6040 // Find enclosing struct or class 6033 6041 for (Dsymbol *s = sc->parent; 1; s = s->parent) 6034 6042 { 6035 6043 ClassDeclaration *cd; 6036 6044 StructDeclaration *sd; 6037 6045 6038 6046 if (!s) 6039 6047 { 6040 6048 error(loc, "%s is not in a struct or class scope", exp->toChars()); 6041 6049 goto Lerr; 6042 6050 } 6043 6051 cd = s->isClassDeclaration(); 6044 6052 if (cd) … … 6107 6115 { 6108 6116 if (!s) 6109 6117 break; 6110 6118 Identifier *id = (Identifier *)idents.data[i]; 6111 6119 s = s->searchX(loc, sc, id); 6112 6120 } 6113 6121 6114 6122 if (s) 6115 6123 { 6116 6124 t = s->getType(); 6117 6125 if (!t) 6118 6126 { error(loc, "%s is not a type", s->toChars()); 6119 6127 goto Lerr; 6120 6128 } 6121 6129 } 6122 6130 else 6123 6131 { error(loc, "cannot resolve .property for %s", toChars()); 6124 6132 goto Lerr; 6125 6133 } 6126 6134 } 6135 inuse--; 6127 6136 return t; 6128 6137 6129 6138 Lerr: 6139 inuse--; 6130 6140 return terror; 6131 6141 } 6132 6142 6133 6143 d_uns64 TypeTypeof::size(Loc loc) 6134 6144 { 6135 6145 if (exp->type) 6136 6146 return exp->type->size(loc); 6137 6147 else 6138 6148 return TypeQualified::size(loc); 6139 6149 } 6140 6150 6141 6151 6142 6152 6143 6153 /***************************** TypeReturn *****************************/ 6144 6154 6145 6155 TypeReturn::TypeReturn(Loc loc) 6146 6156 : TypeQualified(Treturn, loc) 6147 6157 { 6148 6158 } 6149 6159 trunk/src/mtype.h
r769 r842 660 660 /* Similar to TypeIdentifier, but with a TemplateInstance as the root 661 661 */ 662 662 struct TypeInstance : TypeQualified 663 663 { 664 664 TemplateInstance *tempinst; 665 665 666 666 TypeInstance(Loc loc, TemplateInstance *tempinst); 667 667 Type *syntaxCopy(); 668 668 //char *toChars(); 669 669 //void toDecoBuffer(OutBuffer *buf, int flag); 670 670 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod); 671 671 void resolve(Loc loc, Scope *sc, Expression **pe, Type **pt, Dsymbol **ps); 672 672 Type *semantic(Loc loc, Scope *sc); 673 673 Dsymbol *toDsymbol(Scope *sc); 674 674 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes); 675 675 }; 676 676 677 677 struct TypeTypeof : TypeQualified 678 678 { 679 679 Expression *exp; 680 int inuse; 680 681 681 682 TypeTypeof(Loc loc, Expression *exp); 682 683 Type *syntaxCopy(); 683 684 Dsymbol *toDsymbol(Scope *sc); 684 685 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod); 685 686 Type *semantic(Loc loc, Scope *sc); 686 687 d_uns64 size(Loc loc); 687 688 }; 688 689 689 690 struct TypeReturn : TypeQualified 690 691 { 691 692 TypeReturn(Loc loc); 692 693 Type *syntaxCopy(); 693 694 Dsymbol *toDsymbol(Scope *sc); 694 695 Type *semantic(Loc loc, Scope *sc); 695 696 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod); 696 697 }; 697 698 698 699 struct TypeStruct : Type 699 700 {
