comparison dmd/StructDeclaration.d @ 131:206db751bd4c

dmdfe 2.037 compiles now
author Eldar Insafutdinov <e.insafutdinov@gmail.com>
date Fri, 10 Sep 2010 00:27:37 +0100
parents 60bb0fe4563e
children af1bebfd96a4
comparison
equal deleted inserted replaced
130:60bb0fe4563e 131:206db751bd4c
51 import dmd.VarDeclaration; 51 import dmd.VarDeclaration;
52 import dmd.InvariantDeclaration; 52 import dmd.InvariantDeclaration;
53 import dmd.NewDeclaration; 53 import dmd.NewDeclaration;
54 import dmd.DeleteDeclaration; 54 import dmd.DeleteDeclaration;
55 import dmd.Global; 55 import dmd.Global;
56 import dmd.MOD;
57 import dmd.IntegerExp;
58 import dmd.EqualExp;
59 import dmd.AndAndExp;
56 60
57 import dmd.backend.dt_t; 61 import dmd.backend.dt_t;
58 import dmd.backend.Util; 62 import dmd.backend.Util;
59 import dmd.backend.SC; 63 import dmd.backend.SC;
60 import dmd.backend.DT; 64 import dmd.backend.DT;
298 } 302 }
299 } 303 }
300 version (DMDV2) { 304 version (DMDV2) {
301 /* Try to find the opEquals function. Build it if necessary. 305 /* Try to find the opEquals function. Build it if necessary.
302 */ 306 */
303 TypeFunction *tfeqptr; 307 TypeFunction tfeqptr;
304 { // bool opEquals(const T*) const; 308 { // bool opEquals(const T*) const;
305 auto parameters = new Parameters; 309 auto parameters = new Parameters;
306 version(STRUCTTHISREF) { 310 version(STRUCTTHISREF) {
307 // bool opEquals(ref const T) const; 311 // bool opEquals(ref const T) const;
308 auto param = new Parameter(STC.STCref, type.constOf(), null, null); 312 auto param = new Parameter(STC.STCref, type.constOf(), null, null);
312 } 316 }
313 317
314 parameters.push(param); 318 parameters.push(param);
315 tfeqptr = new TypeFunction(parameters, Type.tbool, 0, LINK.LINKd); 319 tfeqptr = new TypeFunction(parameters, Type.tbool, 0, LINK.LINKd);
316 tfeqptr.mod = MOD.MODconst; 320 tfeqptr.mod = MOD.MODconst;
317 tfeqptr = cast(TypeFunction)(tfeqptr.semantic(0, sc2)); 321 tfeqptr = cast(TypeFunction)(tfeqptr.semantic(Loc(0), sc2));
318 322
319 Dsymbol s = search_function(this, Id.eq); 323 Dsymbol s = search_function(this, Id.eq);
320 FuncDeclaration fdx = s ? s.isFuncDeclaration() : null; 324 FuncDeclaration fdx = s ? s.isFuncDeclaration() : null;
321 if (fdx) 325 if (fdx)
322 { 326 {
642 Loc loc = this.loc; 646 Loc loc = this.loc;
643 647
644 auto parameters = new Parameters; 648 auto parameters = new Parameters;
645 version (STRUCTTHISREF) { 649 version (STRUCTTHISREF) {
646 // bool opEquals(ref const T) const; 650 // bool opEquals(ref const T) const;
647 auto param = new Parameter(STC.STCref, type.constOf(), Id.p, NULL); 651 auto param = new Parameter(STC.STCref, type.constOf(), Id.p, null);
648 } else { 652 } else {
649 // bool opEquals(const T*) const; 653 // bool opEquals(const T*) const;
650 auto param = new Parameter(STC.STCin, type.pointerTo(), Id.p, NULL); 654 auto param = new Parameter(STC.STCin, type.pointerTo(), Id.p, null);
651 } 655 }
652 656
653 parameters.push(param); 657 parameters.push(param);
654 auto ftype = new TypeFunction(parameters, Type.tbool, 0, LINKd); 658 auto ftype = new TypeFunction(parameters, Type.tbool, 0, LINKd);
655 ftype.mod = MOD.MODconst; 659 ftype.mod = MOD.MODconst;
656 ftype = cast(TypeFunction)ftype.semantic(loc, sc); 660 ftype = cast(TypeFunction)ftype.semantic(loc, sc);
657 661
658 auto fop = new FuncDeclaration(loc, 0, Id.eq, STD.STCundefined, ftype); 662 auto fop = new FuncDeclaration(loc, Loc(0), Id.eq, STC.STCundefined, ftype);
659 663
660 Expression *e = NULL; 664 Expression e = null;
661 /* Do memberwise compare 665 /* Do memberwise compare
662 */ 666 */
663 //printf("\tmemberwise compare\n"); 667 //printf("\tmemberwise compare\n");
664 foreach (s; fields) 668 foreach (s; fields)
665 { 669 {
666 VarDeclaration v = s.isVarDeclaration(); 670 VarDeclaration v = s.isVarDeclaration();
667 assert(v && v.storage_class & STD.STCfield); 671 assert(v && v.storage_class & STC.STCfield);
668 if (v.storage_class & STC.STCref) 672 if (v.storage_class & STC.STCref)
669 assert(0); // what should we do with this? 673 assert(0); // what should we do with this?
670 // this.v == s.v; 674 // this.v == s.v;
671 auto ec = new EqualExp(TOKequal, loc, 675 auto ec = new EqualExp(TOKequal, loc,
672 new DotVarExp(loc, new ThisExp(loc), v, 0), 676 new DotVarExp(loc, new ThisExp(loc), v, 0),