rt/vm/src/main/java/org/apidesign/vm4brwsr/ByteCodeToJavaScript.java
branchclosure
changeset 1082 977cc6141083
parent 1029 b1fe994d4267
child 1083 9d6130cb464f
     1.1 --- a/rt/vm/src/main/java/org/apidesign/vm4brwsr/ByteCodeToJavaScript.java	Fri Apr 26 18:48:34 2013 +0200
     1.2 +++ b/rt/vm/src/main/java/org/apidesign/vm4brwsr/ByteCodeToJavaScript.java	Fri May 03 18:15:47 2013 +0200
     1.3 @@ -185,13 +185,9 @@
     1.4              out.append("\n    ").append(destObject).append(".").append(mn).append(".cls = CLS;");
     1.5          }
     1.6          out.append("\n    c.constructor = CLS;");
     1.7 -        String instOfName = "$instOf_" + className;
     1.8 -        out.append("\n    c.").append(instOfName).append(" = true;");
     1.9 -//        obfuscationDelegate.exportJSProperty(out, "c", instOfName);
    1.10 +        out.append("\n    c['$instOf_").append(className).append("'] = true;");
    1.11          for (String superInterface : jc.getSuperInterfaces()) {
    1.12 -            instOfName = "$instOf_" + superInterface.replace('/', '_');
    1.13 -            out.append("\n    c.").append(instOfName).append(" = true;");
    1.14 -//            obfuscationDelegate.exportJSProperty(out, "c", instOfName);
    1.15 +            out.append("\n    c['$instOf_").append(superInterface.replace('/', '_')).append("'] = true;");
    1.16          }
    1.17          out.append("\n    CLS.$class = 'temp';");
    1.18          out.append("\n    CLS.$class = ");
    1.19 @@ -1783,7 +1779,7 @@
    1.20                  final String classInternalName = jc.getClassName(e.catch_cpx);
    1.21                  addReference(classInternalName);
    1.22                  if ("java/lang/Throwable".equals(classInternalName)) {
    1.23 -                    out.append("if (e.$instOf_java_lang_Throwable) {");
    1.24 +                    out.append("if (e['$instOf_java_lang_Throwable']) {");
    1.25                      out.append("  var stA0 = e;");
    1.26                      out.append("} else {");
    1.27                      out.append("  var stA0 = vm.java_lang_Throwable(true);");
    1.28 @@ -1791,7 +1787,7 @@
    1.29                      out.append("}");
    1.30                      goTo(out, current, e.handler_pc, topMostLabel);
    1.31                  } else {
    1.32 -                    out.append("if (e.$instOf_" + classInternalName.replace('/', '_') + ") {");
    1.33 +                    out.append("if (e['$instOf_" + classInternalName.replace('/', '_') + "']) {");
    1.34                      out.append("var stA0 = e;");
    1.35                      goTo(out, current, e.handler_pc, topMostLabel);
    1.36                      out.append("}\n");
    1.37 @@ -1920,7 +1916,7 @@
    1.38      private void generateInstanceOf(int indx, final StackMapper smapper) throws IOException {
    1.39          final String type = jc.getClassName(indx);
    1.40          if (!type.startsWith("[")) {
    1.41 -            emit(out, "var @2 = @1 != null && @1.$instOf_@3 ? 1 : 0;",
    1.42 +            emit(out, "var @2 = @1 != null && @1['$instOf_@3'] ? 1 : 0;",
    1.43                   smapper.popA(), smapper.pushI(),
    1.44                   type.replace('/', '_'));
    1.45          } else {
    1.46 @@ -1935,7 +1931,7 @@
    1.47          final String type = jc.getClassName(indx);
    1.48          if (!type.startsWith("[")) {
    1.49              emit(out,
    1.50 -                 "if (@1 !== null && !@1.$instOf_@2) throw vm.java_lang_ClassCastException(true);",
    1.51 +                 "if (@1 !== null && !@1['$instOf_@2']) throw vm.java_lang_ClassCastException(true);",
    1.52                   smapper.getA(0), type.replace('/', '_'));
    1.53          } else {
    1.54              emit(out, "vm.java_lang_Class(false).forName__Ljava_lang_Class_2Ljava_lang_String_2('@2').cast__Ljava_lang_Object_2Ljava_lang_Object_2(@1);",