Skip to content

Commit 014f2e2

Browse files
authored
Another lua fix (#1179)
1 parent 91cdc24 commit 014f2e2

File tree

9 files changed

+619
-122
lines changed

9 files changed

+619
-122
lines changed

de.peeeq.wurstscript/parserspec/jass_im.parseq

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ ImMethod(@ignoreForEquality de.peeeq.wurstscript.ast.Element trace,
6868
String name,
6969
ref ImFunction implementation,
7070
java.util.List<ImMethod> subMethods,
71+
java.util.List<String> luaMethodDispatchAliases,
72+
String luaDispatchGroupKey,
7173
boolean isAbstract)
7274

7375

de.peeeq.wurstscript/src/main/java/de/peeeq/wurstio/WurstCompilerJassImpl.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -943,6 +943,10 @@ public LuaCompilationUnit transformProgToLua() {
943943
imProg.flatten(imTranslator);
944944
timeTaker.endPhase();
945945

946+
beginPhase(13, "prepare lua dispatch");
947+
LuaDispatchPreparation.prepare(imProg);
948+
timeTaker.endPhase();
949+
946950
beginPhase(14, "translate to lua");
947951
LuaTranslator luaTranslator = new LuaTranslator(imProg, imTranslator);
948952
LuaCompilationUnit luaCode = luaTranslator.translate();

de.peeeq.wurstscript/src/main/java/de/peeeq/wurstscript/translation/imtranslation/ClosureTranslator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ private ImClass createClass() {
195195
tr.getImProg().getFunctions().remove(impl);
196196
c.getFunctions().add(impl);
197197
ImClassType methodClass = JassIm.ImClassType(c, JassIm.ImTypeArguments());
198-
ImMethod m = JassIm.ImMethod(e, methodClass, superMethod.getName(), impl, JassIm.ImMethods(), false);
198+
ImMethod m = JassIm.ImMethod(e, methodClass, superMethod.getName(), impl, JassIm.ImMethods(), Lists.newArrayList(), "", false);
199199
c.getMethods().add(m);
200200

201201
OverrideUtils.addOverrideClosure(tr, superMethod, m, e);

de.peeeq.wurstscript/src/main/java/de/peeeq/wurstscript/translation/imtranslation/GetAForB.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@ public abstract class GetAForB<B, A> {
1111
public abstract A initFor(B a);
1212

1313
public A getFor(B a) {
14-
if (thing.containsKey(a)) {
15-
return thing.get(a);
14+
A existing = thing.get(a);
15+
if (existing != null) {
16+
return existing;
1617
}
17-
A b = initFor(a);
18-
thing.put(a, b);
19-
return b;
18+
A created = initFor(a);
19+
thing.put(a, created);
20+
return created;
2021
}
2122

2223
}

de.peeeq.wurstscript/src/main/java/de/peeeq/wurstscript/translation/imtranslation/ImTranslator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,7 @@ public ImFunction initFor(StructureDef classDef) {
772772
public ImMethod initFor(StructureDef classDef) {
773773
ImFunction impl = destroyFunc.getFor(classDef);
774774
ImMethod m = JassIm.ImMethod(classDef, selfType(classDef), "destroy" + classDef.getName(),
775-
impl, Lists.newArrayList(), false);
775+
impl, Lists.newArrayList(), Lists.newArrayList(), "", false);
776776
return m;
777777
}
778778
};
@@ -2039,7 +2039,7 @@ public ImMethod getMethodFor(FuncDef f) {
20392039
// otherwise EliminateClasses dispatch lookup can fail.
20402040
String methodName = imFunc.getName();
20412041
WLogger.trace(() -> "[GENCAP] getMethodFor " + elementNameWithPath(f) + " -> methodName=" + methodName);
2042-
m = JassIm.ImMethod(f, selfType(f), methodName, imFunc, Lists.newArrayList(), false);
2042+
m = JassIm.ImMethod(f, selfType(f), methodName, imFunc, Lists.newArrayList(), Lists.newArrayList(), "", false);
20432043
methodForFuncDef.put(f, m);
20442044
}
20452045
return m;

0 commit comments

Comments
 (0)