• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

wurstscript / WurstScript / 271

29 Sep 2025 12:12PM UTC coverage: 64.649% (+2.4%) from 62.222%
271

Pull #1096

circleci

Frotty
Merge branch 'perf-improvements' of https://github.com/wurstscript/WurstScript into perf-improvements
Pull Request #1096: Perf improvements

18202 of 28155 relevant lines covered (64.65%)

0.65 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

74.7
de.peeeq.wurstscript/src/main/java/de/peeeq/wurstscript/translation/imtranslation/Flatten.java
1
package de.peeeq.wurstscript.translation.imtranslation;
2

3
import com.google.common.base.Preconditions;
4
import com.google.common.collect.ImmutableList;
5
import com.google.common.collect.Lists;
6
import de.peeeq.wurstscript.WurstOperator;
7
import de.peeeq.wurstscript.jassIm.*;
8
import de.peeeq.wurstscript.translation.imtranslation.purity.Pure;
9
import de.peeeq.wurstscript.types.WurstTypeBool;
10

11
import java.util.ArrayList;
12
import java.util.Arrays;
13
import java.util.Collections;
14
import java.util.List;
15

16
import static de.peeeq.wurstscript.jassIm.JassIm.*;
17

18
/**
19
 * flattening expressions and statements
20
 * after flattening there will be no more StatementExprs
21
 * for expressions there might be a StatementExpr on the top level
22
 * <p>
23
 * TODO wait, its not that easy: you have to make sure that the execution order is not changed for functions and global variables
24
 * <p>
25
 * e.g. take
26
 * <p>
27
 * y = x + StatementExpr(setX(4), 2)
28
 * <p>
29
 * this should be translated to:
30
 * <p>
31
 * temp = x
32
 * setX(4)
33
 * y = temp + 2
34
 * <p>
35
 * <p>
36
 * alternative: relax language semantics
37
 */
38
public class Flatten {
×
39

40

41
    public static Result flatten(ImTypeVarDispatch imTypeVarDispatch, ImTranslator translator, ImFunction f) {
42
        throw new RuntimeException("called too early");
×
43
    }
44

45
    public static Result flatten(ImCast imCast, ImTranslator translator, ImFunction f) {
46
        Result res = imCast.getExpr().flatten(translator, f);
1✔
47
        return new Result(res.stmts, ImCast(res.expr, imCast.getToType()));
1✔
48
    }
49

50
    public static Result flatten(ImTypeIdOfObj e, ImTranslator translator, ImFunction f) {
51
        Result o = e.getObj().flatten(translator, f);
×
52
        return new Result(o.stmts, ImTypeIdOfObj(o.expr, e.getClazz()));
×
53
    }
54

55
    public static Result flatten(ImTypeIdOfClass e, ImTranslator translator, ImFunction f) {
56
        e.setParent(null);
×
57
        return new Result(e);
×
58
    }
59

60
    public static Result flatten(ImDealloc d, ImTranslator translator, ImFunction f) {
61
        Result o = d.getObj().flatten(translator, f);
1✔
62
        return new Result(o.stmts, ImDealloc(d.getTrace(), d.getClazz(), o.expr));
1✔
63
    }
64

65
    public static Result flatten(ImInstanceof e, ImTranslator translator, ImFunction f) {
66
        Result res = e.getObj().flatten(translator, f);
×
67
        return new Result(res.stmts, ImInstanceof(res.expr, e.getClazz()));
×
68
    }
69

70
    public static Result flatten(ImAlloc e, ImTranslator translator, ImFunction f) {
71
        e.setParent(null);
1✔
72
        return new Result(e);
1✔
73
    }
74

75

76
    public static class Result {
77

78
        List<ImStmt> stmts;
79
        final ImExpr expr;
80

81
        public Result(List<ImStmt> stmts, ImExpr expr) {
1✔
82
            Preconditions.checkArgument(expr.getParent() == null, "expression must not have a parent");
1✔
83
            Preconditions.checkArgument(stmts.stream().allMatch(s -> s.getParent() == null), "statement must not have a parent");
1✔
84
            this.stmts = stmts;
1✔
85
            this.expr = expr;
1✔
86
        }
1✔
87

88
        public Result(ImExpr expr) {
89
            this(Collections.emptyList(), expr);
1✔
90
        }
1✔
91

92
        public Result(List<ImStmt> stmts) {
93
            this(stmts, ImHelper.nullExpr());
1✔
94
        }
1✔
95

96
        public void intoStatements(List<ImStmt> result, ImTranslator t, ImFunction f) {
97
            result.addAll(stmts);
1✔
98
            exprToStatements(result, expr, t, f);
1✔
99
        }
1✔
100

101
        public List<ImStmt> getStmts() {
102
            return stmts;
×
103
        }
104

105
        public ImExpr getExpr() {
106
            return expr;
×
107
        }
108

109
        public ImStatementExpr toStatementExpr() {
110
            return JassIm.ImStatementExpr(JassIm.ImStmts(stmts), expr);
×
111
        }
112

113
        public void addStmts(List<ImStmt> stmts) {
114
            if (stmts.isEmpty()) {
1✔
115
                return;
1✔
116
            }
117
            this.stmts = new ArrayList<>(this.stmts);
1✔
118
            this.stmts.addAll(stmts);
1✔
119
        }
1✔
120
    }
121

122
    public static class ResultL extends Result {
123
        public ResultL(List<ImStmt> stmts, ImLExpr expr) {
124
            super(stmts, expr);
1✔
125
        }
1✔
126

127
        public ResultL(ImLExpr expr) {
128
            super(expr);
1✔
129
        }
1✔
130

131
        @Override
132
        public ImLExpr getExpr() {
133
            return (ImLExpr) super.getExpr();
×
134
        }
135
    }
136

137
    public static class MultiResult {
138

139
        final List<ImStmt> stmts;
140
        final List<ImExpr> exprs;
141

142
        public MultiResult(List<ImStmt> stmts, List<ImExpr> exprs) {
1✔
143
            this.stmts = stmts;
1✔
144
            this.exprs = exprs;
1✔
145
        }
1✔
146

147

148
        public ImExpr expr(int i) {
149
            return exprs.get(i);
×
150
        }
151

152
    }
153

154
    public static class MultiResultL extends MultiResult {
155

156
        public MultiResultL(List<ImStmt> stmts, List<ImLExpr> exprs) {
157
            super(stmts, ImmutableList.copyOf(exprs));
×
158
        }
×
159

160
        public ImLExpr expr(int i) {
161
            return (ImLExpr) super.expr(i);
×
162
        }
163

164
        public List<ImLExpr> getLExprs() {
165
            //noinspection unchecked,rawtypes
166
            return (List) exprs;
×
167
        }
168

169
    }
170

171
    private static void exprToStatements(List<ImStmt> result, Element e, ImTranslator t, ImFunction f) {
172
        if (e instanceof ImFunctionCall) {
1✔
173
            Result res = flatten((ImFunctionCall) e, t, f);
1✔
174
            result.addAll(res.stmts);
1✔
175
            result.add(res.expr);
1✔
176
        } else if (e instanceof ImDealloc) {
1✔
177
            Result res = flatten((ImDealloc) e, t, f);
1✔
178
            result.addAll(res.stmts);
1✔
179
            result.add(res.expr);
1✔
180
        } else if (e instanceof ImMethodCall) {
1✔
181
            Result res = flatten((ImMethodCall) e, t, f);
1✔
182
            result.addAll(res.stmts);
1✔
183
            result.add(res.expr);
1✔
184
        } else if (e instanceof ImStatementExpr) {
1✔
185
            ImStatementExpr e2 = (ImStatementExpr) e;
×
186
            flattenStatementsInto(result, e2.getStatements(), t, f);
×
187
            exprToStatements(result, e2, t, f);
×
188
        } else if (e instanceof ImOperatorCall &&
1✔
189
            (((ImOperatorCall) e).getOp() == WurstOperator.AND
1✔
190
                || ((ImOperatorCall) e).getOp() == WurstOperator.OR)) {
1✔
191
            // short circuiting operators have to be handled in a special way:
192
            // we translate them to if statements when necessary
193
            ImOperatorCall oc = (ImOperatorCall) e;
1✔
194
            ImStmts rightStmts = JassIm.ImStmts();
1✔
195
            ImExpr right = oc.getArguments().get(1);
1✔
196
            ImExpr left = oc.getArguments().get(0);
1✔
197
            exprToStatements(rightStmts, right, t, f);
1✔
198
            if (rightStmts.isEmpty()) {
1✔
199
                // if no statements for righthand side, then just use left hand side as result
200
                exprToStatements(result, left, t, f);
1✔
201
            } else {
202
                // if righthandside contains some statements, transform the whole thing to an if statement:
203
                if (oc.getOp() == WurstOperator.AND) {
1✔
204
                    result.add(JassIm.ImIf(e.attrTrace(), left.copy(), rightStmts, JassIm.ImStmts()));
1✔
205
                } else { // WurstOperator.OR
206
                    result.add(JassIm.ImIf(e.attrTrace(), left.copy(), JassIm.ImStmts(), rightStmts));
×
207
                }
208
            }
209
        } else {
1✔
210
            // visit children:
211
            for (int i = 0; i < e.size(); i++) {
1✔
212
                exprToStatements(result, e.get(i), t, f);
1✔
213
            }
214
        }
215
    }
1✔
216

217

218
    private static ImStmts flattenStatements(ImStmts statements, ImTranslator t, ImFunction f) {
219
        ImStmts result = ImStmts();
1✔
220
        flattenStatementsInto(result, statements, t, f);
1✔
221
        return result;
1✔
222
    }
223

224
    private static void flattenStatementsInto(List<ImStmt> result, ImStmts statements, ImTranslator t, ImFunction f) {
225
        for (ImStmt s : statements) {
1✔
226
            s.flatten(t, f).intoStatements(result, t, f);
1✔
227
        }
1✔
228
    }
1✔
229

230
    public static Result flatten(ImExitwhen s, ImTranslator t, ImFunction f) {
231
        Result cond = s.getCondition().flatten(t, f);
1✔
232
        List<ImStmt> stmts = Lists.newArrayList(cond.stmts);
1✔
233
        stmts.add(ImExitwhen(s.getTrace(), cond.expr));
1✔
234
        return new Result(stmts);
1✔
235
    }
236

237

238
    public static Result flatten(ImIf s, ImTranslator t, ImFunction f) {
239
        Result cond = s.getCondition().flatten(t, f);
1✔
240
        List<ImStmt> stmts = Lists.newArrayList(cond.stmts);
1✔
241
        stmts.add(
1✔
242
            JassIm.ImIf(s.getTrace(), cond.expr,
1✔
243
                flattenStatements(s.getThenBlock(), t, f),
1✔
244
                flattenStatements(s.getElseBlock(), t, f)));
1✔
245
        return new Result(stmts);
1✔
246
    }
247

248

249
    public static Result flatten(ImLoop s, ImTranslator t, ImFunction f) {
250
        return new Result(Collections.singletonList(
1✔
251
            JassIm.ImLoop(s.getTrace(), flattenStatements(s.getBody(), t, f))));
1✔
252
    }
253

254
    public static Result flatten(ImReturn s, ImTranslator t, ImFunction f) {
255
        if (s.getReturnValue() instanceof ImExpr) {
1✔
256
            ImExpr ret = (ImExpr) s.getReturnValue();
1✔
257
            Result result = ret.flatten(t, f);
1✔
258
            List<ImStmt> stmts = Lists.newArrayList(result.stmts);
1✔
259
            stmts.add(ImReturn(s.getTrace(), result.expr));
1✔
260
            return new Result(stmts);
1✔
261
        } else {
262
            s.setParent(null);
1✔
263
            return new Result(Collections.singletonList(s));
1✔
264
        }
265
    }
266

267

268
    public static Result flatten(ImSet s, ImTranslator t, ImFunction f) {
269
        Result l = s.getLeft().flatten(t, f);
1✔
270
        Result r = s.getRight().flatten(t, f);
1✔
271
        List<ImStmt> stmts = Lists.newArrayList(l.stmts);
1✔
272
        stmts.addAll(r.stmts);
1✔
273
        stmts.add(JassIm.ImSet(s.getTrace(), (ImLExpr) l.expr, r.expr));
1✔
274
        return new Result(stmts);
1✔
275
    }
276

277

278
    public static Result flatten(ImFunctionCall e, ImTranslator t, ImFunction f) {
279
        MultiResult r = flattenExprs(t, f, e.getArguments());
1✔
280
        return new Result(r.stmts, ImFunctionCall(e.getTrace(), e.getFunc(), e.getTypeArguments().copy(), ImExprs(r.exprs), e.getTuplesEliminated(), e.getCallType()));
1✔
281
    }
282

283
    public static Result flatten(ImMethodCall e, ImTranslator t, ImFunction f) {
284
        Result recR = e.getReceiver().flatten(t, f);
1✔
285
        MultiResult argsR = flattenExprs(t, f, e.getArguments());
1✔
286
        Result res = new Result(recR.stmts, ImMethodCall(e.getTrace(), e.getMethod(), e.getTypeArguments().copy(), recR.expr, ImExprs(argsR.exprs), e.getTuplesEliminated()));
1✔
287
        res.addStmts(argsR.stmts);
1✔
288
        return res;
1✔
289
    }
290

291
    public static Result flatten(ImOperatorCall e, ImTranslator t, ImFunction f) {
292
        // TODO special case and, or
293
        de.peeeq.wurstscript.ast.Element trace = e.attrTrace();
1✔
294
        switch (e.getOp()) {
1✔
295
            case AND: {
296
                Result left = e.getArguments().get(0).flatten(t, f);
1✔
297
                Result right = e.getArguments().get(1).flatten(t, f);
1✔
298

299
                if (right.stmts.isEmpty()) {
1✔
300
                    return new Result(left.stmts, JassIm.ImOperatorCall(WurstOperator.AND, ImExprs(left.expr, right.expr)));
1✔
301
                } else {
302
                    ArrayList<ImStmt> stmts = Lists.newArrayList(left.stmts);
1✔
303
                    ImVar tempVar = JassIm.ImVar(e.attrTrace(), WurstTypeBool.instance().imTranslateType(t), "andLeft", false);
1✔
304
                    f.getLocals().add(tempVar);
1✔
305
                    ImStmts thenBlock = JassIm.ImStmts();
1✔
306
                    // if left is true then check right
307
                    thenBlock.addAll(right.stmts);
1✔
308
                    thenBlock.add(ImSet(trace, ImVarAccess(tempVar), right.expr));
1✔
309
                    // else the result is false
310
                    ImStmts elseBlock = JassIm.ImStmts(ImSet(trace, ImVarAccess(tempVar), JassIm.ImBoolVal(false)));
1✔
311
                    stmts.add(ImIf(trace, left.expr, thenBlock, elseBlock));
1✔
312
                    return new Result(stmts, JassIm.ImVarAccess(tempVar));
1✔
313
                }
314
            }
315
            case OR: {
316
                Result left = e.getArguments().get(0).flatten(t, f);
1✔
317
                Result right = e.getArguments().get(1).flatten(t, f);
1✔
318

319
                if (right.stmts.isEmpty()) {
1✔
320
                    return new Result(left.stmts, JassIm.ImOperatorCall(WurstOperator.OR, ImExprs(left.expr, right.expr)));
1✔
321
                } else {
322
                    ArrayList<ImStmt> stmts = Lists.newArrayList(left.stmts);
1✔
323
                    ImVar tempVar = JassIm.ImVar(trace, WurstTypeBool.instance().imTranslateType(t), "andLeft", false);
1✔
324
                    f.getLocals().add(tempVar);
1✔
325
                    // if left is true then result is ture
326
                    ImStmts thenBlock = JassIm.ImStmts(ImSet(trace, ImVarAccess(tempVar), JassIm.ImBoolVal(true)));
1✔
327
                    // else check right
328
                    ImStmts elseBlock = JassIm.ImStmts();
1✔
329
                    elseBlock.addAll(right.stmts);
1✔
330
                    elseBlock.add(ImSet(trace, ImVarAccess(tempVar), right.expr));
1✔
331
                    stmts.add(ImIf(trace, left.expr, thenBlock, elseBlock));
1✔
332
                    return new Result(stmts, JassIm.ImVarAccess(tempVar));
1✔
333
                }
334
            }
335
            default:
336
                MultiResult r = flattenExprs(t, f, e.getArguments());
1✔
337
                return new Result(r.stmts, JassIm.ImOperatorCall(e.getOp(), ImExprs(r.exprs)));
1✔
338
        }
339
    }
340

341

342
    public static Result flatten(ImConst e, ImTranslator t, ImFunction f) {
343
        e.setParent(null);
1✔
344
        return new Result(e);
1✔
345
    }
346

347

348
    public static Result flatten(ImStatementExpr e, ImTranslator t, ImFunction f) {
349
        List<ImStmt> stmts = Lists.newArrayList();
1✔
350
        flattenStatementsInto(stmts, e.getStatements(), t, f);
1✔
351
        Result r = e.getExpr().flatten(t, f);
1✔
352
        stmts.addAll(r.stmts);
1✔
353
        return new Result(stmts, r.expr);
1✔
354
    }
355

356
    public static ResultL flattenL(ImStatementExpr e, ImTranslator t, ImFunction f) {
357
        List<ImStmt> stmts = Lists.newArrayList();
×
358
        flattenStatementsInto(stmts, e.getStatements(), t, f);
×
359
        ResultL r = ((ImLExpr) e.getExpr()).flattenL(t, f);
×
360
        stmts.addAll(r.stmts);
×
361
        return new ResultL(stmts, r.getExpr());
×
362
    }
363

364

365
    public static Result flatten(ImTupleExpr e, ImTranslator t, ImFunction f) {
366
        MultiResult r = flattenExprs(t, f, e.getExprs());
1✔
367
        return new Result(r.stmts, JassIm.ImTupleExpr(ImExprs(r.exprs)));
1✔
368
    }
369

370
    public static ResultL flattenL(ImTupleExpr e, ImTranslator t, ImFunction f) {
371
        @SuppressWarnings({"unchecked", "rawtypes"})
372
        List<ImLExpr> exprs = (List) e.getExprs();
×
373
        MultiResultL r = flattenExprsL(t, f, exprs);
×
374
        ImExprs newExprs = ImExprs();
×
375
        newExprs.addAll(r.getLExprs());
×
376
        return new ResultL(r.stmts, JassIm.ImTupleExpr(newExprs));
×
377
    }
378

379

380
    public static Result flatten(ImTupleSelection e, ImTranslator t, ImFunction f) {
381
        return flattenL(e, t, f);
1✔
382
    }
383

384
    public static ResultL flattenL(ImTupleSelection e, ImTranslator t, ImFunction f) {
385
        Result r = e.getTupleExpr().flatten(t, f);
1✔
386
        ImLExpr tupleExpr;
387
        List<ImStmt> stmts;
388
        if (r.expr instanceof ImLExpr) {
1✔
389
            tupleExpr = (ImLExpr) r.expr;
1✔
390
            stmts = r.stmts;
1✔
391
        } else {
392
            // in the unlikely event that this is not an l-value (e.g. foo().x)
393
            // we create a temporary variable and store the result there
394
            ImVar v = JassIm.ImVar(e.attrTrace(), r.expr.attrTyp(), "tuple_temp", false);
×
395
            f.getLocals().add(v);
×
396
            stmts = new ArrayList<>(r.stmts);
×
397
            stmts.add(JassIm.ImSet(e.attrTrace(), ImVarAccess(v), r.expr));
×
398
            tupleExpr = JassIm.ImVarAccess(v);
×
399
        }
400
        return new ResultL(stmts, JassIm.ImTupleSelection(tupleExpr, e.getTupleIndex()));
1✔
401
    }
402

403
    public static ResultL flattenL(ImVarAccess e, ImTranslator t, ImFunction f) {
404
        e.setParent(null);
1✔
405
        return new ResultL(e);
1✔
406
    }
407

408

409
    public static ResultL flatten(ImLExpr e, ImTranslator t, ImFunction f) {
410
        return e.flattenL(t, f);
1✔
411
    }
412

413
    public static ResultL flattenL(ImVarArrayAccess e, ImTranslator t, ImFunction f) {
414
        MultiResult indexes = flattenExprs(t, f, e.getIndexes());
1✔
415
        return new ResultL(indexes.stmts, ImVarArrayAccess(e.getTrace(), e.getVar(), ImExprs(indexes.exprs)));
1✔
416
    }
417

418

419
    public static void flattenFunc(ImFunction f, ImTranslator translator) {
420
        ImStmts newBody = flattenStatements(f.getBody(), translator, f);
1✔
421
        f.setBody(newBody);
1✔
422
    }
1✔
423

424
    public static void flattenProg(ImProg imProg, ImTranslator translator) {
425
        imProg.getFunctions().parallelStream().forEach(f -> f.flatten(translator));
1✔
426
        imProg.getClasses().parallelStream().forEach(c ->
1✔
427
            c.getFunctions().parallelStream().forEach(f -> f.flatten(translator)));
1✔
428

429
        translator.assertProperties(AssertProperty.FLAT);
1✔
430
    }
1✔
431

432
    public static Result flatten(ImCompiletimeExpr e, ImTranslator translator, ImFunction f) {
433
        e.setParent(null);
×
434
        return new Result(e);
×
435
    }
436

437

438
    private static MultiResult flattenExprs(ImTranslator t, ImFunction f, ImExpr... exprs) {
439
        return flattenExprs(t, f, Arrays.asList(exprs));
×
440
    }
441

442
    private static MultiResult flattenExprs(ImTranslator t, ImFunction f, List<ImExpr> exprs) {
443
        // TODO optimize this function to use less temporary variables
444
        List<ImStmt> stmts = Lists.newArrayList();
1✔
445
        List<ImExpr> newExprs = Lists.newArrayList();
1✔
446
        List<Result> results = Lists.newArrayList();
1✔
447
        int withStmts = -1;
1✔
448
        for (int i = 0; i < exprs.size(); i++) {
1✔
449
            Result r = exprs.get(i).flatten(t, f);
1✔
450
            results.add(r);
1✔
451
            if (!r.stmts.isEmpty()) {
1✔
452
                withStmts = i;
1✔
453
            }
454
        }
455
        for (int i = 0; i < exprs.size(); i++) {
1✔
456
            ImExpr e = exprs.get(i);
1✔
457
            Result r = results.get(i);
1✔
458

459
            stmts.addAll(r.stmts);
1✔
460
            if (r.expr.attrPurity() instanceof Pure
1✔
461
                || i >= withStmts) {
462
                newExprs.add(r.expr);
1✔
463
            } else {
464
                ImVar tempVar = JassIm.ImVar(e.attrTrace(), r.expr.attrTyp(), "temp", false);
1✔
465
                f.getLocals().add(tempVar);
1✔
466
                stmts.add(ImSet(e.attrTrace(), ImVarAccess(tempVar), r.expr));
1✔
467
                newExprs.add(JassIm.ImVarAccess(tempVar));
1✔
468
            }
469
        }
470
        return new MultiResult(stmts, newExprs);
1✔
471
    }
472

473
    private static MultiResultL flattenExprsL(ImTranslator t, ImFunction f, List<ImLExpr> exprs) {
474
        // TODO optimize this function to use less temporary variables
475
        List<ImStmt> stmts = Lists.newArrayList();
×
476
        List<ImLExpr> newExprs = Lists.newArrayList();
×
477
        List<ResultL> results = Lists.newArrayList();
×
478
        int withStmts = -1;
×
479
        for (int i = 0; i < exprs.size(); i++) {
×
480
            ResultL r = exprs.get(i).flattenL(t, f);
×
481
            results.add(r);
×
482
            if (!r.stmts.isEmpty()) {
×
483
                withStmts = i;
×
484
            }
485
        }
486
        for (int i = 0; i < exprs.size(); i++) {
×
487
            ImExpr e = exprs.get(i);
×
488
            ResultL r = results.get(i);
×
489

490
            stmts.addAll(r.stmts);
×
491
            if (r.expr.attrPurity() instanceof Pure
×
492
                || i >= withStmts) {
493
                newExprs.add(r.getExpr());
×
494
            } else {
495
                ImVar tempVar = JassIm.ImVar(e.attrTrace(), r.expr.attrTyp(), "temp", false);
×
496
                f.getLocals().add(tempVar);
×
497
                stmts.add(ImSet(e.attrTrace(), ImVarAccess(tempVar), r.expr));
×
498
                newExprs.add(JassIm.ImVarAccess(tempVar));
×
499
            }
500
        }
501
        return new MultiResultL(stmts, newExprs);
×
502
    }
503

504

505
    public static Result flatten(ImMemberAccess e,
506
                                 ImTranslator t, ImFunction f) {
507
        Result rr = e.getReceiver().flatten(t, f);
1✔
508
        MultiResult ir = flattenExprs(t, f, e.getIndexes());
1✔
509
        Result res = new Result(rr.stmts, ImMemberAccess(e.getTrace(), rr.expr, e.getTypeArguments().copy(), e.getVar(), ImExprs(ir.exprs)));
1✔
510
        res.addStmts(ir.stmts);
1✔
511
        return res;
1✔
512
    }
513

514
    public static ResultL flattenL(ImMemberAccess e,
515
                                   ImTranslator t, ImFunction f) {
516
        Result rr = e.getReceiver().flatten(t, f);
×
517
        MultiResult ir = flattenExprs(t, f, e.getIndexes());
×
518
        ResultL res = new ResultL(rr.stmts, ImMemberAccess(e.getTrace(), rr.expr, e.getTypeArguments(), e.getVar(), ImExprs(ir.exprs)));
×
519
        res.addStmts(ir.stmts);
×
520
        return res;
×
521
    }
522

523

524
    public static Result flatten(ImGetStackTrace e, ImTranslator translator,
525
                                 ImFunction f) {
526
        e.setParent(null);
1✔
527
        return new Result(e);
1✔
528
    }
529

530

531
    public static Result flatten(ImVarargLoop s, ImTranslator translator, ImFunction f) {
532
        return new Result(Collections.singletonList(
1✔
533
            JassIm.ImVarargLoop(s.getTrace(), flattenStatements(s.getBody(), translator, f), s.getLoopVar())));
1✔
534
    }
535

536

537
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc