Mercurial > projects > ddmd
annotate dmd/NotExp.d @ 187:b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
author | Abscissa |
---|---|
date | Tue, 07 Jun 2011 23:37:34 -0400 |
parents | e3afd1303184 |
children | 52188e7e3fb5 |
rev | line source |
---|---|
72 | 1 module dmd.NotExp; |
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.Loc; | |
9 import dmd.Scope; | |
10 import dmd.IRState; | |
0 | 11 import dmd.TOK; |
12 import dmd.Type; | |
13 | |
14 import dmd.expression.Not; | |
15 | |
16 import dmd.backend.OPER; | |
72 | 17 import dmd.backend.Util; |
18 | |
187
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
178
diff
changeset
|
19 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
|
20 |
0 | 21 class NotExp : UnaExp |
22 { | |
187
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
178
diff
changeset
|
23 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
|
24 |
0 | 25 this(Loc loc, Expression e) |
26 { | |
178 | 27 register(); |
0 | 28 super(loc, TOK.TOKnot, NotExp.sizeof, e); |
29 } | |
30 | |
72 | 31 override Expression semantic(Scope sc) |
0 | 32 { |
33 UnaExp.semantic(sc); | |
34 e1 = resolveProperties(sc, e1); | |
35 e1 = e1.checkToBoolean(); | |
36 type = Type.tboolean; | |
37 return this; | |
38 } | |
39 | |
72 | 40 override Expression optimize(int result) |
0 | 41 { |
42 Expression e; | |
43 | |
44 e1 = e1.optimize(result); | |
45 if (e1.isConst() == 1) | |
46 e = Not(type, e1); | |
47 else | |
48 e = this; | |
49 | |
50 return e; | |
51 } | |
52 | |
72 | 53 override Expression interpret(InterState istate) |
0 | 54 { |
55 assert(false); | |
56 } | |
57 | |
72 | 58 override int isBit() |
0 | 59 { |
60 assert(false); | |
61 } | |
62 | |
72 | 63 override elem* toElem(IRState* irs) |
0 | 64 { |
65 elem* e = el_una(OPnot, type.totym(), e1.toElem(irs)); | |
66 el_setLoc(e,loc); | |
67 return e; | |
68 } | |
72 | 69 } |