• 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

0.0
de.peeeq.wurstscript/src/main/java/de/peeeq/wurstscript/translation/imtranslation/NormalizeNames.java
1
package de.peeeq.wurstscript.translation.imtranslation;
2

3
import com.google.common.collect.ImmutableMultimap;
4
import com.google.common.collect.Multimap;
5
import de.peeeq.wurstscript.ast.AstElementWithNameId;
6
import de.peeeq.wurstscript.ast.Element;
7
import de.peeeq.wurstscript.ast.OnDestroyDef;
8
import de.peeeq.wurstscript.jassIm.ImClass;
9
import de.peeeq.wurstscript.jassIm.ImMethod;
10
import de.peeeq.wurstscript.jassIm.ImProg;
11
import de.peeeq.wurstscript.jassIm.ImVar;
12

13
/**
14
 *
15
 */
16
public class NormalizeNames {
×
17
    /**
18
     * uses the original names when possible instead of the mangled names
19
     */
20
    public static void normalizeNames(ImProg prog) {
21
        Multimap<ImMethod, ImMethod> superMethods = calculateSuperMethods(prog);
×
22
//        for (ImVar g : prog.getGlobals()) {
23
//            normalizeName(g);
24
//        }
25
//        for (ImFunction f : prog.getFunctions()) {
26
//            normalizeName(f);
27
//        }
28
        for (ImClass c : prog.getClasses()) {
×
29
            for (ImVar g : c.getFields()) {
×
30
                normalizeName(g);
×
31
            }
×
32
//            for (ImFunction f : c.getFunctions()) {
33
//                normalizeName(f);
34
//            }
35
            for (ImMethod m : c.getMethods()) {
×
36
                Element trace = m.attrTrace();
×
37
                if (trace instanceof AstElementWithNameId) {
×
38
                    m.setName(((AstElementWithNameId) trace).getNameId().getName());
×
39
                }
40
                if (trace instanceof OnDestroyDef) {
×
41
                    m.setName("__onDestroy");
×
42
                }
43
                // if this has no supermethods, make sure all submethods
44
                // have the same name
45
                if (superMethods.get(m).isEmpty()) {
×
46
                    for (ImMethod subMethod : m.getSubMethods()) {
×
47
                        subMethod.setName(m.getName());
×
48
                    }
×
49
                }
50

51
            }
×
52

53
//            Element trace = c.attrTrace();
54
//            if (trace instanceof AstElementWithNameId) {
55
//                c.setName(((AstElementWithNameId) trace).getNameId().getName());
56
//            }
57
        }
×
58
    }
×
59

60
    private static void normalizeName(ImVar g) {
61
        Element trace = g.attrTrace();
×
62
        if (trace instanceof AstElementWithNameId) {
×
63
            g.setName(((AstElementWithNameId) trace).getNameId().getName());
×
64
        }
65
    }
×
66

67
    private static Multimap<ImMethod, ImMethod> calculateSuperMethods(ImProg prog) {
68
        ImmutableMultimap.Builder<ImMethod, ImMethod> builder = ImmutableMultimap.builder();
×
69
        for (ImClass c : prog.getClasses()) {
×
70
            for (ImMethod m : c.getMethods()) {
×
71
                for (ImMethod subMethod : m.getSubMethods()) {
×
72
                    builder.put(subMethod, m);
×
73
                }
×
74
            }
×
75
        }
×
76
        return builder.build();
×
77
    }
78
}
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