Mercurial > projects > ddmd
annotate dmd/BoolExp.d @ 191:52188e7e3fb5
Fixed deprecated features, now compiles with DMD2.058
Also changed Array allocation policy:
Now doesn't reallocate but malloc's, followed by a memcpy (no free).
(this fixes a crash while compiling druntime. Same bug in dmd)
author | korDen@korDen-pc |
---|---|
date | Sun, 25 Mar 2012 03:11:12 +0400 |
parents | b0d41ff5e0df |
children |
rev | line source |
---|---|
72 | 1 module dmd.BoolExp; |
2 | |
114 | 3 import dmd.common; |
72 | 4 import dmd.Expression; |
5 import dmd.backend.elem; | |
6 import dmd.UnaExp; | |
7 import dmd.InterState; | |
8 import dmd.Type; | |
9 import dmd.Loc; | |
10 import dmd.Scope; | |
0 | 11 import dmd.IRState; |
72 | 12 import dmd.TOK; |
0 | 13 |
142 | 14 import dmd.expression.Bool; |
0 | 15 import dmd.backend.OPER; |
16 import dmd.backend.Util; | |
72 | 17 |
187
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
178
diff
changeset
|
18 import dmd.DDMDExtensions; |
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
178
diff
changeset
|
19 |
0 | 20 class BoolExp : UnaExp |
21 { | |
187
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
178
diff
changeset
|
22 mixin insertMemberExtension!(typeof(this)); |
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
178
diff
changeset
|
23 |
0 | 24 this(Loc loc, Expression e, Type t) |
25 { | |
178 | 26 register(); |
27 | |
36 | 28 super(loc, TOKtobool, BoolExp.sizeof, e); |
0 | 29 type = t; |
30 } | |
31 | |
72 | 32 override Expression semantic(Scope sc) |
0 | 33 { |
141 | 34 super.semantic(sc); |
0 | 35 e1 = resolveProperties(sc, e1); |
36 e1 = e1.checkToBoolean(); | |
37 type = Type.tboolean; | |
38 return this; | |
39 } | |
40 | |
72 | 41 override Expression optimize(int result) |
0 | 42 { |
141 | 43 Expression e; |
44 | |
45 e1 = e1.optimize(result); | |
46 if (e1.isConst() == 1) | |
47 { | |
48 e = Bool(type, e1); | |
49 } | |
50 else | |
51 e = this; | |
52 return e; | |
0 | 53 } |
54 | |
72 | 55 override Expression interpret(InterState istate) |
0 | 56 { |
57 assert(false); | |
58 } | |
59 | |
191
52188e7e3fb5
Fixed deprecated features, now compiles with DMD2.058
korDen@korDen-pc
parents:
187
diff
changeset
|
60 override bool isBit() |
0 | 61 { |
62 return true; | |
63 } | |
64 | |
72 | 65 override elem* toElem(IRState* irs) |
0 | 66 { |
67 elem* e1 = this.e1.toElem(irs); | |
68 return el_una(OPbool,type.totym(),e1); | |
69 } | |
70 } | |
71 |