diff -r 9d6130cb464f -r 2ac4283ee209 rt/vm/src/main/java/org/apidesign/vm4brwsr/ClosureWrapper.java --- a/rt/vm/src/main/java/org/apidesign/vm4brwsr/ClosureWrapper.java Mon May 06 11:57:29 2013 +0200 +++ b/rt/vm/src/main/java/org/apidesign/vm4brwsr/ClosureWrapper.java Wed May 08 14:54:32 2013 +0200 @@ -37,19 +37,23 @@ private final Bck2Brwsr.Resources res; private final StringArray classes; + private final boolean extension; private String compiledCode; private String externsCode; private ClosureWrapper(Appendable out, String compilationLevel, - Bck2Brwsr.Resources res, StringArray classes) { + Bck2Brwsr.Resources res, + StringArray classes, + boolean extension) { super( generateArguments(compilationLevel), new PrintStream(new APS(out)), System.err ); this.res = res; this.classes = classes; + this.extension = extension; } @Override @@ -92,7 +96,7 @@ if (compiledCode == null) { StringBuilder sb = new StringBuilder(); try { - VM.compileStandalone(res, sb, classes); + VM.compile(sb, res, classes, extension); compiledCode = sb.toString(); } catch (IOException ex) { compiledCode = ex.getMessage(); @@ -134,8 +138,17 @@ return finalArgs; } - static int produceTo(Appendable w, ObfuscationLevel obfuscationLevel, Bck2Brwsr.Resources resources, StringArray arr) throws IOException { - ClosureWrapper cw = create(w, obfuscationLevel, resources, arr); + static int produceTo(Appendable output, + ObfuscationLevel obfuscationLevel, + Bck2Brwsr.Resources resources, + StringArray arr, + boolean extension) throws IOException { + final ClosureWrapper cw = + new ClosureWrapper(output, + (obfuscationLevel == ObfuscationLevel.FULL) + ? "ADVANCED_OPTIMIZATIONS" + : "SIMPLE_OPTIMIZATIONS", + resources, arr, extension); try { return cw.doRun(); } catch (FlagUsageException ex) { @@ -143,24 +156,6 @@ } } - private static ClosureWrapper create(Appendable w, - ObfuscationLevel obfuscationLevel, - Bck2Brwsr.Resources resources, - StringArray arr) { - switch (obfuscationLevel) { - case MINIMAL: - return new ClosureWrapper(w, "SIMPLE_OPTIMIZATIONS", - resources, arr); - - case FULL: - return new ClosureWrapper(w, "ADVANCED_OPTIMIZATIONS", - resources, arr); - default: - throw new IllegalArgumentException( - "Unsupported level: " + obfuscationLevel); - } - } - private static final String[] FIXED_EXTERNS = { "bck2brwsr", "$class",