annotate dmd/UnaExp.d @ 72:2e2a5c3f943a

reduced warnings by adding override to the methods think this also normalizes different line endings used all over the place
author Trass3r
date Sat, 28 Aug 2010 16:19:48 +0200
parents 4290d870944a
children e28b18c23469
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: 64
diff changeset
1 module dmd.UnaExp;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
2
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
3 import dmd.Expression;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
4 import dmd.InterState;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
5 import dmd.TY;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
6 import dmd.TypeClass;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
7 import dmd.TypeStruct;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
8 import dmd.Dsymbol;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
9 import dmd.AggregateDeclaration;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
10 import dmd.Type;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
11 import dmd.OutBuffer;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
12 import dmd.Loc;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
13 import dmd.TOK;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
14 import dmd.Scope;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
15 import dmd.InlineCostState;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
16 import dmd.InlineDoState;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
17 import dmd.HdrGenState;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
18 import dmd.InlineScanState;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
19 import dmd.DotIdExp;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
20 import dmd.ArrayExp;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
21 import dmd.CallExp;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
22 import dmd.PREC;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
23 import dmd.Token;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
24 import dmd.expression.Util;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
25
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
26 class UnaExp : Expression
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
27 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
28 Expression e1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
29
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
30 this(Loc loc, TOK op, int size, Expression e1)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
31 {
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
32 super(loc, op, size);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
33 this.e1 = e1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
34 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
35
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
36 override Expression syntaxCopy()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
37 {
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
38 UnaExp e = cast(UnaExp)copy();
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
39 e.type = null;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
40 e.e1 = e.e1.syntaxCopy();
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
41
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
42 return e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
43 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
44
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
45 override Expression semantic(Scope sc)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
46 {
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
47 version (LOGSEMANTIC) {
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
48 writef("UnaExp.semantic('%s')\n", toChars());
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
49 }
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
50 e1 = e1.semantic(sc);
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
51 // if (!e1.type)
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
52 // error("%s has no value", e1.toChars());
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
53 return this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
54 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
55
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
56 override void toCBuffer(OutBuffer buf, HdrGenState* hgs)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
57 {
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
58 buf.writestring(Token.toChars(op));
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
59 expToCBuffer(buf, hgs, e1, precedence[op]);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
60 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
61
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
62 override Expression optimize(int result)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
63 {
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
64 e1 = e1.optimize(result);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
65 return this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
66 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
67
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
68 override void dump(int indent)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
69 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
70 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
71 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
72
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
73 override void scanForNestedRef(Scope sc)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
74 {
64
4290d870944a More fixes
korDen
parents: 63
diff changeset
75 e1.scanForNestedRef(sc);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
76 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
77
63
cab4c37afb89 A bunch of implementations
korDen
parents: 0
diff changeset
78 Expression interpretCommon(InterState istate, Expression *(*fp)(Type* a0, Expression* a1))
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
79 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
80 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
81 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
82
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
83 override bool canThrow()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
84 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
85 return e1.canThrow();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
86 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
87
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
88 override int inlineCost(InlineCostState* ics)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
89 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
90 return 1 + e1.inlineCost(ics);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
91 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
92
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
93 override Expression doInline(InlineDoState ids)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
94 {
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
95 UnaExp ue = cast(UnaExp)copy();
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
96
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
97 ue.e1 = e1.doInline(ids);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
98 return ue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
99 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
100
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
101 override Expression inlineScan(InlineScanState* iss)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
102 {
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
103 e1 = e1.inlineScan(iss);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
104 return this;
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
105 }
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
106
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
107 /************************************
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
108 * Operator overload.
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
109 * Check for operator overload, if so, replace
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
110 * with function call.
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
111 * Return null if not an operator overload.
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
112 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
113 Expression op_overload(Scope sc)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
114 {
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
115 //printf("UnaExp.op_overload() (%s)\n", toChars());
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
116 AggregateDeclaration ad;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
117 Dsymbol fd;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
118 Type t1 = e1.type.toBasetype();
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
119
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
120 if (t1.ty == TY.Tclass)
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
121 {
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
122 ad = (cast(TypeClass)t1).sym;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
123 goto L1;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
124 }
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
125 else if (t1.ty == TY.Tstruct)
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
126 {
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
127 ad = (cast(TypeStruct)t1).sym;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
128
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
129 L1:
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
130 fd = search_function(ad, opId());
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
131 if (fd)
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
132 {
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
133 if (op == TOK.TOKarray)
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
134 {
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
135 /* Rewrite op e1[arguments] as:
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
136 * e1.fd(arguments)
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
137 */
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
138 Expression e = new DotIdExp(loc, e1, fd.ident);
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
139 ArrayExp ae = cast(ArrayExp)this;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
140 e = new CallExp(loc, e, ae.arguments);
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
141 e = e.semantic(sc);
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
142 return e;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
143 }
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
144 else
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
145 {
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
146 // Rewrite +e1 as e1.add()
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
147 return build_overload(loc, sc, e1, null, fd.ident);
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
148 }
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
149 }
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
150
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
151 version (DMDV2) {
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
152 // Didn't find it. Forward to aliasthis
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
153 if (ad.aliasthis)
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
154 {
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
155 /* Rewrite op(e1) as:
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
156 * op(e1.aliasthis)
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
157 */
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
158 Expression e1 = new DotIdExp(loc, this.e1, ad.aliasthis.ident);
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
159 Expression e = copy();
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
160 (cast(UnaExp)e).e1 = e1;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
161 e = e.semantic(sc);
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
162 return e;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
163 }
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
164 }
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
165 }
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
166 return null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
167 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
168 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
169