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); listeners.add(listener);
} }
public void startListeners() {
for (DependencyListener listener : listeners) {
listener.started(this);
}
}
public void addEntryPoint(MethodReference methodRef, String... argumentTypes) { public void addEntryPoint(MethodReference methodRef, String... argumentTypes) {
ValueType[] parameters = methodRef.getDescriptor().getParameterTypes(); ValueType[] parameters = methodRef.getDescriptor().getParameterTypes();
if (parameters.length != argumentTypes.length) { if (parameters.length != argumentTypes.length) {

View File

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

View File

@ -112,6 +112,7 @@ public class JavascriptBuilder implements JavascriptBuilderHost {
SourceWriterBuilder builder = new SourceWriterBuilder(naming); SourceWriterBuilder builder = new SourceWriterBuilder(naming);
builder.setMinified(minifying); builder.setMinified(minifying);
SourceWriter sourceWriter = builder.build(writer); SourceWriter sourceWriter = builder.build(writer);
dependencyChecker.startListeners();
dependencyChecker.attachMethodGraph(new MethodReference("java.lang.Class", new MethodDescriptor("createNew", dependencyChecker.attachMethodGraph(new MethodReference("java.lang.Class", new MethodDescriptor("createNew",
ValueType.object("java.lang.Class")))); ValueType.object("java.lang.Class"))));
dependencyChecker.attachMethodGraph(new MethodReference("java.lang.String", new MethodDescriptor("<init>", 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) { public String getParameterName(int index) {
return variableName(index); return variableName(index);
} }
@Override
public ClassReaderSource getClassSource() {
return classSource;
}
} }
@Override @Override

View File

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