Mercurial > projects > ddmd
annotate dmd/ComExp.d @ 192:eb38fdcb3e62 default tip
updated to compile with dmd2.062
author | korDen |
---|---|
date | Sat, 02 Mar 2013 01:25:52 -0800 |
parents | b0d41ff5e0df |
children |
rev | line source |
---|---|
72 | 1 module dmd.ComExp; |
2 | |
114 | 3 import dmd.common; |
72 | 4 import dmd.Expression; |
5 import dmd.Identifier; | |
6 import dmd.backend.elem; | |
7 import dmd.UnaExp; | |
8 import dmd.InterState; | |
9 import dmd.OutBuffer; | |
10 import dmd.Loc; | |
11 import dmd.Scope; | |
12 import dmd.IRState; | |
13 import dmd.ArrayTypes; | |
0 | 14 import dmd.TOK; |
15 import dmd.TY; | |
123 | 16 import dmd.Id; |
0 | 17 |
18 import dmd.backend.Util; | |
19 import dmd.backend.OPER; | |
20 | |
21 import dmd.expression.Util; | |
72 | 22 import dmd.expression.Com; |
23 | |
187
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
178
diff
changeset
|
24 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
|
25 |
0 | 26 class ComExp : UnaExp |
27 { | |
187
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
178
diff
changeset
|
28 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
|
29 |
0 | 30 this(Loc loc, Expression e) |
31 { | |
178 | 32 register(); |
33 | |
0 | 34 super(loc, TOKtilde, ComExp.sizeof, e); |
35 } | |
36 | |
72 | 37 override Expression semantic(Scope sc) |
0 | 38 { |
39 Expression e; | |
40 | |
41 if (!type) | |
42 { | |
43 UnaExp.semantic(sc); | |
44 e1 = resolveProperties(sc, e1); | |
45 e = op_overload(sc); | |
46 if (e) | |
47 return e; | |
48 | |
49 e1.checkNoBool(); | |
50 if (e1.op != TOKslice) | |
51 e1 = e1.checkIntegral(); | |
52 type = e1.type; | |
53 } | |
54 return this; | |
55 } | |
56 | |
72 | 57 override Expression optimize(int result) |
0 | 58 { |
59 Expression e; | |
60 | |
61 e1 = e1.optimize(result); | |
62 if (e1.isConst() == 1) | |
63 { | |
64 e = Com(type, e1); | |
65 } | |
66 else | |
67 e = this; | |
68 | |
69 return e; | |
70 } | |
71 | |
72 | 72 override Expression interpret(InterState istate) |
0 | 73 { |
74 assert(false); | |
75 } | |
76 | |
72 | 77 override void buildArrayIdent(OutBuffer buf, Expressions arguments) |
0 | 78 { |
123 | 79 e1.buildArrayIdent(buf, arguments); |
80 buf.writestring("Com"); | |
0 | 81 } |
82 | |
130
60bb0fe4563e
dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
123
diff
changeset
|
83 override Expression buildArrayLoop(Parameters fparams) |
0 | 84 { |
123 | 85 Expression ex1 = e1.buildArrayLoop(fparams); |
86 Expression e = new ComExp(Loc(0), ex1); | |
87 return e; | |
0 | 88 } |
89 | |
72 | 90 override Identifier opId() |
0 | 91 { |
123 | 92 return Id.com; |
0 | 93 } |
94 | |
72 | 95 override elem* toElem(IRState* irs) |
0 | 96 { |
97 elem *e; | |
98 | |
99 elem *e1 = this.e1.toElem(irs); | |
100 tym_t ty = type.totym(); | |
101 if (this.e1.type.toBasetype().ty == Tbool) | |
102 e = el_bin(OPxor, ty, e1, el_long(ty, 1)); | |
103 else | |
104 e = el_una(OPcom,ty,e1); | |
105 el_setLoc(e,loc); | |
106 return e; | |
107 } | |
108 } | |
109 |