Refactoring. Fix checkstyle errors

This commit is contained in:
Alexey Andreev 2016-08-20 17:04:21 +03:00
parent 6483f518cf
commit 4fd20794c1
68 changed files with 506 additions and 1297 deletions

View File

@ -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<Statement> 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);
}
}

View File

@ -16,231 +16,25 @@
package org.teavm.ast.decompilation; package org.teavm.ast.decompilation;
import java.util.HashSet; import java.util.HashSet;
import java.util.List;
import java.util.Set; import java.util.Set;
import org.teavm.ast.AssignmentStatement; 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.InvocationExpr;
import org.teavm.ast.MonitorEnterStatement; import org.teavm.ast.RecursiveVisitor;
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.model.MethodReference; import org.teavm.model.MethodReference;
class AsyncCallsFinder implements StatementVisitor, ExprVisitor { class AsyncCallsFinder extends RecursiveVisitor {
final Set<MethodReference> asyncCalls = new HashSet<>(); final Set<MethodReference> asyncCalls = new HashSet<>();
final Set<MethodReference> allCalls = new HashSet<>(); final Set<MethodReference> allCalls = new HashSet<>();
private void visitList(List<Statement> statements) {
for (Statement stmt : statements) {
stmt.acceptVisitor(this);
}
}
@Override @Override
public void visit(AssignmentStatement statement) { 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(); InvocationExpr invocation = (InvocationExpr) statement.getRightValue();
asyncCalls.add(invocation.getMethod()); 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 @Override
public void visit(InvocationExpr expr) { public void visit(InvocationExpr expr) {
super.visit(expr);
allCalls.add(expr.getMethod()); 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);
} }
} }

View File

@ -44,15 +44,15 @@ import org.teavm.ast.VariableNode;
import org.teavm.ast.WhileStatement; import org.teavm.ast.WhileStatement;
import org.teavm.ast.cache.MethodNodeCache; import org.teavm.ast.cache.MethodNodeCache;
import org.teavm.ast.optimization.Optimizer; 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.cache.NoCache;
import org.teavm.common.Graph; import org.teavm.common.Graph;
import org.teavm.common.GraphIndexer; import org.teavm.common.GraphIndexer;
import org.teavm.common.Loop; import org.teavm.common.Loop;
import org.teavm.common.LoopGraph; import org.teavm.common.LoopGraph;
import org.teavm.common.RangeTree; 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.AnnotationHolder;
import org.teavm.model.ClassHolder; import org.teavm.model.ClassHolder;
import org.teavm.model.ClassHolderSource; import org.teavm.model.ClassHolderSource;

View File

@ -15,35 +15,16 @@
*/ */
package org.teavm.ast.optimization; package org.teavm.ast.optimization;
import java.util.List;
import org.teavm.ast.AssignmentStatement;
import org.teavm.ast.BlockStatement; import org.teavm.ast.BlockStatement;
import org.teavm.ast.BreakStatement; import org.teavm.ast.BreakStatement;
import org.teavm.ast.ConditionalStatement;
import org.teavm.ast.ContinueStatement; import org.teavm.ast.ContinueStatement;
import org.teavm.ast.GotoPartStatement; import org.teavm.ast.RecursiveVisitor;
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;
/** class BlockCountVisitor extends RecursiveVisitor {
*
* @author Alexey Andreev
*/
class BlockCountVisitor implements StatementVisitor {
private BlockStatement blockToCount; private BlockStatement blockToCount;
private int count; private int count;
public BlockCountVisitor(BlockStatement blockToCount) { BlockCountVisitor(BlockStatement blockToCount) {
this.blockToCount = blockToCount; this.blockToCount = blockToCount;
} }
@ -51,48 +32,6 @@ class BlockCountVisitor implements StatementVisitor {
return count; return count;
} }
public void visit(List<Statement> 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 @Override
public void visit(BreakStatement statement) { public void visit(BreakStatement statement) {
if (statement.getTarget() == blockToCount) { if (statement.getTarget() == blockToCount) {
@ -106,34 +45,4 @@ class BlockCountVisitor implements StatementVisitor {
++count; ++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) {
}
} }

View File

@ -16,31 +16,13 @@
package org.teavm.ast.optimization; package org.teavm.ast.optimization;
import java.util.List; import java.util.List;
import org.teavm.ast.AssignmentStatement;
import org.teavm.ast.BlockStatement;
import org.teavm.ast.BreakStatement; import org.teavm.ast.BreakStatement;
import org.teavm.ast.ConditionalStatement;
import org.teavm.ast.ContinueStatement; import org.teavm.ast.ContinueStatement;
import org.teavm.ast.GotoPartStatement;
import org.teavm.ast.IdentifiedStatement; import org.teavm.ast.IdentifiedStatement;
import org.teavm.ast.InitClassStatement; import org.teavm.ast.RecursiveVisitor;
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.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;
/** class BreakToContinueReplacer extends RecursiveVisitor {
*
* @author Alexey Andreev
*/
class BreakToContinueReplacer implements StatementVisitor {
private IdentifiedStatement replacedBreak; private IdentifiedStatement replacedBreak;
private IdentifiedStatement replacement; private IdentifiedStatement replacement;
private ContinueStatement replaceBy; private ContinueStatement replaceBy;
@ -51,10 +33,7 @@ class BreakToContinueReplacer implements StatementVisitor {
} }
@Override @Override
public void visit(AssignmentStatement statement) { public void visit(List<Statement> statements) {
}
public void visitSequence(List<Statement> statements) {
if (statements == null) { if (statements == null) {
return; 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 @Override
public void visit(BreakStatement statement) { public void visit(BreakStatement statement) {
if (statement.getTarget() == replacedBreak) { if (statement.getTarget() == replacedBreak) {
@ -112,34 +62,4 @@ class BreakToContinueReplacer implements StatementVisitor {
statement.setTarget(replacement); 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) {
}
} }

View File

@ -16,44 +16,20 @@
package org.teavm.ast.optimization; package org.teavm.ast.optimization;
import java.util.List; import java.util.List;
import org.teavm.ast.BinaryExpr;
import org.teavm.ast.CastExpr;
import org.teavm.ast.ConditionalExpr; import org.teavm.ast.ConditionalExpr;
import org.teavm.ast.ConditionalStatement; 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.InvocationExpr;
import org.teavm.ast.NewArrayExpr;
import org.teavm.ast.NewExpr; import org.teavm.ast.NewExpr;
import org.teavm.ast.NewMultiArrayExpr; import org.teavm.ast.RecursiveVisitor;
import org.teavm.ast.PrimitiveCastExpr;
import org.teavm.ast.QualificationExpr;
import org.teavm.ast.Statement; 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<Statement> target; private List<Statement> target;
public ExpressionSideEffectDecomposer(List<Statement> target) { public ExpressionSideEffectDecomposer(List<Statement> target) {
this.target = 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 @Override
public void visit(ConditionalExpr expr) { public void visit(ConditionalExpr expr) {
ConditionalStatement statement = new ConditionalStatement(); ConditionalStatement statement = new ConditionalStatement();
@ -62,67 +38,13 @@ public class ExpressionSideEffectDecomposer implements ExprVisitor {
expr.getAlternative().acceptVisitor(new ExpressionSideEffectDecomposer(statement.getAlternative())); expr.getAlternative().acceptVisitor(new ExpressionSideEffectDecomposer(statement.getAlternative()));
target.add(statement); 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 @Override
public void visit(InvocationExpr expr) { public void visit(InvocationExpr expr) {
target.add(Statement.assign(null, expr)); target.add(Statement.assign(null, expr));
} }
@Override
public void visit(QualificationExpr expr) {
if (expr.getQualified() != null) {
expr.getQualified().acceptVisitor(this);
}
}
@Override @Override
public void visit(NewExpr expr) { public void visit(NewExpr expr) {
target.add(Statement.assign(null, 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);
}
} }

View File

@ -592,7 +592,7 @@ class OptimizingVisitor implements StatementVisitor, ExprVisitor {
if (statement.getBody().size() == 1 && statement.getBody().get(0) instanceof WhileStatement) { if (statement.getBody().size() == 1 && statement.getBody().get(0) instanceof WhileStatement) {
WhileStatement innerLoop = (WhileStatement) statement.getBody().get(0); WhileStatement innerLoop = (WhileStatement) statement.getBody().get(0);
BreakToContinueReplacer replacer = new BreakToContinueReplacer(innerLoop, statement); BreakToContinueReplacer replacer = new BreakToContinueReplacer(innerLoop, statement);
replacer.visitSequence(innerLoop.getBody()); replacer.visit(innerLoop.getBody());
statement.getBody().clear(); statement.getBody().clear();
statement.getBody().addAll(innerLoop.getBody()); statement.getBody().addAll(innerLoop.getBody());
} }

View File

@ -16,65 +16,28 @@
package org.teavm.ast.optimization; package org.teavm.ast.optimization;
import java.util.HashSet; import java.util.HashSet;
import java.util.List;
import java.util.Set; import java.util.Set;
import org.teavm.ast.AssignmentStatement;
import org.teavm.ast.BlockStatement; import org.teavm.ast.BlockStatement;
import org.teavm.ast.BreakStatement; import org.teavm.ast.BreakStatement;
import org.teavm.ast.ConditionalStatement;
import org.teavm.ast.ContinueStatement; import org.teavm.ast.ContinueStatement;
import org.teavm.ast.GotoPartStatement;
import org.teavm.ast.IdentifiedStatement; import org.teavm.ast.IdentifiedStatement;
import org.teavm.ast.InitClassStatement; import org.teavm.ast.RecursiveVisitor;
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.SwitchClause;
import org.teavm.ast.SwitchStatement; import org.teavm.ast.SwitchStatement;
import org.teavm.ast.ThrowStatement;
import org.teavm.ast.TryCatchStatement;
import org.teavm.ast.WhileStatement; import org.teavm.ast.WhileStatement;
/** class RedundantLabelEliminator extends RecursiveVisitor {
*
* @author Alexey Andreev
*/
class RedundantLabelEliminator implements StatementVisitor {
private IdentifiedStatement currentBlock; private IdentifiedStatement currentBlock;
private Set<IdentifiedStatement> hasRefs = new HashSet<>(); private Set<IdentifiedStatement> hasRefs = new HashSet<>();
void visitSequence(List<Statement> 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 @Override
public void visit(SwitchStatement statement) { public void visit(SwitchStatement statement) {
IdentifiedStatement currentBlockBackup = currentBlock; IdentifiedStatement currentBlockBackup = currentBlock;
currentBlock = statement; currentBlock = statement;
for (SwitchClause clause : statement.getClauses()) { for (SwitchClause clause : statement.getClauses()) {
visitSequence(clause.getBody()); visit(clause.getBody());
} }
visitSequence(statement.getDefaultClause()); visit(statement.getDefaultClause());
if (!hasRefs.contains(currentBlock)) { if (!hasRefs.contains(currentBlock)) {
currentBlock.setId(null); currentBlock.setId(null);
} }
@ -85,7 +48,7 @@ class RedundantLabelEliminator implements StatementVisitor {
public void visit(WhileStatement statement) { public void visit(WhileStatement statement) {
IdentifiedStatement currentBlockBackup = currentBlock; IdentifiedStatement currentBlockBackup = currentBlock;
currentBlock = statement; currentBlock = statement;
visitSequence(statement.getBody()); visit(statement.getBody());
if (!hasRefs.contains(currentBlock)) { if (!hasRefs.contains(currentBlock)) {
currentBlock.setId(null); currentBlock.setId(null);
} }
@ -96,7 +59,7 @@ class RedundantLabelEliminator implements StatementVisitor {
public void visit(BlockStatement statement) { public void visit(BlockStatement statement) {
IdentifiedStatement currentBlockBackup = currentBlock; IdentifiedStatement currentBlockBackup = currentBlock;
currentBlock = null; currentBlock = null;
visitSequence(statement.getBody()); visit(statement.getBody());
currentBlock = currentBlockBackup; currentBlock = currentBlockBackup;
} }
@ -117,34 +80,4 @@ class RedundantLabelEliminator implements StatementVisitor {
hasRefs.add(statement.getTarget()); 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) {
}
} }

View File

@ -18,44 +18,12 @@ package org.teavm.ast.optimization;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import org.teavm.ast.AssignmentStatement; import org.teavm.ast.RecursiveVisitor;
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.TryCatchStatement;
import org.teavm.ast.UnaryExpr;
import org.teavm.ast.UnwrapArrayExpr;
import org.teavm.ast.VariableExpr; import org.teavm.ast.VariableExpr;
import org.teavm.ast.VariableNode; 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 VariableNode[] variableNodes;
private final int[] variables; private final int[] variables;
private final int[] indexes; private final int[] indexes;
@ -85,82 +53,6 @@ class UnusedVariableEliminator implements ExprVisitor, StatementVisitor {
return reorderedVariables; 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) { private int renumber(int var) {
int index = indexes[variables[var]]; int index = indexes[variables[var]];
if (index == -1) { if (index == -1) {
@ -171,101 +63,14 @@ class UnusedVariableEliminator implements ExprVisitor, StatementVisitor {
return index; 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 @Override
public void visit(VariableExpr expr) { public void visit(VariableExpr expr) {
expr.setIndex(renumber(expr.getIndex())); 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 @Override
public void visit(TryCatchStatement statement) { public void visit(TryCatchStatement statement) {
for (Statement part : statement.getProtectedBody()) { super.visit(statement);
part.acceptVisitor(this);
}
for (Statement part : statement.getHandler()) {
part.acceptVisitor(this);
}
if (statement.getExceptionVariable() != null) { if (statement.getExceptionVariable() != null) {
if (variables[statement.getExceptionVariable()] < 0) { if (variables[statement.getExceptionVariable()] < 0) {
statement.setExceptionVariable(null); 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);
}
} }

View File

@ -30,33 +30,32 @@ import org.teavm.ast.ClassNode;
import org.teavm.ast.cache.EmptyRegularMethodNodeCache; import org.teavm.ast.cache.EmptyRegularMethodNodeCache;
import org.teavm.ast.cache.MethodNodeCache; import org.teavm.ast.cache.MethodNodeCache;
import org.teavm.ast.decompilation.Decompiler; 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.AliasProvider;
import org.teavm.backend.javascript.codegen.DefaultAliasProvider; import org.teavm.backend.javascript.codegen.DefaultAliasProvider;
import org.teavm.backend.javascript.codegen.DefaultNamingStrategy; import org.teavm.backend.javascript.codegen.DefaultNamingStrategy;
import org.teavm.backend.javascript.codegen.MinifyingAliasProvider; import org.teavm.backend.javascript.codegen.MinifyingAliasProvider;
import org.teavm.backend.javascript.codegen.SourceWriter; import org.teavm.backend.javascript.codegen.SourceWriter;
import org.teavm.backend.javascript.codegen.SourceWriterBuilder; 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.DebugInformationEmitter;
import org.teavm.debugging.information.SourceLocation; import org.teavm.debugging.information.SourceLocation;
import org.teavm.dependency.DependencyChecker; import org.teavm.dependency.DependencyChecker;
import org.teavm.dependency.DependencyListener; import org.teavm.dependency.DependencyListener;
import org.teavm.dependency.MethodDependency; import org.teavm.dependency.MethodDependency;
import org.teavm.backend.javascript.spi.Generator;
import org.teavm.model.BasicBlock; import org.teavm.model.BasicBlock;
import org.teavm.model.CallLocation; import org.teavm.model.CallLocation;
import org.teavm.model.ClassHolder; import org.teavm.model.ClassHolder;
import org.teavm.model.ClassHolderTransformer; import org.teavm.model.ClassHolderTransformer;
import org.teavm.model.ElementModifier; import org.teavm.model.ElementModifier;
import org.teavm.model.TextLocation;
import org.teavm.model.ListableClassHolderSource; import org.teavm.model.ListableClassHolderSource;
import org.teavm.model.MethodHolder; import org.teavm.model.MethodHolder;
import org.teavm.model.MethodReference; import org.teavm.model.MethodReference;
import org.teavm.model.Program; import org.teavm.model.Program;
import org.teavm.model.TextLocation;
import org.teavm.model.ValueType; import org.teavm.model.ValueType;
import org.teavm.model.Variable; import org.teavm.model.Variable;
import org.teavm.model.instructions.ConstructInstruction; 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.AsyncMethodFinder;
import org.teavm.model.util.ProgramUtils; import org.teavm.model.util.ProgramUtils;
import org.teavm.vm.BuildTarget; import org.teavm.vm.BuildTarget;
import org.teavm.vm.RenderingException;
import org.teavm.vm.TeaVMEntryPoint; import org.teavm.vm.TeaVMEntryPoint;
import org.teavm.vm.TeaVMTarget; import org.teavm.vm.TeaVMTarget;
import org.teavm.vm.TeaVMTargetController; import org.teavm.vm.TeaVMTargetController;

View File

@ -15,24 +15,14 @@
*/ */
package org.teavm.backend.javascript.rendering; package org.teavm.backend.javascript.rendering;
import java.util.List;
import java.util.Set; import java.util.Set;
import org.teavm.ast.AssignmentStatement; import org.teavm.ast.AssignmentStatement;
import org.teavm.ast.AsyncMethodNode; import org.teavm.ast.AsyncMethodNode;
import org.teavm.ast.AsyncMethodPart; import org.teavm.ast.AsyncMethodPart;
import org.teavm.ast.BinaryExpr; 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.ClassNode;
import org.teavm.ast.ConditionalExpr;
import org.teavm.ast.ConditionalStatement;
import org.teavm.ast.ConstantExpr; 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.FieldNode;
import org.teavm.ast.GotoPartStatement;
import org.teavm.ast.InitClassStatement; import org.teavm.ast.InitClassStatement;
import org.teavm.ast.InstanceOfExpr; import org.teavm.ast.InstanceOfExpr;
import org.teavm.ast.InvocationExpr; import org.teavm.ast.InvocationExpr;
@ -44,22 +34,12 @@ import org.teavm.ast.NativeMethodNode;
import org.teavm.ast.NewArrayExpr; import org.teavm.ast.NewArrayExpr;
import org.teavm.ast.NewExpr; import org.teavm.ast.NewExpr;
import org.teavm.ast.NewMultiArrayExpr; import org.teavm.ast.NewMultiArrayExpr;
import org.teavm.ast.PrimitiveCastExpr;
import org.teavm.ast.QualificationExpr; import org.teavm.ast.QualificationExpr;
import org.teavm.ast.RecursiveVisitor;
import org.teavm.ast.RegularMethodNode; 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.ThrowStatement;
import org.teavm.ast.TryCatchStatement; import org.teavm.ast.TryCatchStatement;
import org.teavm.ast.UnaryExpr; 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.backend.javascript.codegen.NameFrequencyConsumer;
import org.teavm.model.ClassReader; import org.teavm.model.ClassReader;
import org.teavm.model.ClassReaderSource; import org.teavm.model.ClassReaderSource;
@ -70,7 +50,7 @@ import org.teavm.model.MethodReader;
import org.teavm.model.MethodReference; import org.teavm.model.MethodReference;
import org.teavm.model.ValueType; import org.teavm.model.ValueType;
class NameFrequencyEstimator implements StatementVisitor, ExprVisitor, MethodNodeVisitor { class NameFrequencyEstimator extends RecursiveVisitor implements MethodNodeVisitor {
private final NameFrequencyConsumer consumer; private final NameFrequencyConsumer consumer;
private final ClassReaderSource classSource; private final ClassReaderSource classSource;
private boolean async; private boolean async;
@ -85,12 +65,6 @@ class NameFrequencyEstimator implements StatementVisitor, ExprVisitor, MethodNod
this.asyncFamilyMethods = asyncFamilyMethods; this.asyncFamilyMethods = asyncFamilyMethods;
} }
private void visit(List<Statement> statements) {
for (Statement part : statements) {
part.acceptVisitor(this);
}
}
public void estimate(ClassNode cls) { public void estimate(ClassNode cls) {
// Declaration // Declaration
consumer.consume(cls.getName()); consumer.consume(cls.getName());
@ -159,64 +133,12 @@ class NameFrequencyEstimator implements StatementVisitor, ExprVisitor, MethodNod
@Override @Override
public void visit(AssignmentStatement statement) { public void visit(AssignmentStatement statement) {
if (statement.getLeftValue() != null) { super.visit(statement);
statement.getLeftValue().acceptVisitor(this);
}
statement.getRightValue().acceptVisitor(this);
if (statement.isAsync()) { if (statement.isAsync()) {
consumer.consumeFunction("$rt_suspending"); 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 @Override
public void visit(ThrowStatement statement) { public void visit(ThrowStatement statement) {
statement.getException().acceptVisitor(this); statement.getException().acceptVisitor(this);
@ -230,19 +152,15 @@ class NameFrequencyEstimator implements StatementVisitor, ExprVisitor, MethodNod
@Override @Override
public void visit(TryCatchStatement statement) { public void visit(TryCatchStatement statement) {
visit(statement.getProtectedBody()); super.visit(statement);
visit(statement.getHandler());
if (statement.getExceptionType() != null) { if (statement.getExceptionType() != null) {
consumer.consume(statement.getExceptionType()); consumer.consume(statement.getExceptionType());
} }
} }
@Override
public void visit(GotoPartStatement statement) {
}
@Override @Override
public void visit(MonitorEnterStatement statement) { public void visit(MonitorEnterStatement statement) {
super.visit(statement);
if (async) { if (async) {
MethodReference monitorEnterRef = new MethodReference( MethodReference monitorEnterRef = new MethodReference(
Object.class, "monitorEnter", Object.class, void.class); Object.class, "monitorEnter", Object.class, void.class);
@ -257,6 +175,7 @@ class NameFrequencyEstimator implements StatementVisitor, ExprVisitor, MethodNod
@Override @Override
public void visit(MonitorExitStatement statement) { public void visit(MonitorExitStatement statement) {
super.visit(statement);
if (async) { if (async) {
MethodReference monitorEnterRef = new MethodReference( MethodReference monitorEnterRef = new MethodReference(
Object.class, "monitorExit", Object.class, void.class); Object.class, "monitorExit", Object.class, void.class);
@ -270,8 +189,7 @@ class NameFrequencyEstimator implements StatementVisitor, ExprVisitor, MethodNod
@Override @Override
public void visit(BinaryExpr expr) { public void visit(BinaryExpr expr) {
expr.getFirstOperand().acceptVisitor(this); super.visit(expr);
expr.getSecondOperand().acceptVisitor(this);
switch (expr.getOperation()) { switch (expr.getOperation()) {
case COMPARE: case COMPARE:
consumer.consumeFunction("$rt_compare"); consumer.consumeFunction("$rt_compare");
@ -283,7 +201,7 @@ class NameFrequencyEstimator implements StatementVisitor, ExprVisitor, MethodNod
@Override @Override
public void visit(UnaryExpr expr) { public void visit(UnaryExpr expr) {
expr.getOperand().acceptVisitor(this); super.visit(expr);
switch (expr.getOperation()) { switch (expr.getOperation()) {
case NULL_CHECK: case NULL_CHECK:
consumer.consumeFunction("$rt_nullCheck"); 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 @Override
public void visit(ConstantExpr expr) { public void visit(ConstantExpr expr) {
if (expr.getValue() instanceof ValueType) { if (expr.getValue() instanceof ValueType) {
@ -317,24 +228,9 @@ class NameFrequencyEstimator implements StatementVisitor, ExprVisitor, MethodNod
consumer.consumeFunction("$rt_cls"); 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 @Override
public void visit(InvocationExpr expr) { public void visit(InvocationExpr expr) {
super.visit(expr);
if (injectedMethods.contains(expr.getMethod())) { if (injectedMethods.contains(expr.getMethod())) {
return; return;
} }
@ -354,21 +250,20 @@ class NameFrequencyEstimator implements StatementVisitor, ExprVisitor, MethodNod
@Override @Override
public void visit(QualificationExpr expr) { public void visit(QualificationExpr expr) {
if (expr.getQualified() != null) { super.visit(expr);
expr.getQualified().acceptVisitor(this);
}
consumer.consume(expr.getField()); consumer.consume(expr.getField());
} }
@Override @Override
public void visit(NewExpr expr) { public void visit(NewExpr expr) {
super.visit(expr);
consumer.consume(expr.getConstructedClass()); consumer.consume(expr.getConstructedClass());
} }
@Override @Override
public void visit(NewArrayExpr expr) { public void visit(NewArrayExpr expr) {
super.visit(expr);
visitType(expr.getType()); visitType(expr.getType());
expr.getLength().acceptVisitor(this);
if (!(expr.getType() instanceof ValueType.Primitive)) { if (!(expr.getType() instanceof ValueType.Primitive)) {
consumer.consumeFunction("$rt_createArray"); consumer.consumeFunction("$rt_createArray");
} }
@ -376,15 +271,13 @@ class NameFrequencyEstimator implements StatementVisitor, ExprVisitor, MethodNod
@Override @Override
public void visit(NewMultiArrayExpr expr) { public void visit(NewMultiArrayExpr expr) {
super.visit(expr);
visitType(expr.getType()); visitType(expr.getType());
for (Expr dimension : expr.getDimensions()) {
dimension.acceptVisitor(this);
}
} }
@Override @Override
public void visit(InstanceOfExpr expr) { public void visit(InstanceOfExpr expr) {
expr.getExpr().acceptVisitor(this); super.visit(expr);
visitType(expr.getType()); visitType(expr.getType());
if (expr.getType() instanceof ValueType.Object) { if (expr.getType() instanceof ValueType.Object) {
String clsName = ((ValueType.Object) expr.getType()).getClassName(); String clsName = ((ValueType.Object) expr.getType()).getClassName();
@ -396,14 +289,4 @@ class NameFrequencyEstimator implements StatementVisitor, ExprVisitor, MethodNod
consumer.consumeFunction("$rt_isInstance"); consumer.consumeFunction("$rt_isInstance");
} }
} }
@Override
public void visit(CastExpr expr) {
expr.getValue().acceptVisitor(this);
}
@Override
public void visit(PrimitiveCastExpr expr) {
expr.getValue().acceptVisitor(this);
}
} }

View File

@ -75,19 +75,19 @@ import org.teavm.ast.UnwrapArrayExpr;
import org.teavm.ast.VariableExpr; import org.teavm.ast.VariableExpr;
import org.teavm.ast.VariableNode; import org.teavm.ast.VariableNode;
import org.teavm.ast.WhileStatement; 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.NamingException;
import org.teavm.backend.javascript.codegen.NamingOrderer; import org.teavm.backend.javascript.codegen.NamingOrderer;
import org.teavm.backend.javascript.codegen.NamingStrategy; import org.teavm.backend.javascript.codegen.NamingStrategy;
import org.teavm.backend.javascript.codegen.SourceWriter; 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.common.ServiceRepository;
import org.teavm.debugging.information.DebugInformationEmitter; import org.teavm.debugging.information.DebugInformationEmitter;
import org.teavm.debugging.information.DeferredCallSite; import org.teavm.debugging.information.DeferredCallSite;
import org.teavm.debugging.information.DummyDebugInformationEmitter; import org.teavm.debugging.information.DummyDebugInformationEmitter;
import org.teavm.diagnostics.Diagnostics; import org.teavm.diagnostics.Diagnostics;
import org.teavm.backend.javascript.spi.GeneratorContext;
import org.teavm.model.AnnotationHolder; import org.teavm.model.AnnotationHolder;
import org.teavm.model.ClassHolder; import org.teavm.model.ClassHolder;
import org.teavm.model.ClassReader; import org.teavm.model.ClassReader;
@ -101,6 +101,7 @@ import org.teavm.model.MethodReader;
import org.teavm.model.MethodReference; import org.teavm.model.MethodReference;
import org.teavm.model.TextLocation; import org.teavm.model.TextLocation;
import org.teavm.model.ValueType; import org.teavm.model.ValueType;
import org.teavm.vm.RenderingException;
public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext { public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext {
private static final String variableNames = "abcdefghijkmnopqrstuvwxyz"; private static final String variableNames = "abcdefghijkmnopqrstuvwxyz";

View File

@ -19,8 +19,8 @@ import java.io.IOException;
import java.util.Properties; import java.util.Properties;
import org.teavm.ast.Expr; import org.teavm.ast.Expr;
import org.teavm.backend.javascript.codegen.SourceWriter; import org.teavm.backend.javascript.codegen.SourceWriter;
import org.teavm.common.ServiceRepository;
import org.teavm.backend.javascript.rendering.Precedence; import org.teavm.backend.javascript.rendering.Precedence;
import org.teavm.common.ServiceRepository;
import org.teavm.model.ListableClassReaderSource; import org.teavm.model.ListableClassReaderSource;
import org.teavm.model.ValueType; import org.teavm.model.ValueType;

View File

@ -26,6 +26,41 @@ import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import org.teavm.ast.decompilation.Decompiler; 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.ClassDependency;
import org.teavm.dependency.DependencyChecker; import org.teavm.dependency.DependencyChecker;
import org.teavm.dependency.DependencyListener; import org.teavm.dependency.DependencyListener;
@ -65,41 +100,6 @@ import org.teavm.vm.TeaVMEntryPoint;
import org.teavm.vm.TeaVMTarget; import org.teavm.vm.TeaVMTarget;
import org.teavm.vm.TeaVMTargetController; import org.teavm.vm.TeaVMTargetController;
import org.teavm.vm.spi.TeaVMHostExtension; 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 { public class WasmTarget implements TeaVMTarget {
private TeaVMTargetController controller; private TeaVMTargetController controller;

View File

@ -22,6 +22,12 @@ import java.util.HashMap;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; 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.Address;
import org.teavm.interop.Structure; import org.teavm.interop.Structure;
import org.teavm.model.ClassReader; 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.VirtualTableEntry;
import org.teavm.model.classes.VirtualTableProvider; import org.teavm.model.classes.VirtualTableProvider;
import org.teavm.runtime.RuntimeClass; 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 { public class WasmClassGenerator {
private ClassReaderSource classSource; private ClassReaderSource classSource;

View File

@ -19,6 +19,7 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.teavm.backend.wasm.intrinsics.WasmIntrinsic;
import org.teavm.diagnostics.Diagnostics; import org.teavm.diagnostics.Diagnostics;
import org.teavm.interop.Import; import org.teavm.interop.Import;
import org.teavm.model.AnnotationReader; import org.teavm.model.AnnotationReader;
@ -32,7 +33,6 @@ import org.teavm.model.MethodReference;
import org.teavm.model.ValueType; import org.teavm.model.ValueType;
import org.teavm.model.classes.TagRegistry; import org.teavm.model.classes.TagRegistry;
import org.teavm.model.classes.VirtualTableProvider; import org.teavm.model.classes.VirtualTableProvider;
import org.teavm.backend.wasm.intrinsics.WasmIntrinsic;
public class WasmGenerationContext { public class WasmGenerationContext {
private ClassReaderSource classSource; private ClassReaderSource classSource;

View File

@ -61,17 +61,6 @@ import org.teavm.ast.UnaryExpr;
import org.teavm.ast.UnwrapArrayExpr; import org.teavm.ast.UnwrapArrayExpr;
import org.teavm.ast.VariableExpr; import org.teavm.ast.VariableExpr;
import org.teavm.ast.WhileStatement; 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.WasmRuntime;
import org.teavm.backend.wasm.intrinsics.WasmIntrinsic; import org.teavm.backend.wasm.intrinsics.WasmIntrinsic;
import org.teavm.backend.wasm.intrinsics.WasmIntrinsicManager; 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.WasmStoreInt64;
import org.teavm.backend.wasm.model.expression.WasmSwitch; import org.teavm.backend.wasm.model.expression.WasmSwitch;
import org.teavm.backend.wasm.model.expression.WasmUnreachable; 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 { class WasmGenerationVisitor implements StatementVisitor, ExprVisitor {
private static FieldReference tagField = new FieldReference(RuntimeClass.class.getName(), "tag"); private static FieldReference tagField = new FieldReference(RuntimeClass.class.getName(), "tag");
@ -1031,7 +1031,7 @@ class WasmGenerationVisitor implements StatementVisitor, ExprVisitor {
result = block; result = block;
} else if (expr.getType() instanceof ValueType.Array) { } else if (expr.getType() instanceof ValueType.Array) {
throw new UnsupportedOperationException();
} else { } else {
throw new AssertionError(); throw new AssertionError();
} }

View File

@ -18,14 +18,6 @@ package org.teavm.backend.wasm.generate;
import org.teavm.ast.RegularMethodNode; import org.teavm.ast.RegularMethodNode;
import org.teavm.ast.VariableNode; import org.teavm.ast.VariableNode;
import org.teavm.ast.decompilation.Decompiler; 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.WasmFunction;
import org.teavm.backend.wasm.model.WasmLocal; import org.teavm.backend.wasm.model.WasmLocal;
import org.teavm.backend.wasm.model.WasmType; 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.WasmIntBinaryOperation;
import org.teavm.backend.wasm.model.expression.WasmIntType; import org.teavm.backend.wasm.model.expression.WasmIntType;
import org.teavm.backend.wasm.model.expression.WasmLoadInt32; 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 { public class WasmGenerator {
private Decompiler decompiler; private Decompiler decompiler;

View File

@ -16,9 +16,9 @@
package org.teavm.backend.wasm.generate; package org.teavm.backend.wasm.generate;
import org.teavm.ast.OperationType; import org.teavm.ast.OperationType;
import org.teavm.backend.wasm.model.WasmType;
import org.teavm.model.ValueType; import org.teavm.model.ValueType;
import org.teavm.model.util.VariableType; import org.teavm.model.util.VariableType;
import org.teavm.backend.wasm.model.WasmType;
public final class WasmGeneratorUtil { public final class WasmGeneratorUtil {
private WasmGeneratorUtil() { private WasmGeneratorUtil() {

View File

@ -17,12 +17,12 @@ package org.teavm.backend.wasm.generate;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.teavm.model.ValueType;
import org.teavm.backend.wasm.binary.BinaryWriter; import org.teavm.backend.wasm.binary.BinaryWriter;
import org.teavm.backend.wasm.binary.DataArray; import org.teavm.backend.wasm.binary.DataArray;
import org.teavm.backend.wasm.binary.DataPrimitives; import org.teavm.backend.wasm.binary.DataPrimitives;
import org.teavm.backend.wasm.binary.DataStructure; import org.teavm.backend.wasm.binary.DataStructure;
import org.teavm.backend.wasm.binary.DataValue; import org.teavm.backend.wasm.binary.DataValue;
import org.teavm.model.ValueType;
public class WasmStringPool { public class WasmStringPool {
private WasmClassGenerator classGenerator; private WasmClassGenerator classGenerator;

View File

@ -17,19 +17,19 @@ package org.teavm.backend.wasm.intrinsics;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.teavm.ast.InvocationExpr; 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.WasmRuntime;
import org.teavm.backend.wasm.generate.WasmMangling; import org.teavm.backend.wasm.generate.WasmMangling;
import org.teavm.backend.wasm.model.expression.WasmCall; import org.teavm.backend.wasm.model.expression.WasmCall;
import org.teavm.backend.wasm.model.expression.WasmExpression; 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 { public class AllocatorIntrinsic implements WasmIntrinsic {
@Override @Override
public boolean isApplicable(MethodReference methodReference) { public boolean isApplicable(MethodReference methodReference) {
return methodReference.getClassName().equals(Allocator.class.getName()) && return methodReference.getClassName().equals(Allocator.class.getName())
methodReference.getName().equals("fillZero"); && methodReference.getName().equals("fillZero");
} }
@Override @Override

View File

@ -16,9 +16,9 @@
package org.teavm.backend.wasm.intrinsics; package org.teavm.backend.wasm.intrinsics;
import org.teavm.ast.InvocationExpr; import org.teavm.ast.InvocationExpr;
import org.teavm.backend.wasm.model.expression.WasmExpression;
import org.teavm.model.MethodDescriptor; import org.teavm.model.MethodDescriptor;
import org.teavm.model.MethodReference; import org.teavm.model.MethodReference;
import org.teavm.backend.wasm.model.expression.WasmExpression;
public class ClassIntrinsic implements WasmIntrinsic { public class ClassIntrinsic implements WasmIntrinsic {
@Override @Override

View File

@ -16,9 +16,9 @@
package org.teavm.backend.wasm.intrinsics; package org.teavm.backend.wasm.intrinsics;
import org.teavm.ast.InvocationExpr; 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.WasmBlock;
import org.teavm.backend.wasm.model.expression.WasmExpression; import org.teavm.backend.wasm.model.expression.WasmExpression;
import org.teavm.model.MethodReference;
public class PlatformClassIntrinsic implements WasmIntrinsic { public class PlatformClassIntrinsic implements WasmIntrinsic {
private static final String PLATFORM_CLASS_NAME = "org.teavm.platform.PlatformClass"; private static final String PLATFORM_CLASS_NAME = "org.teavm.platform.PlatformClass";

View File

@ -17,10 +17,10 @@ package org.teavm.backend.wasm.intrinsics;
import org.teavm.ast.InvocationExpr; import org.teavm.ast.InvocationExpr;
import org.teavm.ast.QualificationExpr; import org.teavm.ast.QualificationExpr;
import org.teavm.backend.wasm.model.expression.WasmExpression;
import org.teavm.model.FieldReference; import org.teavm.model.FieldReference;
import org.teavm.model.MethodReference; import org.teavm.model.MethodReference;
import org.teavm.runtime.RuntimeClass; import org.teavm.runtime.RuntimeClass;
import org.teavm.backend.wasm.model.expression.WasmExpression;
public class PlatformClassMetadataIntrinsic implements WasmIntrinsic { public class PlatformClassMetadataIntrinsic implements WasmIntrinsic {
private static final String PLATFORM_CLASS_METADATA_NAME = "org.teavm.platform.PlatformClassMetadata"; private static final String PLATFORM_CLASS_METADATA_NAME = "org.teavm.platform.PlatformClassMetadata";

View File

@ -16,8 +16,8 @@
package org.teavm.backend.wasm.intrinsics; package org.teavm.backend.wasm.intrinsics;
import org.teavm.ast.InvocationExpr; import org.teavm.ast.InvocationExpr;
import org.teavm.model.MethodReference;
import org.teavm.backend.wasm.model.expression.WasmExpression; import org.teavm.backend.wasm.model.expression.WasmExpression;
import org.teavm.model.MethodReference;
public class PlatformIntrinsic implements WasmIntrinsic { public class PlatformIntrinsic implements WasmIntrinsic {
private static final String PLATFORM = "org.teavm.platform.Platform"; private static final String PLATFORM = "org.teavm.platform.Platform";

View File

@ -16,9 +16,6 @@
package org.teavm.backend.wasm.intrinsics; package org.teavm.backend.wasm.intrinsics;
import org.teavm.ast.InvocationExpr; 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.generate.WasmClassGenerator;
import org.teavm.backend.wasm.model.expression.WasmExpression; import org.teavm.backend.wasm.model.expression.WasmExpression;
import org.teavm.backend.wasm.model.expression.WasmInt32Constant; 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.WasmIntBinaryOperation;
import org.teavm.backend.wasm.model.expression.WasmIntType; import org.teavm.backend.wasm.model.expression.WasmIntType;
import org.teavm.backend.wasm.model.expression.WasmLoadInt32; 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 { public class PlatformObjectIntrinsic implements WasmIntrinsic {
private static final String PLATFORM_OBJECT = "org.teavm.platform.PlatformObject"; private static final String PLATFORM_OBJECT = "org.teavm.platform.PlatformObject";

View File

@ -16,9 +16,6 @@
package org.teavm.backend.wasm.intrinsics; package org.teavm.backend.wasm.intrinsics;
import org.teavm.ast.InvocationExpr; 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.WasmType;
import org.teavm.backend.wasm.model.expression.WasmConversion; import org.teavm.backend.wasm.model.expression.WasmConversion;
import org.teavm.backend.wasm.model.expression.WasmExpression; 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.WasmStoreFloat64;
import org.teavm.backend.wasm.model.expression.WasmStoreInt32; import org.teavm.backend.wasm.model.expression.WasmStoreInt32;
import org.teavm.backend.wasm.model.expression.WasmStoreInt64; 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 { public class WasmAddressIntrinsic implements WasmIntrinsic {
@Override @Override

View File

@ -16,8 +16,8 @@
package org.teavm.backend.wasm.intrinsics; package org.teavm.backend.wasm.intrinsics;
import org.teavm.ast.InvocationExpr; import org.teavm.ast.InvocationExpr;
import org.teavm.model.MethodReference;
import org.teavm.backend.wasm.model.expression.WasmExpression; import org.teavm.backend.wasm.model.expression.WasmExpression;
import org.teavm.model.MethodReference;
public interface WasmIntrinsic { public interface WasmIntrinsic {
boolean isApplicable(MethodReference methodReference); boolean isApplicable(MethodReference methodReference);

View File

@ -16,7 +16,6 @@
package org.teavm.backend.wasm.intrinsics; package org.teavm.backend.wasm.intrinsics;
import org.teavm.ast.InvocationExpr; import org.teavm.ast.InvocationExpr;
import org.teavm.model.MethodReference;
import org.teavm.backend.wasm.WasmRuntime; import org.teavm.backend.wasm.WasmRuntime;
import org.teavm.backend.wasm.generate.WasmGeneratorUtil; import org.teavm.backend.wasm.generate.WasmGeneratorUtil;
import org.teavm.backend.wasm.model.WasmType; 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.WasmIntBinary;
import org.teavm.backend.wasm.model.expression.WasmIntBinaryOperation; import org.teavm.backend.wasm.model.expression.WasmIntBinaryOperation;
import org.teavm.backend.wasm.model.expression.WasmIntType; import org.teavm.backend.wasm.model.expression.WasmIntType;
import org.teavm.model.MethodReference;
public class WasmRuntimeIntrinsic implements WasmIntrinsic { public class WasmRuntimeIntrinsic implements WasmIntrinsic {
@Override @Override
public boolean isApplicable(MethodReference methodReference) { public boolean isApplicable(MethodReference methodReference) {
return methodReference.getClassName().equals(WasmRuntime.class.getName()) && return methodReference.getClassName().equals(WasmRuntime.class.getName())
(methodReference.getName().equals("lt") || methodReference.getName().equals("gt")); && (methodReference.getName().equals("lt") || methodReference.getName().equals("gt"));
} }
@Override @Override

View File

@ -17,12 +17,12 @@ package org.teavm.backend.wasm.intrinsics;
import org.teavm.ast.ConstantExpr; import org.teavm.ast.ConstantExpr;
import org.teavm.ast.InvocationExpr; 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.generate.WasmClassGenerator;
import org.teavm.backend.wasm.model.expression.WasmExpression; import org.teavm.backend.wasm.model.expression.WasmExpression;
import org.teavm.backend.wasm.model.expression.WasmInt32Constant; 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 { public class WasmStructureIntrinsic implements WasmIntrinsic {
private WasmClassGenerator classGenerator; private WasmClassGenerator classGenerator;

View File

@ -28,47 +28,14 @@ import java.io.InputStream;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import org.teavm.ast.AssignmentStatement;
import org.teavm.ast.AsyncMethodNode; import org.teavm.ast.AsyncMethodNode;
import org.teavm.ast.AsyncMethodPart; 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.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.QualificationExpr;
import org.teavm.ast.RecursiveVisitor;
import org.teavm.ast.RegularMethodNode; 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.ast.cache.MethodNodeCache;
import org.teavm.model.MethodReference; import org.teavm.model.MethodReference;
import org.teavm.parsing.ClassDateProvider; import org.teavm.parsing.ClassDateProvider;
@ -198,181 +165,19 @@ public class DiskRegularMethodNodeCache implements MethodNodeCache {
+ (async ? "-async" : "")); + (async ? "-async" : ""));
} }
private static class AstDependencyAnalyzer implements StatementVisitor, ExprVisitor { private static class AstDependencyAnalyzer extends RecursiveVisitor {
final Set<String> dependencies = new HashSet<>(); final Set<String> dependencies = new HashSet<>();
private void visitSequence(List<Statement> 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 @Override
public void visit(InvocationExpr expr) { public void visit(InvocationExpr expr) {
super.visit(expr);
dependencies.add(expr.getMethod().getClassName()); dependencies.add(expr.getMethod().getClassName());
for (Expr argument : expr.getArguments()) {
argument.acceptVisitor(this);
}
} }
@Override @Override
public void visit(QualificationExpr expr) { public void visit(QualificationExpr expr) {
super.visit(expr);
dependencies.add(expr.getField().getClassName()); 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) {
} }
} }

View File

@ -15,10 +15,15 @@
*/ */
package org.teavm.callgraph; 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.FieldReference;
import org.teavm.model.TextLocation;
import org.teavm.model.MethodReference; import org.teavm.model.MethodReference;
import org.teavm.model.TextLocation;
/** /**
* *

View File

@ -42,17 +42,17 @@ import org.teavm.model.ElementModifier;
import org.teavm.model.FieldHolder; import org.teavm.model.FieldHolder;
import org.teavm.model.FieldReader; import org.teavm.model.FieldReader;
import org.teavm.model.FieldReference; import org.teavm.model.FieldReference;
import org.teavm.model.TextLocation;
import org.teavm.model.MethodDescriptor; import org.teavm.model.MethodDescriptor;
import org.teavm.model.MethodHolder; import org.teavm.model.MethodHolder;
import org.teavm.model.MethodReader; import org.teavm.model.MethodReader;
import org.teavm.model.MethodReference; import org.teavm.model.MethodReference;
import org.teavm.model.Program; import org.teavm.model.Program;
import org.teavm.model.ReferenceCache; import org.teavm.model.ReferenceCache;
import org.teavm.model.TextLocation;
import org.teavm.model.ValueType; import org.teavm.model.ValueType;
import org.teavm.model.optimization.UnreachableBasicBlockEliminator;
import org.teavm.model.util.ModelUtils; import org.teavm.model.util.ModelUtils;
import org.teavm.model.util.ProgramUtils; import org.teavm.model.util.ProgramUtils;
import org.teavm.model.optimization.UnreachableBasicBlockEliminator;
import org.teavm.parsing.Parser; import org.teavm.parsing.Parser;
public class DependencyChecker implements DependencyInfo { public class DependencyChecker implements DependencyInfo {

View File

@ -27,8 +27,8 @@ import org.teavm.model.ClassHolderTransformer;
import org.teavm.model.ClassReader; import org.teavm.model.ClassReader;
import org.teavm.model.ClassReaderSource; import org.teavm.model.ClassReaderSource;
import org.teavm.model.MethodHolder; import org.teavm.model.MethodHolder;
import org.teavm.model.util.ModelUtils;
import org.teavm.model.optimization.UnreachableBasicBlockEliminator; import org.teavm.model.optimization.UnreachableBasicBlockEliminator;
import org.teavm.model.util.ModelUtils;
class DependencyClassSource implements ClassHolderSource { class DependencyClassSource implements ClassHolderSource {
private ClassReaderSource innerSource; private ClassReaderSource innerSource;

View File

@ -33,7 +33,6 @@ import org.teavm.model.FieldReference;
import org.teavm.model.Incoming; import org.teavm.model.Incoming;
import org.teavm.model.IncomingReader; import org.teavm.model.IncomingReader;
import org.teavm.model.Instruction; import org.teavm.model.Instruction;
import org.teavm.model.TextLocation;
import org.teavm.model.InvokeDynamicInstruction; import org.teavm.model.InvokeDynamicInstruction;
import org.teavm.model.MethodDescriptor; import org.teavm.model.MethodDescriptor;
import org.teavm.model.MethodHandle; import org.teavm.model.MethodHandle;
@ -43,6 +42,7 @@ import org.teavm.model.Phi;
import org.teavm.model.PhiReader; import org.teavm.model.PhiReader;
import org.teavm.model.Program; import org.teavm.model.Program;
import org.teavm.model.RuntimeConstant; import org.teavm.model.RuntimeConstant;
import org.teavm.model.TextLocation;
import org.teavm.model.TryCatchBlockReader; import org.teavm.model.TryCatchBlockReader;
import org.teavm.model.TryCatchJointReader; import org.teavm.model.TryCatchJointReader;
import org.teavm.model.ValueType; import org.teavm.model.ValueType;

View File

@ -16,14 +16,10 @@
package org.teavm.diagnostics; package org.teavm.diagnostics;
import org.teavm.model.FieldReference; import org.teavm.model.FieldReference;
import org.teavm.model.TextLocation;
import org.teavm.model.MethodReference; import org.teavm.model.MethodReference;
import org.teavm.model.TextLocation;
import org.teavm.model.ValueType; import org.teavm.model.ValueType;
/**
*
* @author Alexey Andreev
*/
public class DefaultProblemTextConsumer implements ProblemTextConsumer { public class DefaultProblemTextConsumer implements ProblemTextConsumer {
private StringBuilder sb = new StringBuilder(); private StringBuilder sb = new StringBuilder();

View File

@ -16,14 +16,10 @@
package org.teavm.diagnostics; package org.teavm.diagnostics;
import org.teavm.model.FieldReference; import org.teavm.model.FieldReference;
import org.teavm.model.TextLocation;
import org.teavm.model.MethodReference; import org.teavm.model.MethodReference;
import org.teavm.model.TextLocation;
import org.teavm.model.ValueType; import org.teavm.model.ValueType;
/**
*
* @author Alexey Andreev
*/
public interface ProblemTextConsumer { public interface ProblemTextConsumer {
void append(String text); void append(String text);

View File

@ -21,12 +21,12 @@ import org.teavm.model.ClassReaderSource;
import org.teavm.model.FieldReader; import org.teavm.model.FieldReader;
import org.teavm.model.FieldReference; import org.teavm.model.FieldReference;
import org.teavm.model.Instruction; import org.teavm.model.Instruction;
import org.teavm.model.TextLocation;
import org.teavm.model.MethodDescriptor; import org.teavm.model.MethodDescriptor;
import org.teavm.model.MethodHolder; import org.teavm.model.MethodHolder;
import org.teavm.model.MethodReference; import org.teavm.model.MethodReference;
import org.teavm.model.Phi; import org.teavm.model.Phi;
import org.teavm.model.Program; import org.teavm.model.Program;
import org.teavm.model.TextLocation;
import org.teavm.model.ValueType; import org.teavm.model.ValueType;
import org.teavm.model.Variable; import org.teavm.model.Variable;
import org.teavm.model.instructions.ClassConstantInstruction; import org.teavm.model.instructions.ClassConstantInstruction;

View File

@ -15,16 +15,45 @@
*/ */
package org.teavm.model.util; 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.CallGraph;
import org.teavm.callgraph.CallGraphNode; import org.teavm.callgraph.CallGraphNode;
import org.teavm.callgraph.CallSite; import org.teavm.callgraph.CallSite;
import org.teavm.diagnostics.Diagnostics; import org.teavm.diagnostics.Diagnostics;
import org.teavm.interop.Async; import org.teavm.interop.Async;
import org.teavm.backend.javascript.spi.InjectedBy;
import org.teavm.interop.Sync; import org.teavm.interop.Sync;
import org.teavm.model.*; import org.teavm.model.BasicBlockReader;
import org.teavm.model.instructions.*; 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;
/** /**
* *

View File

@ -21,13 +21,13 @@ import org.teavm.model.BasicBlock;
import org.teavm.model.BasicBlockReader; import org.teavm.model.BasicBlockReader;
import org.teavm.model.FieldReference; import org.teavm.model.FieldReference;
import org.teavm.model.Instruction; import org.teavm.model.Instruction;
import org.teavm.model.TextLocation;
import org.teavm.model.InvokeDynamicInstruction; import org.teavm.model.InvokeDynamicInstruction;
import org.teavm.model.MethodDescriptor; import org.teavm.model.MethodDescriptor;
import org.teavm.model.MethodHandle; import org.teavm.model.MethodHandle;
import org.teavm.model.MethodReference; import org.teavm.model.MethodReference;
import org.teavm.model.Program; import org.teavm.model.Program;
import org.teavm.model.RuntimeConstant; import org.teavm.model.RuntimeConstant;
import org.teavm.model.TextLocation;
import org.teavm.model.ValueType; import org.teavm.model.ValueType;
import org.teavm.model.Variable; import org.teavm.model.Variable;
import org.teavm.model.VariableReader; import org.teavm.model.VariableReader;

View File

@ -15,17 +15,22 @@
*/ */
package org.teavm.model.util; 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.common.Graph;
import org.teavm.model.BasicBlock; import org.teavm.model.BasicBlock;
import org.teavm.model.Instruction; import org.teavm.model.Instruction;
import org.teavm.model.TextLocation;
import org.teavm.model.Program; import org.teavm.model.Program;
import org.teavm.model.TextLocation;
/**
*
* @author Alexey Andreev
*/
class LocationGraphBuilder { class LocationGraphBuilder {
private Map<TextLocation, Set<TextLocation>> graphBuilder; private Map<TextLocation, Set<TextLocation>> graphBuilder;
private List<Set<TextLocation>> startLocations; private List<Set<TextLocation>> startLocations;

View File

@ -25,11 +25,11 @@ import org.teavm.model.BasicBlockReader;
import org.teavm.model.Incoming; import org.teavm.model.Incoming;
import org.teavm.model.IncomingReader; import org.teavm.model.IncomingReader;
import org.teavm.model.Instruction; import org.teavm.model.Instruction;
import org.teavm.model.TextLocation;
import org.teavm.model.Phi; import org.teavm.model.Phi;
import org.teavm.model.PhiReader; import org.teavm.model.PhiReader;
import org.teavm.model.Program; import org.teavm.model.Program;
import org.teavm.model.ProgramReader; import org.teavm.model.ProgramReader;
import org.teavm.model.TextLocation;
import org.teavm.model.TryCatchBlock; import org.teavm.model.TryCatchBlock;
import org.teavm.model.TryCatchBlockReader; import org.teavm.model.TryCatchBlockReader;
import org.teavm.model.TryCatchJoint; import org.teavm.model.TryCatchJoint;

View File

@ -26,14 +26,36 @@ import java.util.Map;
import org.objectweb.asm.Opcodes; import org.objectweb.asm.Opcodes;
import org.objectweb.asm.Type; import org.objectweb.asm.Type;
import org.objectweb.asm.commons.JSRInlinerAdapter; 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.Graph;
import org.teavm.common.GraphUtils; 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.DefinitionExtractor;
import org.teavm.model.util.PhiUpdater; import org.teavm.model.util.PhiUpdater;
import org.teavm.model.util.ProgramUtils; import org.teavm.model.util.ProgramUtils;
import org.teavm.model.optimization.UnreachableBasicBlockEliminator;
public class Parser { public class Parser {
private ReferenceCache referenceCache; private ReferenceCache referenceCache;

View File

@ -21,6 +21,9 @@ import org.teavm.interop.Structure;
@StaticInit @StaticInit
public final class Allocator { public final class Allocator {
private Allocator() {
}
private static Address address = initialize(); private static Address address = initialize();
private static native Address initialize(); private static native Address initialize();

View File

@ -16,8 +16,8 @@
package org.teavm.runtime; package org.teavm.runtime;
public class RuntimeClass extends RuntimeJavaObject { public class RuntimeClass extends RuntimeJavaObject {
public static int INITIALIZED = 1; public static final int INITIALIZED = 1;
public static int PRIMITIVE = 2; public static final int PRIMITIVE = 2;
public int size; public int size;
public int flags; public int flags;
@ -27,7 +27,7 @@ public class RuntimeClass extends RuntimeJavaObject {
public RuntimeClass arrayType; public RuntimeClass arrayType;
public static int computeCanary(int size, int tag) { 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() { public int computeCanary() {

View File

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.teavm.backend.javascript.rendering; package org.teavm.vm;
public class RenderingException extends RuntimeException { public class RenderingException extends RuntimeException {
private static final long serialVersionUID = 631804556597569547L; private static final long serialVersionUID = 631804556597569547L;

View File

@ -39,7 +39,6 @@ import org.teavm.dependency.Linker;
import org.teavm.diagnostics.AccumulationDiagnostics; import org.teavm.diagnostics.AccumulationDiagnostics;
import org.teavm.diagnostics.Diagnostics; import org.teavm.diagnostics.Diagnostics;
import org.teavm.diagnostics.ProblemProvider; import org.teavm.diagnostics.ProblemProvider;
import org.teavm.backend.javascript.rendering.RenderingException;
import org.teavm.model.ClassHolder; import org.teavm.model.ClassHolder;
import org.teavm.model.ClassHolderSource; import org.teavm.model.ClassHolderSource;
import org.teavm.model.ClassHolderTransformer; import org.teavm.model.ClassHolderTransformer;
@ -52,10 +51,6 @@ import org.teavm.model.MethodReference;
import org.teavm.model.MutableClassHolderSource; import org.teavm.model.MutableClassHolderSource;
import org.teavm.model.Program; import org.teavm.model.Program;
import org.teavm.model.ProgramCache; 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.ArrayUnwrapMotion;
import org.teavm.model.optimization.ClassInitElimination; import org.teavm.model.optimization.ClassInitElimination;
import org.teavm.model.optimization.ConstantConditionElimination; 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.RedundantJumpElimination;
import org.teavm.model.optimization.UnreachableBasicBlockElimination; import org.teavm.model.optimization.UnreachableBasicBlockElimination;
import org.teavm.model.optimization.UnusedVariableElimination; 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.TeaVMHost;
import org.teavm.vm.spi.TeaVMHostExtension; import org.teavm.vm.spi.TeaVMHostExtension;
import org.teavm.vm.spi.TeaVMPlugin; 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 output where to generate JavaScript. Should not be null.
* @param buildTarget where to generate additional resources. Can be null, but if there are * @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. * 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); target.setController(targetController);
// Check dependencies // Check dependencies
@ -497,13 +494,13 @@ public class TeaVM implements TeaVMHost, ServiceRepository {
new UnreachableBasicBlockElimination()); 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))) { try (OutputStream output = new FileOutputStream(new File(dir, fileName))) {
build(output, new DirectoryBuildTarget(dir)); build(output, new DirectoryBuildTarget(dir));
} catch (UnsupportedEncodingException e) { } catch (UnsupportedEncodingException e) {
throw new RuntimeException("Platform does not support UTF-8", e); throw new RuntimeException("Platform does not support UTF-8", e);
} catch (IOException e) { } catch (IOException e) {
throw new RenderingException("IO error occured", e); throw new RenderingException("IO error occurred", e);
} }
} }

View File

@ -16,14 +16,17 @@
package org.teavm.html4j; package org.teavm.html4j;
import net.java.html.js.JavaScriptBody; import net.java.html.js.JavaScriptBody;
import org.teavm.diagnostics.Diagnostics;
import org.teavm.backend.javascript.spi.GeneratedBy; 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 { public class JavaScriptBodyTransformer implements ClassHolderTransformer {
@Override @Override
public void transformClass(ClassHolder cls, ClassReaderSource innerSource, Diagnostics diagnostics) { public void transformClass(ClassHolder cls, ClassReaderSource innerSource, Diagnostics diagnostics) {

View File

@ -21,16 +21,12 @@ import java.io.StringWriter;
import net.java.html.js.JavaScriptResource; import net.java.html.js.JavaScriptResource;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.teavm.backend.javascript.rendering.RenderingContext; import org.teavm.backend.javascript.rendering.RenderingContext;
import org.teavm.backend.javascript.rendering.RenderingException;
import org.teavm.model.AnnotationReader; import org.teavm.model.AnnotationReader;
import org.teavm.model.ClassReader; import org.teavm.model.ClassReader;
import org.teavm.vm.BuildTarget; import org.teavm.vm.BuildTarget;
import org.teavm.vm.RenderingException;
import org.teavm.vm.spi.AbstractRendererListener; import org.teavm.vm.spi.AbstractRendererListener;
/**
*
* @author Alexey Andreev
*/
public class JavaScriptResourceInterceptor extends AbstractRendererListener { public class JavaScriptResourceInterceptor extends AbstractRendererListener {
@Override @Override
public void begin(RenderingContext context, BuildTarget buildTarget) throws IOException { public void begin(RenderingContext context, BuildTarget buildTarget) throws IOException {

View File

@ -16,43 +16,43 @@
package org.teavm.interop; package org.teavm.interop;
public final class Address { 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 extends Structure> T toStructure(); public native <T extends Structure> 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); public static native Address fromInt(int value);

View File

@ -17,9 +17,9 @@ package org.teavm.jso.impl;
import java.lang.reflect.Array; import java.lang.reflect.Array;
import java.util.function.Function; import java.util.function.Function;
import org.teavm.dependency.PluggableDependency;
import org.teavm.backend.javascript.spi.GeneratedBy; import org.teavm.backend.javascript.spi.GeneratedBy;
import org.teavm.backend.javascript.spi.InjectedBy; import org.teavm.backend.javascript.spi.InjectedBy;
import org.teavm.dependency.PluggableDependency;
import org.teavm.jso.JSBody; import org.teavm.jso.JSBody;
import org.teavm.jso.JSObject; import org.teavm.jso.JSObject;
import org.teavm.jso.core.JSArray; import org.teavm.jso.core.JSArray;

View File

@ -30,10 +30,10 @@ import org.mozilla.javascript.Context;
import org.mozilla.javascript.ast.AstNode; import org.mozilla.javascript.ast.AstNode;
import org.mozilla.javascript.ast.AstRoot; import org.mozilla.javascript.ast.AstRoot;
import org.mozilla.javascript.ast.FunctionNode; 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.GeneratedBy;
import org.teavm.backend.javascript.spi.InjectedBy; 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.interop.Sync;
import org.teavm.jso.JSBody; import org.teavm.jso.JSBody;
import org.teavm.jso.JSFunctor; import org.teavm.jso.JSFunctor;
@ -55,12 +55,12 @@ import org.teavm.model.ClassReaderSource;
import org.teavm.model.ElementModifier; import org.teavm.model.ElementModifier;
import org.teavm.model.FieldHolder; import org.teavm.model.FieldHolder;
import org.teavm.model.Instruction; import org.teavm.model.Instruction;
import org.teavm.model.TextLocation;
import org.teavm.model.MethodDescriptor; import org.teavm.model.MethodDescriptor;
import org.teavm.model.MethodHolder; import org.teavm.model.MethodHolder;
import org.teavm.model.MethodReader; import org.teavm.model.MethodReader;
import org.teavm.model.MethodReference; import org.teavm.model.MethodReference;
import org.teavm.model.Program; import org.teavm.model.Program;
import org.teavm.model.TextLocation;
import org.teavm.model.ValueType; import org.teavm.model.ValueType;
import org.teavm.model.Variable; import org.teavm.model.Variable;
import org.teavm.model.instructions.AssignInstruction; import org.teavm.model.instructions.AssignInstruction;

View File

@ -20,15 +20,15 @@ import org.teavm.ast.ConstantExpr;
import org.teavm.ast.Expr; import org.teavm.ast.Expr;
import org.teavm.ast.InvocationExpr; import org.teavm.ast.InvocationExpr;
import org.teavm.backend.javascript.codegen.SourceWriter; 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.Precedence;
import org.teavm.backend.javascript.rendering.Renderer; import org.teavm.backend.javascript.rendering.Renderer;
import org.teavm.backend.javascript.spi.Generator; import org.teavm.backend.javascript.spi.Generator;
import org.teavm.backend.javascript.spi.GeneratorContext; import org.teavm.backend.javascript.spi.GeneratorContext;
import org.teavm.backend.javascript.spi.Injector; import org.teavm.backend.javascript.spi.Injector;
import org.teavm.backend.javascript.spi.InjectorContext; 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.CallLocation;
import org.teavm.model.ClassReader; import org.teavm.model.ClassReader;
import org.teavm.model.MethodReader; import org.teavm.model.MethodReader;

View File

@ -22,13 +22,13 @@ import java.util.stream.Collectors;
import org.teavm.common.DisjointSet; import org.teavm.common.DisjointSet;
import org.teavm.model.BasicBlockReader; import org.teavm.model.BasicBlockReader;
import org.teavm.model.FieldReference; import org.teavm.model.FieldReference;
import org.teavm.model.TextLocation;
import org.teavm.model.MethodDescriptor; import org.teavm.model.MethodDescriptor;
import org.teavm.model.MethodHandle; import org.teavm.model.MethodHandle;
import org.teavm.model.MethodReference; import org.teavm.model.MethodReference;
import org.teavm.model.PhiReader; import org.teavm.model.PhiReader;
import org.teavm.model.ProgramReader; import org.teavm.model.ProgramReader;
import org.teavm.model.RuntimeConstant; import org.teavm.model.RuntimeConstant;
import org.teavm.model.TextLocation;
import org.teavm.model.TryCatchBlockReader; import org.teavm.model.TryCatchBlockReader;
import org.teavm.model.TryCatchJointReader; import org.teavm.model.TryCatchJointReader;
import org.teavm.model.ValueType; import org.teavm.model.ValueType;

View File

@ -39,7 +39,6 @@ import org.teavm.model.FieldReference;
import org.teavm.model.Incoming; import org.teavm.model.Incoming;
import org.teavm.model.IncomingReader; import org.teavm.model.IncomingReader;
import org.teavm.model.Instruction; import org.teavm.model.Instruction;
import org.teavm.model.TextLocation;
import org.teavm.model.InvokeDynamicInstruction; import org.teavm.model.InvokeDynamicInstruction;
import org.teavm.model.MethodDescriptor; import org.teavm.model.MethodDescriptor;
import org.teavm.model.MethodHandle; import org.teavm.model.MethodHandle;
@ -49,6 +48,7 @@ import org.teavm.model.PhiReader;
import org.teavm.model.Program; import org.teavm.model.Program;
import org.teavm.model.ProgramReader; import org.teavm.model.ProgramReader;
import org.teavm.model.RuntimeConstant; import org.teavm.model.RuntimeConstant;
import org.teavm.model.TextLocation;
import org.teavm.model.TryCatchBlock; import org.teavm.model.TryCatchBlock;
import org.teavm.model.TryCatchBlockReader; import org.teavm.model.TryCatchBlockReader;
import org.teavm.model.ValueType; import org.teavm.model.ValueType;

View File

@ -39,11 +39,11 @@ import org.teavm.model.ClassHolder;
import org.teavm.model.ClassReaderSource; import org.teavm.model.ClassReaderSource;
import org.teavm.model.ElementModifier; import org.teavm.model.ElementModifier;
import org.teavm.model.Instruction; import org.teavm.model.Instruction;
import org.teavm.model.TextLocation;
import org.teavm.model.MethodHolder; import org.teavm.model.MethodHolder;
import org.teavm.model.MethodReader; import org.teavm.model.MethodReader;
import org.teavm.model.MethodReference; import org.teavm.model.MethodReference;
import org.teavm.model.Program; import org.teavm.model.Program;
import org.teavm.model.TextLocation;
import org.teavm.model.ValueType; import org.teavm.model.ValueType;
import org.teavm.model.Variable; import org.teavm.model.Variable;
import org.teavm.model.instructions.DoubleConstantInstruction; import org.teavm.model.instructions.DoubleConstantInstruction;

View File

@ -16,9 +16,9 @@
package org.teavm.platform; package org.teavm.platform;
import java.lang.annotation.Annotation; import java.lang.annotation.Annotation;
import org.teavm.dependency.PluggableDependency;
import org.teavm.backend.javascript.spi.GeneratedBy; import org.teavm.backend.javascript.spi.GeneratedBy;
import org.teavm.backend.javascript.spi.InjectedBy; import org.teavm.backend.javascript.spi.InjectedBy;
import org.teavm.dependency.PluggableDependency;
import org.teavm.jso.JSBody; import org.teavm.jso.JSBody;
import org.teavm.jso.JSObject; import org.teavm.jso.JSObject;
import org.teavm.jso.browser.Window; import org.teavm.jso.browser.Window;

View File

@ -15,17 +15,12 @@
*/ */
package org.teavm.platform; package org.teavm.platform;
import org.teavm.dependency.PluggableDependency;
import org.teavm.backend.javascript.spi.InjectedBy; import org.teavm.backend.javascript.spi.InjectedBy;
import org.teavm.dependency.PluggableDependency;
import org.teavm.jso.JSObject; import org.teavm.jso.JSObject;
import org.teavm.jso.JSProperty; import org.teavm.jso.JSProperty;
import org.teavm.platform.plugin.PlatformQueueGenerator; import org.teavm.platform.plugin.PlatformQueueGenerator;
/**
*
* @author Alexey Andreev
* @param <T>
*/
public abstract class PlatformQueue<T> implements JSObject { public abstract class PlatformQueue<T> implements JSObject {
@JSProperty @JSProperty
public abstract int getLength(); public abstract int getLength();

View File

@ -17,11 +17,11 @@ package org.teavm.platform.plugin;
import java.io.IOException; import java.io.IOException;
import org.teavm.backend.javascript.codegen.SourceWriter; 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.DependencyAgent;
import org.teavm.dependency.DependencyPlugin; import org.teavm.dependency.DependencyPlugin;
import org.teavm.dependency.MethodDependency; 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.CallLocation;
import org.teavm.model.ClassReader; import org.teavm.model.ClassReader;
import org.teavm.model.ElementModifier; import org.teavm.model.ElementModifier;

View File

@ -15,12 +15,21 @@
*/ */
package org.teavm.platform.plugin; package org.teavm.platform.plugin;
import org.teavm.backend.javascript.spi.GeneratedBy;
import org.teavm.dependency.PluggableDependency; import org.teavm.dependency.PluggableDependency;
import org.teavm.diagnostics.Diagnostics; import org.teavm.diagnostics.Diagnostics;
import org.teavm.interop.Async; import org.teavm.interop.Async;
import org.teavm.backend.javascript.spi.GeneratedBy;
import org.teavm.interop.Sync; 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; import org.teavm.platform.async.AsyncCallback;
/** /**

View File

@ -15,9 +15,9 @@
*/ */
package org.teavm.platform.plugin; package org.teavm.platform.plugin;
import org.teavm.backend.javascript.spi.GeneratedBy;
import org.teavm.cache.NoCache; import org.teavm.cache.NoCache;
import org.teavm.diagnostics.Diagnostics; import org.teavm.diagnostics.Diagnostics;
import org.teavm.backend.javascript.spi.GeneratedBy;
import org.teavm.model.AccessLevel; import org.teavm.model.AccessLevel;
import org.teavm.model.AnnotationHolder; import org.teavm.model.AnnotationHolder;
import org.teavm.model.AnnotationReader; 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.ClassScopedMetadataProvider;
import org.teavm.platform.metadata.MetadataProvider; import org.teavm.platform.metadata.MetadataProvider;
/**
*
* @author Alexey Andreev
*/
class MetadataProviderTransformer implements ClassHolderTransformer { class MetadataProviderTransformer implements ClassHolderTransformer {
static int fieldIdGen; static int fieldIdGen;

View File

@ -18,13 +18,13 @@ package org.teavm.platform.plugin;
import java.io.IOException; import java.io.IOException;
import java.lang.annotation.Annotation; import java.lang.annotation.Annotation;
import org.teavm.backend.javascript.codegen.SourceWriter; 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.Generator;
import org.teavm.backend.javascript.spi.GeneratorContext; import org.teavm.backend.javascript.spi.GeneratorContext;
import org.teavm.backend.javascript.spi.Injector; import org.teavm.backend.javascript.spi.Injector;
import org.teavm.backend.javascript.spi.InjectorContext; 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.CallLocation;
import org.teavm.model.ClassReader; import org.teavm.model.ClassReader;
import org.teavm.model.MethodDescriptor; import org.teavm.model.MethodDescriptor;

View File

@ -16,11 +16,11 @@
package org.teavm.platform.plugin; package org.teavm.platform.plugin;
import java.io.IOException; 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.DependencyAgent;
import org.teavm.dependency.DependencyPlugin; import org.teavm.dependency.DependencyPlugin;
import org.teavm.dependency.MethodDependency; 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.CallLocation;
import org.teavm.model.MethodReference; import org.teavm.model.MethodReference;
import org.teavm.platform.PlatformObject; import org.teavm.platform.PlatformObject;

View File

@ -15,9 +15,13 @@
*/ */
package org.teavm.platform.plugin; package org.teavm.platform.plugin;
import org.teavm.diagnostics.Diagnostics;
import org.teavm.backend.javascript.TeaVMJavaScriptHost; 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; import org.teavm.vm.spi.TeaVMHost;
class ResourceAccessorTransformer implements ClassHolderTransformer { class ResourceAccessorTransformer implements ClassHolderTransformer {

View File

@ -80,6 +80,7 @@
<modules> <modules>
<module>metaprogramming/api</module> <module>metaprogramming/api</module>
<module>interop/core</module>
<module>core</module> <module>core</module>
<module>classlib</module> <module>classlib</module>
<module>jso/core</module> <module>jso/core</module>

View File

@ -22,8 +22,8 @@ import org.teavm.callgraph.CallSite;
import org.teavm.diagnostics.DefaultProblemTextConsumer; import org.teavm.diagnostics.DefaultProblemTextConsumer;
import org.teavm.diagnostics.Problem; import org.teavm.diagnostics.Problem;
import org.teavm.model.CallLocation; import org.teavm.model.CallLocation;
import org.teavm.model.TextLocation;
import org.teavm.model.MethodReference; import org.teavm.model.MethodReference;
import org.teavm.model.TextLocation;
import org.teavm.vm.TeaVM; import org.teavm.vm.TeaVM;
public final class TeaVMProblemRenderer { public final class TeaVMProblemRenderer {

View File

@ -34,6 +34,9 @@ import java.util.List;
import java.util.Properties; import java.util.Properties;
import java.util.Set; import java.util.Set;
import org.apache.commons.io.IOUtils; 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.DiskCachedClassHolderSource;
import org.teavm.cache.DiskProgramCache; import org.teavm.cache.DiskProgramCache;
import org.teavm.cache.DiskRegularMethodNodeCache; import org.teavm.cache.DiskRegularMethodNodeCache;
@ -42,8 +45,6 @@ import org.teavm.debugging.information.DebugInformation;
import org.teavm.debugging.information.DebugInformationBuilder; import org.teavm.debugging.information.DebugInformationBuilder;
import org.teavm.dependency.DependencyInfo; import org.teavm.dependency.DependencyInfo;
import org.teavm.diagnostics.ProblemProvider; 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.ClassHolderSource;
import org.teavm.model.ClassHolderTransformer; import org.teavm.model.ClassHolderTransformer;
import org.teavm.model.ClassReader; import org.teavm.model.ClassReader;
@ -64,7 +65,6 @@ import org.teavm.vm.TeaVMEntryPoint;
import org.teavm.vm.TeaVMProgressListener; import org.teavm.vm.TeaVMProgressListener;
import org.teavm.vm.TeaVMTarget; import org.teavm.vm.TeaVMTarget;
import org.teavm.vm.spi.AbstractRendererListener; import org.teavm.vm.spi.AbstractRendererListener;
import org.teavm.backend.wasm.WasmTarget;
public class TeaVMTool implements BaseTeaVMTool { public class TeaVMTool implements BaseTeaVMTool {
private File targetDirectory = new File("."); private File targetDirectory = new File(".");

View File

@ -44,10 +44,10 @@ import org.junit.runner.Runner;
import org.junit.runner.notification.Failure; import org.junit.runner.notification.Failure;
import org.junit.runner.notification.RunNotifier; import org.junit.runner.notification.RunNotifier;
import org.junit.runners.model.InitializationError; import org.junit.runners.model.InitializationError;
import org.teavm.backend.javascript.JavaScriptTarget;
import org.teavm.callgraph.CallGraph; import org.teavm.callgraph.CallGraph;
import org.teavm.diagnostics.DefaultProblemTextConsumer; import org.teavm.diagnostics.DefaultProblemTextConsumer;
import org.teavm.diagnostics.Problem; import org.teavm.diagnostics.Problem;
import org.teavm.backend.javascript.JavaScriptTarget;
import org.teavm.model.ClassHolder; import org.teavm.model.ClassHolder;
import org.teavm.model.ClassHolderSource; import org.teavm.model.ClassHolderSource;
import org.teavm.model.MethodDescriptor; import org.teavm.model.MethodDescriptor;