diff -r 519bcc6999c4 -r 437df2a719e7 vm/src/main/java/org/apidesign/vm4brwsr/ByteCodeToJavaScript.java
--- a/vm/src/main/java/org/apidesign/vm4brwsr/ByteCodeToJavaScript.java Tue Oct 09 18:26:23 2012 -0700
+++ b/vm/src/main/java/org/apidesign/vm4brwsr/ByteCodeToJavaScript.java Tue Oct 09 18:47:42 2012 -0700
@@ -70,11 +70,12 @@
* JVM form so String is java/lang/String
. Can be null
* if one is not interested in knowing references
* @param scripts write only collection with names of resources to read
+ * @return the initialization code for this class, if any. Otherwise null
*
* @throws IOException if something goes wrong during read or write or translating
*/
- public static void compile(
+ public static String compile(
InputStream classFile, Appendable out,
Collection super String> references,
Collection super String> scripts
@@ -88,7 +89,7 @@
scripts.add(res);
final AnnotationComponent process = a.getComponent("processByteCode");
if (process != null && "const=0".equals(process.getValue().toString())) {
- return;
+ return null;
}
}
@@ -132,9 +133,12 @@
for (ClassName superInterface : jc.getInterfaces()) {
out.append("\n" + className + ".prototype.$instOf_").append(superInterface.getInternalName().replace('/', '_')).append(" = true;");
}
+
+ StringBuilder sb = new StringBuilder();
for (String init : toInitilize) {
- out.append("\n").append(init).append("();");
+ sb.append("\n").append(init).append("();");
}
+ return sb.toString();
}
private void generateStaticMethod(Method m, List toInitilize) throws IOException {
if (javaScriptBody(m, true)) {