rt/vm/src/main/java/org/apidesign/vm4brwsr/ByteCodeToJavaScript.java
branchLibraries
changeset 1966 80851e48a68f
parent 1965 973e52d4cabb
child 1967 f807d02bb3d0
     1.1 --- a/rt/vm/src/main/java/org/apidesign/vm4brwsr/ByteCodeToJavaScript.java	Tue Jun 07 06:20:20 2016 +0200
     1.2 +++ b/rt/vm/src/main/java/org/apidesign/vm4brwsr/ByteCodeToJavaScript.java	Wed Jun 08 06:50:38 2016 +0200
     1.3 @@ -1823,7 +1823,7 @@
     1.4              in.equals("org/netbeans/html/boot/spi/Fn")
     1.5          )) {
     1.6              mcn = "java_lang_Class";
     1.7 -        } else if (in.startsWith("net/java/html/lib/") && in.endsWith("/Exports")) {
     1.8 +        } else if (DirectlLibraries.isScriptLibrary(in) && in.endsWith("/Exports")) {
     1.9              append(mi[1]);
    1.10              append('(');
    1.11              mcn = null;
    1.12 @@ -2394,6 +2394,13 @@
    1.13  
    1.14      private void generateInstanceOf(int indx, final StackMapper smapper) throws IOException {
    1.15          String type = jc.getClassName(indx);
    1.16 +        if (DirectlLibraries.isScriptLibrary(type)) {
    1.17 +            emit(smapper, this,
    1.18 +                    "var @2 = @1 !== null && @1 !== undefined",
    1.19 +                 smapper.popA(), smapper.pushI(),
    1.20 +                 mangleClassName(type));
    1.21 +            return;
    1.22 +        }
    1.23          if (!type.startsWith("[")) {
    1.24              emit(smapper, this, 
    1.25                      "var @2 = @1 != null && @1['$instOf_@3'] ? 1 : 0;",
    1.26 @@ -2424,6 +2431,12 @@
    1.27  
    1.28      private void generateCheckcast(int indx, final StackMapper smapper) throws IOException {
    1.29          String type = jc.getClassName(indx);
    1.30 +        if (DirectlLibraries.isScriptLibrary(type)) {
    1.31 +            emitNoFlush(smapper,
    1.32 +                 "",
    1.33 +                 smapper.getT(0, VarType.REFERENCE, false), mangleClassName(type), type.replace('/', '.'));
    1.34 +            return;
    1.35 +        }
    1.36          if (!type.startsWith("[")) {
    1.37              emitNoFlush(smapper, 
    1.38                   "if (@1 !== null && !@1['$instOf_@2']) vm.java_lang_Class(false).castEx(@1, '@3');",