1.1 --- a/vm/src/main/java/org/apidesign/vm4brwsr/ByteCodeToJavaScript.java Fri Sep 28 07:48:24 2012 +0200
1.2 +++ b/vm/src/main/java/org/apidesign/vm4brwsr/ByteCodeToJavaScript.java Fri Sep 28 07:52:17 2012 +0200
1.3 @@ -90,11 +90,6 @@
1.4 final String className = jc.getName().getInternalName().replace('/', '_');
1.5 out.append("\nfunction ").append(className);
1.6 out.append("() {");
1.7 - for (Method m : jc.getMethods()) {
1.8 - if (!m.isStatic() && !m.isPrivate() && !m.getName().contains("<init>")) {
1.9 - compiler.generateMethodReference(m);
1.10 - }
1.11 - }
1.12 for (Variable v : jc.getVariables()) {
1.13 if (!v.isStatic()) {
1.14 out.append("\n this." + v.getName() + " = 0;");
1.15 @@ -110,6 +105,11 @@
1.16 out.append("\n").append(className)
1.17 .append(".prototype = new ").append(sc.getInternalName().replace('/', '_'));
1.18 }
1.19 + for (Method m : jc.getMethods()) {
1.20 + if (!m.isStatic() && !m.isPrivate() && !m.getName().contains("<init>")) {
1.21 + compiler.generateMethodReference("\n" + className + ".prototype.", m);
1.22 + }
1.23 + }
1.24 for (String init : toInitilize) {
1.25 out.append("\n").append(init).append("();");
1.26 }
1.27 @@ -152,9 +152,9 @@
1.28 out.append("}");
1.29 }
1.30
1.31 - private void generateMethodReference(Method m) throws IOException {
1.32 + private void generateMethodReference(String prefix, Method m) throws IOException {
1.33 final String name = findMethodName(m);
1.34 - out.append("\n this.").append(name).append(" = ")
1.35 + out.append(prefix).append(name).append(" = ")
1.36 .append(jc.getName().getInternalName().replace('/', '_'))
1.37 .append('_').append(name).append(";");
1.38 }