Adds a new dependency event that is emitted when dependency checker is

about to start. Adds ability to examine classes from generators.
This commit is contained in:
konsoletyper 2014-02-13 22:59:30 +04:00
parent e5ea6b51a7
commit 4dd9eaa1fd
5 changed files with 18 additions and 0 deletions

View File

@ -89,6 +89,12 @@ public class DependencyChecker implements DependencyInformation {
listeners.add(listener);
}
public void startListeners() {
for (DependencyListener listener : listeners) {
listener.started(this);
}
}
public void addEntryPoint(MethodReference methodRef, String... argumentTypes) {
ValueType[] parameters = methodRef.getDescriptor().getParameterTypes();
if (parameters.length != argumentTypes.length) {

View File

@ -23,6 +23,8 @@ import org.teavm.model.MethodReference;
* @author Alexey Andreev
*/
public interface DependencyListener {
void started(DependencyChecker dependencyChecker);
void classAchieved(DependencyChecker dependencyChecker, String className);
void methodAchieved(DependencyChecker dependencyChecker, MethodReference method);

View File

@ -112,6 +112,7 @@ public class JavascriptBuilder implements JavascriptBuilderHost {
SourceWriterBuilder builder = new SourceWriterBuilder(naming);
builder.setMinified(minifying);
SourceWriter sourceWriter = builder.build(writer);
dependencyChecker.startListeners();
dependencyChecker.attachMethodGraph(new MethodReference("java.lang.Class", new MethodDescriptor("createNew",
ValueType.object("java.lang.Class"))));
dependencyChecker.attachMethodGraph(new MethodReference("java.lang.String", new MethodDescriptor("<init>",

View File

@ -373,6 +373,11 @@ public class Renderer implements ExprVisitor, StatementVisitor {
public String getParameterName(int index) {
return variableName(index);
}
@Override
public ClassReaderSource getClassSource() {
return classSource;
}
}
@Override

View File

@ -15,10 +15,14 @@
*/
package org.teavm.javascript.ni;
import org.teavm.model.ClassReaderSource;
/**
*
* @author Alexey Andreev <konsoletyper@gmail.com>
*/
public interface GeneratorContext {
String getParameterName(int index);
ClassReaderSource getClassSource();
}