• 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

93.94
de.peeeq.wurstscript/src/main/java/de/peeeq/wurstscript/attributes/AttrTypeExprType.java
1
package de.peeeq.wurstscript.attributes;
2

3
import de.peeeq.wurstscript.ast.*;
4
import de.peeeq.wurstscript.types.*;
5
import de.peeeq.wurstscript.utils.Utils;
6

7
/**
8
 * this attribute gives you the type for a type expr
9
 */
10
public class AttrTypeExprType {
×
11

12

13
    public static WurstType calculate(TypeExprSimple node) {
14
        WurstType baseType = getBaseType(node);
1✔
15
        if (node.getTypeArgs().size() > 0) {
1✔
16
            if (baseType instanceof WurstTypeNamedScope) {
1✔
17
                WurstTypeNamedScope ns = (WurstTypeNamedScope) baseType;
1✔
18
                return ns.replaceTypeVarsUsingTypeArgs(node.getTypeArgs());
1✔
19
            } else {
20
                node.addError("Type " + baseType + " cannot have type args");
×
21
            }
22
        }
23
        return baseType;
1✔
24
    }
25

26

27
    public static WurstType calculate(TypeExprThis node) {
28
        WurstType scopeType = node.getScopeType().attrTyp();
1✔
29
        Element scope;
30
        if (scopeType instanceof WurstTypeNamedScope) {
1✔
31
            WurstTypeNamedScope wtns = (WurstTypeNamedScope) scopeType;
1✔
32
            scope = wtns.getDef();
1✔
33
        } else {
1✔
34
            scope = node;
1✔
35
        }
36
        return AttrExprType.caclulateThistype(scope, false, "thistype");
1✔
37
//                ClassOrModule n = node.attrNearestClassOrModule();
38
//                if (n == null) {
39
//                        node.addError("'thistype' can only be used in classes and modules.");
40
//                        return WurstTypeUnknown.instance();
41
//                }
42
//                return n.match(new ClassOrModule.Matcher<WurstType>() {
43
//
44
//                        @Override
45
//                        public WurstType case_ClassDef(ClassDef classDef) {
46
//                                WurstTypeClass t = (WurstTypeClass) classDef.attrTyp();
47
//                                t.gett
48
//                        }
49
//
50
//                        @Override
51
//                        public WurstType case_ModuleDef(ModuleDef moduleDef) {
52
//                                return new WurstTypeModule(moduleDef, true);
53
//                        }
54
//
55
//                });
56
    }
57

58
    public static WurstType calculate(NoTypeExpr optType) {
59
        return WurstTypeVoid.instance();
1✔
60
    }
61

62

63
    public static WurstType calculate(TypeExprArray typeExprArray) {
64
        WurstType baseType = typeExprArray.getBase().attrTyp().dynamic();
1✔
65
        if (typeExprArray.getArraySize() instanceof NoExpr) {
1✔
66
            return new WurstTypeArray(baseType);
1✔
67
        } else { // otherwise it must be an Expr
68
            Expr arSize = (Expr) typeExprArray.getArraySize();
1✔
69
            return new WurstTypeArray(baseType, arSize);
1✔
70
        }
71
    }
72

73
    private static WurstType getBaseType(TypeExprSimple node) {
74
        final String typename = node.getTypeName();
1✔
75
        final boolean isJassCode = Utils.isJassCode(node);
1✔
76
        TypeDef t = node.attrTypeDef();
1✔
77
        if (t == null) {
1✔
78
            WurstType nativeType = NativeTypes.nativeType(typename, isJassCode);
1✔
79
            if (nativeType != null) {
1✔
80
                return nativeType;
1✔
81
            }
82
            node.addError("Unknown type " + typename);
1✔
83
            return new WurstTypeUnknown(typename);
1✔
84
        }
85
        return t.attrTyp();
1✔
86
    }
87

88
    public static WurstType normalizedType(OptTypeExpr e) {
89
        return e.attrTypRaw().normalize();
1✔
90
    }
91

92
    public static WurstType calculate(TypeExprResolved e) {
93
        return e.getResolvedType();
1✔
94
    }
95

96

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