Skip to content

Commit

Permalink
additional flatten step, because it introduces statement-expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
peq committed Oct 20, 2018
1 parent 7cab74d commit be6bd94
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import de.peeeq.wurstscript.WurstOperator;
import de.peeeq.wurstscript.jassIm.*;
import de.peeeq.wurstscript.translation.imtranslation.Flatten;
import de.peeeq.wurstscript.translation.imtranslation.ImTranslator;

import java.util.Arrays;
Expand All @@ -23,7 +24,7 @@ public int optimize(ImTranslator trans) {
totalCallsRemoved = 0;
ImProg prog = trans.getImProg();
for (ImFunction func : prog.getFunctions()) {
optimizeFunc(func);
optimizeFunc(func, trans);
}
return totalCallsRemoved;
}
Expand All @@ -33,9 +34,9 @@ public String getName() {
return "Useless function calls removed";
}

private void optimizeFunc(ImFunction func) {
private void optimizeFunc(ImFunction func, ImTranslator trans) {
optimizeStmts(func.getBody());

func.flatten(trans);
}

private void optimizeStmts(ImStmts stmts) {
Expand Down

0 comments on commit be6bd94

Please sign in to comment.