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

wurstscript / WurstScript / 228

29 Nov 2023 05:00PM UTC coverage: 62.48% (-0.09%) from 62.574%
228

push

circleci

web-flow
Show dialog for choosing game path, cleanup (#1083)

* show dialog for choosing game path

* cleanup code

* remove logs and refactor

* remove confusing mpq error, make some mpq loads readonly

17295 of 27681 relevant lines covered (62.48%)

0.62 hits per line

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

69.7
de.peeeq.wurstscript/src/main/java/de/peeeq/wurstscript/translation/lua/translation/StmtTranslation.java
1
package de.peeeq.wurstscript.translation.lua.translation;
2

3
import de.peeeq.wurstscript.jassIm.*;
4
import de.peeeq.wurstscript.luaAst.*;
5

6
import java.util.List;
7

8
public class StmtTranslation {
×
9

10
    public static void translate(ImExpr e, List<LuaStatement> res, LuaTranslator tr) {
11
        LuaExpr expr = e.translateToLua(tr);
1✔
12
        res.add(expr);
1✔
13
    }
1✔
14

15
    public static void translate(ImExitwhen s, List<LuaStatement> res, LuaTranslator tr) {
16
        LuaIf r = LuaAst.LuaIf(s.getCondition().translateToLua(tr),
1✔
17
            LuaAst.LuaStatements(LuaAst.LuaBreak()),
1✔
18
            LuaAst.LuaStatements());
1✔
19
        res.add(r);
1✔
20
    }
1✔
21

22
    public static void translate(ImLoop s, List<LuaStatement> res, LuaTranslator tr) {
23
        res.add(LuaAst.LuaWhile(LuaAst.LuaExprBoolVal(true), tr.translateStatements(s.getBody())));
1✔
24
    }
1✔
25

26
    public static void translate(ImIf s, List<LuaStatement> res, LuaTranslator tr) {
27
        res.add(LuaAst.LuaIf(s.getCondition().translateToLua(tr),
1✔
28
            tr.translateStatements(s.getThenBlock()),
1✔
29
            tr.translateStatements(s.getElseBlock())));
1✔
30
    }
1✔
31

32
    public static void translate(ImReturn s, List<LuaStatement> res, LuaTranslator tr) {
33
        res.add(LuaAst.LuaReturn(tr.translateOptional(s.getReturnValue())));
1✔
34
    }
1✔
35

36
    public static void translate(ImSet s, List<LuaStatement> res, LuaTranslator tr) {
37
        LuaExpr left = s.getLeft().translateToLua(tr);
1✔
38
        LuaExpr right = s.getRight().translateToLua(tr);
1✔
39
        if (s.getRight().attrTyp() instanceof ImTupleType) {
1✔
40
            ImTupleType tt = (ImTupleType) s.getRight().attrTyp();
1✔
41
            // tuples must be copied, unless they are literals
42
            if(!(right instanceof LuaTableConstructor)) {
1✔
43
                right = LuaAst.LuaExprFunctionCall(ExprTranslation.getTupleCopyFunc(tt, tr), LuaAst.LuaExprlist(right));
×
44
            }
45
        }
46
        res.add(LuaAst.LuaAssignment(left, right));
1✔
47
    }
1✔
48

49

50
    public static void translate(ImVarargLoop loop, List<LuaStatement> res, LuaTranslator tr) {
51
        LuaVariable loopVar = tr.luaVar.getFor(loop.getLoopVar());
×
52
//        res.add(loopVar);
53
        LuaVariable i = LuaAst.LuaVariable(tr.uniqueName("i"),  LuaAst.LuaExprIntVal("0"));
×
54
        res.add(LuaAst.LuaLiteral("local __args = table.pack(...)"));
×
55
        res.add(LuaAst.LuaLiteral("for " + i.getName() + "=1,__args.n do"));
×
56
        res.add(LuaAst.LuaAssignment(LuaAst.LuaExprVarAccess(loopVar), LuaAst.LuaExprArrayAccess(LuaAst.LuaLiteral("__args"), LuaAst.LuaExprlist(LuaAst.LuaExprVarAccess(i)))));
×
57
        tr.translateStatements(res, loop.getBody());
×
58
        res.add(LuaAst.LuaLiteral("end"));
×
59
    }
×
60

61
}
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