Refactor TeaVM core for new diagnostics API

This commit is contained in:
Alexey Andreev 2014-12-11 18:54:15 +04:00
parent 0945c27f16
commit 47f5943e8b
11 changed files with 159 additions and 110 deletions

View File

@ -89,10 +89,13 @@ public class DefaultCallGraphNode implements CallGraphNode {
return safeFieldAccessSites; return safeFieldAccessSites;
} }
public void addFieldAccess(FieldReference field, InstructionLocation location) { public boolean addFieldAccess(FieldReference field, InstructionLocation location) {
DefaultFieldAccessSite site = new DefaultFieldAccessSite(location, this, field); DefaultFieldAccessSite site = new DefaultFieldAccessSite(location, this, field);
if (fieldAccessSites.add(site)) { if (fieldAccessSites.add(site)) {
graph.addFieldAccess(site); graph.addFieldAccess(site);
return true;
} else {
return false;
} }
} }
@ -104,10 +107,13 @@ public class DefaultCallGraphNode implements CallGraphNode {
return safeClassAccessSites; return safeClassAccessSites;
} }
public void addClassAccess(String className, InstructionLocation location) { public boolean addClassAccess(String className, InstructionLocation location) {
DefaultClassAccessSite site = new DefaultClassAccessSite(location, this, className); DefaultClassAccessSite site = new DefaultClassAccessSite(location, this, className);
if (classAccessSites.add(site)) { if (classAccessSites.add(site)) {
graph.addClassAccess(site); graph.addClassAccess(site);
return true;
} else {
return false;
} }
} }
} }

View File

@ -15,14 +15,34 @@
*/ */
package org.teavm.dependency; package org.teavm.dependency;
import java.io.IOException; import java.util.ArrayDeque;
import java.util.*; import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import org.teavm.callgraph.CallGraph; import org.teavm.callgraph.CallGraph;
import org.teavm.callgraph.DefaultCallGraph; import org.teavm.callgraph.DefaultCallGraph;
import org.teavm.common.*; import org.teavm.callgraph.DefaultCallGraphNode;
import org.teavm.common.CachedMapper;
import org.teavm.common.CachedMapper.KeyListener; import org.teavm.common.CachedMapper.KeyListener;
import org.teavm.common.Mapper;
import org.teavm.common.ServiceRepository;
import org.teavm.diagnostics.Diagnostics; import org.teavm.diagnostics.Diagnostics;
import org.teavm.model.*; import org.teavm.model.AnnotationReader;
import org.teavm.model.CallLocation;
import org.teavm.model.ClassHolder;
import org.teavm.model.ClassHolderTransformer;
import org.teavm.model.ClassReader;
import org.teavm.model.ClassReaderSource;
import org.teavm.model.FieldReader;
import org.teavm.model.FieldReference;
import org.teavm.model.InstructionLocation;
import org.teavm.model.MethodDescriptor;
import org.teavm.model.MethodReader;
import org.teavm.model.MethodReference;
import org.teavm.model.ValueType;
import org.teavm.model.util.ModelUtils; import org.teavm.model.util.ModelUtils;
/** /**
@ -42,9 +62,6 @@ public class DependencyChecker implements DependencyInfo, DependencyAgent {
private List<DependencyListener> listeners = new ArrayList<>(); private List<DependencyListener> listeners = new ArrayList<>();
private ServiceRepository services; private ServiceRepository services;
private Queue<Runnable> tasks = new ArrayDeque<>(); private Queue<Runnable> tasks = new ArrayDeque<>();
Set<MethodDependency> missingMethods = new HashSet<>();
Set<ClassDependency> missingClasses = new HashSet<>();
Set<FieldDependency> missingFields = new HashSet<>();
List<DependencyType> types = new ArrayList<>(); List<DependencyType> types = new ArrayList<>();
Map<String, DependencyType> typeMap = new HashMap<>(); Map<String, DependencyType> typeMap = new HashMap<>();
private DependencyCheckerInterruptor interruptor; private DependencyCheckerInterruptor interruptor;
@ -216,20 +233,38 @@ public class DependencyChecker implements DependencyInfo, DependencyAgent {
@Override @Override
public ClassDependency linkClass(String className, CallLocation callLocation) { public ClassDependency linkClass(String className, CallLocation callLocation) {
return classCache.map(className); ClassDependency dep = classCache.map(className);
if (callLocation != null && callLocation.getMethod() != null) {
DefaultCallGraphNode callGraphNode = callGraph.getNode(callLocation.getMethod());
addClassAccess(callGraphNode, className, callLocation.getSourceLocation());
}
return dep;
} }
private ClassDependency createClassDependency(String className, CallLocation callLocation) { private void addClassAccess(DefaultCallGraphNode node, String className, InstructionLocation loc) {
if (!node.addClassAccess(className, loc)) {
return;
}
ClassReader cls = classSource.get(className); ClassReader cls = classSource.get(className);
ClassDependency dependency = new ClassDependency(this, className, stack, cls); if (cls != null) {
if (dependency.isMissing()) { if (cls.getParent() != null && !cls.getParent().equals(cls.getName())) {
missingClasses.add(dependency); addClassAccess(node, cls.getParent(), loc);
} else { }
for (String iface : cls.getInterfaces()) {
addClassAccess(node, iface, loc);
}
}
}
private ClassDependency createClassDependency(String className) {
ClassReader cls = classSource.get(className);
ClassDependency dependency = new ClassDependency(this, className, cls);
if (!dependency.isMissing()) {
if (cls.getParent() != null && !cls.getParent().equals(className)) { if (cls.getParent() != null && !cls.getParent().equals(className)) {
linkClass(cls.getParent(), stack); linkClass(cls.getParent(), null);
} }
for (String ifaceName : cls.getInterfaces()) { for (String ifaceName : cls.getInterfaces()) {
linkClass(ifaceName, stack); linkClass(ifaceName, null);
} }
} }
return dependency; return dependency;
@ -241,9 +276,8 @@ public class DependencyChecker implements DependencyInfo, DependencyAgent {
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }
callGraph.getNode(methodRef); callGraph.getNode(methodRef);
if (callLocation != null) { if (callLocation != null && callLocation.getMethod() != null) {
callGraph.addNode(caller); callGraph.getNode(callLocation.getMethod()).addCallSite(methodRef, callLocation.getSourceLocation());
callGraph.getNode(caller).addCallSite(methodRef, location);
} }
return methodCache.map(methodRef); return methodCache.map(methodRef);
} }
@ -306,10 +340,7 @@ public class DependencyChecker implements DependencyInfo, DependencyAgent {
return null; return null;
} }
private MethodDependency createMethodDep(MethodReference methodRef, MethodReader method, DependencyStack stack) { private MethodDependency createMethodDep(MethodReference methodRef, MethodReader method) {
if (stack == null) {
stack = DependencyStack.ROOT;
}
ValueType[] arguments = methodRef.getParameterTypes(); ValueType[] arguments = methodRef.getParameterTypes();
int paramCount = arguments.length + 1; int paramCount = arguments.length + 1;
int varCount = Math.max(paramCount, method != null && method.getProgram() != null ? int varCount = Math.max(paramCount, method != null && method.getProgram() != null ?
@ -335,16 +366,14 @@ public class DependencyChecker implements DependencyInfo, DependencyAgent {
thrown.setTag(methodRef + ":THROWN"); thrown.setTag(methodRef + ":THROWN");
} }
final MethodDependency dep = new MethodDependency(this, parameterNodes, paramCount, resultNode, thrown, final MethodDependency dep = new MethodDependency(this, parameterNodes, paramCount, resultNode, thrown,
stack, method, methodRef); method, methodRef);
if (method != null) { if (method != null) {
final DependencyStack initClassStack = stack;
tasks.add(new Runnable() { tasks.add(new Runnable() {
@Override public void run() { @Override public void run() {
linkClass(dep.getMethod().getOwnerName(), dep.getStack()).initClass(initClassStack); CallLocation caller = new CallLocation(dep.getMethod().getReference());
linkClass(dep.getMethod().getOwnerName(), caller).initClass(caller);
} }
}); });
} else {
missingMethods.add(dep);
} }
return dep; return dep;
} }
@ -374,9 +403,19 @@ public class DependencyChecker implements DependencyInfo, DependencyAgent {
} }
@Override @Override
public FieldDependency linkField(FieldReference fieldRef, MethodReference caller, InstructionLocation location) { public FieldDependency linkField(final FieldReference fieldRef, final CallLocation location) {
fieldStacks.put(fieldRef, stack); if (location != null) {
return fieldCache.map(fieldRef); callGraph.getNode(location.getMethod()).addFieldAccess(fieldRef, location.getSourceLocation());
}
FieldDependency dep = fieldCache.map(fieldRef);
if (!dep.isMissing()) {
tasks.add(new Runnable() {
@Override public void run() {
linkClass(fieldRef.getClassName(), location).initClass(location);
}
});
}
return dep;
} }
@Override @Override
@ -389,19 +428,16 @@ public class DependencyChecker implements DependencyInfo, DependencyAgent {
return classCache.getKnown(className); return classCache.getKnown(className);
} }
private FieldDependency createFieldNode(final FieldReference fieldRef, FieldReader field, private FieldDependency createFieldNode(final FieldReference fieldRef, FieldReader field) {
final DependencyStack stack) {
DependencyNode node = new DependencyNode(this); DependencyNode node = new DependencyNode(this);
if (shouldLog) { if (shouldLog) {
node.setTag(fieldRef.getClassName() + "#" + fieldRef.getFieldName()); node.setTag(fieldRef.getClassName() + "#" + fieldRef.getFieldName());
} }
FieldDependency dep = new FieldDependency(node, stack, field, fieldRef); FieldDependency dep = new FieldDependency(node, field, fieldRef);
if (dep.isMissing()) { if (!dep.isMissing()) {
missingFields.add(dep);
} else {
tasks.add(new Runnable() { tasks.add(new Runnable() {
@Override public void run() { @Override public void run() {
linkClass(fieldRef.getClassName(), stack).initClass(stack); linkClass(fieldRef.getClassName(), null).initClass(null);
} }
}); });
} }

View File

@ -63,7 +63,7 @@ class DependencyGraphBuilder {
} }
for (TryCatchBlockReader tryCatch : block.readTryCatchBlocks()) { for (TryCatchBlockReader tryCatch : block.readTryCatchBlocks()) {
if (tryCatch.getExceptionType() != null) { if (tryCatch.getExceptionType() != null) {
dependencyChecker.linkClass(tryCatch.getExceptionType(), caller.getMethod(), null); dependencyChecker.linkClass(tryCatch.getExceptionType(), new CallLocation(caller.getMethod()));
} }
} }
} }
@ -151,7 +151,7 @@ class DependencyGraphBuilder {
return; return;
} }
MethodReference methodRef = new MethodReference(className, methodDesc); MethodReference methodRef = new MethodReference(className, methodDesc);
MethodDependency methodDep = checker.linkMethod(methodRef, caller.getMethod(), location); MethodDependency methodDep = checker.linkMethod(methodRef, new CallLocation(caller.getMethod(), location));
if (!methodDep.isMissing() && knownMethods.add(methodRef)) { if (!methodDep.isMissing() && knownMethods.add(methodRef)) {
methodDep.use(); methodDep.use();
DependencyNode[] targetParams = methodDep.getVariables(); DependencyNode[] targetParams = methodDep.getVariables();
@ -204,7 +204,7 @@ class DependencyGraphBuilder {
} }
if (cst instanceof ValueType.Object) { if (cst instanceof ValueType.Object) {
final String className = ((ValueType.Object)cst).getClassName(); final String className = ((ValueType.Object)cst).getClassName();
dependencyChecker.linkClass(className, caller.getMethod(), currentLocation); dependencyChecker.linkClass(className, new CallLocation(caller.getMethod(), currentLocation));
} }
} }
@ -232,7 +232,7 @@ class DependencyGraphBuilder {
public void stringConstant(VariableReader receiver, String cst) { public void stringConstant(VariableReader receiver, String cst) {
nodes[receiver.getIndex()].propagate(dependencyChecker.getType("java.lang.String")); nodes[receiver.getIndex()].propagate(dependencyChecker.getType("java.lang.String"));
MethodDependency method = dependencyChecker.linkMethod(new MethodReference(String.class, MethodDependency method = dependencyChecker.linkMethod(new MethodReference(String.class,
"<init>", char[].class, void.class), caller.getMethod(), currentLocation); "<init>", char[].class, void.class), new CallLocation(caller.getMethod(), currentLocation));
method.use(); method.use();
} }
@ -320,7 +320,7 @@ class DependencyGraphBuilder {
nodes[receiver.getIndex()].propagate(dependencyChecker.getType("[" + itemType)); nodes[receiver.getIndex()].propagate(dependencyChecker.getType("[" + itemType));
String className = extractClassName(itemType); String className = extractClassName(itemType);
if (className != null) { if (className != null) {
dependencyChecker.linkClass(className, caller.getMethod(), currentLocation); dependencyChecker.linkClass(className, new CallLocation(caller.getMethod(), currentLocation));
} }
} }
@ -342,7 +342,7 @@ class DependencyGraphBuilder {
nodes[receiver.getIndex()].propagate(dependencyChecker.getType(sb.toString())); nodes[receiver.getIndex()].propagate(dependencyChecker.getType(sb.toString()));
String className = extractClassName(itemType); String className = extractClassName(itemType);
if (className != null) { if (className != null) {
dependencyChecker.linkClass(className, caller.getMethod(), currentLocation); dependencyChecker.linkClass(className, new CallLocation(caller.getMethod(), currentLocation));
} }
} }
@ -354,7 +354,8 @@ class DependencyGraphBuilder {
@Override @Override
public void getField(VariableReader receiver, VariableReader instance, FieldReference field, public void getField(VariableReader receiver, VariableReader instance, FieldReference field,
ValueType fieldType) { ValueType fieldType) {
FieldDependency fieldDep = dependencyChecker.linkField(field, caller.getMethod(), currentLocation); FieldDependency fieldDep = dependencyChecker.linkField(field,
new CallLocation(caller.getMethod(), currentLocation));
DependencyNode receiverNode = nodes[receiver.getIndex()]; DependencyNode receiverNode = nodes[receiver.getIndex()];
fieldDep.getValue().connect(receiverNode); fieldDep.getValue().connect(receiverNode);
initClass(field.getClassName()); initClass(field.getClassName());
@ -362,7 +363,8 @@ class DependencyGraphBuilder {
@Override @Override
public void putField(VariableReader instance, FieldReference field, VariableReader value) { public void putField(VariableReader instance, FieldReference field, VariableReader value) {
FieldDependency fieldDep = dependencyChecker.linkField(field, caller.getMethod(), currentLocation); FieldDependency fieldDep = dependencyChecker.linkField(field,
new CallLocation(caller.getMethod(), currentLocation));
DependencyNode valueNode = nodes[value.getIndex()]; DependencyNode valueNode = nodes[value.getIndex()];
valueNode.connect(fieldDep.getValue()); valueNode.connect(fieldDep.getValue());
initClass(field.getClassName()); initClass(field.getClassName());
@ -424,7 +426,8 @@ class DependencyGraphBuilder {
private void invokeSpecial(VariableReader receiver, VariableReader instance, MethodReference method, private void invokeSpecial(VariableReader receiver, VariableReader instance, MethodReference method,
List<? extends VariableReader> arguments) { List<? extends VariableReader> arguments) {
MethodDependency methodDep = dependencyChecker.linkMethod(method, caller.getMethod(), currentLocation); MethodDependency methodDep = dependencyChecker.linkMethod(method,
new CallLocation(caller.getMethod(), currentLocation));
if (methodDep.isMissing()) { if (methodDep.isMissing()) {
return; return;
} }
@ -445,7 +448,8 @@ class DependencyGraphBuilder {
private void invokeVirtual(VariableReader receiver, VariableReader instance, MethodReference method, private void invokeVirtual(VariableReader receiver, VariableReader instance, MethodReference method,
List<? extends VariableReader> arguments) { List<? extends VariableReader> arguments) {
MethodDependency methodDep = dependencyChecker.linkMethod(method, caller.getMethod(), currentLocation); MethodDependency methodDep = dependencyChecker.linkMethod(method,
new CallLocation(caller.getMethod(), currentLocation));
if (methodDep.isMissing()) { if (methodDep.isMissing()) {
return; return;
} }
@ -466,14 +470,14 @@ class DependencyGraphBuilder {
public void isInstance(VariableReader receiver, VariableReader value, final ValueType type) { public void isInstance(VariableReader receiver, VariableReader value, final ValueType type) {
String className = extractClassName(type); String className = extractClassName(type);
if (className != null) { if (className != null) {
dependencyChecker.linkClass(className, caller.getMethod(), currentLocation); dependencyChecker.linkClass(className, new CallLocation(caller.getMethod(), currentLocation));
} }
} }
@Override @Override
public void initClass(final String className) { public void initClass(final String className) {
dependencyChecker.linkClass(className, caller.getMethod(), currentLocation) CallLocation callLocation = new CallLocation(caller.getMethod(), currentLocation);
.initClass(caller.getMethod(), currentLocation); dependencyChecker.linkClass(className, callLocation).initClass(callLocation);
} }
@Override @Override
@ -482,7 +486,7 @@ class DependencyGraphBuilder {
DependencyNode receiverNode = nodes[receiver.getIndex()]; DependencyNode receiverNode = nodes[receiver.getIndex()];
valueNode.connect(receiverNode); valueNode.connect(receiverNode);
dependencyChecker.linkMethod(new MethodReference(NullPointerException.class, "<init>", void.class), dependencyChecker.linkMethod(new MethodReference(NullPointerException.class, "<init>", void.class),
caller.getMethod(), currentLocation).use(); new CallLocation(caller.getMethod(), currentLocation)).use();
currentExceptionConsumer.consume(dependencyChecker.getType("java.lang.NullPointerException")); currentExceptionConsumer.consume(dependencyChecker.getType("java.lang.NullPointerException"));
} }
}; };

View File

@ -24,13 +24,11 @@ import org.teavm.model.FieldReference;
*/ */
public class FieldDependency implements FieldDependencyInfo { public class FieldDependency implements FieldDependencyInfo {
private DependencyNode value; private DependencyNode value;
private DependencyStack stack;
private FieldReader field; private FieldReader field;
private FieldReference reference; private FieldReference reference;
FieldDependency(DependencyNode value, DependencyStack stack, FieldReader field, FieldReference reference) { FieldDependency(DependencyNode value, FieldReader field, FieldReference reference) {
this.value = value; this.value = value;
this.stack = stack;
this.field = field; this.field = field;
this.reference = reference; this.reference = reference;
} }
@ -40,11 +38,6 @@ public class FieldDependency implements FieldDependencyInfo {
return value; return value;
} }
@Override
public DependencyStack getStack() {
return stack;
}
public FieldReader getField() { public FieldReader getField() {
return field; return field;
} }

View File

@ -29,20 +29,17 @@ public class MethodDependency implements MethodDependencyInfo {
private int parameterCount; private int parameterCount;
private DependencyNode resultNode; private DependencyNode resultNode;
private DependencyNode thrown; private DependencyNode thrown;
private DependencyStack stack;
private MethodReader method; private MethodReader method;
private MethodReference reference; private MethodReference reference;
private boolean used; private boolean used;
MethodDependency(DependencyChecker dependencyChecker, DependencyNode[] variableNodes, int parameterCount, MethodDependency(DependencyChecker dependencyChecker, DependencyNode[] variableNodes, int parameterCount,
DependencyNode resultNode, DependencyNode thrown, DependencyStack stack, MethodReader method, DependencyNode resultNode, DependencyNode thrown, MethodReader method, MethodReference reference) {
MethodReference reference) {
this.dependencyChecker = dependencyChecker; this.dependencyChecker = dependencyChecker;
this.variableNodes = Arrays.copyOf(variableNodes, variableNodes.length); this.variableNodes = Arrays.copyOf(variableNodes, variableNodes.length);
this.parameterCount = parameterCount; this.parameterCount = parameterCount;
this.thrown = thrown; this.thrown = thrown;
this.resultNode = resultNode; this.resultNode = resultNode;
this.stack = stack;
this.method = method; this.method = method;
this.reference = reference; this.reference = reference;
} }
@ -81,11 +78,6 @@ public class MethodDependency implements MethodDependencyInfo {
return thrown; return thrown;
} }
@Override
public DependencyStack getStack() {
return stack;
}
@Override @Override
public MethodReference getReference() { public MethodReference getReference() {
return reference; return reference;

View File

@ -16,6 +16,7 @@
package org.teavm.diagnostics; package org.teavm.diagnostics;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.List; import java.util.List;
import org.teavm.model.CallLocation; import org.teavm.model.CallLocation;
@ -23,9 +24,11 @@ import org.teavm.model.CallLocation;
* *
* @author Alexey Andreev <konsoletyper@gmail.com> * @author Alexey Andreev <konsoletyper@gmail.com>
*/ */
public class AccumulationDiagnostics implements Diagnostics { public class AccumulationDiagnostics implements Diagnostics, ProblemProvider {
private List<Problem> problems = new ArrayList<>(); private List<Problem> problems = new ArrayList<>();
private List<Problem> readonlyProblems = Collections.unmodifiableList(problems);
private List<Problem> severeProblems = new ArrayList<>(); private List<Problem> severeProblems = new ArrayList<>();
private List<Problem> readonlySevereProblems = Collections.unmodifiableList(severeProblems);
@Override @Override
public void error(CallLocation location, String error, Object... params) { public void error(CallLocation location, String error, Object... params) {
@ -40,11 +43,13 @@ public class AccumulationDiagnostics implements Diagnostics {
problems.add(problem); problems.add(problem);
} }
@Override
public List<Problem> getProblems() { public List<Problem> getProblems() {
return problems; return readonlyProblems;
} }
@Override
public List<Problem> getSevereProblems() { public List<Problem> getSevereProblems() {
return severeProblems; return readonlySevereProblems;
} }
} }

View File

@ -0,0 +1,28 @@
/*
* Copyright 2014 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.diagnostics;
import java.util.List;
/**
*
* @author Alexey Andreev
*/
public interface ProblemProvider {
List<Problem> getProblems();
List<Problem> getSevereProblems();
}

View File

@ -25,7 +25,14 @@ public class CallLocation {
private MethodReference method; private MethodReference method;
private InstructionLocation sourceLocation; private InstructionLocation sourceLocation;
public CallLocation(MethodReference method) {
this(method, null);
}
public CallLocation(MethodReference method, InstructionLocation sourceLocation) { public CallLocation(MethodReference method, InstructionLocation sourceLocation) {
if (method == null) {
throw new IllegalArgumentException("Method must not be null");
}
this.method = method; this.method = method;
this.sourceLocation = sourceLocation; this.sourceLocation = sourceLocation;
} }

View File

@ -366,21 +366,11 @@ public class TeaVMTestTool {
vm.exportType("TestClass", cons.getClassName()); vm.exportType("TestClass", cons.getClassName());
vm.setDebugEmitter(debugInfoBuilder); vm.setDebugEmitter(debugInfoBuilder);
vm.build(innerWriter, new DirectoryBuildTarget(outputDir)); vm.build(innerWriter, new DirectoryBuildTarget(outputDir));
if (!vm.hasMissingItems()) { innerWriter.append("\n");
innerWriter.append("\n"); innerWriter.append("\nJUnitClient.run();");
innerWriter.append("\nJUnitClient.run();"); if (sourceMapsGenerated) {
if (sourceMapsGenerated) { String sourceMapsFileName = targetName.substring(targetName.lastIndexOf('/') + 1) + ".map";
String sourceMapsFileName = targetName.substring(targetName.lastIndexOf('/') + 1) + ".map"; innerWriter.append("\n//# sourceMappingURL=").append(sourceMapsFileName);
innerWriter.append("\n//# sourceMappingURL=").append(sourceMapsFileName);
}
} else {
innerWriter.append("JUnitClient.reportError(\n");
StringBuilder sb = new StringBuilder();
vm.showMissingItems(sb);
escapeStringLiteral(sb.toString(), innerWriter);
innerWriter.append(");");
log.warning("Error building test " + methodRef);
log.warning(sb.toString());
} }
} }
if (sourceMapsGenerated) { if (sourceMapsGenerated) {
@ -402,20 +392,6 @@ public class TeaVMTestTool {
} }
} }
private void escapeStringLiteral(String text, Writer writer) throws IOException {
int index = 0;
while (true) {
int next = text.indexOf('\n', index);
if (next < 0) {
break;
}
escapeString(text.substring(index, next + 1), writer);
writer.append(" +\n");
index = next + 1;
}
escapeString(text.substring(index), writer);
}
private void escapeString(String string, Writer writer) throws IOException { private void escapeString(String string, Writer writer) throws IOException {
writer.append('\"'); writer.append('\"');
for (int i = 0; i < string.length(); ++i) { for (int i = 0; i < string.length(); ++i) {

View File

@ -24,6 +24,7 @@ import org.teavm.cache.DiskRegularMethodNodeCache;
import org.teavm.cache.FileSymbolTable; import org.teavm.cache.FileSymbolTable;
import org.teavm.debugging.information.DebugInformation; import org.teavm.debugging.information.DebugInformation;
import org.teavm.debugging.information.DebugInformationBuilder; import org.teavm.debugging.information.DebugInformationBuilder;
import org.teavm.diagnostics.ProblemProvider;
import org.teavm.javascript.RenderingContext; import org.teavm.javascript.RenderingContext;
import org.teavm.model.*; import org.teavm.model.*;
import org.teavm.parsing.ClasspathClassHolderSource; import org.teavm.parsing.ClasspathClassHolderSource;
@ -199,6 +200,10 @@ public class TeaVMTool {
return cancelled; return cancelled;
} }
public ProblemProvider getProblemProvider() {
return vm != null ? vm.getProblemProvider() : null;
}
public Collection<String> getClasses() { public Collection<String> getClasses() {
return vm != null ? vm.getClasses() : Collections.<String>emptyList(); return vm != null ? vm.getClasses() : Collections.<String>emptyList();
} }
@ -289,10 +294,6 @@ public class TeaVMTool {
cancelled = true; cancelled = true;
return; return;
} }
if (vm.hasMissingItems()) {
log.info("Missing items found");
return;
}
log.info("JavaScript file successfully built"); log.info("JavaScript file successfully built");
if (debugInformationGenerated) { if (debugInformationGenerated) {
DebugInformation debugInfo = debugEmitter.getDebugInformation(); DebugInformation debugInfo = debugEmitter.getDebugInformation();
@ -344,10 +345,6 @@ public class TeaVMTool {
} }
} }
public void checkForMissingItems() {
vm.checkForViolations();
}
private void copySourceFiles() { private void copySourceFiles() {
if (vm.getWrittenClasses() == null) { if (vm.getWrittenClasses() == null) {
return; return;

View File

@ -23,6 +23,7 @@ import org.teavm.debugging.information.DebugInformationEmitter;
import org.teavm.debugging.information.SourceLocation; import org.teavm.debugging.information.SourceLocation;
import org.teavm.dependency.*; import org.teavm.dependency.*;
import org.teavm.diagnostics.AccumulationDiagnostics; import org.teavm.diagnostics.AccumulationDiagnostics;
import org.teavm.diagnostics.ProblemProvider;
import org.teavm.javascript.*; import org.teavm.javascript.*;
import org.teavm.javascript.ast.ClassNode; import org.teavm.javascript.ast.ClassNode;
import org.teavm.javascript.ni.Generator; import org.teavm.javascript.ni.Generator;
@ -214,6 +215,10 @@ public class TeaVM implements TeaVMHost, ServiceRepository {
return cancelled; return cancelled;
} }
public ProblemProvider getProblemProvider() {
return diagnostics;
}
/** /**
* <p>Adds an entry point. TeaVM guarantees, that all methods that are required by the entry point * <p>Adds an entry point. TeaVM guarantees, that all methods that are required by the entry point
* will be available at run-time in browser. Also you need to specify for each parameter of entry point * will be available at run-time in browser. Also you need to specify for each parameter of entry point