diff -r 18b3a9a85716 -r 4fef6b767f61 rt/vm/src/main/java/org/apidesign/vm4brwsr/VM.java --- a/rt/vm/src/main/java/org/apidesign/vm4brwsr/VM.java Fri Feb 27 18:11:54 2015 +0100 +++ b/rt/vm/src/main/java/org/apidesign/vm4brwsr/VM.java Wed Mar 11 18:58:39 2015 +0100 @@ -20,6 +20,7 @@ import java.io.IOException; import java.io.InputStream; import org.apidesign.bck2brwsr.core.JavaScriptBody; +import org.apidesign.vm4brwsr.Bck2Brwsr.Flow; import org.apidesign.vm4brwsr.ByteCodeParser.ClassData; import org.apidesign.vm4brwsr.ByteCodeParser.FieldData; import org.apidesign.vm4brwsr.ByteCodeParser.MethodData; @@ -35,11 +36,12 @@ private final ExportedSymbols exportedSymbols; private final StringBuilder invokerMethods; private final StringArray asBinary; + private final Flow.Analyzer flow; int exportedCount; private VM( Appendable out, Bck2Brwsr.Resources resources, - StringArray explicitlyExported, StringArray asBinary + StringArray explicitlyExported, StringArray asBinary, Flow.Analyzer flow ) { super(out); this.resources = resources; @@ -47,6 +49,7 @@ this.exportedSymbols = new ExportedSymbols(resources, explicitlyExported); this.invokerMethods = new StringBuilder(); this.asBinary = asBinary; + this.flow = flow; } static { @@ -79,7 +82,8 @@ fixedNames.add(VM.class.getName().replace('.', '/')); vm = new Extension(out, config.getResources(), both, config.exported(), - config.allResources(), config.classpath() + config.allResources(), config.classpath(), + config.flow() ); } else { if (config.includeVM()) { @@ -87,7 +91,8 @@ } vm = new Standalone(out, config.getResources(), config.exported(), - config.allResources() + config.allResources(), + config.flow() ); } vm.doCompile(fixedNames.addAndNew(both)); @@ -419,6 +424,15 @@ return object + "." + mangledName; } + @Override + protected Flow checkFlow(byte[] byteCodes) { + if (flow == null) { + return null; + } + Flow f = new Flow(byteCodes); + return flow.analyze(f) ? f : null; + } + private final class ExportedMethodFinder implements ClassDataCache.TraversalCallback { private final ExportedSymbols exportedSymbols; @@ -452,9 +466,10 @@ private static final class Standalone extends VM { private Standalone(Appendable out, Bck2Brwsr.Resources resources, - StringArray explicitlyExported, StringArray asBinary + StringArray explicitlyExported, StringArray asBinary, + Flow.Analyzer flow ) { - super(out, resources, explicitlyExported, asBinary); + super(out, resources, explicitlyExported, asBinary, flow); } @Override @@ -700,9 +715,9 @@ private Extension(Appendable out, Bck2Brwsr.Resources resources, String[] extClassesArray, StringArray explicitlyExported, - StringArray asBinary, StringArray classpath + StringArray asBinary, StringArray classpath, Flow.Analyzer flow ) throws IOException { - super(out, resources, explicitlyExported, asBinary); + super(out, resources, explicitlyExported, asBinary, flow); this.extensionClasses = StringArray.asList(extClassesArray); this.classpath = classpath; }