diff --git a/core/src/main/java/org/teavm/ast/RecursiveVisitor.java b/core/src/main/java/org/teavm/ast/RecursiveVisitor.java new file mode 100644 index 000000000..efd0483cb --- /dev/null +++ b/core/src/main/java/org/teavm/ast/RecursiveVisitor.java @@ -0,0 +1,194 @@ +/* + * Copyright 2016 Alexey Andreev. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.teavm.ast; + +import java.util.List; + +public class RecursiveVisitor implements ExprVisitor, StatementVisitor { + @Override + public void visit(BinaryExpr expr) { + expr.getFirstOperand().acceptVisitor(this); + expr.getSecondOperand().acceptVisitor(this); + } + + @Override + public void visit(UnaryExpr expr) { + expr.getOperand().acceptVisitor(this); + } + + @Override + public void visit(AssignmentStatement statement) { + if (statement.getLeftValue() != null) { + statement.getLeftValue().acceptVisitor(this); + } + statement.getRightValue().acceptVisitor(this); + } + + @Override + public void visit(ConditionalExpr expr) { + expr.getCondition().acceptVisitor(this); + expr.getConsequent().acceptVisitor(this); + expr.getAlternative().acceptVisitor(this); + } + + public void visit(List statements) { + for (Statement part : statements) { + part.acceptVisitor(this); + } + } + + @Override + public void visit(SequentialStatement statement) { + visit(statement.getSequence()); + } + + @Override + public void visit(ConstantExpr expr) { + } + + @Override + public void visit(ConditionalStatement statement) { + statement.getCondition().acceptVisitor(this); + visit(statement.getConsequent()); + visit(statement.getAlternative()); + } + + @Override + public void visit(VariableExpr expr) { + } + + @Override + public void visit(SubscriptExpr expr) { + expr.getArray().acceptVisitor(this); + expr.getIndex().acceptVisitor(this); + } + + @Override + public void visit(SwitchStatement statement) { + statement.getValue().acceptVisitor(this); + for (SwitchClause clause : statement.getClauses()) { + visit(clause.getBody()); + } + visit(statement.getDefaultClause()); + } + + @Override + public void visit(UnwrapArrayExpr expr) { + expr.getArray().acceptVisitor(this); + } + + @Override + public void visit(WhileStatement statement) { + if (statement.getCondition() != null) { + statement.getCondition().acceptVisitor(this); + } + visit(statement.getBody()); + } + + @Override + public void visit(InvocationExpr expr) { + for (Expr argument : expr.getArguments()) { + argument.acceptVisitor(this); + } + } + + @Override + public void visit(BlockStatement statement) { + visit(statement.getBody()); + } + + @Override + public void visit(QualificationExpr expr) { + if (expr.getQualified() != null) { + expr.getQualified().acceptVisitor(this); + } + } + + @Override + public void visit(BreakStatement statement) { + } + + @Override + public void visit(NewExpr expr) { + } + + @Override + public void visit(ContinueStatement statement) { + } + + @Override + public void visit(NewArrayExpr expr) { + expr.getLength().acceptVisitor(this); + } + + @Override + public void visit(NewMultiArrayExpr expr) { + for (Expr dimension : expr.getDimensions()) { + dimension.acceptVisitor(this); + } + } + + @Override + public void visit(ReturnStatement statement) { + if (statement.getResult() != null) { + statement.getResult().acceptVisitor(this); + } + } + + @Override + public void visit(InstanceOfExpr expr) { + expr.getExpr().acceptVisitor(this); + } + + @Override + public void visit(ThrowStatement statement) { + statement.getException().acceptVisitor(this); + } + + @Override + public void visit(CastExpr expr) { + expr.getValue().acceptVisitor(this); + } + + @Override + public void visit(InitClassStatement statement) { + } + + @Override + public void visit(PrimitiveCastExpr expr) { + expr.getValue().acceptVisitor(this); + } + + @Override + public void visit(TryCatchStatement statement) { + visit(statement.getProtectedBody()); + visit(statement.getHandler()); + } + + @Override + public void visit(GotoPartStatement statement) { + } + + @Override + public void visit(MonitorEnterStatement statement) { + statement.getObjectRef().acceptVisitor(this); + } + + @Override + public void visit(MonitorExitStatement statement) { + statement.getObjectRef().acceptVisitor(this); + } +} diff --git a/core/src/main/java/org/teavm/ast/decompilation/AsyncCallsFinder.java b/core/src/main/java/org/teavm/ast/decompilation/AsyncCallsFinder.java index 7c6328a34..4b3cedba4 100644 --- a/core/src/main/java/org/teavm/ast/decompilation/AsyncCallsFinder.java +++ b/core/src/main/java/org/teavm/ast/decompilation/AsyncCallsFinder.java @@ -16,231 +16,25 @@ package org.teavm.ast.decompilation; import java.util.HashSet; -import java.util.List; import java.util.Set; import org.teavm.ast.AssignmentStatement; -import org.teavm.ast.BinaryExpr; -import org.teavm.ast.BlockStatement; -import org.teavm.ast.BreakStatement; -import org.teavm.ast.CastExpr; -import org.teavm.ast.ConditionalExpr; -import org.teavm.ast.ConditionalStatement; -import org.teavm.ast.ConstantExpr; -import org.teavm.ast.ContinueStatement; -import org.teavm.ast.Expr; -import org.teavm.ast.ExprVisitor; -import org.teavm.ast.GotoPartStatement; -import org.teavm.ast.InitClassStatement; -import org.teavm.ast.InstanceOfExpr; import org.teavm.ast.InvocationExpr; -import org.teavm.ast.MonitorEnterStatement; -import org.teavm.ast.MonitorExitStatement; -import org.teavm.ast.NewArrayExpr; -import org.teavm.ast.NewExpr; -import org.teavm.ast.NewMultiArrayExpr; -import org.teavm.ast.PrimitiveCastExpr; -import org.teavm.ast.QualificationExpr; -import org.teavm.ast.ReturnStatement; -import org.teavm.ast.SequentialStatement; -import org.teavm.ast.Statement; -import org.teavm.ast.StatementVisitor; -import org.teavm.ast.SubscriptExpr; -import org.teavm.ast.SwitchClause; -import org.teavm.ast.SwitchStatement; -import org.teavm.ast.ThrowStatement; -import org.teavm.ast.TryCatchStatement; -import org.teavm.ast.UnaryExpr; -import org.teavm.ast.UnwrapArrayExpr; -import org.teavm.ast.VariableExpr; -import org.teavm.ast.WhileStatement; +import org.teavm.ast.RecursiveVisitor; import org.teavm.model.MethodReference; -class AsyncCallsFinder implements StatementVisitor, ExprVisitor { +class AsyncCallsFinder extends RecursiveVisitor { final Set asyncCalls = new HashSet<>(); final Set allCalls = new HashSet<>(); - private void visitList(List statements) { - for (Statement stmt : statements) { - stmt.acceptVisitor(this); - } - } - @Override public void visit(AssignmentStatement statement) { - if (statement.getLeftValue() != null) { - statement.getLeftValue().acceptVisitor(this); - } - statement.getRightValue().acceptVisitor(this); - if (!statement.isAsync()) { - statement.getRightValue().acceptVisitor(this); - return; - } - if (!(statement.getRightValue() instanceof InvocationExpr)) { - statement.getRightValue().acceptVisitor(this); - return; - } InvocationExpr invocation = (InvocationExpr) statement.getRightValue(); asyncCalls.add(invocation.getMethod()); } - @Override - public void visit(SequentialStatement statement) { - visitList(statement.getSequence()); - } - - @Override - public void visit(ConditionalStatement statement) { - visitList(statement.getConsequent()); - visitList(statement.getAlternative()); - statement.getCondition().acceptVisitor(this); - } - - @Override - public void visit(SwitchStatement statement) { - for (SwitchClause clause : statement.getClauses()) { - visitList(clause.getBody()); - } - visitList(statement.getDefaultClause()); - statement.getValue().acceptVisitor(this); - } - - @Override - public void visit(WhileStatement statement) { - visitList(statement.getBody()); - if (statement.getCondition() != null) { - statement.getCondition().acceptVisitor(this); - } - } - - @Override - public void visit(BlockStatement statement) { - visitList(statement.getBody()); - } - - @Override - public void visit(BreakStatement statement) { - } - - @Override - public void visit(ContinueStatement statement) { - } - - @Override - public void visit(ReturnStatement statement) { - if (statement.getResult() != null) { - statement.getResult().acceptVisitor(this); - } - } - - @Override - public void visit(ThrowStatement statement) { - statement.getException().acceptVisitor(this); - } - - @Override - public void visit(InitClassStatement statement) { - } - - @Override - public void visit(TryCatchStatement statement) { - visitList(statement.getProtectedBody()); - visitList(statement.getHandler()); - } - - @Override - public void visit(GotoPartStatement statement) { - } - - @Override - public void visit(MonitorEnterStatement statement) { - statement.getObjectRef().acceptVisitor(this); - } - - @Override - public void visit(MonitorExitStatement statement) { - statement.getObjectRef().acceptVisitor(this); - } - - @Override - public void visit(BinaryExpr expr) { - expr.getFirstOperand().acceptVisitor(this); - expr.getSecondOperand().acceptVisitor(this); - } - - @Override - public void visit(UnaryExpr expr) { - expr.getOperand().acceptVisitor(this); - } - - @Override - public void visit(ConditionalExpr expr) { - expr.getCondition().acceptVisitor(this); - expr.getConsequent().acceptVisitor(this); - expr.getAlternative().acceptVisitor(this); - } - - @Override - public void visit(ConstantExpr expr) { - } - - @Override - public void visit(VariableExpr expr) { - } - - @Override - public void visit(SubscriptExpr expr) { - expr.getArray().acceptVisitor(this); - expr.getIndex().acceptVisitor(this); - } - - @Override - public void visit(UnwrapArrayExpr expr) { - expr.getArray().acceptVisitor(this); - } - @Override public void visit(InvocationExpr expr) { + super.visit(expr); allCalls.add(expr.getMethod()); - for (Expr arg : expr.getArguments()) { - arg.acceptVisitor(this); - } - } - - @Override - public void visit(QualificationExpr expr) { - if (expr.getQualified() != null) { - expr.getQualified().acceptVisitor(this); - } - } - - @Override - public void visit(NewExpr expr) { - } - - @Override - public void visit(NewArrayExpr expr) { - expr.getLength().acceptVisitor(this); - } - - @Override - public void visit(NewMultiArrayExpr expr) { - for (Expr dim : expr.getDimensions()) { - dim.acceptVisitor(this); - } - } - - @Override - public void visit(InstanceOfExpr expr) { - expr.getExpr().acceptVisitor(this); - } - - @Override - public void visit(CastExpr expr) { - expr.getValue().acceptVisitor(this); - } - - @Override - public void visit(PrimitiveCastExpr expr) { - expr.getValue().acceptVisitor(this); } } diff --git a/core/src/main/java/org/teavm/ast/decompilation/Decompiler.java b/core/src/main/java/org/teavm/ast/decompilation/Decompiler.java index a89701b7e..27c6b63f8 100644 --- a/core/src/main/java/org/teavm/ast/decompilation/Decompiler.java +++ b/core/src/main/java/org/teavm/ast/decompilation/Decompiler.java @@ -44,15 +44,15 @@ import org.teavm.ast.VariableNode; import org.teavm.ast.WhileStatement; import org.teavm.ast.cache.MethodNodeCache; import org.teavm.ast.optimization.Optimizer; +import org.teavm.backend.javascript.spi.GeneratedBy; +import org.teavm.backend.javascript.spi.Generator; +import org.teavm.backend.javascript.spi.InjectedBy; import org.teavm.cache.NoCache; import org.teavm.common.Graph; import org.teavm.common.GraphIndexer; import org.teavm.common.Loop; import org.teavm.common.LoopGraph; import org.teavm.common.RangeTree; -import org.teavm.backend.javascript.spi.GeneratedBy; -import org.teavm.backend.javascript.spi.Generator; -import org.teavm.backend.javascript.spi.InjectedBy; import org.teavm.model.AnnotationHolder; import org.teavm.model.ClassHolder; import org.teavm.model.ClassHolderSource; diff --git a/core/src/main/java/org/teavm/ast/optimization/BlockCountVisitor.java b/core/src/main/java/org/teavm/ast/optimization/BlockCountVisitor.java index cb37eab59..a3ce310ae 100644 --- a/core/src/main/java/org/teavm/ast/optimization/BlockCountVisitor.java +++ b/core/src/main/java/org/teavm/ast/optimization/BlockCountVisitor.java @@ -15,35 +15,16 @@ */ package org.teavm.ast.optimization; -import java.util.List; -import org.teavm.ast.AssignmentStatement; import org.teavm.ast.BlockStatement; import org.teavm.ast.BreakStatement; -import org.teavm.ast.ConditionalStatement; import org.teavm.ast.ContinueStatement; -import org.teavm.ast.GotoPartStatement; -import org.teavm.ast.InitClassStatement; -import org.teavm.ast.MonitorEnterStatement; -import org.teavm.ast.MonitorExitStatement; -import org.teavm.ast.ReturnStatement; -import org.teavm.ast.SequentialStatement; -import org.teavm.ast.Statement; -import org.teavm.ast.StatementVisitor; -import org.teavm.ast.SwitchClause; -import org.teavm.ast.SwitchStatement; -import org.teavm.ast.ThrowStatement; -import org.teavm.ast.TryCatchStatement; -import org.teavm.ast.WhileStatement; +import org.teavm.ast.RecursiveVisitor; -/** - * - * @author Alexey Andreev - */ -class BlockCountVisitor implements StatementVisitor { +class BlockCountVisitor extends RecursiveVisitor { private BlockStatement blockToCount; private int count; - public BlockCountVisitor(BlockStatement blockToCount) { + BlockCountVisitor(BlockStatement blockToCount) { this.blockToCount = blockToCount; } @@ -51,48 +32,6 @@ class BlockCountVisitor implements StatementVisitor { return count; } - public void visit(List statements) { - if (statements == null) { - return; - } - for (Statement part : statements) { - part.acceptVisitor(this); - } - } - - @Override - public void visit(AssignmentStatement statement) { - } - - @Override - public void visit(SequentialStatement statement) { - visit(statement.getSequence()); - } - - @Override - public void visit(ConditionalStatement statement) { - visit(statement.getConsequent()); - visit(statement.getAlternative()); - } - - @Override - public void visit(SwitchStatement statement) { - for (SwitchClause clause : statement.getClauses()) { - visit(clause.getBody()); - } - visit(statement.getDefaultClause()); - } - - @Override - public void visit(WhileStatement statement) { - visit(statement.getBody()); - } - - @Override - public void visit(BlockStatement statement) { - visit(statement.getBody()); - } - @Override public void visit(BreakStatement statement) { if (statement.getTarget() == blockToCount) { @@ -106,34 +45,4 @@ class BlockCountVisitor implements StatementVisitor { ++count; } } - - @Override - public void visit(ReturnStatement statement) { - } - - @Override - public void visit(ThrowStatement statement) { - } - - @Override - public void visit(InitClassStatement statement) { - } - - @Override - public void visit(TryCatchStatement statement) { - visit(statement.getProtectedBody()); - visit(statement.getHandler()); - } - - @Override - public void visit(GotoPartStatement statement) { - } - - @Override - public void visit(MonitorEnterStatement statement) { - } - - @Override - public void visit(MonitorExitStatement statement) { - } } diff --git a/core/src/main/java/org/teavm/ast/optimization/BreakToContinueReplacer.java b/core/src/main/java/org/teavm/ast/optimization/BreakToContinueReplacer.java index e2f14e9e5..b38622791 100644 --- a/core/src/main/java/org/teavm/ast/optimization/BreakToContinueReplacer.java +++ b/core/src/main/java/org/teavm/ast/optimization/BreakToContinueReplacer.java @@ -16,31 +16,13 @@ package org.teavm.ast.optimization; import java.util.List; -import org.teavm.ast.AssignmentStatement; -import org.teavm.ast.BlockStatement; import org.teavm.ast.BreakStatement; -import org.teavm.ast.ConditionalStatement; import org.teavm.ast.ContinueStatement; -import org.teavm.ast.GotoPartStatement; import org.teavm.ast.IdentifiedStatement; -import org.teavm.ast.InitClassStatement; -import org.teavm.ast.MonitorEnterStatement; -import org.teavm.ast.MonitorExitStatement; -import org.teavm.ast.ReturnStatement; -import org.teavm.ast.SequentialStatement; +import org.teavm.ast.RecursiveVisitor; import org.teavm.ast.Statement; -import org.teavm.ast.StatementVisitor; -import org.teavm.ast.SwitchClause; -import org.teavm.ast.SwitchStatement; -import org.teavm.ast.ThrowStatement; -import org.teavm.ast.TryCatchStatement; -import org.teavm.ast.WhileStatement; -/** - * - * @author Alexey Andreev - */ -class BreakToContinueReplacer implements StatementVisitor { +class BreakToContinueReplacer extends RecursiveVisitor { private IdentifiedStatement replacedBreak; private IdentifiedStatement replacement; private ContinueStatement replaceBy; @@ -51,10 +33,7 @@ class BreakToContinueReplacer implements StatementVisitor { } @Override - public void visit(AssignmentStatement statement) { - } - - public void visitSequence(List statements) { + public void visit(List statements) { if (statements == null) { return; } @@ -68,35 +47,6 @@ class BreakToContinueReplacer implements StatementVisitor { } } - @Override - public void visit(SequentialStatement statement) { - visitSequence(statement.getSequence()); - } - - @Override - public void visit(ConditionalStatement statement) { - visitSequence(statement.getConsequent()); - visitSequence(statement.getAlternative()); - } - - @Override - public void visit(SwitchStatement statement) { - for (SwitchClause clause : statement.getClauses()) { - visitSequence(clause.getBody()); - } - visitSequence(statement.getDefaultClause()); - } - - @Override - public void visit(WhileStatement statement) { - visitSequence(statement.getBody()); - } - - @Override - public void visit(BlockStatement statement) { - visitSequence(statement.getBody()); - } - @Override public void visit(BreakStatement statement) { if (statement.getTarget() == replacedBreak) { @@ -112,34 +62,4 @@ class BreakToContinueReplacer implements StatementVisitor { statement.setTarget(replacement); } } - - @Override - public void visit(ReturnStatement statement) { - } - - @Override - public void visit(ThrowStatement statement) { - } - - @Override - public void visit(InitClassStatement statement) { - } - - @Override - public void visit(TryCatchStatement statement) { - visitSequence(statement.getProtectedBody()); - visitSequence(statement.getHandler()); - } - - @Override - public void visit(GotoPartStatement statement) { - } - - @Override - public void visit(MonitorEnterStatement statement) { - } - - @Override - public void visit(MonitorExitStatement statement) { - } } diff --git a/core/src/main/java/org/teavm/ast/optimization/ExpressionSideEffectDecomposer.java b/core/src/main/java/org/teavm/ast/optimization/ExpressionSideEffectDecomposer.java index b6a1cf0b3..74146a144 100644 --- a/core/src/main/java/org/teavm/ast/optimization/ExpressionSideEffectDecomposer.java +++ b/core/src/main/java/org/teavm/ast/optimization/ExpressionSideEffectDecomposer.java @@ -16,44 +16,20 @@ package org.teavm.ast.optimization; import java.util.List; -import org.teavm.ast.BinaryExpr; -import org.teavm.ast.CastExpr; import org.teavm.ast.ConditionalExpr; import org.teavm.ast.ConditionalStatement; -import org.teavm.ast.ConstantExpr; -import org.teavm.ast.Expr; -import org.teavm.ast.ExprVisitor; -import org.teavm.ast.InstanceOfExpr; import org.teavm.ast.InvocationExpr; -import org.teavm.ast.NewArrayExpr; import org.teavm.ast.NewExpr; -import org.teavm.ast.NewMultiArrayExpr; -import org.teavm.ast.PrimitiveCastExpr; -import org.teavm.ast.QualificationExpr; +import org.teavm.ast.RecursiveVisitor; import org.teavm.ast.Statement; -import org.teavm.ast.SubscriptExpr; -import org.teavm.ast.UnaryExpr; -import org.teavm.ast.UnwrapArrayExpr; -import org.teavm.ast.VariableExpr; -public class ExpressionSideEffectDecomposer implements ExprVisitor { +public class ExpressionSideEffectDecomposer extends RecursiveVisitor { private List target; public ExpressionSideEffectDecomposer(List target) { this.target = target; } - @Override - public void visit(BinaryExpr expr) { - expr.getFirstOperand().acceptVisitor(this); - expr.getSecondOperand().acceptVisitor(this); - } - - @Override - public void visit(UnaryExpr expr) { - expr.getOperand().acceptVisitor(this); - } - @Override public void visit(ConditionalExpr expr) { ConditionalStatement statement = new ConditionalStatement(); @@ -62,67 +38,13 @@ public class ExpressionSideEffectDecomposer implements ExprVisitor { expr.getAlternative().acceptVisitor(new ExpressionSideEffectDecomposer(statement.getAlternative())); target.add(statement); } - - @Override - public void visit(ConstantExpr expr) { - } - - @Override - public void visit(VariableExpr expr) { - } - - @Override - public void visit(SubscriptExpr expr) { - expr.getArray().acceptVisitor(this); - expr.getIndex().acceptVisitor(this); - } - - @Override - public void visit(UnwrapArrayExpr expr) { - expr.getArray().acceptVisitor(this); - } - @Override public void visit(InvocationExpr expr) { target.add(Statement.assign(null, expr)); } - @Override - public void visit(QualificationExpr expr) { - if (expr.getQualified() != null) { - expr.getQualified().acceptVisitor(this); - } - } - @Override public void visit(NewExpr expr) { target.add(Statement.assign(null, expr)); } - - @Override - public void visit(NewArrayExpr expr) { - expr.getLength().acceptVisitor(this); - } - - @Override - public void visit(NewMultiArrayExpr expr) { - for (Expr dimension : expr.getDimensions()) { - dimension.acceptVisitor(this); - } - } - - @Override - public void visit(InstanceOfExpr expr) { - expr.getExpr().acceptVisitor(this); - } - - @Override - public void visit(CastExpr expr) { - expr.getValue().acceptVisitor(this); - } - - @Override - public void visit(PrimitiveCastExpr expr) { - expr.getValue().acceptVisitor(this); - } } diff --git a/core/src/main/java/org/teavm/ast/optimization/OptimizingVisitor.java b/core/src/main/java/org/teavm/ast/optimization/OptimizingVisitor.java index 1dc4f20e4..43ffbe3db 100644 --- a/core/src/main/java/org/teavm/ast/optimization/OptimizingVisitor.java +++ b/core/src/main/java/org/teavm/ast/optimization/OptimizingVisitor.java @@ -592,7 +592,7 @@ class OptimizingVisitor implements StatementVisitor, ExprVisitor { if (statement.getBody().size() == 1 && statement.getBody().get(0) instanceof WhileStatement) { WhileStatement innerLoop = (WhileStatement) statement.getBody().get(0); BreakToContinueReplacer replacer = new BreakToContinueReplacer(innerLoop, statement); - replacer.visitSequence(innerLoop.getBody()); + replacer.visit(innerLoop.getBody()); statement.getBody().clear(); statement.getBody().addAll(innerLoop.getBody()); } diff --git a/core/src/main/java/org/teavm/ast/optimization/RedundantLabelEliminator.java b/core/src/main/java/org/teavm/ast/optimization/RedundantLabelEliminator.java index 80d173d91..d39efbe66 100644 --- a/core/src/main/java/org/teavm/ast/optimization/RedundantLabelEliminator.java +++ b/core/src/main/java/org/teavm/ast/optimization/RedundantLabelEliminator.java @@ -16,65 +16,28 @@ package org.teavm.ast.optimization; import java.util.HashSet; -import java.util.List; import java.util.Set; -import org.teavm.ast.AssignmentStatement; import org.teavm.ast.BlockStatement; import org.teavm.ast.BreakStatement; -import org.teavm.ast.ConditionalStatement; import org.teavm.ast.ContinueStatement; -import org.teavm.ast.GotoPartStatement; import org.teavm.ast.IdentifiedStatement; -import org.teavm.ast.InitClassStatement; -import org.teavm.ast.MonitorEnterStatement; -import org.teavm.ast.MonitorExitStatement; -import org.teavm.ast.ReturnStatement; -import org.teavm.ast.SequentialStatement; -import org.teavm.ast.Statement; -import org.teavm.ast.StatementVisitor; +import org.teavm.ast.RecursiveVisitor; import org.teavm.ast.SwitchClause; import org.teavm.ast.SwitchStatement; -import org.teavm.ast.ThrowStatement; -import org.teavm.ast.TryCatchStatement; import org.teavm.ast.WhileStatement; -/** - * - * @author Alexey Andreev - */ -class RedundantLabelEliminator implements StatementVisitor { +class RedundantLabelEliminator extends RecursiveVisitor { private IdentifiedStatement currentBlock; private Set hasRefs = new HashSet<>(); - void visitSequence(List statements) { - for (Statement statement : statements) { - statement.acceptVisitor(this); - } - } - - @Override - public void visit(AssignmentStatement statement) { - } - - @Override - public void visit(SequentialStatement statement) { - visitSequence(statement.getSequence()); - } - - @Override - public void visit(ConditionalStatement statement) { - visitSequence(statement.getConsequent()); - visitSequence(statement.getAlternative()); - } - @Override public void visit(SwitchStatement statement) { IdentifiedStatement currentBlockBackup = currentBlock; currentBlock = statement; for (SwitchClause clause : statement.getClauses()) { - visitSequence(clause.getBody()); + visit(clause.getBody()); } - visitSequence(statement.getDefaultClause()); + visit(statement.getDefaultClause()); if (!hasRefs.contains(currentBlock)) { currentBlock.setId(null); } @@ -85,7 +48,7 @@ class RedundantLabelEliminator implements StatementVisitor { public void visit(WhileStatement statement) { IdentifiedStatement currentBlockBackup = currentBlock; currentBlock = statement; - visitSequence(statement.getBody()); + visit(statement.getBody()); if (!hasRefs.contains(currentBlock)) { currentBlock.setId(null); } @@ -96,7 +59,7 @@ class RedundantLabelEliminator implements StatementVisitor { public void visit(BlockStatement statement) { IdentifiedStatement currentBlockBackup = currentBlock; currentBlock = null; - visitSequence(statement.getBody()); + visit(statement.getBody()); currentBlock = currentBlockBackup; } @@ -117,34 +80,4 @@ class RedundantLabelEliminator implements StatementVisitor { hasRefs.add(statement.getTarget()); } } - - @Override - public void visit(ReturnStatement statement) { - } - - @Override - public void visit(ThrowStatement statement) { - } - - @Override - public void visit(InitClassStatement statement) { - } - - @Override - public void visit(TryCatchStatement statement) { - visitSequence(statement.getProtectedBody()); - visitSequence(statement.getHandler()); - } - - @Override - public void visit(GotoPartStatement statement) { - } - - @Override - public void visit(MonitorEnterStatement statement) { - } - - @Override - public void visit(MonitorExitStatement statement) { - } } diff --git a/core/src/main/java/org/teavm/ast/optimization/UnusedVariableEliminator.java b/core/src/main/java/org/teavm/ast/optimization/UnusedVariableEliminator.java index 0c9d4face..985bca8f1 100644 --- a/core/src/main/java/org/teavm/ast/optimization/UnusedVariableEliminator.java +++ b/core/src/main/java/org/teavm/ast/optimization/UnusedVariableEliminator.java @@ -18,44 +18,12 @@ package org.teavm.ast.optimization; import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import org.teavm.ast.AssignmentStatement; -import org.teavm.ast.BinaryExpr; -import org.teavm.ast.BlockStatement; -import org.teavm.ast.BreakStatement; -import org.teavm.ast.CastExpr; -import org.teavm.ast.ConditionalExpr; -import org.teavm.ast.ConditionalStatement; -import org.teavm.ast.ConstantExpr; -import org.teavm.ast.ContinueStatement; -import org.teavm.ast.Expr; -import org.teavm.ast.ExprVisitor; -import org.teavm.ast.GotoPartStatement; -import org.teavm.ast.InitClassStatement; -import org.teavm.ast.InstanceOfExpr; -import org.teavm.ast.InvocationExpr; -import org.teavm.ast.MonitorEnterStatement; -import org.teavm.ast.MonitorExitStatement; -import org.teavm.ast.NewArrayExpr; -import org.teavm.ast.NewExpr; -import org.teavm.ast.NewMultiArrayExpr; -import org.teavm.ast.PrimitiveCastExpr; -import org.teavm.ast.QualificationExpr; -import org.teavm.ast.ReturnStatement; -import org.teavm.ast.SequentialStatement; -import org.teavm.ast.Statement; -import org.teavm.ast.StatementVisitor; -import org.teavm.ast.SubscriptExpr; -import org.teavm.ast.SwitchClause; -import org.teavm.ast.SwitchStatement; -import org.teavm.ast.ThrowStatement; +import org.teavm.ast.RecursiveVisitor; import org.teavm.ast.TryCatchStatement; -import org.teavm.ast.UnaryExpr; -import org.teavm.ast.UnwrapArrayExpr; import org.teavm.ast.VariableExpr; import org.teavm.ast.VariableNode; -import org.teavm.ast.WhileStatement; -class UnusedVariableEliminator implements ExprVisitor, StatementVisitor { +class UnusedVariableEliminator extends RecursiveVisitor { private final VariableNode[] variableNodes; private final int[] variables; private final int[] indexes; @@ -85,82 +53,6 @@ class UnusedVariableEliminator implements ExprVisitor, StatementVisitor { return reorderedVariables; } - @Override - public void visit(AssignmentStatement statement) { - if (statement.getLeftValue() != null) { - statement.getLeftValue().acceptVisitor(this); - } - statement.getRightValue().acceptVisitor(this); - } - - @Override - public void visit(SequentialStatement statement) { - for (Statement part : statement.getSequence()) { - part.acceptVisitor(this); - } - } - - @Override - public void visit(ConditionalStatement statement) { - statement.getCondition().acceptVisitor(this); - for (Statement part : statement.getConsequent()) { - part.acceptVisitor(this); - } - for (Statement part : statement.getAlternative()) { - part.acceptVisitor(this); - } - } - - @Override - public void visit(SwitchStatement statement) { - statement.getValue().acceptVisitor(this); - for (SwitchClause clause : statement.getClauses()) { - for (Statement part : clause.getBody()) { - part.acceptVisitor(this); - } - } - for (Statement part : statement.getDefaultClause()) { - part.acceptVisitor(this); - } - } - - @Override - public void visit(WhileStatement statement) { - if (statement.getCondition() != null) { - statement.getCondition().acceptVisitor(this); - } - for (Statement part : statement.getBody()) { - part.acceptVisitor(this); - } - } - - @Override - public void visit(BlockStatement statement) { - for (Statement part : statement.getBody()) { - part.acceptVisitor(this); - } - } - - @Override - public void visit(BreakStatement statement) { - } - - @Override - public void visit(ContinueStatement statement) { - } - - @Override - public void visit(ReturnStatement statement) { - if (statement.getResult() != null) { - statement.getResult().acceptVisitor(this); - } - } - - @Override - public void visit(ThrowStatement statement) { - statement.getException().acceptVisitor(this); - } - private int renumber(int var) { int index = indexes[variables[var]]; if (index == -1) { @@ -171,101 +63,14 @@ class UnusedVariableEliminator implements ExprVisitor, StatementVisitor { return index; } - @Override - public void visit(BinaryExpr expr) { - expr.getFirstOperand().acceptVisitor(this); - expr.getSecondOperand().acceptVisitor(this); - } - - @Override - public void visit(UnaryExpr expr) { - expr.getOperand().acceptVisitor(this); - } - - @Override - public void visit(CastExpr expr) { - expr.getValue().acceptVisitor(this); - } - - @Override - public void visit(PrimitiveCastExpr expr) { - expr.getValue().acceptVisitor(this); - } - - @Override - public void visit(ConditionalExpr expr) { - expr.getCondition().acceptVisitor(this); - expr.getConsequent().acceptVisitor(this); - expr.getAlternative().acceptVisitor(this); - } - - @Override - public void visit(ConstantExpr expr) { - } - @Override public void visit(VariableExpr expr) { expr.setIndex(renumber(expr.getIndex())); } - @Override - public void visit(SubscriptExpr expr) { - expr.getArray().acceptVisitor(this); - expr.getIndex().acceptVisitor(this); - } - - @Override - public void visit(UnwrapArrayExpr expr) { - expr.getArray().acceptVisitor(this); - } - - @Override - public void visit(InvocationExpr expr) { - for (Expr arg : expr.getArguments()) { - arg.acceptVisitor(this); - } - } - - @Override - public void visit(QualificationExpr expr) { - if (expr.getQualified() != null) { - expr.getQualified().acceptVisitor(this); - } - } - - @Override - public void visit(NewExpr expr) { - } - - @Override - public void visit(NewArrayExpr expr) { - expr.getLength().acceptVisitor(this); - } - - @Override - public void visit(NewMultiArrayExpr expr) { - for (Expr dimension : expr.getDimensions()) { - dimension.acceptVisitor(this); - } - } - - @Override - public void visit(InstanceOfExpr expr) { - expr.getExpr().acceptVisitor(this); - } - - @Override - public void visit(InitClassStatement statement) { - } - @Override public void visit(TryCatchStatement statement) { - for (Statement part : statement.getProtectedBody()) { - part.acceptVisitor(this); - } - for (Statement part : statement.getHandler()) { - part.acceptVisitor(this); - } + super.visit(statement); if (statement.getExceptionVariable() != null) { if (variables[statement.getExceptionVariable()] < 0) { statement.setExceptionVariable(null); @@ -274,18 +79,4 @@ class UnusedVariableEliminator implements ExprVisitor, StatementVisitor { } } } - - @Override - public void visit(GotoPartStatement statement) { - } - - @Override - public void visit(MonitorEnterStatement statement) { - statement.getObjectRef().acceptVisitor(this); - } - - @Override - public void visit(MonitorExitStatement statement) { - statement.getObjectRef().acceptVisitor(this); - } } diff --git a/core/src/main/java/org/teavm/backend/javascript/JavaScriptTarget.java b/core/src/main/java/org/teavm/backend/javascript/JavaScriptTarget.java index 62ac865be..521f4c177 100644 --- a/core/src/main/java/org/teavm/backend/javascript/JavaScriptTarget.java +++ b/core/src/main/java/org/teavm/backend/javascript/JavaScriptTarget.java @@ -30,33 +30,32 @@ import org.teavm.ast.ClassNode; import org.teavm.ast.cache.EmptyRegularMethodNodeCache; import org.teavm.ast.cache.MethodNodeCache; import org.teavm.ast.decompilation.Decompiler; -import org.teavm.backend.javascript.rendering.Renderer; -import org.teavm.backend.javascript.rendering.RenderingException; -import org.teavm.backend.javascript.spi.GeneratedBy; -import org.teavm.backend.javascript.spi.InjectedBy; -import org.teavm.backend.javascript.spi.Injector; import org.teavm.backend.javascript.codegen.AliasProvider; import org.teavm.backend.javascript.codegen.DefaultAliasProvider; import org.teavm.backend.javascript.codegen.DefaultNamingStrategy; import org.teavm.backend.javascript.codegen.MinifyingAliasProvider; import org.teavm.backend.javascript.codegen.SourceWriter; import org.teavm.backend.javascript.codegen.SourceWriterBuilder; +import org.teavm.backend.javascript.rendering.Renderer; +import org.teavm.backend.javascript.spi.GeneratedBy; +import org.teavm.backend.javascript.spi.Generator; +import org.teavm.backend.javascript.spi.InjectedBy; +import org.teavm.backend.javascript.spi.Injector; import org.teavm.debugging.information.DebugInformationEmitter; import org.teavm.debugging.information.SourceLocation; import org.teavm.dependency.DependencyChecker; import org.teavm.dependency.DependencyListener; import org.teavm.dependency.MethodDependency; -import org.teavm.backend.javascript.spi.Generator; import org.teavm.model.BasicBlock; import org.teavm.model.CallLocation; import org.teavm.model.ClassHolder; import org.teavm.model.ClassHolderTransformer; import org.teavm.model.ElementModifier; -import org.teavm.model.TextLocation; import org.teavm.model.ListableClassHolderSource; import org.teavm.model.MethodHolder; import org.teavm.model.MethodReference; import org.teavm.model.Program; +import org.teavm.model.TextLocation; import org.teavm.model.ValueType; import org.teavm.model.Variable; import org.teavm.model.instructions.ConstructInstruction; @@ -67,6 +66,7 @@ import org.teavm.model.instructions.StringConstantInstruction; import org.teavm.model.util.AsyncMethodFinder; import org.teavm.model.util.ProgramUtils; import org.teavm.vm.BuildTarget; +import org.teavm.vm.RenderingException; import org.teavm.vm.TeaVMEntryPoint; import org.teavm.vm.TeaVMTarget; import org.teavm.vm.TeaVMTargetController; diff --git a/core/src/main/java/org/teavm/backend/javascript/rendering/NameFrequencyEstimator.java b/core/src/main/java/org/teavm/backend/javascript/rendering/NameFrequencyEstimator.java index 44b44de63..049b9be42 100644 --- a/core/src/main/java/org/teavm/backend/javascript/rendering/NameFrequencyEstimator.java +++ b/core/src/main/java/org/teavm/backend/javascript/rendering/NameFrequencyEstimator.java @@ -15,24 +15,14 @@ */ package org.teavm.backend.javascript.rendering; -import java.util.List; import java.util.Set; import org.teavm.ast.AssignmentStatement; import org.teavm.ast.AsyncMethodNode; import org.teavm.ast.AsyncMethodPart; import org.teavm.ast.BinaryExpr; -import org.teavm.ast.BlockStatement; -import org.teavm.ast.BreakStatement; -import org.teavm.ast.CastExpr; import org.teavm.ast.ClassNode; -import org.teavm.ast.ConditionalExpr; -import org.teavm.ast.ConditionalStatement; import org.teavm.ast.ConstantExpr; -import org.teavm.ast.ContinueStatement; -import org.teavm.ast.Expr; -import org.teavm.ast.ExprVisitor; import org.teavm.ast.FieldNode; -import org.teavm.ast.GotoPartStatement; import org.teavm.ast.InitClassStatement; import org.teavm.ast.InstanceOfExpr; import org.teavm.ast.InvocationExpr; @@ -44,22 +34,12 @@ import org.teavm.ast.NativeMethodNode; import org.teavm.ast.NewArrayExpr; import org.teavm.ast.NewExpr; import org.teavm.ast.NewMultiArrayExpr; -import org.teavm.ast.PrimitiveCastExpr; import org.teavm.ast.QualificationExpr; +import org.teavm.ast.RecursiveVisitor; import org.teavm.ast.RegularMethodNode; -import org.teavm.ast.ReturnStatement; -import org.teavm.ast.SequentialStatement; -import org.teavm.ast.Statement; -import org.teavm.ast.StatementVisitor; -import org.teavm.ast.SubscriptExpr; -import org.teavm.ast.SwitchClause; -import org.teavm.ast.SwitchStatement; import org.teavm.ast.ThrowStatement; import org.teavm.ast.TryCatchStatement; import org.teavm.ast.UnaryExpr; -import org.teavm.ast.UnwrapArrayExpr; -import org.teavm.ast.VariableExpr; -import org.teavm.ast.WhileStatement; import org.teavm.backend.javascript.codegen.NameFrequencyConsumer; import org.teavm.model.ClassReader; import org.teavm.model.ClassReaderSource; @@ -70,7 +50,7 @@ import org.teavm.model.MethodReader; import org.teavm.model.MethodReference; import org.teavm.model.ValueType; -class NameFrequencyEstimator implements StatementVisitor, ExprVisitor, MethodNodeVisitor { +class NameFrequencyEstimator extends RecursiveVisitor implements MethodNodeVisitor { private final NameFrequencyConsumer consumer; private final ClassReaderSource classSource; private boolean async; @@ -85,12 +65,6 @@ class NameFrequencyEstimator implements StatementVisitor, ExprVisitor, MethodNod this.asyncFamilyMethods = asyncFamilyMethods; } - private void visit(List statements) { - for (Statement part : statements) { - part.acceptVisitor(this); - } - } - public void estimate(ClassNode cls) { // Declaration consumer.consume(cls.getName()); @@ -159,64 +133,12 @@ class NameFrequencyEstimator implements StatementVisitor, ExprVisitor, MethodNod @Override public void visit(AssignmentStatement statement) { - if (statement.getLeftValue() != null) { - statement.getLeftValue().acceptVisitor(this); - } - statement.getRightValue().acceptVisitor(this); + super.visit(statement); if (statement.isAsync()) { consumer.consumeFunction("$rt_suspending"); } } - @Override - public void visit(SequentialStatement statement) { - visit(statement.getSequence()); - } - - @Override - public void visit(ConditionalStatement statement) { - statement.getCondition().acceptVisitor(this); - visit(statement.getConsequent()); - visit(statement.getAlternative()); - } - - @Override - public void visit(SwitchStatement statement) { - statement.getValue().acceptVisitor(this); - for (SwitchClause clause : statement.getClauses()) { - visit(clause.getBody()); - } - visit(statement.getDefaultClause()); - } - - @Override - public void visit(WhileStatement statement) { - if (statement.getCondition() != null) { - statement.getCondition().acceptVisitor(this); - } - visit(statement.getBody()); - } - - @Override - public void visit(BlockStatement statement) { - visit(statement.getBody()); - } - - @Override - public void visit(BreakStatement statement) { - } - - @Override - public void visit(ContinueStatement statement) { - } - - @Override - public void visit(ReturnStatement statement) { - if (statement.getResult() != null) { - statement.getResult().acceptVisitor(this); - } - } - @Override public void visit(ThrowStatement statement) { statement.getException().acceptVisitor(this); @@ -230,19 +152,15 @@ class NameFrequencyEstimator implements StatementVisitor, ExprVisitor, MethodNod @Override public void visit(TryCatchStatement statement) { - visit(statement.getProtectedBody()); - visit(statement.getHandler()); + super.visit(statement); if (statement.getExceptionType() != null) { consumer.consume(statement.getExceptionType()); } } - @Override - public void visit(GotoPartStatement statement) { - } - @Override public void visit(MonitorEnterStatement statement) { + super.visit(statement); if (async) { MethodReference monitorEnterRef = new MethodReference( Object.class, "monitorEnter", Object.class, void.class); @@ -257,6 +175,7 @@ class NameFrequencyEstimator implements StatementVisitor, ExprVisitor, MethodNod @Override public void visit(MonitorExitStatement statement) { + super.visit(statement); if (async) { MethodReference monitorEnterRef = new MethodReference( Object.class, "monitorExit", Object.class, void.class); @@ -270,8 +189,7 @@ class NameFrequencyEstimator implements StatementVisitor, ExprVisitor, MethodNod @Override public void visit(BinaryExpr expr) { - expr.getFirstOperand().acceptVisitor(this); - expr.getSecondOperand().acceptVisitor(this); + super.visit(expr); switch (expr.getOperation()) { case COMPARE: consumer.consumeFunction("$rt_compare"); @@ -283,7 +201,7 @@ class NameFrequencyEstimator implements StatementVisitor, ExprVisitor, MethodNod @Override public void visit(UnaryExpr expr) { - expr.getOperand().acceptVisitor(this); + super.visit(expr); switch (expr.getOperation()) { case NULL_CHECK: consumer.consumeFunction("$rt_nullCheck"); @@ -293,13 +211,6 @@ class NameFrequencyEstimator implements StatementVisitor, ExprVisitor, MethodNod } } - @Override - public void visit(ConditionalExpr expr) { - expr.getCondition().acceptVisitor(this); - expr.getConsequent().acceptVisitor(this); - expr.getAlternative().acceptVisitor(this); - } - @Override public void visit(ConstantExpr expr) { if (expr.getValue() instanceof ValueType) { @@ -317,24 +228,9 @@ class NameFrequencyEstimator implements StatementVisitor, ExprVisitor, MethodNod consumer.consumeFunction("$rt_cls"); } } - - @Override - public void visit(VariableExpr expr) { - } - - @Override - public void visit(SubscriptExpr expr) { - expr.getArray().acceptVisitor(this); - expr.getIndex().acceptVisitor(this); - } - - @Override - public void visit(UnwrapArrayExpr expr) { - expr.getArray().acceptVisitor(this); - } - @Override public void visit(InvocationExpr expr) { + super.visit(expr); if (injectedMethods.contains(expr.getMethod())) { return; } @@ -354,21 +250,20 @@ class NameFrequencyEstimator implements StatementVisitor, ExprVisitor, MethodNod @Override public void visit(QualificationExpr expr) { - if (expr.getQualified() != null) { - expr.getQualified().acceptVisitor(this); - } + super.visit(expr); consumer.consume(expr.getField()); } @Override public void visit(NewExpr expr) { + super.visit(expr); consumer.consume(expr.getConstructedClass()); } @Override public void visit(NewArrayExpr expr) { + super.visit(expr); visitType(expr.getType()); - expr.getLength().acceptVisitor(this); if (!(expr.getType() instanceof ValueType.Primitive)) { consumer.consumeFunction("$rt_createArray"); } @@ -376,15 +271,13 @@ class NameFrequencyEstimator implements StatementVisitor, ExprVisitor, MethodNod @Override public void visit(NewMultiArrayExpr expr) { + super.visit(expr); visitType(expr.getType()); - for (Expr dimension : expr.getDimensions()) { - dimension.acceptVisitor(this); - } } @Override public void visit(InstanceOfExpr expr) { - expr.getExpr().acceptVisitor(this); + super.visit(expr); visitType(expr.getType()); if (expr.getType() instanceof ValueType.Object) { String clsName = ((ValueType.Object) expr.getType()).getClassName(); @@ -396,14 +289,4 @@ class NameFrequencyEstimator implements StatementVisitor, ExprVisitor, MethodNod consumer.consumeFunction("$rt_isInstance"); } } - - @Override - public void visit(CastExpr expr) { - expr.getValue().acceptVisitor(this); - } - - @Override - public void visit(PrimitiveCastExpr expr) { - expr.getValue().acceptVisitor(this); - } } diff --git a/core/src/main/java/org/teavm/backend/javascript/rendering/Renderer.java b/core/src/main/java/org/teavm/backend/javascript/rendering/Renderer.java index 8d664f90b..b249c23ae 100644 --- a/core/src/main/java/org/teavm/backend/javascript/rendering/Renderer.java +++ b/core/src/main/java/org/teavm/backend/javascript/rendering/Renderer.java @@ -75,19 +75,19 @@ import org.teavm.ast.UnwrapArrayExpr; import org.teavm.ast.VariableExpr; import org.teavm.ast.VariableNode; import org.teavm.ast.WhileStatement; -import org.teavm.backend.javascript.spi.InjectedBy; -import org.teavm.backend.javascript.spi.Injector; -import org.teavm.backend.javascript.spi.InjectorContext; import org.teavm.backend.javascript.codegen.NamingException; import org.teavm.backend.javascript.codegen.NamingOrderer; import org.teavm.backend.javascript.codegen.NamingStrategy; import org.teavm.backend.javascript.codegen.SourceWriter; +import org.teavm.backend.javascript.spi.GeneratorContext; +import org.teavm.backend.javascript.spi.InjectedBy; +import org.teavm.backend.javascript.spi.Injector; +import org.teavm.backend.javascript.spi.InjectorContext; import org.teavm.common.ServiceRepository; import org.teavm.debugging.information.DebugInformationEmitter; import org.teavm.debugging.information.DeferredCallSite; import org.teavm.debugging.information.DummyDebugInformationEmitter; import org.teavm.diagnostics.Diagnostics; -import org.teavm.backend.javascript.spi.GeneratorContext; import org.teavm.model.AnnotationHolder; import org.teavm.model.ClassHolder; import org.teavm.model.ClassReader; @@ -101,6 +101,7 @@ import org.teavm.model.MethodReader; import org.teavm.model.MethodReference; import org.teavm.model.TextLocation; import org.teavm.model.ValueType; +import org.teavm.vm.RenderingException; public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext { private static final String variableNames = "abcdefghijkmnopqrstuvwxyz"; diff --git a/core/src/main/java/org/teavm/backend/javascript/spi/InjectorContext.java b/core/src/main/java/org/teavm/backend/javascript/spi/InjectorContext.java index a56438030..921ba83b7 100644 --- a/core/src/main/java/org/teavm/backend/javascript/spi/InjectorContext.java +++ b/core/src/main/java/org/teavm/backend/javascript/spi/InjectorContext.java @@ -19,8 +19,8 @@ import java.io.IOException; import java.util.Properties; import org.teavm.ast.Expr; import org.teavm.backend.javascript.codegen.SourceWriter; -import org.teavm.common.ServiceRepository; import org.teavm.backend.javascript.rendering.Precedence; +import org.teavm.common.ServiceRepository; import org.teavm.model.ListableClassReaderSource; import org.teavm.model.ValueType; diff --git a/core/src/main/java/org/teavm/backend/wasm/WasmTarget.java b/core/src/main/java/org/teavm/backend/wasm/WasmTarget.java index afd53b334..f89c04986 100644 --- a/core/src/main/java/org/teavm/backend/wasm/WasmTarget.java +++ b/core/src/main/java/org/teavm/backend/wasm/WasmTarget.java @@ -26,6 +26,41 @@ import java.util.HashSet; import java.util.List; import java.util.Set; import org.teavm.ast.decompilation.Decompiler; +import org.teavm.backend.wasm.binary.BinaryWriter; +import org.teavm.backend.wasm.generate.WasmClassGenerator; +import org.teavm.backend.wasm.generate.WasmDependencyListener; +import org.teavm.backend.wasm.generate.WasmGenerationContext; +import org.teavm.backend.wasm.generate.WasmGenerator; +import org.teavm.backend.wasm.generate.WasmMangling; +import org.teavm.backend.wasm.generate.WasmStringPool; +import org.teavm.backend.wasm.intrinsics.AllocatorIntrinsic; +import org.teavm.backend.wasm.intrinsics.ClassIntrinsic; +import org.teavm.backend.wasm.intrinsics.PlatformClassIntrinsic; +import org.teavm.backend.wasm.intrinsics.PlatformClassMetadataIntrinsic; +import org.teavm.backend.wasm.intrinsics.PlatformIntrinsic; +import org.teavm.backend.wasm.intrinsics.PlatformObjectIntrinsic; +import org.teavm.backend.wasm.intrinsics.WasmAddressIntrinsic; +import org.teavm.backend.wasm.intrinsics.WasmRuntimeIntrinsic; +import org.teavm.backend.wasm.intrinsics.WasmStructureIntrinsic; +import org.teavm.backend.wasm.model.WasmFunction; +import org.teavm.backend.wasm.model.WasmMemorySegment; +import org.teavm.backend.wasm.model.WasmModule; +import org.teavm.backend.wasm.model.WasmType; +import org.teavm.backend.wasm.model.expression.WasmBlock; +import org.teavm.backend.wasm.model.expression.WasmBranch; +import org.teavm.backend.wasm.model.expression.WasmCall; +import org.teavm.backend.wasm.model.expression.WasmExpression; +import org.teavm.backend.wasm.model.expression.WasmInt32Constant; +import org.teavm.backend.wasm.model.expression.WasmInt32Subtype; +import org.teavm.backend.wasm.model.expression.WasmIntBinary; +import org.teavm.backend.wasm.model.expression.WasmIntBinaryOperation; +import org.teavm.backend.wasm.model.expression.WasmIntType; +import org.teavm.backend.wasm.model.expression.WasmLoadInt32; +import org.teavm.backend.wasm.model.expression.WasmReturn; +import org.teavm.backend.wasm.model.expression.WasmStoreInt32; +import org.teavm.backend.wasm.patches.ClassPatch; +import org.teavm.backend.wasm.patches.ObjectPatch; +import org.teavm.backend.wasm.render.WasmRenderer; import org.teavm.dependency.ClassDependency; import org.teavm.dependency.DependencyChecker; import org.teavm.dependency.DependencyListener; @@ -65,41 +100,6 @@ import org.teavm.vm.TeaVMEntryPoint; import org.teavm.vm.TeaVMTarget; import org.teavm.vm.TeaVMTargetController; import org.teavm.vm.spi.TeaVMHostExtension; -import org.teavm.backend.wasm.binary.BinaryWriter; -import org.teavm.backend.wasm.generate.WasmClassGenerator; -import org.teavm.backend.wasm.generate.WasmDependencyListener; -import org.teavm.backend.wasm.generate.WasmGenerationContext; -import org.teavm.backend.wasm.generate.WasmGenerator; -import org.teavm.backend.wasm.generate.WasmMangling; -import org.teavm.backend.wasm.generate.WasmStringPool; -import org.teavm.backend.wasm.intrinsics.AllocatorIntrinsic; -import org.teavm.backend.wasm.intrinsics.ClassIntrinsic; -import org.teavm.backend.wasm.intrinsics.PlatformClassIntrinsic; -import org.teavm.backend.wasm.intrinsics.PlatformClassMetadataIntrinsic; -import org.teavm.backend.wasm.intrinsics.PlatformIntrinsic; -import org.teavm.backend.wasm.intrinsics.PlatformObjectIntrinsic; -import org.teavm.backend.wasm.intrinsics.WasmAddressIntrinsic; -import org.teavm.backend.wasm.intrinsics.WasmRuntimeIntrinsic; -import org.teavm.backend.wasm.intrinsics.WasmStructureIntrinsic; -import org.teavm.backend.wasm.model.WasmFunction; -import org.teavm.backend.wasm.model.WasmMemorySegment; -import org.teavm.backend.wasm.model.WasmModule; -import org.teavm.backend.wasm.model.WasmType; -import org.teavm.backend.wasm.model.expression.WasmBlock; -import org.teavm.backend.wasm.model.expression.WasmBranch; -import org.teavm.backend.wasm.model.expression.WasmCall; -import org.teavm.backend.wasm.model.expression.WasmExpression; -import org.teavm.backend.wasm.model.expression.WasmInt32Constant; -import org.teavm.backend.wasm.model.expression.WasmInt32Subtype; -import org.teavm.backend.wasm.model.expression.WasmIntBinary; -import org.teavm.backend.wasm.model.expression.WasmIntBinaryOperation; -import org.teavm.backend.wasm.model.expression.WasmIntType; -import org.teavm.backend.wasm.model.expression.WasmLoadInt32; -import org.teavm.backend.wasm.model.expression.WasmReturn; -import org.teavm.backend.wasm.model.expression.WasmStoreInt32; -import org.teavm.backend.wasm.patches.ClassPatch; -import org.teavm.backend.wasm.patches.ObjectPatch; -import org.teavm.backend.wasm.render.WasmRenderer; public class WasmTarget implements TeaVMTarget { private TeaVMTargetController controller; diff --git a/core/src/main/java/org/teavm/backend/wasm/generate/WasmClassGenerator.java b/core/src/main/java/org/teavm/backend/wasm/generate/WasmClassGenerator.java index 94d975f69..ab820937b 100644 --- a/core/src/main/java/org/teavm/backend/wasm/generate/WasmClassGenerator.java +++ b/core/src/main/java/org/teavm/backend/wasm/generate/WasmClassGenerator.java @@ -22,6 +22,12 @@ import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import org.teavm.backend.wasm.binary.BinaryWriter; +import org.teavm.backend.wasm.binary.DataArray; +import org.teavm.backend.wasm.binary.DataPrimitives; +import org.teavm.backend.wasm.binary.DataStructure; +import org.teavm.backend.wasm.binary.DataType; +import org.teavm.backend.wasm.binary.DataValue; import org.teavm.interop.Address; import org.teavm.interop.Structure; import org.teavm.model.ClassReader; @@ -37,12 +43,6 @@ import org.teavm.model.classes.VirtualTable; import org.teavm.model.classes.VirtualTableEntry; import org.teavm.model.classes.VirtualTableProvider; import org.teavm.runtime.RuntimeClass; -import org.teavm.backend.wasm.binary.BinaryWriter; -import org.teavm.backend.wasm.binary.DataArray; -import org.teavm.backend.wasm.binary.DataPrimitives; -import org.teavm.backend.wasm.binary.DataStructure; -import org.teavm.backend.wasm.binary.DataType; -import org.teavm.backend.wasm.binary.DataValue; public class WasmClassGenerator { private ClassReaderSource classSource; diff --git a/core/src/main/java/org/teavm/backend/wasm/generate/WasmGenerationContext.java b/core/src/main/java/org/teavm/backend/wasm/generate/WasmGenerationContext.java index 12debb171..8d2202189 100644 --- a/core/src/main/java/org/teavm/backend/wasm/generate/WasmGenerationContext.java +++ b/core/src/main/java/org/teavm/backend/wasm/generate/WasmGenerationContext.java @@ -19,6 +19,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import org.teavm.backend.wasm.intrinsics.WasmIntrinsic; import org.teavm.diagnostics.Diagnostics; import org.teavm.interop.Import; import org.teavm.model.AnnotationReader; @@ -32,7 +33,6 @@ import org.teavm.model.MethodReference; import org.teavm.model.ValueType; import org.teavm.model.classes.TagRegistry; import org.teavm.model.classes.VirtualTableProvider; -import org.teavm.backend.wasm.intrinsics.WasmIntrinsic; public class WasmGenerationContext { private ClassReaderSource classSource; diff --git a/core/src/main/java/org/teavm/backend/wasm/generate/WasmGenerationVisitor.java b/core/src/main/java/org/teavm/backend/wasm/generate/WasmGenerationVisitor.java index 3a82063e3..80043ca38 100644 --- a/core/src/main/java/org/teavm/backend/wasm/generate/WasmGenerationVisitor.java +++ b/core/src/main/java/org/teavm/backend/wasm/generate/WasmGenerationVisitor.java @@ -61,17 +61,6 @@ import org.teavm.ast.UnaryExpr; import org.teavm.ast.UnwrapArrayExpr; import org.teavm.ast.VariableExpr; import org.teavm.ast.WhileStatement; -import org.teavm.interop.Address; -import org.teavm.model.CallLocation; -import org.teavm.model.FieldReference; -import org.teavm.model.MethodReference; -import org.teavm.model.TextLocation; -import org.teavm.model.ValueType; -import org.teavm.model.classes.TagRegistry; -import org.teavm.model.classes.VirtualTableEntry; -import org.teavm.runtime.Allocator; -import org.teavm.runtime.RuntimeArray; -import org.teavm.runtime.RuntimeClass; import org.teavm.backend.wasm.WasmRuntime; import org.teavm.backend.wasm.intrinsics.WasmIntrinsic; import org.teavm.backend.wasm.intrinsics.WasmIntrinsicManager; @@ -112,6 +101,17 @@ import org.teavm.backend.wasm.model.expression.WasmStoreInt32; import org.teavm.backend.wasm.model.expression.WasmStoreInt64; import org.teavm.backend.wasm.model.expression.WasmSwitch; import org.teavm.backend.wasm.model.expression.WasmUnreachable; +import org.teavm.interop.Address; +import org.teavm.model.CallLocation; +import org.teavm.model.FieldReference; +import org.teavm.model.MethodReference; +import org.teavm.model.TextLocation; +import org.teavm.model.ValueType; +import org.teavm.model.classes.TagRegistry; +import org.teavm.model.classes.VirtualTableEntry; +import org.teavm.runtime.Allocator; +import org.teavm.runtime.RuntimeArray; +import org.teavm.runtime.RuntimeClass; class WasmGenerationVisitor implements StatementVisitor, ExprVisitor { private static FieldReference tagField = new FieldReference(RuntimeClass.class.getName(), "tag"); @@ -1031,7 +1031,7 @@ class WasmGenerationVisitor implements StatementVisitor, ExprVisitor { result = block; } else if (expr.getType() instanceof ValueType.Array) { - + throw new UnsupportedOperationException(); } else { throw new AssertionError(); } diff --git a/core/src/main/java/org/teavm/backend/wasm/generate/WasmGenerator.java b/core/src/main/java/org/teavm/backend/wasm/generate/WasmGenerator.java index 196577f46..ba65dce97 100644 --- a/core/src/main/java/org/teavm/backend/wasm/generate/WasmGenerator.java +++ b/core/src/main/java/org/teavm/backend/wasm/generate/WasmGenerator.java @@ -18,14 +18,6 @@ package org.teavm.backend.wasm.generate; import org.teavm.ast.RegularMethodNode; import org.teavm.ast.VariableNode; import org.teavm.ast.decompilation.Decompiler; -import org.teavm.model.ClassHolder; -import org.teavm.model.ClassHolderSource; -import org.teavm.model.ElementModifier; -import org.teavm.model.FieldReference; -import org.teavm.model.MethodHolder; -import org.teavm.model.MethodReference; -import org.teavm.model.ValueType; -import org.teavm.runtime.RuntimeClass; import org.teavm.backend.wasm.model.WasmFunction; import org.teavm.backend.wasm.model.WasmLocal; import org.teavm.backend.wasm.model.WasmType; @@ -38,6 +30,14 @@ import org.teavm.backend.wasm.model.expression.WasmIntBinary; import org.teavm.backend.wasm.model.expression.WasmIntBinaryOperation; import org.teavm.backend.wasm.model.expression.WasmIntType; import org.teavm.backend.wasm.model.expression.WasmLoadInt32; +import org.teavm.model.ClassHolder; +import org.teavm.model.ClassHolderSource; +import org.teavm.model.ElementModifier; +import org.teavm.model.FieldReference; +import org.teavm.model.MethodHolder; +import org.teavm.model.MethodReference; +import org.teavm.model.ValueType; +import org.teavm.runtime.RuntimeClass; public class WasmGenerator { private Decompiler decompiler; diff --git a/core/src/main/java/org/teavm/backend/wasm/generate/WasmGeneratorUtil.java b/core/src/main/java/org/teavm/backend/wasm/generate/WasmGeneratorUtil.java index 0fc4b00e7..240746e1e 100644 --- a/core/src/main/java/org/teavm/backend/wasm/generate/WasmGeneratorUtil.java +++ b/core/src/main/java/org/teavm/backend/wasm/generate/WasmGeneratorUtil.java @@ -16,9 +16,9 @@ package org.teavm.backend.wasm.generate; import org.teavm.ast.OperationType; +import org.teavm.backend.wasm.model.WasmType; import org.teavm.model.ValueType; import org.teavm.model.util.VariableType; -import org.teavm.backend.wasm.model.WasmType; public final class WasmGeneratorUtil { private WasmGeneratorUtil() { diff --git a/core/src/main/java/org/teavm/backend/wasm/generate/WasmStringPool.java b/core/src/main/java/org/teavm/backend/wasm/generate/WasmStringPool.java index 133a010bc..9e3409da7 100644 --- a/core/src/main/java/org/teavm/backend/wasm/generate/WasmStringPool.java +++ b/core/src/main/java/org/teavm/backend/wasm/generate/WasmStringPool.java @@ -17,12 +17,12 @@ package org.teavm.backend.wasm.generate; import java.util.HashMap; import java.util.Map; -import org.teavm.model.ValueType; import org.teavm.backend.wasm.binary.BinaryWriter; import org.teavm.backend.wasm.binary.DataArray; import org.teavm.backend.wasm.binary.DataPrimitives; import org.teavm.backend.wasm.binary.DataStructure; import org.teavm.backend.wasm.binary.DataValue; +import org.teavm.model.ValueType; public class WasmStringPool { private WasmClassGenerator classGenerator; diff --git a/core/src/main/java/org/teavm/backend/wasm/intrinsics/AllocatorIntrinsic.java b/core/src/main/java/org/teavm/backend/wasm/intrinsics/AllocatorIntrinsic.java index a25585a16..fde320b46 100644 --- a/core/src/main/java/org/teavm/backend/wasm/intrinsics/AllocatorIntrinsic.java +++ b/core/src/main/java/org/teavm/backend/wasm/intrinsics/AllocatorIntrinsic.java @@ -17,19 +17,19 @@ package org.teavm.backend.wasm.intrinsics; import java.util.stream.Collectors; import org.teavm.ast.InvocationExpr; -import org.teavm.interop.Address; -import org.teavm.model.MethodReference; -import org.teavm.runtime.Allocator; import org.teavm.backend.wasm.WasmRuntime; import org.teavm.backend.wasm.generate.WasmMangling; import org.teavm.backend.wasm.model.expression.WasmCall; import org.teavm.backend.wasm.model.expression.WasmExpression; +import org.teavm.interop.Address; +import org.teavm.model.MethodReference; +import org.teavm.runtime.Allocator; public class AllocatorIntrinsic implements WasmIntrinsic { @Override public boolean isApplicable(MethodReference methodReference) { - return methodReference.getClassName().equals(Allocator.class.getName()) && - methodReference.getName().equals("fillZero"); + return methodReference.getClassName().equals(Allocator.class.getName()) + && methodReference.getName().equals("fillZero"); } @Override diff --git a/core/src/main/java/org/teavm/backend/wasm/intrinsics/ClassIntrinsic.java b/core/src/main/java/org/teavm/backend/wasm/intrinsics/ClassIntrinsic.java index b8584d4e2..e2108a308 100644 --- a/core/src/main/java/org/teavm/backend/wasm/intrinsics/ClassIntrinsic.java +++ b/core/src/main/java/org/teavm/backend/wasm/intrinsics/ClassIntrinsic.java @@ -16,9 +16,9 @@ package org.teavm.backend.wasm.intrinsics; import org.teavm.ast.InvocationExpr; +import org.teavm.backend.wasm.model.expression.WasmExpression; import org.teavm.model.MethodDescriptor; import org.teavm.model.MethodReference; -import org.teavm.backend.wasm.model.expression.WasmExpression; public class ClassIntrinsic implements WasmIntrinsic { @Override diff --git a/core/src/main/java/org/teavm/backend/wasm/intrinsics/PlatformClassIntrinsic.java b/core/src/main/java/org/teavm/backend/wasm/intrinsics/PlatformClassIntrinsic.java index ebc143f30..50e404fb1 100644 --- a/core/src/main/java/org/teavm/backend/wasm/intrinsics/PlatformClassIntrinsic.java +++ b/core/src/main/java/org/teavm/backend/wasm/intrinsics/PlatformClassIntrinsic.java @@ -16,9 +16,9 @@ package org.teavm.backend.wasm.intrinsics; import org.teavm.ast.InvocationExpr; -import org.teavm.model.MethodReference; import org.teavm.backend.wasm.model.expression.WasmBlock; import org.teavm.backend.wasm.model.expression.WasmExpression; +import org.teavm.model.MethodReference; public class PlatformClassIntrinsic implements WasmIntrinsic { private static final String PLATFORM_CLASS_NAME = "org.teavm.platform.PlatformClass"; diff --git a/core/src/main/java/org/teavm/backend/wasm/intrinsics/PlatformClassMetadataIntrinsic.java b/core/src/main/java/org/teavm/backend/wasm/intrinsics/PlatformClassMetadataIntrinsic.java index 81d7cf9fb..4b25e33cd 100644 --- a/core/src/main/java/org/teavm/backend/wasm/intrinsics/PlatformClassMetadataIntrinsic.java +++ b/core/src/main/java/org/teavm/backend/wasm/intrinsics/PlatformClassMetadataIntrinsic.java @@ -17,10 +17,10 @@ package org.teavm.backend.wasm.intrinsics; import org.teavm.ast.InvocationExpr; import org.teavm.ast.QualificationExpr; +import org.teavm.backend.wasm.model.expression.WasmExpression; import org.teavm.model.FieldReference; import org.teavm.model.MethodReference; import org.teavm.runtime.RuntimeClass; -import org.teavm.backend.wasm.model.expression.WasmExpression; public class PlatformClassMetadataIntrinsic implements WasmIntrinsic { private static final String PLATFORM_CLASS_METADATA_NAME = "org.teavm.platform.PlatformClassMetadata"; diff --git a/core/src/main/java/org/teavm/backend/wasm/intrinsics/PlatformIntrinsic.java b/core/src/main/java/org/teavm/backend/wasm/intrinsics/PlatformIntrinsic.java index cfb2032be..de9444c03 100644 --- a/core/src/main/java/org/teavm/backend/wasm/intrinsics/PlatformIntrinsic.java +++ b/core/src/main/java/org/teavm/backend/wasm/intrinsics/PlatformIntrinsic.java @@ -16,8 +16,8 @@ package org.teavm.backend.wasm.intrinsics; import org.teavm.ast.InvocationExpr; -import org.teavm.model.MethodReference; import org.teavm.backend.wasm.model.expression.WasmExpression; +import org.teavm.model.MethodReference; public class PlatformIntrinsic implements WasmIntrinsic { private static final String PLATFORM = "org.teavm.platform.Platform"; diff --git a/core/src/main/java/org/teavm/backend/wasm/intrinsics/PlatformObjectIntrinsic.java b/core/src/main/java/org/teavm/backend/wasm/intrinsics/PlatformObjectIntrinsic.java index 2008032c0..39f69097f 100644 --- a/core/src/main/java/org/teavm/backend/wasm/intrinsics/PlatformObjectIntrinsic.java +++ b/core/src/main/java/org/teavm/backend/wasm/intrinsics/PlatformObjectIntrinsic.java @@ -16,9 +16,6 @@ package org.teavm.backend.wasm.intrinsics; import org.teavm.ast.InvocationExpr; -import org.teavm.model.FieldReference; -import org.teavm.model.MethodReference; -import org.teavm.runtime.RuntimeObject; import org.teavm.backend.wasm.generate.WasmClassGenerator; import org.teavm.backend.wasm.model.expression.WasmExpression; import org.teavm.backend.wasm.model.expression.WasmInt32Constant; @@ -27,6 +24,9 @@ import org.teavm.backend.wasm.model.expression.WasmIntBinary; import org.teavm.backend.wasm.model.expression.WasmIntBinaryOperation; import org.teavm.backend.wasm.model.expression.WasmIntType; import org.teavm.backend.wasm.model.expression.WasmLoadInt32; +import org.teavm.model.FieldReference; +import org.teavm.model.MethodReference; +import org.teavm.runtime.RuntimeObject; public class PlatformObjectIntrinsic implements WasmIntrinsic { private static final String PLATFORM_OBJECT = "org.teavm.platform.PlatformObject"; diff --git a/core/src/main/java/org/teavm/backend/wasm/intrinsics/WasmAddressIntrinsic.java b/core/src/main/java/org/teavm/backend/wasm/intrinsics/WasmAddressIntrinsic.java index da5f75457..88229dc12 100644 --- a/core/src/main/java/org/teavm/backend/wasm/intrinsics/WasmAddressIntrinsic.java +++ b/core/src/main/java/org/teavm/backend/wasm/intrinsics/WasmAddressIntrinsic.java @@ -16,9 +16,6 @@ package org.teavm.backend.wasm.intrinsics; import org.teavm.ast.InvocationExpr; -import org.teavm.interop.Address; -import org.teavm.model.MethodReference; -import org.teavm.model.ValueType; import org.teavm.backend.wasm.model.WasmType; import org.teavm.backend.wasm.model.expression.WasmConversion; import org.teavm.backend.wasm.model.expression.WasmExpression; @@ -35,6 +32,9 @@ import org.teavm.backend.wasm.model.expression.WasmStoreFloat32; import org.teavm.backend.wasm.model.expression.WasmStoreFloat64; import org.teavm.backend.wasm.model.expression.WasmStoreInt32; import org.teavm.backend.wasm.model.expression.WasmStoreInt64; +import org.teavm.interop.Address; +import org.teavm.model.MethodReference; +import org.teavm.model.ValueType; public class WasmAddressIntrinsic implements WasmIntrinsic { @Override diff --git a/core/src/main/java/org/teavm/backend/wasm/intrinsics/WasmIntrinsic.java b/core/src/main/java/org/teavm/backend/wasm/intrinsics/WasmIntrinsic.java index 565450c38..f11e51856 100644 --- a/core/src/main/java/org/teavm/backend/wasm/intrinsics/WasmIntrinsic.java +++ b/core/src/main/java/org/teavm/backend/wasm/intrinsics/WasmIntrinsic.java @@ -16,8 +16,8 @@ package org.teavm.backend.wasm.intrinsics; import org.teavm.ast.InvocationExpr; -import org.teavm.model.MethodReference; import org.teavm.backend.wasm.model.expression.WasmExpression; +import org.teavm.model.MethodReference; public interface WasmIntrinsic { boolean isApplicable(MethodReference methodReference); diff --git a/core/src/main/java/org/teavm/backend/wasm/intrinsics/WasmRuntimeIntrinsic.java b/core/src/main/java/org/teavm/backend/wasm/intrinsics/WasmRuntimeIntrinsic.java index 66868d888..68e07c8c6 100644 --- a/core/src/main/java/org/teavm/backend/wasm/intrinsics/WasmRuntimeIntrinsic.java +++ b/core/src/main/java/org/teavm/backend/wasm/intrinsics/WasmRuntimeIntrinsic.java @@ -16,7 +16,6 @@ package org.teavm.backend.wasm.intrinsics; import org.teavm.ast.InvocationExpr; -import org.teavm.model.MethodReference; import org.teavm.backend.wasm.WasmRuntime; import org.teavm.backend.wasm.generate.WasmGeneratorUtil; import org.teavm.backend.wasm.model.WasmType; @@ -27,12 +26,13 @@ import org.teavm.backend.wasm.model.expression.WasmFloatType; import org.teavm.backend.wasm.model.expression.WasmIntBinary; import org.teavm.backend.wasm.model.expression.WasmIntBinaryOperation; import org.teavm.backend.wasm.model.expression.WasmIntType; +import org.teavm.model.MethodReference; public class WasmRuntimeIntrinsic implements WasmIntrinsic { @Override public boolean isApplicable(MethodReference methodReference) { - return methodReference.getClassName().equals(WasmRuntime.class.getName()) && - (methodReference.getName().equals("lt") || methodReference.getName().equals("gt")); + return methodReference.getClassName().equals(WasmRuntime.class.getName()) + && (methodReference.getName().equals("lt") || methodReference.getName().equals("gt")); } @Override diff --git a/core/src/main/java/org/teavm/backend/wasm/intrinsics/WasmStructureIntrinsic.java b/core/src/main/java/org/teavm/backend/wasm/intrinsics/WasmStructureIntrinsic.java index a9b028c4c..92d6894aa 100644 --- a/core/src/main/java/org/teavm/backend/wasm/intrinsics/WasmStructureIntrinsic.java +++ b/core/src/main/java/org/teavm/backend/wasm/intrinsics/WasmStructureIntrinsic.java @@ -17,12 +17,12 @@ package org.teavm.backend.wasm.intrinsics; import org.teavm.ast.ConstantExpr; import org.teavm.ast.InvocationExpr; -import org.teavm.interop.Address; -import org.teavm.model.MethodReference; -import org.teavm.model.ValueType; import org.teavm.backend.wasm.generate.WasmClassGenerator; import org.teavm.backend.wasm.model.expression.WasmExpression; import org.teavm.backend.wasm.model.expression.WasmInt32Constant; +import org.teavm.interop.Address; +import org.teavm.model.MethodReference; +import org.teavm.model.ValueType; public class WasmStructureIntrinsic implements WasmIntrinsic { private WasmClassGenerator classGenerator; diff --git a/core/src/main/java/org/teavm/cache/DiskRegularMethodNodeCache.java b/core/src/main/java/org/teavm/cache/DiskRegularMethodNodeCache.java index 4281eeadd..f187a3723 100644 --- a/core/src/main/java/org/teavm/cache/DiskRegularMethodNodeCache.java +++ b/core/src/main/java/org/teavm/cache/DiskRegularMethodNodeCache.java @@ -28,47 +28,14 @@ import java.io.InputStream; import java.util.Date; import java.util.HashMap; import java.util.HashSet; -import java.util.List; import java.util.Map; import java.util.Set; -import org.teavm.ast.AssignmentStatement; import org.teavm.ast.AsyncMethodNode; import org.teavm.ast.AsyncMethodPart; -import org.teavm.ast.BinaryExpr; -import org.teavm.ast.BlockStatement; -import org.teavm.ast.BreakStatement; -import org.teavm.ast.CastExpr; -import org.teavm.ast.ConditionalExpr; -import org.teavm.ast.ConditionalStatement; -import org.teavm.ast.ConstantExpr; -import org.teavm.ast.ContinueStatement; -import org.teavm.ast.Expr; -import org.teavm.ast.ExprVisitor; -import org.teavm.ast.GotoPartStatement; -import org.teavm.ast.InitClassStatement; -import org.teavm.ast.InstanceOfExpr; import org.teavm.ast.InvocationExpr; -import org.teavm.ast.MonitorEnterStatement; -import org.teavm.ast.MonitorExitStatement; -import org.teavm.ast.NewArrayExpr; -import org.teavm.ast.NewExpr; -import org.teavm.ast.NewMultiArrayExpr; -import org.teavm.ast.PrimitiveCastExpr; import org.teavm.ast.QualificationExpr; +import org.teavm.ast.RecursiveVisitor; import org.teavm.ast.RegularMethodNode; -import org.teavm.ast.ReturnStatement; -import org.teavm.ast.SequentialStatement; -import org.teavm.ast.Statement; -import org.teavm.ast.StatementVisitor; -import org.teavm.ast.SubscriptExpr; -import org.teavm.ast.SwitchClause; -import org.teavm.ast.SwitchStatement; -import org.teavm.ast.ThrowStatement; -import org.teavm.ast.TryCatchStatement; -import org.teavm.ast.UnaryExpr; -import org.teavm.ast.UnwrapArrayExpr; -import org.teavm.ast.VariableExpr; -import org.teavm.ast.WhileStatement; import org.teavm.ast.cache.MethodNodeCache; import org.teavm.model.MethodReference; import org.teavm.parsing.ClassDateProvider; @@ -198,181 +165,19 @@ public class DiskRegularMethodNodeCache implements MethodNodeCache { + (async ? "-async" : "")); } - private static class AstDependencyAnalyzer implements StatementVisitor, ExprVisitor { + private static class AstDependencyAnalyzer extends RecursiveVisitor { final Set dependencies = new HashSet<>(); - private void visitSequence(List statements) { - for (Statement stmt : statements) { - stmt.acceptVisitor(this); - } - } - - @Override - public void visit(AssignmentStatement statement) { - if (statement.getLeftValue() != null) { - statement.getLeftValue().acceptVisitor(this); - } - statement.getRightValue().acceptVisitor(this); - } - - @Override - public void visit(SequentialStatement statement) { - visitSequence(statement.getSequence()); - } - - @Override - public void visit(ConditionalStatement statement) { - statement.getCondition().acceptVisitor(this); - visitSequence(statement.getConsequent()); - visitSequence(statement.getAlternative()); - } - - @Override - public void visit(SwitchStatement statement) { - statement.getValue().acceptVisitor(this); - for (SwitchClause clause : statement.getClauses()) { - visitSequence(clause.getBody()); - } - visitSequence(statement.getDefaultClause()); - } - - @Override - public void visit(WhileStatement statement) { - if (statement.getCondition() != null) { - statement.getCondition().acceptVisitor(this); - } - visitSequence(statement.getBody()); - } - - @Override - public void visit(BlockStatement statement) { - visitSequence(statement.getBody()); - } - - @Override - public void visit(BreakStatement statement) { - } - - @Override - public void visit(ContinueStatement statement) { - } - - @Override - public void visit(ReturnStatement statement) { - if (statement.getResult() != null) { - statement.getResult().acceptVisitor(this); - } - } - - @Override - public void visit(ThrowStatement statement) { - statement.getException().acceptVisitor(this); - } - - @Override - public void visit(InitClassStatement statement) { - } - - @Override - public void visit(TryCatchStatement statement) { - visitSequence(statement.getProtectedBody()); - visitSequence(statement.getHandler()); - } - - @Override - public void visit(BinaryExpr expr) { - expr.getFirstOperand().acceptVisitor(this); - expr.getSecondOperand().acceptVisitor(this); - } - - @Override - public void visit(UnaryExpr expr) { - expr.getOperand().acceptVisitor(this); - } - - @Override - public void visit(ConditionalExpr expr) { - expr.getCondition().acceptVisitor(this); - expr.getConsequent().acceptVisitor(this); - expr.getAlternative().acceptVisitor(this); - } - - @Override - public void visit(ConstantExpr expr) { - } - - @Override - public void visit(VariableExpr expr) { - } - - @Override - public void visit(SubscriptExpr expr) { - expr.getArray().acceptVisitor(this); - expr.getIndex().acceptVisitor(this); - } - - @Override - public void visit(UnwrapArrayExpr expr) { - expr.getArray().acceptVisitor(this); - } - @Override public void visit(InvocationExpr expr) { + super.visit(expr); dependencies.add(expr.getMethod().getClassName()); - for (Expr argument : expr.getArguments()) { - argument.acceptVisitor(this); - } } @Override public void visit(QualificationExpr expr) { + super.visit(expr); dependencies.add(expr.getField().getClassName()); - if (expr.getQualified() != null) { - expr.getQualified().acceptVisitor(this); - } - } - - @Override - public void visit(NewExpr expr) { - } - - @Override - public void visit(NewArrayExpr expr) { - expr.getLength().acceptVisitor(this); - } - - @Override - public void visit(NewMultiArrayExpr expr) { - for (Expr dimension : expr.getDimensions()) { - dimension.acceptVisitor(this); - } - } - - @Override - public void visit(CastExpr expr) { - expr.getValue().acceptVisitor(this); - } - - @Override - public void visit(PrimitiveCastExpr expr) { - expr.getValue().acceptVisitor(this); - } - - @Override - public void visit(InstanceOfExpr expr) { - expr.getExpr().acceptVisitor(this); - } - - @Override - public void visit(GotoPartStatement statement) { - } - - @Override - public void visit(MonitorEnterStatement statement) { - } - - @Override - public void visit(MonitorExitStatement statement) { } } diff --git a/core/src/main/java/org/teavm/callgraph/DefaultCallGraphNode.java b/core/src/main/java/org/teavm/callgraph/DefaultCallGraphNode.java index 55415a788..f1563c57d 100644 --- a/core/src/main/java/org/teavm/callgraph/DefaultCallGraphNode.java +++ b/core/src/main/java/org/teavm/callgraph/DefaultCallGraphNode.java @@ -15,10 +15,15 @@ */ package org.teavm.callgraph; -import java.util.*; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; import org.teavm.model.FieldReference; -import org.teavm.model.TextLocation; import org.teavm.model.MethodReference; +import org.teavm.model.TextLocation; /** * diff --git a/core/src/main/java/org/teavm/dependency/DependencyChecker.java b/core/src/main/java/org/teavm/dependency/DependencyChecker.java index 7bbe4e27c..5b5e00a54 100644 --- a/core/src/main/java/org/teavm/dependency/DependencyChecker.java +++ b/core/src/main/java/org/teavm/dependency/DependencyChecker.java @@ -42,17 +42,17 @@ import org.teavm.model.ElementModifier; import org.teavm.model.FieldHolder; import org.teavm.model.FieldReader; import org.teavm.model.FieldReference; -import org.teavm.model.TextLocation; import org.teavm.model.MethodDescriptor; import org.teavm.model.MethodHolder; import org.teavm.model.MethodReader; import org.teavm.model.MethodReference; import org.teavm.model.Program; import org.teavm.model.ReferenceCache; +import org.teavm.model.TextLocation; import org.teavm.model.ValueType; +import org.teavm.model.optimization.UnreachableBasicBlockEliminator; import org.teavm.model.util.ModelUtils; import org.teavm.model.util.ProgramUtils; -import org.teavm.model.optimization.UnreachableBasicBlockEliminator; import org.teavm.parsing.Parser; public class DependencyChecker implements DependencyInfo { diff --git a/core/src/main/java/org/teavm/dependency/DependencyClassSource.java b/core/src/main/java/org/teavm/dependency/DependencyClassSource.java index 2c840024b..8278f15a5 100644 --- a/core/src/main/java/org/teavm/dependency/DependencyClassSource.java +++ b/core/src/main/java/org/teavm/dependency/DependencyClassSource.java @@ -27,8 +27,8 @@ import org.teavm.model.ClassHolderTransformer; import org.teavm.model.ClassReader; import org.teavm.model.ClassReaderSource; import org.teavm.model.MethodHolder; -import org.teavm.model.util.ModelUtils; import org.teavm.model.optimization.UnreachableBasicBlockEliminator; +import org.teavm.model.util.ModelUtils; class DependencyClassSource implements ClassHolderSource { private ClassReaderSource innerSource; diff --git a/core/src/main/java/org/teavm/dependency/DependencyGraphBuilder.java b/core/src/main/java/org/teavm/dependency/DependencyGraphBuilder.java index 52d5459b1..f3b088eea 100644 --- a/core/src/main/java/org/teavm/dependency/DependencyGraphBuilder.java +++ b/core/src/main/java/org/teavm/dependency/DependencyGraphBuilder.java @@ -33,7 +33,6 @@ import org.teavm.model.FieldReference; import org.teavm.model.Incoming; import org.teavm.model.IncomingReader; import org.teavm.model.Instruction; -import org.teavm.model.TextLocation; import org.teavm.model.InvokeDynamicInstruction; import org.teavm.model.MethodDescriptor; import org.teavm.model.MethodHandle; @@ -43,6 +42,7 @@ import org.teavm.model.Phi; import org.teavm.model.PhiReader; import org.teavm.model.Program; import org.teavm.model.RuntimeConstant; +import org.teavm.model.TextLocation; import org.teavm.model.TryCatchBlockReader; import org.teavm.model.TryCatchJointReader; import org.teavm.model.ValueType; diff --git a/core/src/main/java/org/teavm/diagnostics/DefaultProblemTextConsumer.java b/core/src/main/java/org/teavm/diagnostics/DefaultProblemTextConsumer.java index 5413016b5..cff7b230c 100644 --- a/core/src/main/java/org/teavm/diagnostics/DefaultProblemTextConsumer.java +++ b/core/src/main/java/org/teavm/diagnostics/DefaultProblemTextConsumer.java @@ -16,14 +16,10 @@ package org.teavm.diagnostics; import org.teavm.model.FieldReference; -import org.teavm.model.TextLocation; import org.teavm.model.MethodReference; +import org.teavm.model.TextLocation; import org.teavm.model.ValueType; -/** - * - * @author Alexey Andreev - */ public class DefaultProblemTextConsumer implements ProblemTextConsumer { private StringBuilder sb = new StringBuilder(); diff --git a/core/src/main/java/org/teavm/diagnostics/ProblemTextConsumer.java b/core/src/main/java/org/teavm/diagnostics/ProblemTextConsumer.java index fda9160c4..5ca0c5a0e 100644 --- a/core/src/main/java/org/teavm/diagnostics/ProblemTextConsumer.java +++ b/core/src/main/java/org/teavm/diagnostics/ProblemTextConsumer.java @@ -16,14 +16,10 @@ package org.teavm.diagnostics; import org.teavm.model.FieldReference; -import org.teavm.model.TextLocation; import org.teavm.model.MethodReference; +import org.teavm.model.TextLocation; import org.teavm.model.ValueType; -/** - * - * @author Alexey Andreev - */ public interface ProblemTextConsumer { void append(String text); diff --git a/core/src/main/java/org/teavm/model/emit/ProgramEmitter.java b/core/src/main/java/org/teavm/model/emit/ProgramEmitter.java index 8721c382a..58017e8eb 100644 --- a/core/src/main/java/org/teavm/model/emit/ProgramEmitter.java +++ b/core/src/main/java/org/teavm/model/emit/ProgramEmitter.java @@ -21,12 +21,12 @@ import org.teavm.model.ClassReaderSource; import org.teavm.model.FieldReader; import org.teavm.model.FieldReference; import org.teavm.model.Instruction; -import org.teavm.model.TextLocation; import org.teavm.model.MethodDescriptor; import org.teavm.model.MethodHolder; import org.teavm.model.MethodReference; import org.teavm.model.Phi; import org.teavm.model.Program; +import org.teavm.model.TextLocation; import org.teavm.model.ValueType; import org.teavm.model.Variable; import org.teavm.model.instructions.ClassConstantInstruction; diff --git a/core/src/main/java/org/teavm/model/util/AsyncMethodFinder.java b/core/src/main/java/org/teavm/model/util/AsyncMethodFinder.java index 7588d9675..c46d0992a 100644 --- a/core/src/main/java/org/teavm/model/util/AsyncMethodFinder.java +++ b/core/src/main/java/org/teavm/model/util/AsyncMethodFinder.java @@ -15,16 +15,45 @@ */ package org.teavm.model.util; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import org.teavm.backend.javascript.spi.InjectedBy; import org.teavm.callgraph.CallGraph; import org.teavm.callgraph.CallGraphNode; import org.teavm.callgraph.CallSite; import org.teavm.diagnostics.Diagnostics; import org.teavm.interop.Async; -import org.teavm.backend.javascript.spi.InjectedBy; import org.teavm.interop.Sync; -import org.teavm.model.*; -import org.teavm.model.instructions.*; +import org.teavm.model.BasicBlockReader; +import org.teavm.model.CallLocation; +import org.teavm.model.ClassReader; +import org.teavm.model.ElementModifier; +import org.teavm.model.FieldReference; +import org.teavm.model.ListableClassReaderSource; +import org.teavm.model.MethodDescriptor; +import org.teavm.model.MethodHandle; +import org.teavm.model.MethodReader; +import org.teavm.model.MethodReference; +import org.teavm.model.ProgramReader; +import org.teavm.model.RuntimeConstant; +import org.teavm.model.TextLocation; +import org.teavm.model.ValueType; +import org.teavm.model.VariableReader; +import org.teavm.model.instructions.ArrayElementType; +import org.teavm.model.instructions.BinaryBranchingCondition; +import org.teavm.model.instructions.BinaryOperation; +import org.teavm.model.instructions.BranchingCondition; +import org.teavm.model.instructions.CastIntegerDirection; +import org.teavm.model.instructions.InstructionReader; +import org.teavm.model.instructions.IntegerSubtype; +import org.teavm.model.instructions.InvocationType; +import org.teavm.model.instructions.NumericOperandType; +import org.teavm.model.instructions.SwitchTableEntryReader; /** * diff --git a/core/src/main/java/org/teavm/model/util/InstructionCopyReader.java b/core/src/main/java/org/teavm/model/util/InstructionCopyReader.java index d9cc2262c..d99517dc3 100644 --- a/core/src/main/java/org/teavm/model/util/InstructionCopyReader.java +++ b/core/src/main/java/org/teavm/model/util/InstructionCopyReader.java @@ -21,13 +21,13 @@ import org.teavm.model.BasicBlock; import org.teavm.model.BasicBlockReader; import org.teavm.model.FieldReference; import org.teavm.model.Instruction; -import org.teavm.model.TextLocation; import org.teavm.model.InvokeDynamicInstruction; import org.teavm.model.MethodDescriptor; import org.teavm.model.MethodHandle; import org.teavm.model.MethodReference; import org.teavm.model.Program; import org.teavm.model.RuntimeConstant; +import org.teavm.model.TextLocation; import org.teavm.model.ValueType; import org.teavm.model.Variable; import org.teavm.model.VariableReader; diff --git a/core/src/main/java/org/teavm/model/util/LocationGraphBuilder.java b/core/src/main/java/org/teavm/model/util/LocationGraphBuilder.java index 84c2eac4a..3a5199c92 100644 --- a/core/src/main/java/org/teavm/model/util/LocationGraphBuilder.java +++ b/core/src/main/java/org/teavm/model/util/LocationGraphBuilder.java @@ -15,17 +15,22 @@ */ package org.teavm.model.util; -import java.util.*; +import java.util.ArrayDeque; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Deque; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; import org.teavm.common.Graph; import org.teavm.model.BasicBlock; import org.teavm.model.Instruction; -import org.teavm.model.TextLocation; import org.teavm.model.Program; +import org.teavm.model.TextLocation; -/** - * - * @author Alexey Andreev - */ class LocationGraphBuilder { private Map> graphBuilder; private List> startLocations; diff --git a/core/src/main/java/org/teavm/model/util/ProgramUtils.java b/core/src/main/java/org/teavm/model/util/ProgramUtils.java index 9a955f418..e000227c4 100644 --- a/core/src/main/java/org/teavm/model/util/ProgramUtils.java +++ b/core/src/main/java/org/teavm/model/util/ProgramUtils.java @@ -25,11 +25,11 @@ import org.teavm.model.BasicBlockReader; import org.teavm.model.Incoming; import org.teavm.model.IncomingReader; import org.teavm.model.Instruction; -import org.teavm.model.TextLocation; import org.teavm.model.Phi; import org.teavm.model.PhiReader; import org.teavm.model.Program; import org.teavm.model.ProgramReader; +import org.teavm.model.TextLocation; import org.teavm.model.TryCatchBlock; import org.teavm.model.TryCatchBlockReader; import org.teavm.model.TryCatchJoint; diff --git a/core/src/main/java/org/teavm/parsing/Parser.java b/core/src/main/java/org/teavm/parsing/Parser.java index dfa8c0ec3..ad99c1a1b 100644 --- a/core/src/main/java/org/teavm/parsing/Parser.java +++ b/core/src/main/java/org/teavm/parsing/Parser.java @@ -26,14 +26,36 @@ import java.util.Map; import org.objectweb.asm.Opcodes; import org.objectweb.asm.Type; import org.objectweb.asm.commons.JSRInlinerAdapter; -import org.objectweb.asm.tree.*; +import org.objectweb.asm.tree.AnnotationNode; +import org.objectweb.asm.tree.ClassNode; +import org.objectweb.asm.tree.FieldNode; +import org.objectweb.asm.tree.MethodNode; import org.teavm.common.Graph; import org.teavm.common.GraphUtils; -import org.teavm.model.*; +import org.teavm.model.AccessLevel; +import org.teavm.model.AnnotationContainer; +import org.teavm.model.AnnotationHolder; +import org.teavm.model.AnnotationValue; +import org.teavm.model.BasicBlock; +import org.teavm.model.ClassHolder; +import org.teavm.model.ElementHolder; +import org.teavm.model.ElementModifier; +import org.teavm.model.FieldHolder; +import org.teavm.model.FieldReference; +import org.teavm.model.Instruction; +import org.teavm.model.MethodDescriptor; +import org.teavm.model.MethodHolder; +import org.teavm.model.Phi; +import org.teavm.model.PrimitiveType; +import org.teavm.model.Program; +import org.teavm.model.ReferenceCache; +import org.teavm.model.TryCatchJoint; +import org.teavm.model.ValueType; +import org.teavm.model.Variable; +import org.teavm.model.optimization.UnreachableBasicBlockEliminator; import org.teavm.model.util.DefinitionExtractor; import org.teavm.model.util.PhiUpdater; import org.teavm.model.util.ProgramUtils; -import org.teavm.model.optimization.UnreachableBasicBlockEliminator; public class Parser { private ReferenceCache referenceCache; diff --git a/core/src/main/java/org/teavm/runtime/Allocator.java b/core/src/main/java/org/teavm/runtime/Allocator.java index c35057346..27fd00dc3 100644 --- a/core/src/main/java/org/teavm/runtime/Allocator.java +++ b/core/src/main/java/org/teavm/runtime/Allocator.java @@ -21,6 +21,9 @@ import org.teavm.interop.Structure; @StaticInit public final class Allocator { + private Allocator() { + } + private static Address address = initialize(); private static native Address initialize(); diff --git a/core/src/main/java/org/teavm/runtime/RuntimeClass.java b/core/src/main/java/org/teavm/runtime/RuntimeClass.java index 0dd37e943..4f2f7089f 100644 --- a/core/src/main/java/org/teavm/runtime/RuntimeClass.java +++ b/core/src/main/java/org/teavm/runtime/RuntimeClass.java @@ -16,8 +16,8 @@ package org.teavm.runtime; public class RuntimeClass extends RuntimeJavaObject { - public static int INITIALIZED = 1; - public static int PRIMITIVE = 2; + public static final int INITIALIZED = 1; + public static final int PRIMITIVE = 2; public int size; public int flags; @@ -27,7 +27,7 @@ public class RuntimeClass extends RuntimeJavaObject { public RuntimeClass arrayType; public static int computeCanary(int size, int tag) { - return size ^ (tag << 8) ^ (tag >>> 24) ^ (0xAAAAAAAA); + return size ^ (tag << 8) ^ (tag >>> 24) ^ 0xAAAAAAAA; } public int computeCanary() { diff --git a/core/src/main/java/org/teavm/backend/javascript/rendering/RenderingException.java b/core/src/main/java/org/teavm/vm/RenderingException.java similarity index 95% rename from core/src/main/java/org/teavm/backend/javascript/rendering/RenderingException.java rename to core/src/main/java/org/teavm/vm/RenderingException.java index 035a02daa..c8fb410b2 100644 --- a/core/src/main/java/org/teavm/backend/javascript/rendering/RenderingException.java +++ b/core/src/main/java/org/teavm/vm/RenderingException.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.teavm.backend.javascript.rendering; +package org.teavm.vm; public class RenderingException extends RuntimeException { private static final long serialVersionUID = 631804556597569547L; diff --git a/core/src/main/java/org/teavm/vm/TeaVM.java b/core/src/main/java/org/teavm/vm/TeaVM.java index 298d60c40..7d2cd4b4c 100644 --- a/core/src/main/java/org/teavm/vm/TeaVM.java +++ b/core/src/main/java/org/teavm/vm/TeaVM.java @@ -39,7 +39,6 @@ import org.teavm.dependency.Linker; import org.teavm.diagnostics.AccumulationDiagnostics; import org.teavm.diagnostics.Diagnostics; import org.teavm.diagnostics.ProblemProvider; -import org.teavm.backend.javascript.rendering.RenderingException; import org.teavm.model.ClassHolder; import org.teavm.model.ClassHolderSource; import org.teavm.model.ClassHolderTransformer; @@ -52,10 +51,6 @@ import org.teavm.model.MethodReference; import org.teavm.model.MutableClassHolderSource; import org.teavm.model.Program; import org.teavm.model.ProgramCache; -import org.teavm.model.util.MissingItemsProcessor; -import org.teavm.model.util.ModelUtils; -import org.teavm.model.util.ProgramUtils; -import org.teavm.model.util.RegisterAllocator; import org.teavm.model.optimization.ArrayUnwrapMotion; import org.teavm.model.optimization.ClassInitElimination; import org.teavm.model.optimization.ConstantConditionElimination; @@ -68,6 +63,10 @@ import org.teavm.model.optimization.MethodOptimization; import org.teavm.model.optimization.RedundantJumpElimination; import org.teavm.model.optimization.UnreachableBasicBlockElimination; import org.teavm.model.optimization.UnusedVariableElimination; +import org.teavm.model.util.MissingItemsProcessor; +import org.teavm.model.util.ModelUtils; +import org.teavm.model.util.ProgramUtils; +import org.teavm.model.util.RegisterAllocator; import org.teavm.vm.spi.TeaVMHost; import org.teavm.vm.spi.TeaVMHostExtension; import org.teavm.vm.spi.TeaVMPlugin; @@ -323,10 +322,8 @@ public class TeaVM implements TeaVMHost, ServiceRepository { * @param output where to generate JavaScript. Should not be null. * @param buildTarget where to generate additional resources. Can be null, but if there are * plugins or inteceptors that generate additional resources, the build process will fail. - * - * @throws RenderingException when something went wrong during rendering phase. */ - public void build(OutputStream output, BuildTarget buildTarget) throws RenderingException { + public void build(OutputStream output, BuildTarget buildTarget) { target.setController(targetController); // Check dependencies @@ -497,13 +494,13 @@ public class TeaVM implements TeaVMHost, ServiceRepository { new UnreachableBasicBlockElimination()); } - public void build(File dir, String fileName) throws RenderingException { + public void build(File dir, String fileName) { try (OutputStream output = new FileOutputStream(new File(dir, fileName))) { build(output, new DirectoryBuildTarget(dir)); } catch (UnsupportedEncodingException e) { throw new RuntimeException("Platform does not support UTF-8", e); } catch (IOException e) { - throw new RenderingException("IO error occured", e); + throw new RenderingException("IO error occurred", e); } } diff --git a/html4j/src/main/java/org/teavm/html4j/JavaScriptBodyTransformer.java b/html4j/src/main/java/org/teavm/html4j/JavaScriptBodyTransformer.java index 50def6608..56390240a 100644 --- a/html4j/src/main/java/org/teavm/html4j/JavaScriptBodyTransformer.java +++ b/html4j/src/main/java/org/teavm/html4j/JavaScriptBodyTransformer.java @@ -16,14 +16,17 @@ package org.teavm.html4j; import net.java.html.js.JavaScriptBody; -import org.teavm.diagnostics.Diagnostics; import org.teavm.backend.javascript.spi.GeneratedBy; -import org.teavm.model.*; +import org.teavm.diagnostics.Diagnostics; +import org.teavm.model.AnnotationHolder; +import org.teavm.model.AnnotationValue; +import org.teavm.model.ClassHolder; +import org.teavm.model.ClassHolderTransformer; +import org.teavm.model.ClassReaderSource; +import org.teavm.model.ElementModifier; +import org.teavm.model.MethodHolder; +import org.teavm.model.ValueType; -/** - * - * @author Alexey Andreev - */ public class JavaScriptBodyTransformer implements ClassHolderTransformer { @Override public void transformClass(ClassHolder cls, ClassReaderSource innerSource, Diagnostics diagnostics) { diff --git a/html4j/src/main/java/org/teavm/html4j/JavaScriptResourceInterceptor.java b/html4j/src/main/java/org/teavm/html4j/JavaScriptResourceInterceptor.java index 3a0d3f4ad..a4dd920d1 100644 --- a/html4j/src/main/java/org/teavm/html4j/JavaScriptResourceInterceptor.java +++ b/html4j/src/main/java/org/teavm/html4j/JavaScriptResourceInterceptor.java @@ -21,16 +21,12 @@ import java.io.StringWriter; import net.java.html.js.JavaScriptResource; import org.apache.commons.io.IOUtils; import org.teavm.backend.javascript.rendering.RenderingContext; -import org.teavm.backend.javascript.rendering.RenderingException; import org.teavm.model.AnnotationReader; import org.teavm.model.ClassReader; import org.teavm.vm.BuildTarget; +import org.teavm.vm.RenderingException; import org.teavm.vm.spi.AbstractRendererListener; -/** - * - * @author Alexey Andreev - */ public class JavaScriptResourceInterceptor extends AbstractRendererListener { @Override public void begin(RenderingContext context, BuildTarget buildTarget) throws IOException { diff --git a/interop/core/src/main/java/org/teavm/interop/Address.java b/interop/core/src/main/java/org/teavm/interop/Address.java index ea07e251e..3fcfc84b9 100644 --- a/interop/core/src/main/java/org/teavm/interop/Address.java +++ b/interop/core/src/main/java/org/teavm/interop/Address.java @@ -16,43 +16,43 @@ package org.teavm.interop; public final class Address { - public final native Address add(int offset); + public native Address add(int offset); - public final native Address add(long offset); + public native Address add(long offset); - public final native int toInt(); + public native int toInt(); - public final native long toLong(); + public native long toLong(); - public final native T toStructure(); + public native T toStructure(); - public final native byte getByte(); + public native byte getByte(); - public final native void putByte(byte value); + public native void putByte(byte value); - public final native char getChar(); + public native char getChar(); - public final native void putChar(char value); + public native void putChar(char value); - public final native short getShort(); + public native short getShort(); - public final native void putShort(short value); + public native void putShort(short value); - public final native int getInt(); + public native int getInt(); - public final native void putInt(int value); + public native void putInt(int value); - public final native long getLong(); + public native long getLong(); - public final native void putLong(long value); + public native void putLong(long value); - public final native float getFloat(); + public native float getFloat(); - public final native void putFloat(float value); + public native void putFloat(float value); - public final native double getDouble(); + public native double getDouble(); - public final native void putDouble(double value); + public native void putDouble(double value); public static native Address fromInt(int value); diff --git a/jso/impl/src/main/java/org/teavm/jso/impl/JS.java b/jso/impl/src/main/java/org/teavm/jso/impl/JS.java index ec3702466..0f15264da 100644 --- a/jso/impl/src/main/java/org/teavm/jso/impl/JS.java +++ b/jso/impl/src/main/java/org/teavm/jso/impl/JS.java @@ -17,9 +17,9 @@ package org.teavm.jso.impl; import java.lang.reflect.Array; import java.util.function.Function; -import org.teavm.dependency.PluggableDependency; import org.teavm.backend.javascript.spi.GeneratedBy; import org.teavm.backend.javascript.spi.InjectedBy; +import org.teavm.dependency.PluggableDependency; import org.teavm.jso.JSBody; import org.teavm.jso.JSObject; import org.teavm.jso.core.JSArray; diff --git a/jso/impl/src/main/java/org/teavm/jso/impl/JSClassProcessor.java b/jso/impl/src/main/java/org/teavm/jso/impl/JSClassProcessor.java index c4bb40147..76629e62a 100644 --- a/jso/impl/src/main/java/org/teavm/jso/impl/JSClassProcessor.java +++ b/jso/impl/src/main/java/org/teavm/jso/impl/JSClassProcessor.java @@ -30,10 +30,10 @@ import org.mozilla.javascript.Context; import org.mozilla.javascript.ast.AstNode; import org.mozilla.javascript.ast.AstRoot; import org.mozilla.javascript.ast.FunctionNode; -import org.teavm.cache.NoCache; -import org.teavm.diagnostics.Diagnostics; import org.teavm.backend.javascript.spi.GeneratedBy; import org.teavm.backend.javascript.spi.InjectedBy; +import org.teavm.cache.NoCache; +import org.teavm.diagnostics.Diagnostics; import org.teavm.interop.Sync; import org.teavm.jso.JSBody; import org.teavm.jso.JSFunctor; @@ -55,12 +55,12 @@ import org.teavm.model.ClassReaderSource; import org.teavm.model.ElementModifier; import org.teavm.model.FieldHolder; import org.teavm.model.Instruction; -import org.teavm.model.TextLocation; import org.teavm.model.MethodDescriptor; import org.teavm.model.MethodHolder; import org.teavm.model.MethodReader; import org.teavm.model.MethodReference; import org.teavm.model.Program; +import org.teavm.model.TextLocation; import org.teavm.model.ValueType; import org.teavm.model.Variable; import org.teavm.model.instructions.AssignInstruction; diff --git a/jso/impl/src/main/java/org/teavm/jso/impl/JSNativeGenerator.java b/jso/impl/src/main/java/org/teavm/jso/impl/JSNativeGenerator.java index fae7b2fe3..ee371be52 100644 --- a/jso/impl/src/main/java/org/teavm/jso/impl/JSNativeGenerator.java +++ b/jso/impl/src/main/java/org/teavm/jso/impl/JSNativeGenerator.java @@ -20,15 +20,15 @@ import org.teavm.ast.ConstantExpr; import org.teavm.ast.Expr; import org.teavm.ast.InvocationExpr; import org.teavm.backend.javascript.codegen.SourceWriter; -import org.teavm.dependency.DependencyAgent; -import org.teavm.dependency.DependencyPlugin; -import org.teavm.dependency.MethodDependency; import org.teavm.backend.javascript.rendering.Precedence; import org.teavm.backend.javascript.rendering.Renderer; import org.teavm.backend.javascript.spi.Generator; import org.teavm.backend.javascript.spi.GeneratorContext; import org.teavm.backend.javascript.spi.Injector; import org.teavm.backend.javascript.spi.InjectorContext; +import org.teavm.dependency.DependencyAgent; +import org.teavm.dependency.DependencyPlugin; +import org.teavm.dependency.MethodDependency; import org.teavm.model.CallLocation; import org.teavm.model.ClassReader; import org.teavm.model.MethodReader; diff --git a/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/AliasFinder.java b/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/AliasFinder.java index 925633854..d0df8414e 100644 --- a/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/AliasFinder.java +++ b/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/AliasFinder.java @@ -22,13 +22,13 @@ import java.util.stream.Collectors; import org.teavm.common.DisjointSet; import org.teavm.model.BasicBlockReader; import org.teavm.model.FieldReference; -import org.teavm.model.TextLocation; import org.teavm.model.MethodDescriptor; import org.teavm.model.MethodHandle; import org.teavm.model.MethodReference; import org.teavm.model.PhiReader; import org.teavm.model.ProgramReader; import org.teavm.model.RuntimeConstant; +import org.teavm.model.TextLocation; import org.teavm.model.TryCatchBlockReader; import org.teavm.model.TryCatchJointReader; import org.teavm.model.ValueType; diff --git a/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/CompositeMethodGenerator.java b/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/CompositeMethodGenerator.java index 507ac817c..dab93e8af 100644 --- a/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/CompositeMethodGenerator.java +++ b/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/CompositeMethodGenerator.java @@ -39,7 +39,6 @@ import org.teavm.model.FieldReference; import org.teavm.model.Incoming; import org.teavm.model.IncomingReader; import org.teavm.model.Instruction; -import org.teavm.model.TextLocation; import org.teavm.model.InvokeDynamicInstruction; import org.teavm.model.MethodDescriptor; import org.teavm.model.MethodHandle; @@ -49,6 +48,7 @@ import org.teavm.model.PhiReader; import org.teavm.model.Program; import org.teavm.model.ProgramReader; import org.teavm.model.RuntimeConstant; +import org.teavm.model.TextLocation; import org.teavm.model.TryCatchBlock; import org.teavm.model.TryCatchBlockReader; import org.teavm.model.ValueType; diff --git a/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/MetaprogrammingImpl.java b/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/MetaprogrammingImpl.java index 3938adcc6..6967bd236 100644 --- a/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/MetaprogrammingImpl.java +++ b/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/MetaprogrammingImpl.java @@ -39,11 +39,11 @@ import org.teavm.model.ClassHolder; import org.teavm.model.ClassReaderSource; import org.teavm.model.ElementModifier; import org.teavm.model.Instruction; -import org.teavm.model.TextLocation; import org.teavm.model.MethodHolder; import org.teavm.model.MethodReader; import org.teavm.model.MethodReference; import org.teavm.model.Program; +import org.teavm.model.TextLocation; import org.teavm.model.ValueType; import org.teavm.model.Variable; import org.teavm.model.instructions.DoubleConstantInstruction; diff --git a/platform/src/main/java/org/teavm/platform/Platform.java b/platform/src/main/java/org/teavm/platform/Platform.java index 906b01bfa..dc25502b5 100644 --- a/platform/src/main/java/org/teavm/platform/Platform.java +++ b/platform/src/main/java/org/teavm/platform/Platform.java @@ -16,9 +16,9 @@ package org.teavm.platform; import java.lang.annotation.Annotation; -import org.teavm.dependency.PluggableDependency; import org.teavm.backend.javascript.spi.GeneratedBy; import org.teavm.backend.javascript.spi.InjectedBy; +import org.teavm.dependency.PluggableDependency; import org.teavm.jso.JSBody; import org.teavm.jso.JSObject; import org.teavm.jso.browser.Window; diff --git a/platform/src/main/java/org/teavm/platform/PlatformQueue.java b/platform/src/main/java/org/teavm/platform/PlatformQueue.java index affd10e93..eae38420c 100644 --- a/platform/src/main/java/org/teavm/platform/PlatformQueue.java +++ b/platform/src/main/java/org/teavm/platform/PlatformQueue.java @@ -15,17 +15,12 @@ */ package org.teavm.platform; -import org.teavm.dependency.PluggableDependency; import org.teavm.backend.javascript.spi.InjectedBy; +import org.teavm.dependency.PluggableDependency; import org.teavm.jso.JSObject; import org.teavm.jso.JSProperty; import org.teavm.platform.plugin.PlatformQueueGenerator; -/** - * - * @author Alexey Andreev - * @param - */ public abstract class PlatformQueue implements JSObject { @JSProperty public abstract int getLength(); diff --git a/platform/src/main/java/org/teavm/platform/plugin/AsyncMethodGenerator.java b/platform/src/main/java/org/teavm/platform/plugin/AsyncMethodGenerator.java index da8ef3cc1..df6acb517 100644 --- a/platform/src/main/java/org/teavm/platform/plugin/AsyncMethodGenerator.java +++ b/platform/src/main/java/org/teavm/platform/plugin/AsyncMethodGenerator.java @@ -17,11 +17,11 @@ package org.teavm.platform.plugin; import java.io.IOException; import org.teavm.backend.javascript.codegen.SourceWriter; +import org.teavm.backend.javascript.spi.Generator; +import org.teavm.backend.javascript.spi.GeneratorContext; import org.teavm.dependency.DependencyAgent; import org.teavm.dependency.DependencyPlugin; import org.teavm.dependency.MethodDependency; -import org.teavm.backend.javascript.spi.Generator; -import org.teavm.backend.javascript.spi.GeneratorContext; import org.teavm.model.CallLocation; import org.teavm.model.ClassReader; import org.teavm.model.ElementModifier; diff --git a/platform/src/main/java/org/teavm/platform/plugin/AsyncMethodProcessor.java b/platform/src/main/java/org/teavm/platform/plugin/AsyncMethodProcessor.java index e0361a4c6..b3d77e44c 100644 --- a/platform/src/main/java/org/teavm/platform/plugin/AsyncMethodProcessor.java +++ b/platform/src/main/java/org/teavm/platform/plugin/AsyncMethodProcessor.java @@ -15,12 +15,21 @@ */ package org.teavm.platform.plugin; +import org.teavm.backend.javascript.spi.GeneratedBy; import org.teavm.dependency.PluggableDependency; import org.teavm.diagnostics.Diagnostics; import org.teavm.interop.Async; -import org.teavm.backend.javascript.spi.GeneratedBy; import org.teavm.interop.Sync; -import org.teavm.model.*; +import org.teavm.model.AnnotationHolder; +import org.teavm.model.AnnotationValue; +import org.teavm.model.CallLocation; +import org.teavm.model.ClassHolder; +import org.teavm.model.ClassHolderTransformer; +import org.teavm.model.ClassReaderSource; +import org.teavm.model.ElementModifier; +import org.teavm.model.MethodDescriptor; +import org.teavm.model.MethodHolder; +import org.teavm.model.ValueType; import org.teavm.platform.async.AsyncCallback; /** diff --git a/platform/src/main/java/org/teavm/platform/plugin/MetadataProviderTransformer.java b/platform/src/main/java/org/teavm/platform/plugin/MetadataProviderTransformer.java index 9c3e731a0..8b48535e9 100644 --- a/platform/src/main/java/org/teavm/platform/plugin/MetadataProviderTransformer.java +++ b/platform/src/main/java/org/teavm/platform/plugin/MetadataProviderTransformer.java @@ -15,9 +15,9 @@ */ package org.teavm.platform.plugin; +import org.teavm.backend.javascript.spi.GeneratedBy; import org.teavm.cache.NoCache; import org.teavm.diagnostics.Diagnostics; -import org.teavm.backend.javascript.spi.GeneratedBy; import org.teavm.model.AccessLevel; import org.teavm.model.AnnotationHolder; import org.teavm.model.AnnotationReader; @@ -36,10 +36,6 @@ import org.teavm.platform.PlatformClass; import org.teavm.platform.metadata.ClassScopedMetadataProvider; import org.teavm.platform.metadata.MetadataProvider; -/** - * - * @author Alexey Andreev - */ class MetadataProviderTransformer implements ClassHolderTransformer { static int fieldIdGen; diff --git a/platform/src/main/java/org/teavm/platform/plugin/PlatformGenerator.java b/platform/src/main/java/org/teavm/platform/plugin/PlatformGenerator.java index 7b4e6d17f..1ac230379 100644 --- a/platform/src/main/java/org/teavm/platform/plugin/PlatformGenerator.java +++ b/platform/src/main/java/org/teavm/platform/plugin/PlatformGenerator.java @@ -18,13 +18,13 @@ package org.teavm.platform.plugin; import java.io.IOException; import java.lang.annotation.Annotation; import org.teavm.backend.javascript.codegen.SourceWriter; -import org.teavm.dependency.DependencyAgent; -import org.teavm.dependency.DependencyPlugin; -import org.teavm.dependency.MethodDependency; import org.teavm.backend.javascript.spi.Generator; import org.teavm.backend.javascript.spi.GeneratorContext; import org.teavm.backend.javascript.spi.Injector; import org.teavm.backend.javascript.spi.InjectorContext; +import org.teavm.dependency.DependencyAgent; +import org.teavm.dependency.DependencyPlugin; +import org.teavm.dependency.MethodDependency; import org.teavm.model.CallLocation; import org.teavm.model.ClassReader; import org.teavm.model.MethodDescriptor; diff --git a/platform/src/main/java/org/teavm/platform/plugin/PlatformQueueGenerator.java b/platform/src/main/java/org/teavm/platform/plugin/PlatformQueueGenerator.java index dc498d2ed..4d486bb6f 100644 --- a/platform/src/main/java/org/teavm/platform/plugin/PlatformQueueGenerator.java +++ b/platform/src/main/java/org/teavm/platform/plugin/PlatformQueueGenerator.java @@ -16,11 +16,11 @@ package org.teavm.platform.plugin; import java.io.IOException; +import org.teavm.backend.javascript.spi.Injector; +import org.teavm.backend.javascript.spi.InjectorContext; import org.teavm.dependency.DependencyAgent; import org.teavm.dependency.DependencyPlugin; import org.teavm.dependency.MethodDependency; -import org.teavm.backend.javascript.spi.Injector; -import org.teavm.backend.javascript.spi.InjectorContext; import org.teavm.model.CallLocation; import org.teavm.model.MethodReference; import org.teavm.platform.PlatformObject; diff --git a/platform/src/main/java/org/teavm/platform/plugin/ResourceAccessorTransformer.java b/platform/src/main/java/org/teavm/platform/plugin/ResourceAccessorTransformer.java index 0432593ad..27f5c8d0d 100644 --- a/platform/src/main/java/org/teavm/platform/plugin/ResourceAccessorTransformer.java +++ b/platform/src/main/java/org/teavm/platform/plugin/ResourceAccessorTransformer.java @@ -15,9 +15,13 @@ */ package org.teavm.platform.plugin; -import org.teavm.diagnostics.Diagnostics; import org.teavm.backend.javascript.TeaVMJavaScriptHost; -import org.teavm.model.*; +import org.teavm.diagnostics.Diagnostics; +import org.teavm.model.ClassHolder; +import org.teavm.model.ClassHolderTransformer; +import org.teavm.model.ClassReaderSource; +import org.teavm.model.ElementModifier; +import org.teavm.model.MethodHolder; import org.teavm.vm.spi.TeaVMHost; class ResourceAccessorTransformer implements ClassHolderTransformer { diff --git a/pom.xml b/pom.xml index f71cce6a7..76f8ca8f6 100644 --- a/pom.xml +++ b/pom.xml @@ -80,6 +80,7 @@ metaprogramming/api + interop/core core classlib jso/core diff --git a/tools/core/src/main/java/org/teavm/tooling/TeaVMProblemRenderer.java b/tools/core/src/main/java/org/teavm/tooling/TeaVMProblemRenderer.java index bfcbca450..e04669255 100644 --- a/tools/core/src/main/java/org/teavm/tooling/TeaVMProblemRenderer.java +++ b/tools/core/src/main/java/org/teavm/tooling/TeaVMProblemRenderer.java @@ -22,8 +22,8 @@ import org.teavm.callgraph.CallSite; import org.teavm.diagnostics.DefaultProblemTextConsumer; import org.teavm.diagnostics.Problem; import org.teavm.model.CallLocation; -import org.teavm.model.TextLocation; import org.teavm.model.MethodReference; +import org.teavm.model.TextLocation; import org.teavm.vm.TeaVM; public final class TeaVMProblemRenderer { diff --git a/tools/core/src/main/java/org/teavm/tooling/TeaVMTool.java b/tools/core/src/main/java/org/teavm/tooling/TeaVMTool.java index b4fe2a74c..22053d2c6 100644 --- a/tools/core/src/main/java/org/teavm/tooling/TeaVMTool.java +++ b/tools/core/src/main/java/org/teavm/tooling/TeaVMTool.java @@ -34,6 +34,9 @@ import java.util.List; import java.util.Properties; import java.util.Set; import org.apache.commons.io.IOUtils; +import org.teavm.backend.javascript.JavaScriptTarget; +import org.teavm.backend.javascript.rendering.RenderingContext; +import org.teavm.backend.wasm.WasmTarget; import org.teavm.cache.DiskCachedClassHolderSource; import org.teavm.cache.DiskProgramCache; import org.teavm.cache.DiskRegularMethodNodeCache; @@ -42,8 +45,6 @@ import org.teavm.debugging.information.DebugInformation; import org.teavm.debugging.information.DebugInformationBuilder; import org.teavm.dependency.DependencyInfo; import org.teavm.diagnostics.ProblemProvider; -import org.teavm.backend.javascript.rendering.RenderingContext; -import org.teavm.backend.javascript.JavaScriptTarget; import org.teavm.model.ClassHolderSource; import org.teavm.model.ClassHolderTransformer; import org.teavm.model.ClassReader; @@ -64,7 +65,6 @@ import org.teavm.vm.TeaVMEntryPoint; import org.teavm.vm.TeaVMProgressListener; import org.teavm.vm.TeaVMTarget; import org.teavm.vm.spi.AbstractRendererListener; -import org.teavm.backend.wasm.WasmTarget; public class TeaVMTool implements BaseTeaVMTool { private File targetDirectory = new File("."); diff --git a/tools/junit/src/main/java/org/teavm/junit/TeaVMTestRunner.java b/tools/junit/src/main/java/org/teavm/junit/TeaVMTestRunner.java index 1cc15381d..656225218 100644 --- a/tools/junit/src/main/java/org/teavm/junit/TeaVMTestRunner.java +++ b/tools/junit/src/main/java/org/teavm/junit/TeaVMTestRunner.java @@ -44,10 +44,10 @@ import org.junit.runner.Runner; import org.junit.runner.notification.Failure; import org.junit.runner.notification.RunNotifier; import org.junit.runners.model.InitializationError; +import org.teavm.backend.javascript.JavaScriptTarget; import org.teavm.callgraph.CallGraph; import org.teavm.diagnostics.DefaultProblemTextConsumer; import org.teavm.diagnostics.Problem; -import org.teavm.backend.javascript.JavaScriptTarget; import org.teavm.model.ClassHolder; import org.teavm.model.ClassHolderSource; import org.teavm.model.MethodDescriptor;