1.1 --- a/vm/src/main/java/org/apidesign/vm4brwsr/ByteCodeToJavaScript.java Tue Oct 09 18:26:23 2012 -0700
1.2 +++ b/vm/src/main/java/org/apidesign/vm4brwsr/ByteCodeToJavaScript.java Tue Oct 09 18:47:42 2012 -0700
1.3 @@ -70,11 +70,12 @@
1.4 * JVM form so String is <code>java/lang/String</code>. Can be <code>null</code>
1.5 * if one is not interested in knowing references
1.6 * @param scripts write only collection with names of resources to read
1.7 + * @return the initialization code for this class, if any. Otherwise <code>null</code>
1.8 *
1.9 * @throws IOException if something goes wrong during read or write or translating
1.10 */
1.11
1.12 - public static void compile(
1.13 + public static String compile(
1.14 InputStream classFile, Appendable out,
1.15 Collection<? super String> references,
1.16 Collection<? super String> scripts
1.17 @@ -88,7 +89,7 @@
1.18 scripts.add(res);
1.19 final AnnotationComponent process = a.getComponent("processByteCode");
1.20 if (process != null && "const=0".equals(process.getValue().toString())) {
1.21 - return;
1.22 + return null;
1.23 }
1.24 }
1.25
1.26 @@ -132,9 +133,12 @@
1.27 for (ClassName superInterface : jc.getInterfaces()) {
1.28 out.append("\n" + className + ".prototype.$instOf_").append(superInterface.getInternalName().replace('/', '_')).append(" = true;");
1.29 }
1.30 +
1.31 + StringBuilder sb = new StringBuilder();
1.32 for (String init : toInitilize) {
1.33 - out.append("\n").append(init).append("();");
1.34 + sb.append("\n").append(init).append("();");
1.35 }
1.36 + return sb.toString();
1.37 }
1.38 private void generateStaticMethod(Method m, List<String> toInitilize) throws IOException {
1.39 if (javaScriptBody(m, true)) {