annotate dmd/ComExp.d @ 114:e28b18c23469

added a module dmd.common for commonly used stuff it currently holds code for consistency checking of predefined versions also added a VisualD project file
author Trass3r
date Wed, 01 Sep 2010 18:21:58 +0200
parents 2e2a5c3f943a
children 9e39c7de8438
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
1 module dmd.ComExp;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
2
114
e28b18c23469 added a module dmd.common for commonly used stuff
Trass3r
parents: 72
diff changeset
3 import dmd.common;
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
4 import dmd.Expression;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
5 import dmd.Identifier;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
6 import dmd.backend.elem;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
7 import dmd.UnaExp;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
8 import dmd.InterState;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
9 import dmd.OutBuffer;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
10 import dmd.Loc;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
11 import dmd.Scope;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
12 import dmd.IRState;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
13 import dmd.ArrayTypes;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
14 import dmd.TOK;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
15 import dmd.TY;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
16
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
17 import dmd.backend.Util;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
18 import dmd.backend.OPER;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
19
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
20 import dmd.expression.Util;
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
21 import dmd.expression.Com;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
22
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
23 class ComExp : UnaExp
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
24 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
25 this(Loc loc, Expression e)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
26 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
27 super(loc, TOKtilde, ComExp.sizeof, e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
28 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
29
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
30 override Expression semantic(Scope sc)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
31 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
32 Expression e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
33
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
34 if (!type)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
35 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
36 UnaExp.semantic(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
37 e1 = resolveProperties(sc, e1);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
38 e = op_overload(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
39 if (e)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
40 return e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
41
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
42 e1.checkNoBool();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
43 if (e1.op != TOKslice)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
44 e1 = e1.checkIntegral();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
45 type = e1.type;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
46 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
47 return this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
48 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
49
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
50 override Expression optimize(int result)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
51 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
52 Expression e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
53
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
54 e1 = e1.optimize(result);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
55 if (e1.isConst() == 1)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
56 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
57 e = Com(type, e1);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
58 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
59 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
60 e = this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
61
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
62 return e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
63 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
64
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
65 override Expression interpret(InterState istate)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
66 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
67 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
68 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
69
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
70 override void buildArrayIdent(OutBuffer buf, Expressions arguments)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
71 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
72 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
73 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
74
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
75 override Expression buildArrayLoop(Arguments fparams)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
76 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
77 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
78 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
79
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
80 override Identifier opId()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
81 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
82 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
83 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
84
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
85 override elem* toElem(IRState* irs)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
86 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
87 elem *e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
88
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
89 elem *e1 = this.e1.toElem(irs);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
90 tym_t ty = type.totym();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
91 if (this.e1.type.toBasetype().ty == Tbool)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
92 e = el_bin(OPxor, ty, e1, el_long(ty, 1));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
93 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
94 e = el_una(OPcom,ty,e1);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
95 el_setLoc(e,loc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
96 return e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
97 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
98 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
99