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

wurstscript / WurstScript / 254

24 Jun 2025 03:56PM UTC coverage: 62.245% (-0.03%) from 62.277%
254

push

circleci

Frotty
Ignore defunct test

17265 of 27737 relevant lines covered (62.25%)

0.62 hits per line

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

60.87
de.peeeq.wurstscript/src/main/java/de/peeeq/wurstscript/types/TypesHelper.java
1
package de.peeeq.wurstscript.types;
2

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

5
public class TypesHelper {
×
6

7
    private static final ImSimpleType intType = WurstTypeInt.instance().imTranslateType();
1✔
8

9
    private static final ImSimpleType realType = WurstTypeReal.instance().imTranslateType();
1✔
10

11

12
    public static ImSimpleType imInt() {
13
        return intType;
1✔
14
    }
15

16
    public static ImSimpleType imReal() {
17
        return realType;
×
18
    }
19

20
    public static ImSimpleType imString() {
21
        return WurstTypeString.instance().imTranslateType();
1✔
22
    }
23

24
    public static ImType imVoid() {
25
        return WurstTypeVoid.instance().imTranslateType();
1✔
26
    }
27

28

29
    public static ImType imBool() {
30
        return WurstTypeBool.instance().imTranslateType();
×
31
    }
32

33
    public static ImType imHashTable() {
34
        return JassIm.ImSimpleType("hashtable");
1✔
35
    }
36

37
    public static ImArrayType imIntArray() {
38
        return JassIm.ImArrayType(imInt());
×
39
    }
40

41
    public static ImArrayType imStringArray() {
42
        return JassIm.ImArrayType(imString());
1✔
43
    }
44

45
    public static boolean typeContainsTuples(ImType vt) {
46
        return vt instanceof ImTupleType
1✔
47
                || vt instanceof ImArrayType && typeContainsTuples(((ImArrayType) vt).getEntryType())
1✔
48
                || vt instanceof ImArrayTypeMulti && typeContainsTuples(((ImArrayTypeMulti) vt).getEntryType());
1✔
49
    }
50
    
51
    public static ImVar getSimpleAndPureTupleVar(ImTupleSelection ts) {
52
        ImExpr te = ts;
×
53
        while(te instanceof ImTupleSelection) {
×
54
            te = ((ImTupleSelection) te).getTupleExpr();
×
55
        }
56
        if(te instanceof ImVarAccess) {
×
57
            ImVar var = ((ImVarAccess) te).getVar();
×
58
            if(var.isGlobal()) {
×
59
                return null;
×
60
            }
61
            return var;
×
62
        }
63
        return null;
×
64
    }
65
    
66
    public static ImVar getTupleVar(ImTupleSelection ts) {
67
        ImExpr te = ts;
1✔
68
        while(te instanceof ImTupleSelection) {
1✔
69
            te = ((ImTupleSelection) te).getTupleExpr();
1✔
70
        }
71
        if(te instanceof ImVarAccess) {
1✔
72
            return ((ImVarAccess) te).getVar();
1✔
73
        }
74
        if(te instanceof ImVarArrayAccess) {
1✔
75
            return ((ImVarArrayAccess) te).getVar();
1✔
76
        }
77
        if(te instanceof ImMemberAccess) {
×
78
            return ((ImMemberAccess) te).getVar();
×
79
        }
80
        throw new Error("not implemented");
×
81
    }
82

83
    public static boolean isIntType(ImType t) {
84
        if (t instanceof ImSimpleType) {
1✔
85
            return ((ImSimpleType) t).getTypename().equals("integer");
1✔
86
        }
87
        return false;
1✔
88
    }
89

90
    public static boolean isRealType(ImType t) {
91
        if (t instanceof ImSimpleType) {
1✔
92
            return ((ImSimpleType) t).getTypename().equals("real");
1✔
93
        }
94
        return false;
1✔
95
    }
96

97
    public static boolean isBoolType(ImType t) {
98
        if (t instanceof ImSimpleType) {
1✔
99
            return ((ImSimpleType) t).getTypename().equals("boolean");
1✔
100
        }
101
        return false;
×
102
    }
103

104
    public static boolean isStringType(ImType t) {
105
        if (t instanceof ImSimpleType) {
1✔
106
            return ((ImSimpleType) t).getTypename().equals("string");
1✔
107
        }
108
        return false;
1✔
109
    }
110

111
    public static ImSimpleType imTrigger() {
112
        return JassIm.ImSimpleType("trigger");
×
113
    }
114

115

116
//        public static boolean checkTypeArgs(InstanceDef iDef, List<PscriptType> classParams, List<PscriptType> interfaceParams) {
117
//                if (classParams.size() == 0 && interfaceParams.size() == 0) {
118
//                        return true;
119
//                }
120
//                
121
//                Map<TypeParamDef, PscriptType> typeParamBinding = Maps.newLinkedHashMap(); 
122
//                
123
//                PscriptTypeClass classType = (PscriptTypeClass) iDef.getClassTyp().attrTyp();
124
//                int i = 0;
125
//                for (PscriptType classTp : classType.getTypeParameters()) {
126
//                        PscriptTypeTypeParam classTp2 = (PscriptTypeTypeParam) classTp;
127
//                        TypeParamDef tpDef = classTp2.getDef();
128
//                        typeParamBinding.put(tpDef, classParams.get(i));
129
//                        i++;
130
//                }
131
//                
132
//                ArrayList<PscriptType> actualInterfaceTypes = Lists.newArrayList();
133
//                
134
//                PscriptTypeInterface interfaceType = (PscriptTypeInterface) iDef.getImplementedTyp().attrTyp();
135
//                for (PscriptType intTp : interfaceType.getTypeParameters()) {
136
//                        if (intTp instanceof PscriptTypeTypeParam) {
137
//                                PscriptTypeTypeParam intTp2 = (PscriptTypeTypeParam) intTp;
138
//                                actualInterfaceTypes.add(typeParamBinding.get(intTp2.getDef()));
139
//                        } else {
140
//                                actualInterfaceTypes.add(intTp);
141
//                        }
142
//                }
143
//                
144
//                if (actualInterfaceTypes.size() != interfaceParams.size()) {
145
//                        throw new CompileError(iDef.getSource(), "sizes do not match: " + actualInterfaceTypes.size()+ " != " + interfaceParams.size());
146
//                }
147
//                
148
//                i = 0;
149
//                for (PscriptType iTp : interfaceParams) {
150
//                        if (!iTp.equalsType(actualInterfaceTypes.get(i), iDef)) {
151
//                                return false;
152
//                        }
153
//                        i++;
154
//                }
155
//                
156
//                
157
//                return true;
158
//        }
159

160

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

© 2026 Coveralls, Inc