annotate dmd/IndexExp.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
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.IndexExp;
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: 113
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.backend.elem;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
6 import dmd.InterState;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
7 import dmd.OutBuffer;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
8 import dmd.Loc;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
9 import dmd.Scope;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
10 import dmd.VarDeclaration;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
11 import dmd.InlineDoState;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
12 import dmd.Type;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
13 import dmd.ScopeDsymbol;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
14 import dmd.TY;
178
e3afd1303184 Many small bugs fixed
korDen
parents: 130
diff changeset
15 import dmd.Util;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
16 import dmd.ArrayScopeSymbol;
129
010eb8f0e18d further work on dmd test suite
korDen
parents: 123
diff changeset
17 import dmd.PREC;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
18 import dmd.TypeNext;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
19 import dmd.TypeSArray;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
20 import dmd.TypeAArray;
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
21 import dmd.UnaExp;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
22 import dmd.IRState;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
23 import dmd.BinExp;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
24 import dmd.HdrGenState;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
25 import dmd.TOK;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
26 import dmd.WANT;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
27 import dmd.TupleExp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
28 import dmd.TypeTuple;
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
29 import dmd.Parameter;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
30 import dmd.TypeExp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
31 import dmd.VarExp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
32 import dmd.STC;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
33 import dmd.GlobalExpressions;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
34 import dmd.ExpInitializer;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
35 import dmd.Global;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
36
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
37 import dmd.expression.util.arrayTypeCompatible;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
38 import dmd.expression.Util;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
39 import dmd.expression.Index;
129
010eb8f0e18d further work on dmd test suite
korDen
parents: 123
diff changeset
40 import dmd.expression.ArrayLength;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
41
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
42 import dmd.backend.Symbol;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
43 import dmd.backend.Util;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
44 import dmd.codegen.Util;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
45 import dmd.backend.OPER;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
46 import dmd.backend.mTY;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
47 import dmd.backend.TYM;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
48
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
49 import core.stdc.string;
73
ef02e2e203c2 Updating to dmd2.033
korDen
parents: 72
diff changeset
50 import core.stdc.stdio;
ef02e2e203c2 Updating to dmd2.033
korDen
parents: 72
diff changeset
51
187
b0d41ff5e0df Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents: 178
diff changeset
52 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
53
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
54 class IndexExp : BinExp
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
55 {
187
b0d41ff5e0df Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents: 178
diff changeset
56 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
57
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
58 VarDeclaration lengthVar;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
59 int modifiable = 0; // assume it is an rvalue
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
60
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
61 this(Loc loc, Expression e1, Expression e2)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
62 {
178
e3afd1303184 Many small bugs fixed
korDen
parents: 130
diff changeset
63 register();
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
64 super(loc, TOK.TOKindex, IndexExp.sizeof, e1, e2);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
65 //printf("IndexExp.IndexExp('%s')\n", toChars());
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: 63
diff changeset
68 override Expression semantic(Scope sc)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
69 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
70 Expression e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
71 BinExp b;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
72 UnaExp u;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
73 Type t1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
74 ScopeDsymbol sym;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
75
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
76 version (LOGSEMANTIC) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
77 printf("IndexExp.semantic('%s')\n", toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
78 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
79 if (type)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
80 return this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
81 if (!e1.type)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
82 e1 = e1.semantic(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
83 assert(e1.type); // semantic() should already be run on it
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
84 e = this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
85
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
86 // Note that unlike C we do not implement the int[ptr]
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
87
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
88 t1 = e1.type.toBasetype();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
89
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
90 if (t1.ty == Tsarray || t1.ty == Tarray || t1.ty == Ttuple)
178
e3afd1303184 Many small bugs fixed
korDen
parents: 130
diff changeset
91 {
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
92 // Create scope for 'length' variable
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
93 sym = new ArrayScopeSymbol(sc, this);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
94 sym.loc = loc;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
95 sym.parent = sc.scopesym;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
96 sc = sc.push(sym);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
97 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
98
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
99 e2 = e2.semantic(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
100 if (!e2.type)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
101 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
102 error("%s has no value", e2.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
103 e2.type = Type.terror;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
104 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
105 e2 = resolveProperties(sc, e2);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
106
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
107 if (t1.ty == Tsarray || t1.ty == Tarray || t1.ty == Ttuple)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
108 sc = sc.pop();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
109
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
110 switch (t1.ty)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
111 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
112 case Tpointer:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
113 case Tarray:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
114 e2 = e2.implicitCastTo(sc, Type.tsize_t);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
115 e.type = (cast(TypeNext)t1).next;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
116 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
117
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
118 case Tsarray:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
119 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
120 e2 = e2.implicitCastTo(sc, Type.tsize_t);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
121
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
122 TypeSArray tsa = cast(TypeSArray)t1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
123
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
124 static if (false) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
125 // Don't do now, because it might be short-circuit evaluated
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
126 // Do compile time array bounds checking if possible
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
127 e2 = e2.optimize(WANTvalue);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
128 if (e2.op == TOKint64)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
129 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
130 ulong index = e2.toInteger();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
131 ulong length = tsa.dim.toInteger();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
132 if (index < 0 || index >= length)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
133 error("array index [%lld] is outside array bounds [0 .. %lld]", index, length);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
134 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
135 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
136 e.type = t1.nextOf();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
137 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
138 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
139
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
140 case Taarray:
178
e3afd1303184 Many small bugs fixed
korDen
parents: 130
diff changeset
141 {
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
142 TypeAArray taa = cast(TypeAArray)t1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
143 if (!arrayTypeCompatible(e2.loc, e2.type, taa.index))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
144 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
145 e2 = e2.implicitCastTo(sc, taa.index); // type checking
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
146 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
147 type = taa.next;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
148 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
149 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
150
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
151 case Ttuple:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
152 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
153 e2 = e2.implicitCastTo(sc, Type.tsize_t);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
154 e2 = e2.optimize(WANTvalue | WANTinterpret);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
155 ulong index = e2.toUInteger();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
156 size_t length;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
157 TupleExp te;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
158 TypeTuple tup;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
159
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
160 if (e1.op == TOKtuple)
178
e3afd1303184 Many small bugs fixed
korDen
parents: 130
diff changeset
161 {
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
162 te = cast(TupleExp)e1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
163 length = te.exps.dim;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
164 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
165 else if (e1.op == TOKtype)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
166 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
167 tup = cast(TypeTuple)t1;
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
168 length = Parameter.dim(tup.arguments);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
169 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
170 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
171 assert(0);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
172
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
173 if (index < length)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
174 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
175 if (e1.op == TOKtuple)
113
3482c73a991b More cleanup for arrays
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 79
diff changeset
176 e = te.exps[cast(size_t)index];
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
177 else
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
178 e = new TypeExp(e1.loc, Parameter.getNth(tup.arguments, cast(size_t)index).type);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
179 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
180 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
181 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
182 error("array index [%ju] is outside array bounds [0 .. %zu]", index, length);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
183 e = e1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
184 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
185 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
186 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
187
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
188 default:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
189 error("%s must be an array or pointer type, not %s", e1.toChars(), e1.type.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
190 type = Type.tint32;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
191 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
192 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
193
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
194 return e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
195 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
196
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
197 override int isLvalue()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
198 {
129
010eb8f0e18d further work on dmd test suite
korDen
parents: 123
diff changeset
199 return true;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
200 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
201
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
202 override Expression toLvalue(Scope sc, Expression e)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
203 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
204 // if (type && type.toBasetype().ty == Tvoid)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
205 // error("voids have no value");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
206 return this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
207 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
208
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
209 override Expression modifiableLvalue(Scope sc, Expression e)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
210 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
211 //printf("IndexExp::modifiableLvalue(%s)\n", toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
212 modifiable = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
213 if (e1.op == TOKstring)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
214 error("string literals are immutable");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
215 if (type && !type.isMutable())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
216 error("%s isn't mutable", e.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
217 if (e1.type.toBasetype().ty == Taarray)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
218 e1 = e1.modifiableLvalue(sc, e1);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
219 return toLvalue(sc, e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
220 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
221
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
222 override void toCBuffer(OutBuffer buf, HdrGenState* hgs)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
223 {
129
010eb8f0e18d further work on dmd test suite
korDen
parents: 123
diff changeset
224 expToCBuffer(buf, hgs, e1, PREC.PREC_primary);
010eb8f0e18d further work on dmd test suite
korDen
parents: 123
diff changeset
225 buf.writeByte('[');
010eb8f0e18d further work on dmd test suite
korDen
parents: 123
diff changeset
226 expToCBuffer(buf, hgs, e2, PREC.PREC_assign);
010eb8f0e18d further work on dmd test suite
korDen
parents: 123
diff changeset
227 buf.writeByte(']');
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
228 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
229
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
230 override Expression optimize(int result)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
231 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
232 Expression e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
233
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
234 //printf("IndexExp::optimize(result = %d) %s\n", result, toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
235 Expression e1 = this.e1.optimize(WANTvalue | (result & WANTinterpret));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
236 e1 = fromConstInitializer(result, e1);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
237 if (this.e1.op == TOKvar)
178
e3afd1303184 Many small bugs fixed
korDen
parents: 130
diff changeset
238 {
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
239 VarExp ve = cast(VarExp)this.e1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
240 if (ve.var.storage_class & STCmanifest)
178
e3afd1303184 Many small bugs fixed
korDen
parents: 130
diff changeset
241 {
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
242 /* We generally don't want to have more than one copy of an
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
243 * array literal, but if it's an enum we have to because the
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
244 * enum isn't stored elsewhere. See Bugzilla 2559
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
245 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
246 this.e1 = e1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
247 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
248 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
249
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
250 e2 = e2.optimize(WANTvalue | (result & WANTinterpret));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
251 e = Index(type, e1, e2);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
252 if (e is EXP_CANT_INTERPRET)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
253 e = this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
254
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
255 return e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
256 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
257
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
258 override Expression interpret(InterState istate)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
259 {
129
010eb8f0e18d further work on dmd test suite
korDen
parents: 123
diff changeset
260 Expression e;
010eb8f0e18d further work on dmd test suite
korDen
parents: 123
diff changeset
261 Expression e1;
010eb8f0e18d further work on dmd test suite
korDen
parents: 123
diff changeset
262 Expression e2;
010eb8f0e18d further work on dmd test suite
korDen
parents: 123
diff changeset
263
010eb8f0e18d further work on dmd test suite
korDen
parents: 123
diff changeset
264 version (LOG) {
010eb8f0e18d further work on dmd test suite
korDen
parents: 123
diff changeset
265 printf("IndexExp.interpret() %s\n", toChars());
010eb8f0e18d further work on dmd test suite
korDen
parents: 123
diff changeset
266 }
010eb8f0e18d further work on dmd test suite
korDen
parents: 123
diff changeset
267 e1 = this.e1.interpret(istate);
010eb8f0e18d further work on dmd test suite
korDen
parents: 123
diff changeset
268 if (e1 is EXP_CANT_INTERPRET)
010eb8f0e18d further work on dmd test suite
korDen
parents: 123
diff changeset
269 goto Lcant;
010eb8f0e18d further work on dmd test suite
korDen
parents: 123
diff changeset
270
010eb8f0e18d further work on dmd test suite
korDen
parents: 123
diff changeset
271 if (e1.op == TOKstring || e1.op == TOKarrayliteral)
010eb8f0e18d further work on dmd test suite
korDen
parents: 123
diff changeset
272 {
010eb8f0e18d further work on dmd test suite
korDen
parents: 123
diff changeset
273 /* Set the $ variable
010eb8f0e18d further work on dmd test suite
korDen
parents: 123
diff changeset
274 */
010eb8f0e18d further work on dmd test suite
korDen
parents: 123
diff changeset
275 e = ArrayLength(Type.tsize_t, e1);
010eb8f0e18d further work on dmd test suite
korDen
parents: 123
diff changeset
276 if (e is EXP_CANT_INTERPRET)
010eb8f0e18d further work on dmd test suite
korDen
parents: 123
diff changeset
277 goto Lcant;
010eb8f0e18d further work on dmd test suite
korDen
parents: 123
diff changeset
278 if (lengthVar)
010eb8f0e18d further work on dmd test suite
korDen
parents: 123
diff changeset
279 lengthVar.value = e;
010eb8f0e18d further work on dmd test suite
korDen
parents: 123
diff changeset
280 }
010eb8f0e18d further work on dmd test suite
korDen
parents: 123
diff changeset
281
010eb8f0e18d further work on dmd test suite
korDen
parents: 123
diff changeset
282 e2 = this.e2.interpret(istate);
010eb8f0e18d further work on dmd test suite
korDen
parents: 123
diff changeset
283 if (e2 is EXP_CANT_INTERPRET)
010eb8f0e18d further work on dmd test suite
korDen
parents: 123
diff changeset
284 goto Lcant;
010eb8f0e18d further work on dmd test suite
korDen
parents: 123
diff changeset
285 return Index(type, e1, e2);
010eb8f0e18d further work on dmd test suite
korDen
parents: 123
diff changeset
286
010eb8f0e18d further work on dmd test suite
korDen
parents: 123
diff changeset
287 Lcant:
010eb8f0e18d further work on dmd test suite
korDen
parents: 123
diff changeset
288 return EXP_CANT_INTERPRET;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
289 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
290
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
291 override Expression doInline(InlineDoState ids)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
292 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
293 IndexExp are = cast(IndexExp)copy();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
294
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
295 are.e1 = e1.doInline(ids);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
296
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
297 if (lengthVar)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
298 { //printf("lengthVar\n");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
299 VarDeclaration vd = lengthVar;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
300 ExpInitializer ie;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
301 ExpInitializer ieto;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
302 VarDeclaration vto;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
303
178
e3afd1303184 Many small bugs fixed
korDen
parents: 130
diff changeset
304 vto = cloneThis(vd);
e3afd1303184 Many small bugs fixed
korDen
parents: 130
diff changeset
305
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
306 vto.parent = ids.parent;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
307 vto.csym = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
308 vto.isym = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
309
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
310 ids.from.push(cast(void*)vd);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
311 ids.to.push(cast(void*)vto);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
312
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
313 if (vd.init)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
314 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
315 ie = vd.init.isExpInitializer();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
316 assert(ie);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
317 ieto = new ExpInitializer(ie.loc, ie.exp.doInline(ids));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
318 vto.init = ieto;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
319 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
320
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
321 are.lengthVar = vto;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
322 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
323 are.e2 = e2.doInline(ids);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
324 return are;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
325 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
326
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
327 override void scanForNestedRef(Scope sc)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
328 {
123
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
329 e1.scanForNestedRef(sc);
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
330
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
331 if (lengthVar)
178
e3afd1303184 Many small bugs fixed
korDen
parents: 130
diff changeset
332 {
123
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
333 //printf("lengthVar\n");
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
334 lengthVar.parent = sc.parent;
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
335 }
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
336 e2.scanForNestedRef(sc);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
337 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
338
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
339 override elem* toElem(IRState* irs)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
340 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
341 elem* e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
342 elem* n1 = e1.toElem(irs);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
343 elem* eb = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
344
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
345 //printf("IndexExp.toElem() %s\n", toChars());
79
43073c7c7769 updated to 2.035
Trass3r
parents: 73
diff changeset
346 Type t1 = e1.type.toBasetype();
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
347 if (t1.ty == Taarray)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
348 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
349 // set to:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
350 // *aaGet(aa, keyti, valuesize, index);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
351
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
352 TypeAArray taa = cast(TypeAArray)t1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
353 elem* keyti;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
354 elem* ep;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
355 int vsize = cast(int)taa.next.size();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
356 Symbol* s;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
357
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
358 // n2 becomes the index, also known as the key
79
43073c7c7769 updated to 2.035
Trass3r
parents: 73
diff changeset
359 elem* n2 = e2.toElem(irs);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
360 if (tybasic(n2.Ety) == TYstruct || tybasic(n2.Ety) == TYarray)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
361 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
362 n2 = el_una(OPstrpar, TYstruct, n2);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
363 n2.Enumbytes = n2.E1.Enumbytes;
79
43073c7c7769 updated to 2.035
Trass3r
parents: 73
diff changeset
364 if (taa.index.ty == Tsarray)
43073c7c7769 updated to 2.035
Trass3r
parents: 73
diff changeset
365 {
43073c7c7769 updated to 2.035
Trass3r
parents: 73
diff changeset
366 assert(e2.type.size() == taa.index.size());
43073c7c7769 updated to 2.035
Trass3r
parents: 73
diff changeset
367 n2.Enumbytes = cast(size_t) taa.index.size();
43073c7c7769 updated to 2.035
Trass3r
parents: 73
diff changeset
368 }
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
369 //printf("numbytes = %d\n", n2.Enumbytes);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
370 assert(n2.Enumbytes);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
371 }
79
43073c7c7769 updated to 2.035
Trass3r
parents: 73
diff changeset
372 elem* valuesize = el_long(TYuint, vsize); // BUG: should be TYsize_t
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
373 //printf("valuesize: "); elem_print(valuesize);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
374 if (modifiable)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
375 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
376 n1 = el_una(OPaddr, TYnptr, n1);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
377 s = taa.aaGetSymbol("Get", 1);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
378 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
379 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
380 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
381 s = taa.aaGetSymbol("GetRvalue", 1);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
382 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
383 //printf("taa.index = %s\n", taa.index.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
384 keyti = taa.index.getInternalTypeInfo(null).toElem(irs);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
385 //keyti = taa.index.getTypeInfo(null).toElem(irs);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
386 //printf("keyti:\n");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
387 //elem_print(keyti);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
388 ep = el_params(n2, valuesize, keyti, n1, null);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
389 e = el_bin(OPcall, TYnptr, el_var(s), ep);
79
43073c7c7769 updated to 2.035
Trass3r
parents: 73
diff changeset
390
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
391 if (irs.arrayBoundsCheck())
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
392 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
393 elem* ea;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
394
79
43073c7c7769 updated to 2.035
Trass3r
parents: 73
diff changeset
395 elem* n = el_same(&e);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
396
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
397 // Construct: ((e || ModuleAssert(line)),n)
79
43073c7c7769 updated to 2.035
Trass3r
parents: 73
diff changeset
398 Symbol* sassert = irs.blx.module_.toModuleArray();
178
e3afd1303184 Many small bugs fixed
korDen
parents: 130
diff changeset
399
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
400 ea = el_bin(OPcall,TYvoid,el_var(sassert),
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
401 el_long(TYint, loc.linnum));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
402 e = el_bin(OPoror,TYvoid,e,ea);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
403 e = el_bin(OPcomma, TYnptr, e, n);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
404 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
405 e = el_una(OPind, type.totym(), e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
406 if (tybasic(e.Ety) == TYstruct)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
407 e.Enumbytes = cast(uint)type.size();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
408 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
409 else
178
e3afd1303184 Many small bugs fixed
korDen
parents: 130
diff changeset
410 {
79
43073c7c7769 updated to 2.035
Trass3r
parents: 73
diff changeset
411 elem* einit = resolveLengthVar(lengthVar, &n1, t1);
43073c7c7769 updated to 2.035
Trass3r
parents: 73
diff changeset
412 elem* n2 = e2.toElem(irs);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
413
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
414 if (irs.arrayBoundsCheck())
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
415 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
416 elem* elength;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
417 elem* n2x;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
418 elem* ea;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
419
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
420 if (t1.ty == Tsarray)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
421 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
422 TypeSArray tsa = cast(TypeSArray)t1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
423 ulong length = tsa.dim.toInteger();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
424
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
425 elength = el_long(TYuint, length);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
426 goto L1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
427 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
428 else if (t1.ty == Tarray)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
429 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
430 elength = n1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
431 n1 = el_same(&elength);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
432 elength = el_una(OP64_32, TYuint, elength);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
433 L1:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
434 n2x = n2;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
435 n2 = el_same(&n2x);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
436 n2x = el_bin(OPlt, TYint, n2x, elength);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
437
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
438 // Construct: (n2x || ModuleAssert(line))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
439 Symbol* sassert;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
440
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
441 sassert = irs.blx.module_.toModuleArray();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
442 ea = el_bin(OPcall,TYvoid,el_var(sassert),
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
443 el_long(TYint, loc.linnum));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
444 eb = el_bin(OPoror,TYvoid,n2x,ea);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
445 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
446 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
447
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
448 n1 = array_toPtr(t1, n1);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
449
178
e3afd1303184 Many small bugs fixed
korDen
parents: 130
diff changeset
450 {
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
451 elem* escale;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
452
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
453 escale = el_long(TYint, t1.nextOf().size());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
454 n2 = el_bin(OPmul, TYint, n2, escale);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
455 e = el_bin(OPadd, TYnptr, n1, n2);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
456 e = el_una(OPind, type.totym(), e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
457 if (tybasic(e.Ety) == TYstruct || tybasic(e.Ety) == TYarray)
178
e3afd1303184 Many small bugs fixed
korDen
parents: 130
diff changeset
458 {
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
459 e.Ety = TYstruct;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
460 e.Enumbytes = cast(uint)type.size();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
461 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
462 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
463
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
464 eb = el_combine(einit, eb);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
465 e = el_combine(eb, e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
466 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
467
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
468 el_setLoc(e,loc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
469
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
470 return e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
471 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
472 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
473