Skip to content

Commit e7ddf90

Browse files
committed
wip
1 parent 9086113 commit e7ddf90

24 files changed

+91
-179
lines changed

de.peeeq.wurstscript/parserspec/jass_im.parseq

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,11 @@ ImProg(
99
ImFunctions functions,
1010
ImMethods methods,
1111
ImClasses classes,
12-
ImTypeClassFuncs typeClassFunctions,
1312
java.util.Map<ImVar, java.util.List<ImExpr>> globalInits)
1413

1514
ImVars * ImVar
1615
ImFunctions * ImFunction
1716
ImClasses * ImClass
18-
ImTypeClassFuncs * ImTypeClassFunc
1917

2018
ImVar(@ignoreForEquality de.peeeq.wurstscript.ast.Element trace, ref ImType type, String name, boolean isBJ)
2119

@@ -46,11 +44,6 @@ ImFunction(@ignoreForEquality de.peeeq.wurstscript.ast.Element trace,
4644
ImStmts body,
4745
java.util.List<de.peeeq.wurstscript.translation.imtranslation.FunctionFlag> flags)
4846

49-
ImTypeClassFunc(@ignoreForEquality de.peeeq.wurstscript.ast.Element trace,
50-
String name,
51-
ImTypeVars typeVariables,
52-
ImVars parameters,
53-
ref ImType returnType)
5447

5548

5649
ImClass(@ignoreForEquality de.peeeq.wurstscript.ast.Element trace,
@@ -100,8 +93,6 @@ ImExpr =
10093
| ImGetStackTrace()
10194
| ImCompiletimeExpr(@ignoreForEquality de.peeeq.wurstscript.ast.Element trace, ImExpr expr, int executionOrderIndex)
10295
| ImLExpr
103-
| ImTypeVarDispatch(@ignoreForEquality de.peeeq.wurstscript.ast.Element trace, ref ImTypeClassFunc typeClassFunc, ImExprs arguments
104-
, ref ImTypeVar typeVariable)
10596
| ImCast(ImExpr expr, ref ImType toType)
10697

10798
// an expression which can be used on the left hand side of an assignment
@@ -148,7 +139,7 @@ ImConst =
148139

149140
ImTypeArguments * ImTypeArgument
150141

151-
ImTypeArgument(ref ImType type, java.util.Map<ImTypeClassFunc, io.vavr.control.Either<ImMethod, ImFunction>> typeClassBinding)
142+
ImTypeArgument(ref ImType type)
152143

153144
// helper types:
154145

de.peeeq.wurstscript/src/main/java/de/peeeq/wurstscript/intermediatelang/interpreter/EvaluateExpr.java

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -398,28 +398,6 @@ public ILconst get() {
398398
}
399399

400400

401-
public static ILconst eval(ImTypeVarDispatch e, ProgramState globalState, LocalState localState) {
402-
Either<ImMethod, ImFunction> impl = localState.getImplementation(e.getTypeVariable(), e.getTypeClassFunc());
403-
if (impl == null) {
404-
throw new InterpreterException(globalState, "Could not find implementation for " + e.getTypeVariable() + "." + e.getTypeClassFunc().getName());
405-
}
406-
ILconst[] eArgs = e.getArguments().stream()
407-
.map(arg -> arg.evaluate(globalState, localState))
408-
.toArray(ILconst[]::new);
409-
410-
return impl.fold(
411-
(ImMethod m) -> {
412-
ILconst receiver1 = eArgs[0];
413-
ILconstObject receiver = globalState.toObject(receiver1);
414-
globalState.assertAllocated(receiver, e.attrTrace());
415-
ImMethod mostPreciseMethod = findMostPreciseMethod(e.attrTrace(), globalState, receiver, m);
416-
return evaluateFunc(globalState, mostPreciseMethod.getImplementation(), e, Collections.emptyList(), eArgs);
417-
},
418-
(ImFunction f) ->
419-
evaluateFunc(globalState, f, e, Collections.emptyList(), eArgs) // TODO type var dispatch should also have type arguments?
420-
);
421-
}
422-
423401
public static ILconst eval(ImCast imCast, ProgramState globalState, LocalState localState) {
424402
ILconst res = imCast.getExpr().evaluate(globalState, localState);
425403
if (TypesHelper.isIntType(imCast.getToType())) {

de.peeeq.wurstscript/src/main/java/de/peeeq/wurstscript/intermediatelang/interpreter/ILInterpreter.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ public static LocalState runFunc(ProgramState globalState, ImFunction f, @Nullab
7979
}
8080

8181
LocalState localState = new LocalState();
82-
localState.setTypeArguments(f.getTypeVariables(), typeArguments);
8382

8483
int i = 0;
8584
for (ImVar p : f.getParameters()) {

de.peeeq.wurstscript/src/main/java/de/peeeq/wurstscript/intermediatelang/interpreter/LocalState.java

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
public class LocalState extends State {
1515

1616
private @Nullable ILconst returnVal = null;
17-
private Table<ImTypeVar, ImTypeClassFunc, Either<ImMethod, ImFunction>> typeClassImplementations = HashBasedTable.create();
1817

1918
public LocalState(ILconst returnVal) {
2019
this.setReturnVal(returnVal);
@@ -32,18 +31,4 @@ public LocalState setReturnVal(@Nullable ILconst returnVal) {
3231
return this;
3332
}
3433

35-
36-
public Either<ImMethod, ImFunction> getImplementation(ImTypeVar typeVariable, ImTypeClassFunc typeClassFunc) {
37-
return typeClassImplementations.get(typeVariable, typeClassFunc);
38-
}
39-
40-
public void setTypeArguments(ImTypeVars typeVariables, List<ImTypeArgument> typeArguments) {
41-
for (int i = 0; i < typeVariables.size() && i < typeArguments.size(); i++) {
42-
ImTypeVar typeVariable = typeVariables.get(i);
43-
ImTypeArgument typeArgument = typeArguments.get(i);
44-
for (Map.Entry<ImTypeClassFunc, Either<ImMethod, ImFunction>> e : typeArgument.getTypeClassBinding().entrySet()) {
45-
typeClassImplementations.put(typeVariable, e.getKey(), e.getValue());
46-
}
47-
}
48-
}
4934
}

de.peeeq.wurstscript/src/main/java/de/peeeq/wurstscript/intermediatelang/optimizer/SideEffectAnalyzer.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,6 @@ public Boolean case_ImGetStackTrace(ImGetStackTrace imGetStackTrace) {
9696
return true;
9797
}
9898

99-
@Override
100-
public Boolean case_ImTypeVarDispatch(ImTypeVarDispatch imTypeVarDispatch) {
101-
return true;
102-
}
103-
10499
@Override
105100
public Boolean case_ImOperatorCall(ImOperatorCall e) {
106101
return e.getArguments().stream().anyMatch(SideEffectAnalyzer::quickcheckHasSideeffects);

de.peeeq.wurstscript/src/main/java/de/peeeq/wurstscript/translation/imtojass/ExprTranslation.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,6 @@ public static JassExpr translate(ImCompiletimeExpr e, ImToJassTranslator transla
140140
"Enable '-runcompiletimefunctions' to evaluate compiletime expressions.");
141141
}
142142

143-
public static JassExpr translate(ImTypeVarDispatch e, ImToJassTranslator translator) {
144-
throw new CompileError(e, "Typevar dispatch not eliminated.");
145-
}
146143

147144
public static JassExpr translate(ImCast imCast, ImToJassTranslator translator) {
148145
return imCast.getExpr().translate(translator);

de.peeeq.wurstscript/src/main/java/de/peeeq/wurstscript/translation/imtojass/ImAttrType.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,6 @@ public static ImType getType(ImCompiletimeExpr e) {
212212
return e.getExpr().attrTyp();
213213
}
214214

215-
public static ImType getType(ImTypeVarDispatch e) {
216-
return e.getTypeClassFunc().getReturnType();
217-
}
218-
219215
public static ImType getType(ImCast imCast) {
220216
return imCast.getToType();
221217
}

de.peeeq.wurstscript/src/main/java/de/peeeq/wurstscript/translation/imtojass/TypeEquality.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,6 @@ public static boolean isEqualType(ImClassType c, ImType other) {
7575
if (!x.getType().equalsType(y.getType())) {
7676
return false;
7777
}
78-
if (!x.getTypeClassBinding().equals(y.getTypeClassBinding())) {
79-
return false;
80-
}
8178
}
8279
return true;
8380
}

de.peeeq.wurstscript/src/main/java/de/peeeq/wurstscript/translation/imtojass/TypeRewriteMatcher.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public ImType case_ImArrayType(ImArrayType t) {
5353
public ImType case_ImClassType(ImClassType t) {
5454
ImTypeArguments args = t.getTypeArguments()
5555
.stream()
56-
.map(ta -> JassIm.ImTypeArgument(ta.getType().match(this), ta.getTypeClassBinding()))
56+
.map(ta -> JassIm.ImTypeArgument(ta.getType().match(this)))
5757
.collect(Collectors.toCollection(JassIm::ImTypeArguments));
5858
return JassIm.ImClassType(t.getClassDef(), args);
5959
}

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,11 @@ public void check(Element e) {
4343
ImFunction f = (ImFunction) e;
4444
currentFunction = f;
4545
checkType(e, (f).getReturnType());
46-
} else if (e instanceof ImTypeClassFunc) {
47-
checkType(e, ((ImTypeClassFunc) e).getReturnType());
4846
} else if (e instanceof ImMethod) {
4947
checkType(e, ((ImMethod) e).getMethodClass());
5048
checkRooted(e, ((ImMethod) e).getImplementation());
5149
} else if (e instanceof ImVarargLoop) {
5250
checkRooted(e, ((ImVarargLoop) e).getLoopVar());
53-
} else if (e instanceof ImTypeVarDispatch) {
54-
checkRooted(e, ((ImTypeVarDispatch) e).getTypeClassFunc());
55-
checkRooted(e, ((ImTypeVarDispatch) e).getTypeVariable());
5651
} else if (e instanceof ImVarAccess) {
5752
checkRooted(e, ((ImVarAccess) e).getVar());
5853
} else if (e instanceof ImVarArrayAccess) {

0 commit comments

Comments
 (0)