Переглянути джерело

* enable support for creating loadvmtaddr nodes for Java interfaces, because
those are also supported by the Java language (intftype.class) and required
in equivalent Pascal expressions (such as JLClass(intftype))

git-svn-id: branches/jvmbackend@19742 -

Jonas Maebe 13 роки тому
батько
коміт
faaa86238c
3 змінених файлів з 23 додано та 3 видалено
  1. 16 0
      compiler/jvm/njvmcnv.pas
  2. 2 1
      compiler/nmem.pas
  3. 5 2
      compiler/pexpr.pas

+ 16 - 0
compiler/jvm/njvmcnv.pas

@@ -1392,7 +1392,23 @@ implementation
   function asis_target_specific_typecheck(node: tasisnode): boolean;
     var
       realtodef: tdef;
+      temp: tnode;
     begin
+      { the JVM supports loadvmtaddrnodes for interface types, but the generic
+        as/is code doesn't -> convert such loadvmtaddrnodes back to plain
+        type nodes here (they only make sense in the context of treating them
+        as entities loaded to store into e.g. a JLClass) }
+      if (node.right.resultdef.typ=classrefdef) and
+         is_javainterface(tclassrefdef(node.right.resultdef).pointeddef) and
+         (node.right.nodetype=loadvmtaddrn) and
+         (tloadvmtaddrnode(node.right).left.nodetype=typen) then
+        begin
+          temp:=tloadvmtaddrnode(node.right).left;
+          tloadvmtaddrnode(node.right).left:=nil;
+          node.right.free;
+          node.right:=temp;
+        end;
+
       if not(nf_internal in node.flags) then
         begin
           { handle using normal code }

+ 2 - 1
compiler/nmem.pas

@@ -255,7 +255,8 @@ implementation
          else if not is_objcclass(left.resultdef) and
                  not is_objcclassref(left.resultdef) and
                  not is_javaclass(left.resultdef) and
-                 not is_javaclassref(left.resultdef) then
+                 not is_javaclassref(left.resultdef) and
+                 not is_javainterface(left.resultdef) then
            begin
              if not(nf_ignore_for_wpo in flags) and
                 (not assigned(current_procinfo) or

+ 5 - 2
compiler/pexpr.pas

@@ -1542,9 +1542,12 @@ implementation
                           { class reference ? }
                           if is_class(hdef) or
                              is_objcclass(hdef) or
-                             is_javaclass(hdef) then
+                             { Java interfaces also can have loadvmtaddrnodes,
+                               e.g. for expressions such as JLClass(intftype) }
+                             is_java_class_or_interface(hdef) then
                            begin
-                             if getaddr and (token=_POINT) then
+                             if getaddr and (token=_POINT) and
+                                not is_javainterface(hdef) then
                               begin
                                 consume(_POINT);
                                 { allows @Object.Method }