Almost rewritten to javap: @JavaScriptBody and double/long may not yet be supported
1.1 --- a/javap/pom.xml Sat Nov 10 20:31:39 2012 +0100
1.2 +++ b/javap/pom.xml Sun Nov 11 13:23:52 2012 +0100
1.3 @@ -25,8 +25,8 @@
1.4 <compilerArguments>
1.5 <bootclasspath>non-existing</bootclasspath>
1.6 </compilerArguments>
1.7 - <source>1.7</source>
1.8 - <target>1.7</target>
1.9 + <source>1.6</source>
1.10 + <target>1.6</target>
1.11 </configuration>
1.12 </plugin>
1.13 </plugins>
2.1 --- a/javap/src/main/java/sun/tools/javap/ClassData.java Sat Nov 10 20:31:39 2012 +0100
2.2 +++ b/javap/src/main/java/sun/tools/javap/ClassData.java Sun Nov 11 13:23:52 2012 +0100
2.3 @@ -26,7 +26,6 @@
2.4
2.5 package sun.tools.javap;
2.6
2.7 -import java.util.*;
2.8 import java.io.*;
2.9
2.10 /**
2.11 @@ -35,7 +34,7 @@
2.12 *
2.13 * @author Sucheta Dambalkar (Adopted code from jdis)
2.14 */
2.15 -public class ClassData implements RuntimeConstants {
2.16 +public final class ClassData implements RuntimeConstants {
2.17
2.18 private int magic;
2.19 private int minor_version;
2.20 @@ -220,7 +219,11 @@
2.21 * get a string
2.22 */
2.23 public String getString(int n) {
2.24 - return (n == 0) ? null : (String)cpool[n];
2.25 + if (n == 0) {
2.26 + return null;
2.27 + } else {
2.28 + return (String)cpool[n];
2.29 + }
2.30 }
2.31
2.32 /**
2.33 @@ -481,6 +484,9 @@
2.34 * Returns string at that index.
2.35 */
2.36 public String StringValue(int cpx) {
2.37 + return stringValue(cpx, false);
2.38 + }
2.39 + public String stringValue(int cpx, boolean textual) {
2.40 if (cpx==0) return "#0";
2.41 int tag;
2.42 Object x;
2.43 @@ -512,15 +518,24 @@
2.44 case CONSTANT_DOUBLE: {
2.45 Double d=(Double)x;
2.46 String sd=d.toString();
2.47 + if (textual) {
2.48 + return sd;
2.49 + }
2.50 return sd+"d";
2.51 }
2.52 case CONSTANT_FLOAT: {
2.53 Float f=(Float)x;
2.54 String sf=(f).toString();
2.55 + if (textual) {
2.56 + return sf;
2.57 + }
2.58 return sf+"f";
2.59 }
2.60 case CONSTANT_LONG: {
2.61 Long ln = (Long)x;
2.62 + if (textual) {
2.63 + return ln.toString();
2.64 + }
2.65 return ln.toString()+'l';
2.66 }
2.67 case CONSTANT_INTEGER: {
2.68 @@ -528,9 +543,17 @@
2.69 return in.toString();
2.70 }
2.71 case CONSTANT_CLASS:
2.72 + if (textual) {
2.73 + return "new java_lang_Class"; // XXX temporary JS
2.74 + }
2.75 return javaName(getClassName(cpx));
2.76 case CONSTANT_STRING:
2.77 - return StringValue(((CPX)x).cpx);
2.78 + String sv = StringValue(((CPX)x).cpx);
2.79 + if (textual) {
2.80 + return '"' + sv + '"';
2.81 + } else {
2.82 + return sv;
2.83 + }
2.84 case CONSTANT_FIELD:
2.85 case CONSTANT_METHOD:
2.86 case CONSTANT_INTERFACEMETHOD:
2.87 @@ -654,4 +677,22 @@
2.88 private boolean isJavaIdentifierPart(int cp) {
2.89 return isJavaIdentifierStart(cp) || ('0' <= cp && cp <= '9');
2.90 }
2.91 +
2.92 + public String[] getNameAndType(int indx) {
2.93 + return getNameAndType(indx, 0, new String[2]);
2.94 + }
2.95 +
2.96 + private String[] getNameAndType(int indx, int at, String[] arr) {
2.97 + CPX2 c2 = getCpoolEntry(indx);
2.98 + arr[at] = StringValue(c2.cpx1);
2.99 + arr[at + 1] = StringValue(c2.cpx2);
2.100 + return arr;
2.101 + }
2.102 +
2.103 + public String[] getFieldInfoName(int indx) {
2.104 + CPX2 c2 = getCpoolEntry(indx);
2.105 + String[] arr = new String[3];
2.106 + arr[0] = getClassName(c2.cpx1);
2.107 + return getNameAndType(c2.cpx2, 1, arr);
2.108 + }
2.109 }
3.1 --- a/javap/src/main/java/sun/tools/javap/FieldData.java Sat Nov 10 20:31:39 2012 +0100
3.2 +++ b/javap/src/main/java/sun/tools/javap/FieldData.java Sun Nov 11 13:23:52 2012 +0100
3.3 @@ -95,6 +95,10 @@
3.4
3.5 } // end read
3.6
3.7 + public boolean isStatic() {
3.8 + return (access & ACC_STATIC) != 0;
3.9 + }
3.10 +
3.11 /**
3.12 * Returns access of a field.
3.13 */
4.1 --- a/javap/src/main/java/sun/tools/javap/Vector.java Sat Nov 10 20:31:39 2012 +0100
4.2 +++ b/javap/src/main/java/sun/tools/javap/Vector.java Sun Nov 11 13:23:52 2012 +0100
4.3 @@ -22,8 +22,9 @@
4.4 addElement(objectType);
4.5 }
4.6 void addElement(Object obj) {
4.7 - setSize(size() + 1);
4.8 - setElementAt(obj, size());
4.9 + final int s = size();
4.10 + setSize(s + 1);
4.11 + setElementAt(obj, s);
4.12 }
4.13
4.14 int size() {
5.1 --- a/vm/pom.xml Sat Nov 10 20:31:39 2012 +0100
5.2 +++ b/vm/pom.xml Sun Nov 11 13:23:52 2012 +0100
5.3 @@ -59,6 +59,15 @@
5.4 </archive>
5.5 </configuration>
5.6 </plugin>
5.7 + <plugin>
5.8 + <groupId>org.apache.maven.plugins</groupId>
5.9 + <artifactId>maven-compiler-plugin</artifactId>
5.10 + <version>2.3.2</version>
5.11 + <configuration>
5.12 + <source>1.6</source>
5.13 + <target>1.6</target>
5.14 + </configuration>
5.15 + </plugin>
5.16 </plugins>
5.17 </build>
5.18 <dependencies>
5.19 @@ -74,11 +83,6 @@
5.20 </exclusions>
5.21 </dependency>
5.22 <dependency>
5.23 - <groupId>org.netbeans.api</groupId>
5.24 - <artifactId>org-netbeans-modules-classfile</artifactId>
5.25 - <type>jar</type>
5.26 - </dependency>
5.27 - <dependency>
5.28 <groupId>org.apidesign.bck2brwsr</groupId>
5.29 <artifactId>core</artifactId>
5.30 <version>1.0-SNAPSHOT</version>
5.31 @@ -90,5 +94,10 @@
5.32 <version>1.0-SNAPSHOT</version>
5.33 <scope>test</scope>
5.34 </dependency>
5.35 + <dependency>
5.36 + <groupId>${project.groupId}</groupId>
5.37 + <artifactId>javap</artifactId>
5.38 + <version>1.0-SNAPSHOT</version>
5.39 + </dependency>
5.40 </dependencies>
5.41 </project>
6.1 --- a/vm/src/main/java/org/apidesign/vm4brwsr/ByteCodeToJavaScript.java Sat Nov 10 20:31:39 2012 +0100
6.2 +++ b/vm/src/main/java/org/apidesign/vm4brwsr/ByteCodeToJavaScript.java Sun Nov 11 13:23:52 2012 +0100
6.3 @@ -24,35 +24,22 @@
6.4 import java.util.List;
6.5 import org.apidesign.bck2brwsr.core.ExtraJavaScript;
6.6 import org.apidesign.bck2brwsr.core.JavaScriptBody;
6.7 -import org.netbeans.modules.classfile.Annotation;
6.8 -import org.netbeans.modules.classfile.AnnotationComponent;
6.9 -import org.netbeans.modules.classfile.ArrayElementValue;
6.10 -import static org.netbeans.modules.classfile.ByteCodes.*;
6.11 -import org.netbeans.modules.classfile.CPClassInfo;
6.12 -import org.netbeans.modules.classfile.CPEntry;
6.13 -import org.netbeans.modules.classfile.CPFieldInfo;
6.14 -import org.netbeans.modules.classfile.CPMethodInfo;
6.15 -import org.netbeans.modules.classfile.CPStringInfo;
6.16 -import org.netbeans.modules.classfile.ClassFile;
6.17 -import org.netbeans.modules.classfile.ClassName;
6.18 -import org.netbeans.modules.classfile.Code;
6.19 -import org.netbeans.modules.classfile.ElementValue;
6.20 -import org.netbeans.modules.classfile.Method;
6.21 -import org.netbeans.modules.classfile.Parameter;
6.22 -import org.netbeans.modules.classfile.PrimitiveElementValue;
6.23 -import org.netbeans.modules.classfile.Variable;
6.24 +import sun.tools.javap.ClassData;
6.25 +import sun.tools.javap.FieldData;
6.26 +import sun.tools.javap.MethodData;
6.27 +import static sun.tools.javap.RuntimeConstants.*;
6.28
6.29 /** Translator of the code inside class files to JavaScript.
6.30 *
6.31 * @author Jaroslav Tulach <jtulach@netbeans.org>
6.32 */
6.33 public final class ByteCodeToJavaScript {
6.34 - private final ClassFile jc;
6.35 + private final ClassData jc;
6.36 private final Appendable out;
6.37 private final Collection<? super String> references;
6.38
6.39 private ByteCodeToJavaScript(
6.40 - ClassFile jc, Appendable out, Collection<? super String> references
6.41 + ClassData jc, Appendable out, Collection<? super String> references
6.42 ) {
6.43 this.jc = jc;
6.44 this.out = out;
6.45 @@ -80,7 +67,8 @@
6.46 Collection<? super String> references,
6.47 Collection<? super String> scripts
6.48 ) throws IOException {
6.49 - ClassFile jc = new ClassFile(classFile, true);
6.50 + ClassData jc = new ClassData(classFile);
6.51 + /*
6.52 final ClassName extraAnn = ClassName.getClassName(ExtraJavaScript.class.getName().replace('.', '/'));
6.53 Annotation a = jc.getAnnotation(extraAnn);
6.54 if (a != null) {
6.55 @@ -92,28 +80,28 @@
6.56 return null;
6.57 }
6.58 }
6.59 -
6.60 + */
6.61 ByteCodeToJavaScript compiler = new ByteCodeToJavaScript(
6.62 jc, out, references
6.63 );
6.64 List<String> toInitilize = new ArrayList<String>();
6.65 - for (Method m : jc.getMethods()) {
6.66 + for (MethodData m : jc.getMethods()) {
6.67 if (m.isStatic()) {
6.68 compiler.generateStaticMethod(m, toInitilize);
6.69 } else {
6.70 compiler.generateInstanceMethod(m);
6.71 }
6.72 }
6.73 - for (Variable v : jc.getVariables()) {
6.74 + for (FieldData v : jc.getFields()) {
6.75 if (v.isStatic()) {
6.76 compiler.generateStaticField(v);
6.77 }
6.78 }
6.79
6.80 - final String className = jc.getName().getInternalName().replace('/', '_');
6.81 + final String className = className(jc);
6.82 out.append("\nfunction ").append(className);
6.83 out.append("() {");
6.84 - for (Variable v : jc.getVariables()) {
6.85 + for (FieldData v : jc.getFields()) {
6.86 if (!v.isStatic()) {
6.87 out.append("\n this.fld_").
6.88 append(v.getName()).append(" = 0;");
6.89 @@ -124,22 +112,23 @@
6.90 append(".prototype.$instOf_").append(className).append(") {");
6.91 out.append("\n return new ").append(className).append(";");
6.92 out.append("\n }");
6.93 - ClassName sc = jc.getSuperClass();
6.94 + // ClassName sc = jc.getSuperClass();
6.95 + String sc = jc.getSuperClassName(); // with _
6.96 if (sc != null) {
6.97 out.append("\n var p = ").append(className)
6.98 .append(".prototype = ").
6.99 - append(sc.getInternalName().replace('/', '_')).append("_proto();");
6.100 + append(sc.replace('/', '_')).append("_proto();");
6.101 } else {
6.102 out.append("\n var p = ").append(className).append(".prototype;");
6.103 }
6.104 - for (Method m : jc.getMethods()) {
6.105 + for (MethodData m : jc.getMethods()) {
6.106 if (!m.getName().contains("<init>") && !m.getName().contains("<cinit>")) {
6.107 compiler.generateMethodReference("\n p.", m);
6.108 }
6.109 }
6.110 out.append("\n p.$instOf_").append(className).append(" = true;");
6.111 - for (ClassName superInterface : jc.getInterfaces()) {
6.112 - out.append("\n p.$instOf_").append(superInterface.getInternalName().replace('/', '_')).append(" = true;");
6.113 + for (String superInterface : jc.getSuperInterfaces()) {
6.114 + out.append("\n p.$instOf_").append(superInterface.replace('/', '_')).append(" = true;");
6.115 }
6.116 out.append("\n return new ").append(className).append(";");
6.117 out.append("\n}");
6.118 @@ -150,25 +139,25 @@
6.119 }
6.120 return sb.toString();
6.121 }
6.122 - private void generateStaticMethod(Method m, List<String> toInitilize) throws IOException {
6.123 + private void generateStaticMethod(MethodData m, List<String> toInitilize) throws IOException {
6.124 if (javaScriptBody(m, true)) {
6.125 return;
6.126 }
6.127 - final String mn = findMethodName(m);
6.128 + int[] argsCnt = { -1 };
6.129 + final String mn = findMethodName(m, argsCnt);
6.130 out.append("\nfunction ").append(
6.131 - jc.getName().getInternalName().replace('/', '_')
6.132 + className(jc)
6.133 ).append('_').append(mn);
6.134 if (mn.equals("classV")) {
6.135 - toInitilize.add(jc.getName().getInternalName().replace('/', '_') + '_' + mn);
6.136 + toInitilize.add(className(jc) + '_' + mn);
6.137 }
6.138 out.append('(');
6.139 String space = "";
6.140 - List<Parameter> args = m.getParameters();
6.141 - for (int index = 0, i = 0; i < args.size(); i++) {
6.142 + for (int index = 0, i = 0; i < argsCnt[0]; i++) {
6.143 out.append(space);
6.144 out.append("arg").append(String.valueOf(index));
6.145 space = ",";
6.146 - final String desc = findDescriptor(args.get(i).getDescriptor());
6.147 + final String desc = null;// XXX findDescriptor(args.get(i).getDescriptor());
6.148 if ("D".equals(desc) || "J".equals(desc)) {
6.149 index += 2;
6.150 } else {
6.151 @@ -176,42 +165,42 @@
6.152 }
6.153 }
6.154 out.append(") {").append("\n");
6.155 - final Code code = m.getCode();
6.156 + final byte[] code = m.getCode();
6.157 if (code != null) {
6.158 - int len = code.getMaxLocals();
6.159 - for (int index = args.size(), i = args.size(); i < len; i++) {
6.160 + int len = m.getMaxLocals();
6.161 + for (int index = argsCnt[0], i = argsCnt[0]; i < len; i++) {
6.162 out.append(" var ");
6.163 out.append("arg").append(String.valueOf(i)).append(";\n");
6.164 }
6.165 out.append(" var stack = new Array();\n");
6.166 - produceCode(code.getByteCodes());
6.167 + produceCode(code);
6.168 } else {
6.169 - out.append(" /* no code found for ").append(m.getTypeSignature()).append(" */\n");
6.170 + out.append(" /* no code found for ").append(m.getInternalSig()).append(" */\n");
6.171 }
6.172 out.append("}");
6.173 }
6.174
6.175 - private void generateMethodReference(String prefix, Method m) throws IOException {
6.176 - final String name = findMethodName(m);
6.177 + private void generateMethodReference(String prefix, MethodData m) throws IOException {
6.178 + final String name = findMethodName(m, null);
6.179 out.append(prefix).append(name).append(" = ")
6.180 - .append(jc.getName().getInternalName().replace('/', '_'))
6.181 + .append(className(jc))
6.182 .append('_').append(name).append(";");
6.183 }
6.184
6.185 - private void generateInstanceMethod(Method m) throws IOException {
6.186 + private void generateInstanceMethod(MethodData m) throws IOException {
6.187 if (javaScriptBody(m, false)) {
6.188 return;
6.189 }
6.190 + int[] argsCnt = { -1 };
6.191 out.append("\nfunction ").append(
6.192 - jc.getName().getInternalName().replace('/', '_')
6.193 - ).append('_').append(findMethodName(m));
6.194 + className(jc)
6.195 + ).append('_').append(findMethodName(m, argsCnt));
6.196 out.append("(arg0");
6.197 String space = ",";
6.198 - List<Parameter> args = m.getParameters();
6.199 - for (int index = 1, i = 0; i < args.size(); i++) {
6.200 + for (int index = 1, i = 0; i < argsCnt[0]; i++) {
6.201 out.append(space);
6.202 out.append("arg").append(String.valueOf(index));
6.203 - final String desc = findDescriptor(args.get(i).getDescriptor());
6.204 + final String desc = null;// XXX findDescriptor(args.get(i).getDescriptor());
6.205 if ("D".equals(desc) || "J".equals(desc)) {
6.206 index += 2;
6.207 } else {
6.208 @@ -219,17 +208,17 @@
6.209 }
6.210 }
6.211 out.append(") {").append("\n");
6.212 - final Code code = m.getCode();
6.213 + final byte[] code = m.getCode();
6.214 if (code != null) {
6.215 - int len = code.getMaxLocals();
6.216 - for (int index = args.size(), i = args.size(); i < len; i++) {
6.217 + int len = m.getMaxLocals();
6.218 + for (int index = argsCnt[0], i = argsCnt[0]; i < len; i++) {
6.219 out.append(" var ");
6.220 out.append("arg").append(String.valueOf(i + 1)).append(";\n");
6.221 }
6.222 out.append(";\n var stack = new Array();\n");
6.223 - produceCode(code.getByteCodes());
6.224 + produceCode(code);
6.225 } else {
6.226 - out.append(" /* no code found for ").append(m.getTypeSignature()).append(" */\n");
6.227 + out.append(" /* no code found for ").append(m.getInternalSig()).append(" */\n");
6.228 }
6.229 out.append("}");
6.230 }
6.231 @@ -241,137 +230,137 @@
6.232 out.append(" case " + i).append(": ");
6.233 final int c = readByte(byteCodes, i);
6.234 switch (c) {
6.235 - case bc_aload_0:
6.236 - case bc_iload_0:
6.237 - case bc_lload_0:
6.238 - case bc_fload_0:
6.239 - case bc_dload_0:
6.240 + case opc_aload_0:
6.241 + case opc_iload_0:
6.242 + case opc_lload_0:
6.243 + case opc_fload_0:
6.244 + case opc_dload_0:
6.245 out.append("stack.push(arg0);");
6.246 break;
6.247 - case bc_aload_1:
6.248 - case bc_iload_1:
6.249 - case bc_lload_1:
6.250 - case bc_fload_1:
6.251 - case bc_dload_1:
6.252 + case opc_aload_1:
6.253 + case opc_iload_1:
6.254 + case opc_lload_1:
6.255 + case opc_fload_1:
6.256 + case opc_dload_1:
6.257 out.append("stack.push(arg1);");
6.258 break;
6.259 - case bc_aload_2:
6.260 - case bc_iload_2:
6.261 - case bc_lload_2:
6.262 - case bc_fload_2:
6.263 - case bc_dload_2:
6.264 + case opc_aload_2:
6.265 + case opc_iload_2:
6.266 + case opc_lload_2:
6.267 + case opc_fload_2:
6.268 + case opc_dload_2:
6.269 out.append("stack.push(arg2);");
6.270 break;
6.271 - case bc_aload_3:
6.272 - case bc_iload_3:
6.273 - case bc_lload_3:
6.274 - case bc_fload_3:
6.275 - case bc_dload_3:
6.276 + case opc_aload_3:
6.277 + case opc_iload_3:
6.278 + case opc_lload_3:
6.279 + case opc_fload_3:
6.280 + case opc_dload_3:
6.281 out.append("stack.push(arg3);");
6.282 break;
6.283 - case bc_iload:
6.284 - case bc_lload:
6.285 - case bc_fload:
6.286 - case bc_dload:
6.287 - case bc_aload: {
6.288 + case opc_iload:
6.289 + case opc_lload:
6.290 + case opc_fload:
6.291 + case opc_dload:
6.292 + case opc_aload: {
6.293 final int indx = readByte(byteCodes, ++i);
6.294 out.append("stack.push(arg").append(indx + ");");
6.295 break;
6.296 }
6.297 - case bc_istore:
6.298 - case bc_lstore:
6.299 - case bc_fstore:
6.300 - case bc_dstore:
6.301 - case bc_astore: {
6.302 + case opc_istore:
6.303 + case opc_lstore:
6.304 + case opc_fstore:
6.305 + case opc_dstore:
6.306 + case opc_astore: {
6.307 final int indx = readByte(byteCodes, ++i);
6.308 - out.append("arg" + indx).append(" = stack.pop()");
6.309 + out.append("arg" + indx).append(" = stack.pop();");
6.310 break;
6.311 }
6.312 - case bc_astore_0:
6.313 - case bc_istore_0:
6.314 - case bc_lstore_0:
6.315 - case bc_fstore_0:
6.316 - case bc_dstore_0:
6.317 + case opc_astore_0:
6.318 + case opc_istore_0:
6.319 + case opc_lstore_0:
6.320 + case opc_fstore_0:
6.321 + case opc_dstore_0:
6.322 out.append("arg0 = stack.pop();");
6.323 break;
6.324 - case bc_astore_1:
6.325 - case bc_istore_1:
6.326 - case bc_lstore_1:
6.327 - case bc_fstore_1:
6.328 - case bc_dstore_1:
6.329 + case opc_astore_1:
6.330 + case opc_istore_1:
6.331 + case opc_lstore_1:
6.332 + case opc_fstore_1:
6.333 + case opc_dstore_1:
6.334 out.append("arg1 = stack.pop();");
6.335 break;
6.336 - case bc_astore_2:
6.337 - case bc_istore_2:
6.338 - case bc_lstore_2:
6.339 - case bc_fstore_2:
6.340 - case bc_dstore_2:
6.341 + case opc_astore_2:
6.342 + case opc_istore_2:
6.343 + case opc_lstore_2:
6.344 + case opc_fstore_2:
6.345 + case opc_dstore_2:
6.346 out.append("arg2 = stack.pop();");
6.347 break;
6.348 - case bc_astore_3:
6.349 - case bc_istore_3:
6.350 - case bc_lstore_3:
6.351 - case bc_fstore_3:
6.352 - case bc_dstore_3:
6.353 + case opc_astore_3:
6.354 + case opc_istore_3:
6.355 + case opc_lstore_3:
6.356 + case opc_fstore_3:
6.357 + case opc_dstore_3:
6.358 out.append("arg3 = stack.pop();");
6.359 break;
6.360 - case bc_iadd:
6.361 - case bc_ladd:
6.362 - case bc_fadd:
6.363 - case bc_dadd:
6.364 + case opc_iadd:
6.365 + case opc_ladd:
6.366 + case opc_fadd:
6.367 + case opc_dadd:
6.368 out.append("stack.push(stack.pop() + stack.pop());");
6.369 break;
6.370 - case bc_isub:
6.371 - case bc_lsub:
6.372 - case bc_fsub:
6.373 - case bc_dsub:
6.374 + case opc_isub:
6.375 + case opc_lsub:
6.376 + case opc_fsub:
6.377 + case opc_dsub:
6.378 out.append("{ var tmp = stack.pop(); stack.push(stack.pop() - tmp); }");
6.379 break;
6.380 - case bc_imul:
6.381 - case bc_lmul:
6.382 - case bc_fmul:
6.383 - case bc_dmul:
6.384 + case opc_imul:
6.385 + case opc_lmul:
6.386 + case opc_fmul:
6.387 + case opc_dmul:
6.388 out.append("stack.push(stack.pop() * stack.pop());");
6.389 break;
6.390 - case bc_idiv:
6.391 - case bc_ldiv:
6.392 + case opc_idiv:
6.393 + case opc_ldiv:
6.394 out.append("{ var tmp = stack.pop(); stack.push(Math.floor(stack.pop() / tmp)); }");
6.395 break;
6.396 - case bc_fdiv:
6.397 - case bc_ddiv:
6.398 + case opc_fdiv:
6.399 + case opc_ddiv:
6.400 out.append("{ var tmp = stack.pop(); stack.push(stack.pop() / tmp); }");
6.401 break;
6.402 - case bc_iand:
6.403 - case bc_land:
6.404 + case opc_iand:
6.405 + case opc_land:
6.406 out.append("stack.push(stack.pop() & stack.pop());");
6.407 break;
6.408 - case bc_ior:
6.409 - case bc_lor:
6.410 + case opc_ior:
6.411 + case opc_lor:
6.412 out.append("stack.push(stack.pop() | stack.pop());");
6.413 break;
6.414 - case bc_ixor:
6.415 - case bc_lxor:
6.416 + case opc_ixor:
6.417 + case opc_lxor:
6.418 out.append("stack.push(stack.pop() ^ stack.pop());");
6.419 break;
6.420 - case bc_ineg:
6.421 - case bc_lneg:
6.422 - case bc_fneg:
6.423 - case bc_dneg:
6.424 + case opc_ineg:
6.425 + case opc_lneg:
6.426 + case opc_fneg:
6.427 + case opc_dneg:
6.428 out.append("stack.push(- stack.pop());");
6.429 break;
6.430 - case bc_ishl:
6.431 - case bc_lshl:
6.432 + case opc_ishl:
6.433 + case opc_lshl:
6.434 out.append("{ var v = stack.pop(); stack.push(stack.pop() << v); }");
6.435 break;
6.436 - case bc_ishr:
6.437 - case bc_lshr:
6.438 + case opc_ishr:
6.439 + case opc_lshr:
6.440 out.append("{ var v = stack.pop(); stack.push(stack.pop() >> v); }");
6.441 break;
6.442 - case bc_iushr:
6.443 - case bc_lushr:
6.444 + case opc_iushr:
6.445 + case opc_lushr:
6.446 out.append("{ var v = stack.pop(); stack.push(stack.pop() >>> v); }");
6.447 break;
6.448 - case bc_iinc: {
6.449 + case opc_iinc: {
6.450 final int varIndx = readByte(byteCodes, ++i);
6.451 final int incrBy = byteCodes[++i];
6.452 if (incrBy == 1) {
6.453 @@ -381,181 +370,179 @@
6.454 }
6.455 break;
6.456 }
6.457 - case bc_return:
6.458 + case opc_return:
6.459 out.append("return;");
6.460 break;
6.461 - case bc_ireturn:
6.462 - case bc_lreturn:
6.463 - case bc_freturn:
6.464 - case bc_dreturn:
6.465 - case bc_areturn:
6.466 + case opc_ireturn:
6.467 + case opc_lreturn:
6.468 + case opc_freturn:
6.469 + case opc_dreturn:
6.470 + case opc_areturn:
6.471 out.append("return stack.pop();");
6.472 break;
6.473 - case bc_i2l:
6.474 - case bc_i2f:
6.475 - case bc_i2d:
6.476 - case bc_l2i:
6.477 + case opc_i2l:
6.478 + case opc_i2f:
6.479 + case opc_i2d:
6.480 + case opc_l2i:
6.481 // max int check?
6.482 - case bc_l2f:
6.483 - case bc_l2d:
6.484 - case bc_f2d:
6.485 - case bc_d2f:
6.486 + case opc_l2f:
6.487 + case opc_l2d:
6.488 + case opc_f2d:
6.489 + case opc_d2f:
6.490 out.append("/* number conversion */");
6.491 break;
6.492 - case bc_f2i:
6.493 - case bc_f2l:
6.494 - case bc_d2i:
6.495 - case bc_d2l:
6.496 + case opc_f2i:
6.497 + case opc_f2l:
6.498 + case opc_d2i:
6.499 + case opc_d2l:
6.500 out.append("stack.push(Math.floor(stack.pop()));");
6.501 break;
6.502 - case bc_i2b:
6.503 - case bc_i2c:
6.504 - case bc_i2s:
6.505 + case opc_i2b:
6.506 + case opc_i2c:
6.507 + case opc_i2s:
6.508 out.append("/* number conversion */");
6.509 break;
6.510 - case bc_aconst_null:
6.511 + case opc_aconst_null:
6.512 out.append("stack.push(null);");
6.513 break;
6.514 - case bc_iconst_m1:
6.515 + case opc_iconst_m1:
6.516 out.append("stack.push(-1);");
6.517 break;
6.518 - case bc_iconst_0:
6.519 - case bc_dconst_0:
6.520 - case bc_lconst_0:
6.521 - case bc_fconst_0:
6.522 + case opc_iconst_0:
6.523 + case opc_dconst_0:
6.524 + case opc_lconst_0:
6.525 + case opc_fconst_0:
6.526 out.append("stack.push(0);");
6.527 break;
6.528 - case bc_iconst_1:
6.529 - case bc_lconst_1:
6.530 - case bc_fconst_1:
6.531 - case bc_dconst_1:
6.532 + case opc_iconst_1:
6.533 + case opc_lconst_1:
6.534 + case opc_fconst_1:
6.535 + case opc_dconst_1:
6.536 out.append("stack.push(1);");
6.537 break;
6.538 - case bc_iconst_2:
6.539 - case bc_fconst_2:
6.540 + case opc_iconst_2:
6.541 + case opc_fconst_2:
6.542 out.append("stack.push(2);");
6.543 break;
6.544 - case bc_iconst_3:
6.545 + case opc_iconst_3:
6.546 out.append("stack.push(3);");
6.547 break;
6.548 - case bc_iconst_4:
6.549 + case opc_iconst_4:
6.550 out.append("stack.push(4);");
6.551 break;
6.552 - case bc_iconst_5:
6.553 + case opc_iconst_5:
6.554 out.append("stack.push(5);");
6.555 break;
6.556 - case bc_ldc: {
6.557 + case opc_ldc: {
6.558 int indx = readByte(byteCodes, ++i);
6.559 - CPEntry entry = jc.getConstantPool().get(indx);
6.560 - String v = encodeConstant(entry);
6.561 + String v = encodeConstant(indx);
6.562 out.append("stack.push(").append(v).append(");");
6.563 break;
6.564 }
6.565 - case bc_ldc_w:
6.566 - case bc_ldc2_w: {
6.567 + case opc_ldc_w:
6.568 + case opc_ldc2_w: {
6.569 int indx = readIntArg(byteCodes, i);
6.570 - CPEntry entry = jc.getConstantPool().get(indx);
6.571 i += 2;
6.572 - String v = encodeConstant(entry);
6.573 + String v = encodeConstant(indx);
6.574 out.append("stack.push(").append(v).append(");");
6.575 break;
6.576 }
6.577 - case bc_lcmp:
6.578 - case bc_fcmpl:
6.579 - case bc_fcmpg:
6.580 - case bc_dcmpl:
6.581 - case bc_dcmpg: {
6.582 + case opc_lcmp:
6.583 + case opc_fcmpl:
6.584 + case opc_fcmpg:
6.585 + case opc_dcmpl:
6.586 + case opc_dcmpg: {
6.587 out.append("{ var delta = stack.pop() - stack.pop(); stack.push(delta < 0 ?-1 : (delta == 0 ? 0 : 1)); }");
6.588 break;
6.589 }
6.590 - case bc_if_acmpeq:
6.591 + case opc_if_acmpeq:
6.592 i = generateIf(byteCodes, i, "===");
6.593 break;
6.594 - case bc_if_acmpne:
6.595 + case opc_if_acmpne:
6.596 i = generateIf(byteCodes, i, "!=");
6.597 break;
6.598 - case bc_if_icmpeq: {
6.599 + case opc_if_icmpeq: {
6.600 i = generateIf(byteCodes, i, "==");
6.601 break;
6.602 }
6.603 - case bc_ifeq: {
6.604 + case opc_ifeq: {
6.605 int indx = i + readIntArg(byteCodes, i);
6.606 out.append("if (stack.pop() == 0) { gt = " + indx);
6.607 out.append("; continue; }");
6.608 i += 2;
6.609 break;
6.610 }
6.611 - case bc_ifne: {
6.612 + case opc_ifne: {
6.613 int indx = i + readIntArg(byteCodes, i);
6.614 out.append("if (stack.pop() != 0) { gt = " + indx);
6.615 out.append("; continue; }");
6.616 i += 2;
6.617 break;
6.618 }
6.619 - case bc_iflt: {
6.620 + case opc_iflt: {
6.621 int indx = i + readIntArg(byteCodes, i);
6.622 out.append("if (stack.pop() < 0) { gt = " + indx);
6.623 out.append("; continue; }");
6.624 i += 2;
6.625 break;
6.626 }
6.627 - case bc_ifle: {
6.628 + case opc_ifle: {
6.629 int indx = i + readIntArg(byteCodes, i);
6.630 out.append("if (stack.pop() <= 0) { gt = " + indx);
6.631 out.append("; continue; }");
6.632 i += 2;
6.633 break;
6.634 }
6.635 - case bc_ifgt: {
6.636 + case opc_ifgt: {
6.637 int indx = i + readIntArg(byteCodes, i);
6.638 out.append("if (stack.pop() > 0) { gt = " + indx);
6.639 out.append("; continue; }");
6.640 i += 2;
6.641 break;
6.642 }
6.643 - case bc_ifge: {
6.644 + case opc_ifge: {
6.645 int indx = i + readIntArg(byteCodes, i);
6.646 out.append("if (stack.pop() >= 0) { gt = " + indx);
6.647 out.append("; continue; }");
6.648 i += 2;
6.649 break;
6.650 }
6.651 - case bc_ifnonnull: {
6.652 + case opc_ifnonnull: {
6.653 int indx = i + readIntArg(byteCodes, i);
6.654 out.append("if (stack.pop()) { gt = " + indx);
6.655 out.append("; continue; }");
6.656 i += 2;
6.657 break;
6.658 }
6.659 - case bc_ifnull: {
6.660 + case opc_ifnull: {
6.661 int indx = i + readIntArg(byteCodes, i);
6.662 out.append("if (!stack.pop()) { gt = " + indx);
6.663 out.append("; continue; }");
6.664 i += 2;
6.665 break;
6.666 }
6.667 - case bc_if_icmpne:
6.668 + case opc_if_icmpne:
6.669 i = generateIf(byteCodes, i, "!=");
6.670 break;
6.671 - case bc_if_icmplt:
6.672 + case opc_if_icmplt:
6.673 i = generateIf(byteCodes, i, ">");
6.674 break;
6.675 - case bc_if_icmple:
6.676 + case opc_if_icmple:
6.677 i = generateIf(byteCodes, i, ">=");
6.678 break;
6.679 - case bc_if_icmpgt:
6.680 + case opc_if_icmpgt:
6.681 i = generateIf(byteCodes, i, "<");
6.682 break;
6.683 - case bc_if_icmpge:
6.684 + case opc_if_icmpge:
6.685 i = generateIf(byteCodes, i, "<=");
6.686 break;
6.687 - case bc_goto: {
6.688 + case opc_goto: {
6.689 int indx = i + readIntArg(byteCodes, i);
6.690 out.append("gt = " + indx).append("; continue;");
6.691 i += 2;
6.692 break;
6.693 }
6.694 - case bc_lookupswitch: {
6.695 + case opc_lookupswitch: {
6.696 int table = i / 4 * 4 + 4;
6.697 int dflt = i + readInt4(byteCodes, table);
6.698 table += 4;
6.699 @@ -573,7 +560,7 @@
6.700 i = table - 1;
6.701 break;
6.702 }
6.703 - case bc_tableswitch: {
6.704 + case opc_tableswitch: {
6.705 int table = i / 4 * 4 + 4;
6.706 int dflt = i + readInt4(byteCodes, table);
6.707 table += 4;
6.708 @@ -592,40 +579,40 @@
6.709 i = table - 1;
6.710 break;
6.711 }
6.712 - case bc_invokeinterface: {
6.713 + case opc_invokeinterface: {
6.714 i = invokeVirtualMethod(byteCodes, i) + 2;
6.715 break;
6.716 }
6.717 - case bc_invokevirtual:
6.718 + case opc_invokevirtual:
6.719 i = invokeVirtualMethod(byteCodes, i);
6.720 break;
6.721 - case bc_invokespecial:
6.722 + case opc_invokespecial:
6.723 i = invokeStaticMethod(byteCodes, i, false);
6.724 break;
6.725 - case bc_invokestatic:
6.726 + case opc_invokestatic:
6.727 i = invokeStaticMethod(byteCodes, i, true);
6.728 break;
6.729 - case bc_new: {
6.730 + case opc_new: {
6.731 int indx = readIntArg(byteCodes, i);
6.732 - CPClassInfo ci = jc.getConstantPool().getClass(indx);
6.733 + String ci = jc.getClassName(indx);
6.734 out.append("stack.push(");
6.735 - out.append("new ").append(ci.getClassName().getInternalName().replace('/','_'));
6.736 + out.append("new ").append(ci.replace('/','_'));
6.737 out.append(");");
6.738 - addReference(ci.getClassName().getInternalName());
6.739 + addReference(ci);
6.740 i += 2;
6.741 break;
6.742 }
6.743 - case bc_newarray: {
6.744 + case opc_newarray: {
6.745 int type = byteCodes[i++];
6.746 out.append("stack.push(new Array(stack.pop()));");
6.747 break;
6.748 }
6.749 - case bc_anewarray: {
6.750 + case opc_anewarray: {
6.751 i += 2; // skip type of array
6.752 out.append("stack.push(new Array(stack.pop()));");
6.753 break;
6.754 }
6.755 - case bc_multianewarray: {
6.756 + case opc_multianewarray: {
6.757 i += 2;
6.758 int dim = readByte(byteCodes, ++i);
6.759 out.append("{ var a0 = new Array(stack.pop());");
6.760 @@ -645,86 +632,83 @@
6.761 out.append("\nstack.push(a0); }");
6.762 break;
6.763 }
6.764 - case bc_arraylength:
6.765 + case opc_arraylength:
6.766 out.append("stack.push(stack.pop().length);");
6.767 break;
6.768 - case bc_iastore:
6.769 - case bc_lastore:
6.770 - case bc_fastore:
6.771 - case bc_dastore:
6.772 - case bc_aastore:
6.773 - case bc_bastore:
6.774 - case bc_castore:
6.775 - case bc_sastore: {
6.776 + case opc_iastore:
6.777 + case opc_lastore:
6.778 + case opc_fastore:
6.779 + case opc_dastore:
6.780 + case opc_aastore:
6.781 + case opc_bastore:
6.782 + case opc_castore:
6.783 + case opc_sastore: {
6.784 out.append("{ var value = stack.pop(); var indx = stack.pop(); stack.pop()[indx] = value; }");
6.785 break;
6.786 }
6.787 - case bc_iaload:
6.788 - case bc_laload:
6.789 - case bc_faload:
6.790 - case bc_daload:
6.791 - case bc_aaload:
6.792 - case bc_baload:
6.793 - case bc_caload:
6.794 - case bc_saload: {
6.795 + case opc_iaload:
6.796 + case opc_laload:
6.797 + case opc_faload:
6.798 + case opc_daload:
6.799 + case opc_aaload:
6.800 + case opc_baload:
6.801 + case opc_caload:
6.802 + case opc_saload: {
6.803 out.append("{ var indx = stack.pop(); stack.push(stack.pop()[indx]); }");
6.804 break;
6.805 }
6.806 - case bc_pop2:
6.807 + case opc_pop2:
6.808 out.append("stack.pop();");
6.809 - case bc_pop:
6.810 + case opc_pop:
6.811 out.append("stack.pop();");
6.812 break;
6.813 - case bc_dup:
6.814 + case opc_dup:
6.815 out.append("stack.push(stack[stack.length - 1]);");
6.816 break;
6.817 - case bc_bipush:
6.818 + case opc_bipush:
6.819 out.append("stack.push(" + byteCodes[++i] + ");");
6.820 break;
6.821 - case bc_sipush:
6.822 + case opc_sipush:
6.823 out.append("stack.push(" + readIntArg(byteCodes, i) + ");");
6.824 i += 2;
6.825 break;
6.826 - case bc_getfield: {
6.827 + case opc_getfield: {
6.828 int indx = readIntArg(byteCodes, i);
6.829 - CPFieldInfo fi = (CPFieldInfo) jc.getConstantPool().get(indx);
6.830 + String[] fi = jc.getFieldInfoName(indx);
6.831 out.append("stack.push(stack.pop().fld_").
6.832 - append(fi.getFieldName()).append(");");
6.833 + append(fi[1]).append(");");
6.834 i += 2;
6.835 break;
6.836 }
6.837 - case bc_getstatic: {
6.838 + case opc_getstatic: {
6.839 int indx = readIntArg(byteCodes, i);
6.840 - CPFieldInfo fi = (CPFieldInfo) jc.getConstantPool().get(indx);
6.841 - final String in = fi.getClassName().getInternalName();
6.842 - out.append("stack.push(").append(in.replace('/', '_'));
6.843 - out.append('_').append(fi.getFieldName()).append(");");
6.844 + String[] fi = jc.getFieldInfoName(indx);
6.845 + out.append("stack.push(").append(fi[0].replace('/', '_'));
6.846 + out.append('_').append(fi[1]).append(");");
6.847 i += 2;
6.848 - addReference(in);
6.849 + addReference(fi[0]);
6.850 break;
6.851 }
6.852 - case bc_putstatic: {
6.853 + case opc_putstatic: {
6.854 int indx = readIntArg(byteCodes, i);
6.855 - CPFieldInfo fi = (CPFieldInfo) jc.getConstantPool().get(indx);
6.856 - final String in = fi.getClassName().getInternalName();
6.857 - out.append(in.replace('/', '_'));
6.858 - out.append('_').append(fi.getFieldName()).append(" = stack.pop();");
6.859 + String[] fi = jc.getFieldInfoName(indx);
6.860 + out.append(fi[0].replace('/', '_'));
6.861 + out.append('_').append(fi[1]).append(" = stack.pop();");
6.862 i += 2;
6.863 - addReference(in);
6.864 + addReference(fi[0]);
6.865 break;
6.866 }
6.867 - case bc_putfield: {
6.868 + case opc_putfield: {
6.869 int indx = readIntArg(byteCodes, i);
6.870 - CPFieldInfo fi = (CPFieldInfo) jc.getConstantPool().get(indx);
6.871 + String[] fi = jc.getFieldInfoName(indx);
6.872 out.append("{ var v = stack.pop(); stack.pop().fld_")
6.873 - .append(fi.getFieldName()).append(" = v; }");
6.874 + .append(fi[1]).append(" = v; }");
6.875 i += 2;
6.876 break;
6.877 }
6.878 - case bc_checkcast: {
6.879 + case opc_checkcast: {
6.880 int indx = readIntArg(byteCodes, i);
6.881 - CPClassInfo ci = jc.getConstantPool().getClass(indx);
6.882 - final String type = ci.getClassName().getType();
6.883 + final String type = jc.getClassName(indx);
6.884 if (!type.startsWith("[")) {
6.885 // no way to check arrays right now
6.886 out.append("if(stack[stack.length - 1].$instOf_")
6.887 @@ -734,16 +718,16 @@
6.888 i += 2;
6.889 break;
6.890 }
6.891 - case bc_instanceof: {
6.892 + case opc_instanceof: {
6.893 int indx = readIntArg(byteCodes, i);
6.894 - CPClassInfo ci = jc.getConstantPool().getClass(indx);
6.895 + final String type = jc.getClassName(indx);
6.896 out.append("stack.push(stack.pop().$instOf_")
6.897 - .append(ci.getClassName().getInternalName().replace('/', '_'))
6.898 + .append(type.replace('/', '_'))
6.899 .append(" ? 1 : 0);");
6.900 i += 2;
6.901 break;
6.902 }
6.903 - case bc_athrow: {
6.904 + case opc_athrow: {
6.905 out.append("{ var t = stack.pop(); stack = new Array(1); stack[0] = t; throw t; }");
6.906 break;
6.907 }
6.908 @@ -861,15 +845,14 @@
6.909 return cnt;
6.910 }
6.911
6.912 - private void generateStaticField(Variable v) throws IOException {
6.913 + private void generateStaticField(FieldData v) throws IOException {
6.914 out.append("\nvar ")
6.915 - .append(jc.getName().getInternalName().replace('/', '_'))
6.916 + .append(className(jc))
6.917 .append('_').append(v.getName()).append(" = 0;");
6.918 }
6.919
6.920 - private String findMethodName(Method m) {
6.921 + private String findMethodName(MethodData m, int[] cnt) {
6.922 StringBuilder name = new StringBuilder();
6.923 - String descr = m.getDescriptor();
6.924 if ("<init>".equals(m.getName())) { // NOI18N
6.925 name.append("cons"); // NOI18N
6.926 } else if ("<clinit>".equals(m.getName())) { // NOI18N
6.927 @@ -879,26 +862,30 @@
6.928 }
6.929
6.930 boolean hasReturn[] = { false };
6.931 - countArgs(findDescriptor(m.getDescriptor()), hasReturn, name);
6.932 + int argsCnt = countArgs(findDescriptor(m.getInternalSig()), hasReturn, name);
6.933 + if (cnt != null) {
6.934 + cnt[0] = argsCnt;
6.935 + }
6.936 return name.toString();
6.937 }
6.938
6.939 - private String findMethodName(CPMethodInfo mi, int[] cnt, boolean[] hasReturn) {
6.940 + private String findMethodName(String[] mi, int[] cnt, boolean[] hasReturn) {
6.941 StringBuilder name = new StringBuilder();
6.942 - String descr = mi.getDescriptor();
6.943 - if ("<init>".equals(mi.getName())) { // NOI18N
6.944 + String descr = mi[2];//mi.getDescriptor();
6.945 + String nm= mi[1];
6.946 + if ("<init>".equals(nm)) { // NOI18N
6.947 name.append("cons"); // NOI18N
6.948 } else {
6.949 - name.append(mi.getName());
6.950 + name.append(nm);
6.951 }
6.952 - cnt[0] = countArgs(findDescriptor(mi.getDescriptor()), hasReturn, name);
6.953 + cnt[0] = countArgs(findDescriptor(descr), hasReturn, name);
6.954 return name.toString();
6.955 }
6.956
6.957 private int invokeStaticMethod(byte[] byteCodes, int i, boolean isStatic)
6.958 throws IOException {
6.959 int methodIndex = readIntArg(byteCodes, i);
6.960 - CPMethodInfo mi = (CPMethodInfo) jc.getConstantPool().get(methodIndex);
6.961 + String[] mi = jc.getFieldInfoName(methodIndex);
6.962 boolean[] hasReturn = { false };
6.963 int[] cnt = { 0 };
6.964 String mn = findMethodName(mi, cnt, hasReturn);
6.965 @@ -910,7 +897,7 @@
6.966 if (hasReturn[0]) {
6.967 out.append("stack.push(");
6.968 }
6.969 - final String in = mi.getClassName().getInternalName();
6.970 + final String in = mi[0];
6.971 out.append(in.replace('/', '_'));
6.972 if (isStatic) {
6.973 out.append(".prototype.");
6.974 @@ -941,7 +928,7 @@
6.975 private int invokeVirtualMethod(byte[] byteCodes, int i)
6.976 throws IOException {
6.977 int methodIndex = readIntArg(byteCodes, i);
6.978 - CPMethodInfo mi = (CPMethodInfo) jc.getConstantPool().get(methodIndex);
6.979 + String[] mi = jc.getFieldInfoName(methodIndex);
6.980 boolean[] hasReturn = { false };
6.981 int[] cnt = { 0 };
6.982 String mn = findMethodName(mi, cnt, hasReturn);
6.983 @@ -992,29 +979,18 @@
6.984 }
6.985 }
6.986
6.987 - private String encodeConstant(CPEntry entry) {
6.988 - final String v;
6.989 - if (entry instanceof CPClassInfo) {
6.990 - v = "new java_lang_Class";
6.991 - } else if (entry instanceof CPStringInfo) {
6.992 - v = "\"" + entry.getValue().toString().
6.993 - replace("\\", "\\\\").
6.994 - replace("\n", "\\n").
6.995 - replace("\r", "\\r").
6.996 - replace("\t", "\\t").
6.997 - replace("\"", "\\\"")
6.998 - + "\"";
6.999 - } else {
6.1000 - v = entry.getValue().toString();
6.1001 - }
6.1002 - return v;
6.1003 + private String encodeConstant(int entryIndex) {
6.1004 + String s = jc.stringValue(entryIndex, true);
6.1005 + return s;
6.1006 }
6.1007
6.1008 private String findDescriptor(String d) {
6.1009 return d.replace('[', 'A');
6.1010 }
6.1011
6.1012 - private boolean javaScriptBody(Method m, boolean isStatic) throws IOException {
6.1013 + private boolean javaScriptBody(MethodData m, boolean isStatic) throws IOException {
6.1014 + return false;
6.1015 + /*
6.1016 final ClassName extraAnn = ClassName.getClassName(JavaScriptBody.class.getName().replace('.', '/'));
6.1017 Annotation a = m.getAnnotation(extraAnn);
6.1018 if (a != null) {
6.1019 @@ -1054,5 +1030,10 @@
6.1020 return true;
6.1021 }
6.1022 return false;
6.1023 + */
6.1024 + }
6.1025 + private static String className(ClassData jc) {
6.1026 + //return jc.getName().getInternalName().replace('/', '_');
6.1027 + return jc.getClassName().replace('/', '_');
6.1028 }
6.1029 }
7.1 --- a/vm/src/main/java/org/apidesign/vm4brwsr/GenJS.java Sat Nov 10 20:31:39 2012 +0100
7.2 +++ b/vm/src/main/java/org/apidesign/vm4brwsr/GenJS.java Sun Nov 11 13:23:52 2012 +0100
7.3 @@ -86,7 +86,7 @@
7.4 if (out instanceof CharSequence) {
7.5 CharSequence seq = (CharSequence)out;
7.6 int lastBlock = seq.length();
7.7 - while (lastBlock-- >= 0) {
7.8 + while (lastBlock-- > 0) {
7.9 if (seq.charAt(lastBlock) == '{') {
7.10 break;
7.11 }