• 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

87.5
de.peeeq.wurstscript/src/main/java/de/peeeq/wurstscript/types/WurstTypeTuple.java
1
package de.peeeq.wurstscript.types;
2

3
import com.google.common.base.Preconditions;
4
import com.google.common.collect.Lists;
5
import de.peeeq.wurstscript.ast.Element;
6
import de.peeeq.wurstscript.ast.TupleDef;
7
import de.peeeq.wurstscript.ast.VarDef;
8
import de.peeeq.wurstscript.ast.WParameter;
9
import de.peeeq.wurstscript.attributes.CompileError;
10
import de.peeeq.wurstscript.jassIm.*;
11
import de.peeeq.wurstscript.translation.imtranslation.ImTranslator;
12
import de.peeeq.wurstscript.utils.Utils;
13
import org.eclipse.jdt.annotation.Nullable;
14

15
import java.util.List;
16
import java.util.Optional;
17

18

19
public class WurstTypeTuple extends WurstType {
20

21
    private final TupleDef tupleDef;
22

23

24
    public WurstTypeTuple(TupleDef tupleDef) {
1✔
25
        Preconditions.checkNotNull(tupleDef);
1✔
26
        this.tupleDef = tupleDef;
1✔
27
    }
1✔
28

29
    @Override
30
    VariableBinding matchAgainstSupertypeIntern(WurstType other, @Nullable Element location, VariableBinding mapping, VariablePosition variablePosition) {
31
        if (other instanceof WurstTypeTuple) {
1✔
32
            WurstTypeTuple otherTuple = (WurstTypeTuple) other;
1✔
33
            if (tupleDef == otherTuple.tupleDef) {
1✔
34
                return mapping;
1✔
35
            }
36
        }
37
        return null;
1✔
38
    }
39

40

41
    public TupleDef getTupleDef() {
42
        return tupleDef;
1✔
43
    }
44

45
    @Override
46
    public String getName() {
47
        return tupleDef.getName();
1✔
48
    }
49

50
    @Override
51
    public String getFullName() {
52
        return getName();
×
53
    }
54

55

56
    @Override
57
    public ImType imTranslateType(ImTranslator tr) {
58
        List<ImType> types = Lists.newArrayList();
1✔
59
        List<String> names = Lists.newArrayList();
1✔
60
        for (WParameter p : tupleDef.getParameters()) {
1✔
61
            ImType pt = p.attrTyp().imTranslateType(tr);
1✔
62
            types.add(pt);
1✔
63
            names.add(p.getName());
1✔
64
        }
1✔
65
        return JassIm.ImTupleType(types, names);
1✔
66
    }
67

68
    @Override
69
    public ImExprOpt getDefaultValue(ImTranslator tr) {
70
        ImExprs exprs = JassIm.ImExprs();
1✔
71
        for (WParameter p : tupleDef.getParameters()) {
1✔
72
            exprs.add((ImExpr) p.attrTyp().getDefaultValue(tr));
1✔
73
        }
1✔
74
        return JassIm.ImTupleExpr(exprs);
1✔
75
    }
76

77
    @Override
78
    protected boolean isNullable() {
79
        return false;
×
80
    }
81

82
    public int getTupleIndex(VarDef varDef) {
83
        WParameter v = (WParameter) varDef;
1✔
84
        int index = tupleDef.getParameters().indexOf(v);
1✔
85
        if (index < 0) {
1✔
86
            throw new CompileError(varDef.getSource(),
×
87
                "Could not determine tuple index of "
88
                + Utils.printElementWithSource(Optional.of(varDef))
×
89
                + " in tuple "
90
                + this);
91
        }
92
        return index;
1✔
93
    }
94
}
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