annotate dmd/ForeachStatement.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 cd48cb899aee
children 52188e7e3fb5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1 module dmd.ForeachStatement;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2
114
e28b18c23469 added a module dmd.common for commonly used stuff
Trass3r
parents: 96
diff changeset
3 import dmd.common;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
4 import dmd.Statement;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
5 import dmd.TOK;
66
efb1e5bdf63c more implementations
korDen
parents: 63
diff changeset
6 import dmd.Token;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
7 import dmd.Loc;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
8 import dmd.LINK;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
9 import dmd.ArrayTypes;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
10 import dmd.Expression;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
11 import dmd.VarDeclaration;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
12 import dmd.FuncDeclaration;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
13 import dmd.Array;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
14 import dmd.Scope;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
15 import dmd.InterState;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
16 import dmd.InlineScanState;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
17 import dmd.OutBuffer;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
18 import dmd.HdrGenState;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
19 import dmd.IRState;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
20 import dmd.BE;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
21 import dmd.ScopeDsymbol;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
22 import dmd.TypeAArray;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
23 import dmd.Type;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
24 import dmd.CallExp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
25 import dmd.WANT;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
26 import dmd.TY;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
27 import dmd.TypeTuple;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
28 import dmd.TupleExp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
29 import dmd.Global;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
30 import dmd.Initializer;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
31 import dmd.ExpInitializer;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
32 import dmd.IntegerExp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
33 import dmd.ExpStatement;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
34 import dmd.DeclarationExp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
35 import dmd.Dsymbol;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
36 import dmd.BreakStatement;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
37 import dmd.DefaultStatement;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
38 import dmd.CaseStatement;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
39 import dmd.SwitchStatement;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
40 import dmd.VarExp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
41 import dmd.AliasDeclaration;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
42 import dmd.CompoundStatement;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
43 import dmd.ScopeStatement;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
44 import dmd.UnrolledLoopStatement;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
45 import dmd.Identifier;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
46 import dmd.Lexer;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
47 import dmd.DeclarationStatement;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
48 import dmd.CompoundDeclarationStatement;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
49 import dmd.AggregateDeclaration;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
50 import dmd.TypeClass;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
51 import dmd.NotExp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
52 import dmd.TypeStruct;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
53 import dmd.FuncLiteralDeclaration;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
54 import dmd.IdentifierExp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
55 import dmd.TypeFunction;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
56 import dmd.GotoStatement;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
57 import dmd.FuncExp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
58 import dmd.ReturnStatement;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
59 import dmd.IndexExp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
60 import dmd.ForStatement;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
61 import dmd.SliceExp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
62 import dmd.DotIdExp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
63 import dmd.PostExp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
64 import dmd.AddAssignExp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
65 import dmd.CmpExp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
66 import dmd.Id;
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 126
diff changeset
67 import dmd.Parameter;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
68 import dmd.STC;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
69
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
70 import dmd.expression.Util;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
71
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
72 import core.stdc.stdio;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
73
187
b0d41ff5e0df Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents: 179
diff changeset
74 import dmd.DDMDExtensions;
b0d41ff5e0df Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents: 179
diff changeset
75
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
76 class ForeachStatement : Statement
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
77 {
187
b0d41ff5e0df Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents: 179
diff changeset
78 mixin insertMemberExtension!(typeof(this));
b0d41ff5e0df Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents: 179
diff changeset
79
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
80 TOK op; // TOKforeach or TOKforeach_reverse
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 126
diff changeset
81 Parameters arguments; // array of Argument*'s
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
82 Expression aggr;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
83 Statement body_;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
84
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
85 VarDeclaration key;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
86 VarDeclaration value;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
87
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
88 FuncDeclaration func; // function we're lexically in
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
89
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
90 Array cases; // put breaks, continues, gotos and returns here
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
91 Array gotos; // forward referenced goto's go here
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
92
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 126
diff changeset
93 this(Loc loc, TOK op, Parameters arguments, Expression aggr, Statement body_)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
94 {
178
e3afd1303184 Many small bugs fixed
korDen
parents: 175
diff changeset
95 register();
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
96 super(loc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
97
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
98 this.op = op;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
99 this.arguments = arguments;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
100 this.aggr = aggr;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
101 this.body_ = body_;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
102
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
103 gotos = new Array();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
104 cases = new Array();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
105 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
106
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 66
diff changeset
107 override Statement syntaxCopy()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
108 {
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 126
diff changeset
109 auto args = Parameter.arraySyntaxCopy(arguments);
53
a8b50ff7f201 ForeachStatement.syntaxCopy
korDen
parents: 12
diff changeset
110 Expression exp = aggr.syntaxCopy();
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 126
diff changeset
111 auto s = new ForeachStatement(loc, op, args, exp,
53
a8b50ff7f201 ForeachStatement.syntaxCopy
korDen
parents: 12
diff changeset
112 body_ ? body_.syntaxCopy() : null);
a8b50ff7f201 ForeachStatement.syntaxCopy
korDen
parents: 12
diff changeset
113 return s;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
114 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
115
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 66
diff changeset
116 override Statement semantic(Scope sc)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
117 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
118 //printf("ForeachStatement.semantic() %p\n", this);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
119 ScopeDsymbol sym;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
120 Statement s = this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
121 size_t dim = arguments.dim;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
122 TypeAArray taa = null;
135
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 130
diff changeset
123 Dsymbol sapply = null;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
124
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
125 Type tn = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
126 Type tnv = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
127
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
128 func = sc.func;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
129 if (func.fes)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
130 func = func.fes.func;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
131
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
132 aggr = aggr.semantic(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
133 aggr = resolveProperties(sc, aggr);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
134 aggr = aggr.optimize(WANT.WANTvalue);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
135 if (!aggr.type)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
136 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
137 error("invalid foreach aggregate %s", aggr.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
138 return this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
139 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
140
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
141 inferApplyArgTypes(op, arguments, aggr);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
142
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
143 /* Check for inference errors
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
144 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
145 if (dim != arguments.dim)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
146 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
147 //printf("dim = %d, arguments.dim = %d\n", dim, arguments.dim);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
148 error("cannot uniquely infer foreach argument types");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
149 return this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
150 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
151
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
152 Type tab = aggr.type.toBasetype();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
153
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
154 if (tab.ty == TY.Ttuple) // don't generate new scope for tuple loops
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
155 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
156 if (dim < 1 || dim > 2)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
157 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
158 error("only one (value) or two (key,value) arguments for tuple foreach");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
159 return s;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
160 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
161
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 126
diff changeset
162 auto tuple = cast(TypeTuple)tab;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
163 Statements statements = new Statements();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
164 //printf("aggr: op = %d, %s\n", aggr.op, aggr.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
165 size_t n;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
166 TupleExp te = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
167 if (aggr.op == TOK.TOKtuple) // expression tuple
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
168 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
169 te = cast(TupleExp)aggr;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
170 n = te.exps.dim;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
171 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
172 else if (aggr.op == TOK.TOKtype) // type tuple
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
173 {
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 126
diff changeset
174 n = Parameter.dim(tuple.arguments);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
175 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
176 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
177 assert(0);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
178
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
179 for (size_t j = 0; j < n; j++)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
180 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
181 size_t k = (op == TOK.TOKforeach) ? j : n - 1 - j;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
182 Expression e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
183 Type t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
184 if (te)
90
39648eb578f6 more Expressions work
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 84
diff changeset
185 e = te.exps[k];
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
186 else
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 126
diff changeset
187 t = Parameter.getNth(tuple.arguments, k).type;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
188
126
1765f3ef917d ClassDeclarations, Arguments -> Vector
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 122
diff changeset
189 auto arg = arguments[0];
1765f3ef917d ClassDeclarations, Arguments -> Vector
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 122
diff changeset
190 auto st = new Statements();
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
191
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
192 if (dim == 2)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
193 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
194 // Declare key
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
195 if (arg.storageClass & (STC.STCout | STC.STCref | STC.STClazy))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
196 error("no storage class for key %s", arg.ident.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
197 TY keyty = arg.type.ty;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
198 if (keyty != TY.Tint32 && keyty != TY.Tuns32)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
199 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
200 if (global.params.isX86_64)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
201 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
202 if (keyty != TY.Tint64 && keyty != TY.Tuns64)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
203 error("foreach: key type must be int or uint, long or ulong, not %s", arg.type.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
204 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
205 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
206 error("foreach: key type must be int or uint, not %s", arg.type.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
207 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
208 Initializer ie = new ExpInitializer(Loc(0), new IntegerExp(k));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
209 VarDeclaration var = new VarDeclaration(loc, arg.type, arg.ident, ie);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
210 var.storage_class |= STC.STCmanifest;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
211 DeclarationExp de = new DeclarationExp(loc, var);
122
c77e9f4f1793 Statements -> Vector
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
212 st.push(new ExpStatement(loc, de));
126
1765f3ef917d ClassDeclarations, Arguments -> Vector
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 122
diff changeset
213 arg = arguments[1]; // value
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
214 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
215 // Declare value
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
216 if (arg.storageClass & (STC.STCout | STC.STCref | STC.STClazy))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
217 error("no storage class for value %s", arg.ident.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
218 Dsymbol var;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
219 if (te)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
220 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
221 Type tb = e.type.toBasetype();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
222 if ((tb.ty == TY.Tfunction || tb.ty == TY.Tsarray) && e.op == TOK.TOKvar)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
223 {
126
1765f3ef917d ClassDeclarations, Arguments -> Vector
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 122
diff changeset
224 auto ve = cast(VarExp)e;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
225 var = new AliasDeclaration(loc, arg.ident, ve.var);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
226 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
227 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
228 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
229 arg.type = e.type;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
230 Initializer ie = new ExpInitializer(Loc(0), e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
231 VarDeclaration v = new VarDeclaration(loc, arg.type, arg.ident, ie);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
232 if (e.isConst())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
233 v.storage_class |= STC.STCconst;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
234
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
235 var = v;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
236 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
237 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
238 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
239 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
240 var = new AliasDeclaration(loc, arg.ident, t);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
241 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
242
122
c77e9f4f1793 Statements -> Vector
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
243 auto de = new DeclarationExp(loc, var);
c77e9f4f1793 Statements -> Vector
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
244 st.push(new ExpStatement(loc, de));
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
245
122
c77e9f4f1793 Statements -> Vector
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
246 st.push(body_.syntaxCopy());
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
247 s = new CompoundStatement(loc, st);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
248 s = new ScopeStatement(loc, s);
122
c77e9f4f1793 Statements -> Vector
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
249 statements.push(s);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
250 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
251
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
252 s = new UnrolledLoopStatement(loc, statements);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
253 s = s.semantic(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
254 return s;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
255 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
256
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
257 sym = new ScopeDsymbol();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
258 sym.parent = sc.scopesym;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
259 sc = sc.push(sym);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
260
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
261 sc.noctor++;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
262
96
acd69f84627e further work
Trass3r
parents: 90
diff changeset
263 Lagain:
135
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 130
diff changeset
264 Identifier idapply = (op == TOK.TOKforeach_reverse)
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 130
diff changeset
265 ? Id.applyReverse : Id.apply;
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 130
diff changeset
266 sapply = null;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
267 switch (tab.ty)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
268 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
269 case TY.Tarray:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
270 case TY.Tsarray:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
271 if (!checkForArgTypes())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
272 return this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
273
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
274 if (dim < 1 || dim > 2)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
275 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
276 error("only one or two arguments for array foreach");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
277 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
278 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
279
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
280 /* Look for special case of parsing char types out of char type
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
281 * array.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
282 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
283 tn = tab.nextOf().toBasetype();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
284 if (tn.ty == TY.Tchar || tn.ty == TY.Twchar || tn.ty == TY.Tdchar)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
285 {
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 126
diff changeset
286 Parameter arg;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
287
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
288 int i = (dim == 1) ? 0 : 1; // index of value
126
1765f3ef917d ClassDeclarations, Arguments -> Vector
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 122
diff changeset
289 arg = arguments[i];
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
290 arg.type = arg.type.semantic(loc, sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
291 tnv = arg.type.toBasetype();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
292 if (tnv.ty != tn.ty && (tnv.ty == TY.Tchar || tnv.ty == TY.Twchar || tnv.ty == TY.Tdchar))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
293 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
294 if (arg.storageClass & STC.STCref)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
295 error("foreach: value of UTF conversion cannot be ref");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
296 if (dim == 2)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
297 {
126
1765f3ef917d ClassDeclarations, Arguments -> Vector
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 122
diff changeset
298 arg = arguments[0];
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
299 if (arg.storageClass & STC.STCref)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
300 error("foreach: key cannot be ref");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
301 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
302 goto Lapply;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
303 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
304 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
305
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
306 for (size_t i = 0; i < dim; i++)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
307 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
308 // Declare args
126
1765f3ef917d ClassDeclarations, Arguments -> Vector
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 122
diff changeset
309 auto arg = arguments[i];
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
310 Type argtype = arg.type.semantic(loc, sc);
126
1765f3ef917d ClassDeclarations, Arguments -> Vector
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 122
diff changeset
311 auto var = new VarDeclaration(loc, argtype, arg.ident, null);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
312 var.storage_class |= STC.STCforeach;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
313 var.storage_class |= arg.storageClass & (STC.STCin | STC.STCout | STC.STCref | STC.STC_TYPECTOR);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
314 if (var.storage_class & (STC.STCref | STC.STCout))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
315 var.storage_class |= STC.STCnodtor;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
316
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
317 if (dim == 2 && i == 0)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
318 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
319 key = var;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
320 //var.storage_class |= STCfinal;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
321 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
322 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
323 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
324 value = var;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
325 /* Reference to immutable data should be marked as const
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
326 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
327 if (var.storage_class & STC.STCref && !tn.isMutable())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
328 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
329 var.storage_class |= STC.STCconst;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
330 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
331 }
96
acd69f84627e further work
Trass3r
parents: 90
diff changeset
332 static if (false)
acd69f84627e further work
Trass3r
parents: 90
diff changeset
333 {
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
334 DeclarationExp de = new DeclarationExp(loc, var);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
335 de.semantic(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
336 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
337 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
338
96
acd69f84627e further work
Trass3r
parents: 90
diff changeset
339 static if (true)
acd69f84627e further work
Trass3r
parents: 90
diff changeset
340 {
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
341 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
342 /* Convert to a ForStatement
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
343 * foreach (key, value; a) body =>
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
344 * for (T[] tmp = a[], size_t key; key < tmp.length; ++key)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
345 * { T value = tmp[k]; body }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
346 *
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
347 * foreach_reverse (key, value; a) body =>
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
348 * for (T[] tmp = a[], size_t key = tmp.length; key--; )
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
349 * { T value = tmp[k]; body }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
350 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
351 Identifier id = Lexer.uniqueId("__aggr");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
352 ExpInitializer ie = new ExpInitializer(loc, new SliceExp(loc, aggr, null, null));
179
cd48cb899aee Updated to dmd2.040
korDen
parents: 178
diff changeset
353 VarDeclaration tmp = new VarDeclaration(loc, tab.nextOf().arrayOf(), id, ie);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
354
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
355 Expression tmp_length = new DotIdExp(loc, new VarExp(loc, tmp), Id.length);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
356
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
357 if (!key)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
358 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
359 Identifier id2 = Lexer.uniqueId("__key");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
360 key = new VarDeclaration(loc, Type.tsize_t, id2, null);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
361 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
362
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
363 if (op == TOK.TOKforeach_reverse)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
364 key.init = new ExpInitializer(loc, tmp_length);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
365 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
366 key.init = new ExpInitializer(loc, new IntegerExp(0));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
367
122
c77e9f4f1793 Statements -> Vector
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
368 auto cs = new Statements();
c77e9f4f1793 Statements -> Vector
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
369 cs.push(new DeclarationStatement(loc, new DeclarationExp(loc, tmp)));
c77e9f4f1793 Statements -> Vector
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
370 cs.push(new DeclarationStatement(loc, new DeclarationExp(loc, key)));
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
371 Statement forinit = new CompoundDeclarationStatement(loc, cs);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
372
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
373 Expression cond;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
374 if (op == TOK.TOKforeach_reverse)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
375 // key--
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
376 cond = new PostExp(TOK.TOKminusminus, loc, new VarExp(loc, key));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
377 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
378 // key < tmp.length
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
379 cond = new CmpExp(TOK.TOKlt, loc, new VarExp(loc, key), tmp_length);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
380
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
381 Expression increment = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
382 if (op == TOK.TOKforeach)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
383 // key += 1
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
384 increment = new AddAssignExp(loc, new VarExp(loc, key), new IntegerExp(1));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
385
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
386 // T value = tmp[key];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
387 value.init = new ExpInitializer(loc, new IndexExp(loc, new VarExp(loc, tmp), new VarExp(loc, key)));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
388 Statement ds = new DeclarationStatement(loc, new DeclarationExp(loc, value));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
389
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
390 body_ = new CompoundStatement(loc, ds, body_);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
391
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
392 ForStatement fs = new ForStatement(loc, forinit, cond, increment, body_);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
393 s = fs.semantic(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
394 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
395 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
396 } else {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
397 if (tab.nextOf().implicitConvTo(value.type) < MATCH.MATCHconst)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
398 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
399 if (aggr.op == TOK.TOKstring)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
400 aggr = aggr.implicitCastTo(sc, value.type.arrayOf());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
401 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
402 error("foreach: %s is not an array of %s",
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
403 tab.toChars(), value.type.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
404 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
405
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
406 if (key)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
407 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
408 if (key.type.ty != Tint32 && key.type.ty != Tuns32)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
409 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
410 if (global.params.isX86_64)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
411 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
412 if (key.type.ty != Tint64 && key.type.ty != Tuns64)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
413 error("foreach: key type must be int or uint, long or ulong, not %s", key.type.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
414 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
415 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
416 error("foreach: key type must be int or uint, not %s", key.type.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
417 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
418
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
419 if (key.storage_class & (STCout | STCref))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
420 error("foreach: key cannot be out or ref");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
421 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
422
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
423 sc.sbreak = this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
424 sc.scontinue = this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
425 body_ = body_.semantic(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
426 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
427 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
428
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
429 case TY.Taarray:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
430 if (!checkForArgTypes())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
431 return this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
432
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
433 taa = cast(TypeAArray)tab;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
434 if (dim < 1 || dim > 2)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
435 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
436 error("only one or two arguments for associative array foreach");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
437 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
438 }
96
acd69f84627e further work
Trass3r
parents: 90
diff changeset
439 version(SARRAYVALUE)
acd69f84627e further work
Trass3r
parents: 90
diff changeset
440 {
acd69f84627e further work
Trass3r
parents: 90
diff changeset
441 /* This only works if Key or Value is a static array.
acd69f84627e further work
Trass3r
parents: 90
diff changeset
442 */
acd69f84627e further work
Trass3r
parents: 90
diff changeset
443 tab = taa.getImpl().type;
acd69f84627e further work
Trass3r
parents: 90
diff changeset
444 goto Lagain;
acd69f84627e further work
Trass3r
parents: 90
diff changeset
445 }
acd69f84627e further work
Trass3r
parents: 90
diff changeset
446 else
acd69f84627e further work
Trass3r
parents: 90
diff changeset
447 {
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
448 if (op == TOK.TOKforeach_reverse)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
449 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
450 error("no reverse iteration on associative arrays");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
451 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
452 goto Lapply;
96
acd69f84627e further work
Trass3r
parents: 90
diff changeset
453 }
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
454 case TY.Tclass:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
455 case TY.Tstruct:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
456 version (DMDV2) {
135
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 130
diff changeset
457 /* Prefer using opApply, if it exists
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 130
diff changeset
458 */
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 130
diff changeset
459 if (dim != 1) // only one argument allowed with ranges
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 130
diff changeset
460 goto Lapply;
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 130
diff changeset
461
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 130
diff changeset
462 sapply = search_function(cast(AggregateDeclaration)tab.toDsymbol(sc), idapply);
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 130
diff changeset
463 if (sapply)
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 130
diff changeset
464 goto Lapply;
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 130
diff changeset
465
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
466 { /* Look for range iteration, i.e. the properties
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
467 * .empty, .next, .retreat, .head and .rear
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
468 * foreach (e; aggr) { ... }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
469 * translates to:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
470 * for (auto __r = aggr[]; !__r.empty; __r.next)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
471 * { auto e = __r.head;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
472 * ...
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
473 * }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
474 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
475 AggregateDeclaration ad = (tab.ty == TY.Tclass)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
476 ? cast(AggregateDeclaration)(cast(TypeClass)tab).sym
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
477 : cast(AggregateDeclaration)(cast(TypeStruct)tab).sym;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
478
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
479 Identifier idhead;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
480 Identifier idnext;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
481 if (op == TOK.TOKforeach)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
482 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
483 idhead = Id.Fhead;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
484 idnext = Id.Fnext;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
485 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
486 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
487 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
488 idhead = Id.Ftoe;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
489 idnext = Id.Fretreat;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
490 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
491
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
492 Dsymbol shead = search_function(ad, idhead);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
493 if (!shead)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
494 goto Lapply;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
495
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
496 /* Generate a temporary __r and initialize it with the aggregate.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
497 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
498 Identifier id = Identifier.generateId("__r");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
499 Expression rinit = new SliceExp(loc, aggr, null, null);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
500 rinit = rinit.trySemantic(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
501 if (!rinit) // if application of [] failed
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
502 rinit = aggr;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
503
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
504 VarDeclaration r = new VarDeclaration(loc, null, id, new ExpInitializer(loc, rinit));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
505
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
506 // r.semantic(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
507 //printf("r: %s, init: %s\n", r.toChars(), r.init.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
508 Statement init = new DeclarationStatement(loc, r);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
509 //printf("init: %s\n", init.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
510
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
511 // !__r.empty
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
512 Expression e = new VarExp(loc, r);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
513 e = new DotIdExp(loc, e, Id.Fempty);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
514 Expression condition = new NotExp(loc, e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
515
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
516 // __r.next
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
517 e = new VarExp(loc, r);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
518 Expression increment = new DotIdExp(loc, e, idnext);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
519
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
520 /* Declaration statement for e:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
521 * auto e = __r.idhead;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
522 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
523 e = new VarExp(loc, r);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
524 Expression einit = new DotIdExp(loc, e, idhead);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
525 // einit = einit.semantic(sc);
126
1765f3ef917d ClassDeclarations, Arguments -> Vector
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 122
diff changeset
526 auto arg = arguments[0];
1765f3ef917d ClassDeclarations, Arguments -> Vector
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 122
diff changeset
527 auto ve = new VarDeclaration(loc, arg.type, arg.ident, new ExpInitializer(loc, einit));
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
528 ve.storage_class |= STC.STCforeach;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
529 ve.storage_class |= arg.storageClass & (STC.STCin | STC.STCout | STC.STCref | STC.STC_TYPECTOR);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
530
126
1765f3ef917d ClassDeclarations, Arguments -> Vector
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 122
diff changeset
531 auto de = new DeclarationExp(loc, ve);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
532
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
533 Statement body2 = new CompoundStatement(loc, new DeclarationStatement(loc, de), this.body_);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
534 s = new ForStatement(loc, init, condition, increment, body2);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
535
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
536 static if (false) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
537 printf("init: %s\n", init.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
538 printf("condition: %s\n", condition.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
539 printf("increment: %s\n", increment.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
540 printf("body: %s\n", body2.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
541 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
542 s = s.semantic(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
543 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
544 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
545 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
546 case TY.Tdelegate:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
547 Lapply:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
548 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
549 Expression ec;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
550 Expression e;
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 126
diff changeset
551 Parameter a;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
552
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
553 if (!checkForArgTypes())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
554 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
555 body_ = body_.semantic(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
556 return this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
557 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
558
135
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 130
diff changeset
559 Type tret = func.type.nextOf();
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
560
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
561 // Need a variable to hold value from any return statements in body.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
562 if (!sc.func.vresult && tret && tret != Type.tvoid)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
563 {
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 126
diff changeset
564 auto v = new VarDeclaration(loc, tret, Id.result, null);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
565 v.noauto = true;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
566 v.semantic(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
567 if (!sc.insert(v))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
568 assert(0);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
569
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
570 v.parent = sc.func;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
571 sc.func.vresult = v;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
572 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
573
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
574 /* Turn body into the function literal:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
575 * int delegate(ref T arg) { body }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
576 */
135
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 130
diff changeset
577 auto args = new Parameters();
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
578 for (size_t i = 0; i < dim; i++)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
579 {
126
1765f3ef917d ClassDeclarations, Arguments -> Vector
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 122
diff changeset
580 auto arg = arguments[i];
135
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 130
diff changeset
581 Identifier id;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
582
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
583 arg.type = arg.type.semantic(loc, sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
584 if (arg.storageClass & STC.STCref)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
585 id = arg.ident;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
586 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
587 { // Make a copy of the ref argument so it isn't
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
588 // a reference.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
589 id = Lexer.uniqueId("__applyArg", i);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
590
135
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 130
diff changeset
591 Initializer ie = new ExpInitializer(Loc(0), new IdentifierExp(Loc(0), id));
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 130
diff changeset
592 auto v = new VarDeclaration(Loc(0), arg.type, arg.ident, ie);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
593 s = new DeclarationStatement(Loc(0), v);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
594 body_ = new CompoundStatement(loc, s, body_);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
595 }
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 126
diff changeset
596 a = new Parameter(STC.STCref, arg.type, id, null);
126
1765f3ef917d ClassDeclarations, Arguments -> Vector
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 122
diff changeset
597 args.push(a);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
598 }
135
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 130
diff changeset
599 Type t = new TypeFunction(args, Type.tint32, 0, LINK.LINKd);
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 130
diff changeset
600 FuncLiteralDeclaration fld = new FuncLiteralDeclaration(loc, Loc(0), t, TOK.TOKdelegate, this);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
601 fld.fbody = body_;
135
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 130
diff changeset
602 Expression flde = new FuncExp(loc, fld);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
603 flde = flde.semantic(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
604 fld.tookAddressOf = 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
605
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
606 // Resolve any forward referenced goto's
135
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 130
diff changeset
607 for (size_t i = 0; i < gotos.dim; i++)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
608 {
122
c77e9f4f1793 Statements -> Vector
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
609 auto cs = cast(CompoundStatement)gotos.data[i];
c77e9f4f1793 Statements -> Vector
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
610 auto gs = cast(GotoStatement)cs.statements[0];
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
611
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
612 if (!gs.label.statement)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
613 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
614 // 'Promote' it to this scope, and replace with a return
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
615 cases.push(cast(void*)gs);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
616 s = new ReturnStatement(Loc(0), new IntegerExp(cases.dim + 1));
122
c77e9f4f1793 Statements -> Vector
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
617 cs.statements[0] = s;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
618 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
619 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
620
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
621 if (tab.ty == TY.Taarray)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
622 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
623 // Check types
126
1765f3ef917d ClassDeclarations, Arguments -> Vector
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 122
diff changeset
624 auto arg = arguments[0];
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
625 if (dim == 2)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
626 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
627 if (arg.storageClass & STC.STCref)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
628 error("foreach: index cannot be ref");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
629 if (!arg.type.equals(taa.index))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
630 error("foreach: index must be type %s, not %s", taa.index.toChars(), arg.type.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
631
126
1765f3ef917d ClassDeclarations, Arguments -> Vector
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 122
diff changeset
632 arg = arguments[1];
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
633 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
634 if (!arg.type.equals(taa.nextOf()))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
635 error("foreach: value must be type %s, not %s", taa.nextOf().toChars(), arg.type.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
636
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
637 /* Call:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
638 * _aaApply(aggr, keysize, flde)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
639 */
135
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 130
diff changeset
640 FuncDeclaration fdapply;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
641 if (dim == 2)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
642 fdapply = FuncDeclaration.genCfunc(Type.tindex, "_aaApply2");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
643 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
644 fdapply = FuncDeclaration.genCfunc(Type.tindex, "_aaApply");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
645
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
646 ec = new VarExp(Loc(0), fdapply);
84
be2ab491772e Expressions -> Vector!Expression
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 73
diff changeset
647 auto exps = new Expressions();
be2ab491772e Expressions -> Vector!Expression
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 73
diff changeset
648 exps.push(aggr);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
649 size_t keysize = cast(uint)taa.index.size();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
650 keysize = (keysize + (PTRSIZE-1)) & ~(PTRSIZE-1);
84
be2ab491772e Expressions -> Vector!Expression
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 73
diff changeset
651 exps.push(new IntegerExp(Loc(0), keysize, Type.tsize_t));
be2ab491772e Expressions -> Vector!Expression
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 73
diff changeset
652 exps.push(flde);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
653 e = new CallExp(loc, ec, exps);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
654 e.type = Type.tindex; // don't run semantic() on e
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
655 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
656 else if (tab.ty == TY.Tarray || tab.ty == TY.Tsarray)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
657 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
658 /* Call:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
659 * _aApply(aggr, flde)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
660 */
175
94b6033c07f3 get rid of globals
korDen
parents: 135
diff changeset
661 enum char fntab[9][3] =
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
662 [ "cc","cw","cd",
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
663 "wc","cc","wd",
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
664 "dc","dw","dd"
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
665 ];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
666 char fdname[7+1+2+ dim.sizeof*3 + 1];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
667 int flag;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
668
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
669 switch (tn.ty)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
670 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
671 case TY.Tchar: flag = 0; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
672 case TY.Twchar: flag = 3; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
673 case TY.Tdchar: flag = 6; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
674 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
675 switch (tnv.ty)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
676 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
677 case TY.Tchar: flag += 0; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
678 case TY.Twchar: flag += 1; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
679 case TY.Tdchar: flag += 2; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
680 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
681 string r = (op == TOK.TOKforeach_reverse) ? "R" : "";
73
ef02e2e203c2 Updating to dmd2.033
korDen
parents: 72
diff changeset
682 int j = sprintf(fdname.ptr, "_aApply%.*s%.*s%zd".ptr, r, 2, fntab[flag].ptr, dim);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
683 assert(j < fdname.sizeof);
135
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 130
diff changeset
684 FuncDeclaration fdapply = FuncDeclaration.genCfunc(Type.tindex, fdname[0..j].idup);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
685
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
686 ec = new VarExp(Loc(0), fdapply);
84
be2ab491772e Expressions -> Vector!Expression
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 73
diff changeset
687 auto exps = new Expressions();
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
688 if (tab.ty == TY.Tsarray)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
689 aggr = aggr.castTo(sc, tn.arrayOf());
84
be2ab491772e Expressions -> Vector!Expression
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 73
diff changeset
690 exps.push(aggr);
be2ab491772e Expressions -> Vector!Expression
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 73
diff changeset
691 exps.push(flde);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
692 e = new CallExp(loc, ec, exps);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
693 e.type = Type.tindex; // don't run semantic() on e
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
694 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
695 else if (tab.ty == TY.Tdelegate)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
696 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
697 /* Call:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
698 * aggr(flde)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
699 */
84
be2ab491772e Expressions -> Vector!Expression
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 73
diff changeset
700 auto exps = new Expressions();
be2ab491772e Expressions -> Vector!Expression
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 73
diff changeset
701 exps.push(flde);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
702 e = new CallExp(loc, aggr, exps);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
703 e = e.semantic(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
704 if (e.type != Type.tint32)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
705 error("opApply() function for %s must return an int", tab.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
706 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
707 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
708 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
709 assert(tab.ty == TY.Tstruct || tab.ty == TY.Tclass);
135
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 130
diff changeset
710 auto exps = new Expressions();
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 130
diff changeset
711 if (!sapply)
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 130
diff changeset
712 sapply = search_function(cast(AggregateDeclaration)tab.toDsymbol(sc), idapply);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
713 static if (false) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
714 TemplateDeclaration td;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
715 if (sapply && (td = sapply.isTemplateDeclaration()) !is null)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
716 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
717 /* Call:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
718 * aggr.apply!(fld)()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
719 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
720 Objects tiargs = new Objects();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
721 tiargs.push(cast(void*)fld);
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 126
diff changeset
722 ec = new DotTemplateInstanceExp(loc, aggr, idapply, tiargs);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
723 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
724 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
725 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
726 /* Call:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
727 * aggr.apply(flde)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
728 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
729 ec = new DotIdExp(loc, aggr, idapply);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
730 exps.push(cast(void*)flde);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
731 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
732 } else {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
733 ec = new DotIdExp(loc, aggr, idapply);
84
be2ab491772e Expressions -> Vector!Expression
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 73
diff changeset
734 exps.push(flde);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
735 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
736 e = new CallExp(loc, ec, exps);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
737 e = e.semantic(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
738 if (e.type != Type.tint32) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
739 error("opApply() function for %s must return an int", tab.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
740 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
741 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
742
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
743 if (!cases.dim)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
744 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
745 // Easy case, a clean exit from the loop
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
746 s = new ExpStatement(loc, e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
747 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
748 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
749 { // Construct a switch statement around the return value
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
750 // of the apply function.
122
c77e9f4f1793 Statements -> Vector
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
751 auto a2 = new Statements();
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
752
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
753 // default: break; takes care of cases 0 and 1
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
754 s = new BreakStatement(Loc(0), null);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
755 s = new DefaultStatement(Loc(0), s);
122
c77e9f4f1793 Statements -> Vector
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
756 a2.push(s);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
757
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
758 // cases 2...
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
759 for (int i = 0; i < cases.dim; i++)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
760 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
761 s = cast(Statement)cases.data[i];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
762 s = new CaseStatement(Loc(0), new IntegerExp(i + 2), s);
122
c77e9f4f1793 Statements -> Vector
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
763 a2.push(s);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
764 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
765
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
766 s = new CompoundStatement(loc, a2);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
767 s = new SwitchStatement(loc, e, s, false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
768 s = s.semantic(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
769 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
770 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
771 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
772
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
773 default:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
774 error("foreach: %s is not an aggregate type", aggr.type.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
775 s = null; // error recovery
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
776 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
777 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
778
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
779 sc.noctor--;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
780 sc.pop();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
781 return s;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
782 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
783
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
784 bool checkForArgTypes()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
785 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
786 bool result = true;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
787
126
1765f3ef917d ClassDeclarations, Arguments -> Vector
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 122
diff changeset
788 foreach (arg; arguments)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
789 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
790 if (!arg.type)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
791 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
792 error("cannot infer type for %s", arg.ident.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
793 arg.type = Type.terror;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
794 result = false;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
795 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
796 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
797 return result;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
798 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
799
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 66
diff changeset
800 override bool hasBreak()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
801 {
66
efb1e5bdf63c more implementations
korDen
parents: 63
diff changeset
802 return true;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
803 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
804
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 66
diff changeset
805 override bool hasContinue()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
806 {
66
efb1e5bdf63c more implementations
korDen
parents: 63
diff changeset
807 return true;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
808 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
809
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 66
diff changeset
810 override bool usesEH()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
811 {
66
efb1e5bdf63c more implementations
korDen
parents: 63
diff changeset
812 return body_.usesEH();
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
813 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
814
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 66
diff changeset
815 override BE blockExit()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
816 {
66
efb1e5bdf63c more implementations
korDen
parents: 63
diff changeset
817 BE result = BEfallthru;
efb1e5bdf63c more implementations
korDen
parents: 63
diff changeset
818
efb1e5bdf63c more implementations
korDen
parents: 63
diff changeset
819 if (aggr.canThrow())
efb1e5bdf63c more implementations
korDen
parents: 63
diff changeset
820 result |= BEthrow;
efb1e5bdf63c more implementations
korDen
parents: 63
diff changeset
821
efb1e5bdf63c more implementations
korDen
parents: 63
diff changeset
822 if (body_)
efb1e5bdf63c more implementations
korDen
parents: 63
diff changeset
823 {
efb1e5bdf63c more implementations
korDen
parents: 63
diff changeset
824 result |= body_.blockExit() & ~(BEbreak | BEcontinue);
efb1e5bdf63c more implementations
korDen
parents: 63
diff changeset
825 }
efb1e5bdf63c more implementations
korDen
parents: 63
diff changeset
826 return result;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
827 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
828
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 66
diff changeset
829 override bool comeFrom()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
830 {
66
efb1e5bdf63c more implementations
korDen
parents: 63
diff changeset
831 if (body_)
efb1e5bdf63c more implementations
korDen
parents: 63
diff changeset
832 return body_.comeFrom();
efb1e5bdf63c more implementations
korDen
parents: 63
diff changeset
833
efb1e5bdf63c more implementations
korDen
parents: 63
diff changeset
834 return false;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
835 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
836
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 66
diff changeset
837 override Expression interpret(InterState istate)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
838 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
839 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
840 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
841
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 66
diff changeset
842 override void toCBuffer(OutBuffer buf, HdrGenState* hgs)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
843 {
66
efb1e5bdf63c more implementations
korDen
parents: 63
diff changeset
844 buf.writestring(Token.toChars(op));
efb1e5bdf63c more implementations
korDen
parents: 63
diff changeset
845 buf.writestring(" (");
efb1e5bdf63c more implementations
korDen
parents: 63
diff changeset
846 for (int i = 0; i < arguments.dim; i++)
efb1e5bdf63c more implementations
korDen
parents: 63
diff changeset
847 {
126
1765f3ef917d ClassDeclarations, Arguments -> Vector
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 122
diff changeset
848 auto a = arguments[i];
66
efb1e5bdf63c more implementations
korDen
parents: 63
diff changeset
849 if (i)
efb1e5bdf63c more implementations
korDen
parents: 63
diff changeset
850 buf.writestring(", ");
efb1e5bdf63c more implementations
korDen
parents: 63
diff changeset
851 if (a.storageClass & STCref)
efb1e5bdf63c more implementations
korDen
parents: 63
diff changeset
852 buf.writestring((global.params.Dversion == 1) ? "inout " : "ref ");
efb1e5bdf63c more implementations
korDen
parents: 63
diff changeset
853 if (a.type)
efb1e5bdf63c more implementations
korDen
parents: 63
diff changeset
854 a.type.toCBuffer(buf, a.ident, hgs);
efb1e5bdf63c more implementations
korDen
parents: 63
diff changeset
855 else
efb1e5bdf63c more implementations
korDen
parents: 63
diff changeset
856 buf.writestring(a.ident.toChars());
efb1e5bdf63c more implementations
korDen
parents: 63
diff changeset
857 }
efb1e5bdf63c more implementations
korDen
parents: 63
diff changeset
858 buf.writestring("; ");
efb1e5bdf63c more implementations
korDen
parents: 63
diff changeset
859 aggr.toCBuffer(buf, hgs);
efb1e5bdf63c more implementations
korDen
parents: 63
diff changeset
860 buf.writebyte(')');
efb1e5bdf63c more implementations
korDen
parents: 63
diff changeset
861 buf.writenl();
efb1e5bdf63c more implementations
korDen
parents: 63
diff changeset
862 buf.writebyte('{');
efb1e5bdf63c more implementations
korDen
parents: 63
diff changeset
863 buf.writenl();
efb1e5bdf63c more implementations
korDen
parents: 63
diff changeset
864 if (body_)
efb1e5bdf63c more implementations
korDen
parents: 63
diff changeset
865 body_.toCBuffer(buf, hgs);
efb1e5bdf63c more implementations
korDen
parents: 63
diff changeset
866 buf.writebyte('}');
efb1e5bdf63c more implementations
korDen
parents: 63
diff changeset
867 buf.writenl();
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
868 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
869
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 66
diff changeset
870 override Statement inlineScan(InlineScanState* iss)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
871 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
872 aggr = aggr.inlineScan(iss);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
873 if (body_)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
874 body_ = body_.inlineScan(iss);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
875 return this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
876 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
877
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 66
diff changeset
878 override void toIR(IRState* irs)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
879 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
880 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
881 }
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 66
diff changeset
882 }