comparison dmd/CmpExp.d @ 79:43073c7c7769

updated to 2.035 also implemented a few missing functions still crashes in Import.importAll though
author Trass3r
date Mon, 30 Aug 2010 03:57:51 +0200
parents 2e2a5c3f943a
children e28b18c23469
comparison
equal deleted inserted replaced
78:b98fa8a4bf04 79:43073c7c7769
36 } 36 }
37 37
38 override Expression semantic(Scope sc) 38 override Expression semantic(Scope sc)
39 { 39 {
40 Expression e; 40 Expression e;
41 Type t1;
42 Type t2;
43 41
44 version (LOGSEMANTIC) { 42 version (LOGSEMANTIC) {
45 printf("CmpExp.semantic('%s')\n", toChars()); 43 printf("CmpExp.semantic('%s')\n", toChars());
46 } 44 }
47 if (type) 45 if (type)
48 return this; 46 return this;
49 47
50 BinExp.semanticp(sc); 48 BinExp.semanticp(sc);
51 49
52 if (e1.type.toBasetype().ty == Tclass && e2.op == TOKnull || 50 Type t1 = e1.type.toBasetype();
53 e2.type.toBasetype().ty == Tclass && e1.op == TOKnull) 51 Type t2 = e2.type.toBasetype();
52 if (t1.ty == Tclass && e2.op == TOKnull ||
53 t2.ty == Tclass && e1.op == TOKnull)
54 { 54 {
55 error("do not use null when comparing class types"); 55 error("do not use null when comparing class types");
56 } 56 }
57 57
58 e = op_overload(sc); 58 e = op_overload(sc);
68 e = new CmpExp(op, loc, e, new IntegerExp(loc, 0, Type.tint32)); 68 e = new CmpExp(op, loc, e, new IntegerExp(loc, 0, Type.tint32));
69 e = e.semantic(sc); 69 e = e.semantic(sc);
70 } 70 }
71 return e; 71 return e;
72 } 72 }
73
74 // Disallow comparing T[]==T and T==T[]
75 if (e1.op == TOKslice && t1.ty == Tarray && e2.implicitConvTo(t1.nextOf()) ||
76 e2.op == TOKslice && t2.ty == Tarray && e1.implicitConvTo(t2.nextOf()))
77 {
78 incompatibleTypes();
79 return new ErrorExp();
80 }
73 81
74 typeCombine(sc); 82 typeCombine(sc);
75 type = Type.tboolean; 83 type = Type.tboolean;
76 84
77 // Special handling for array comparisons 85 // Special handling for array comparisons