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

* fixed assigning ansi/unicodestrings to shortstrings on the JVM target
(and cleaned up implementing support for special x_to_shortstring
assignments in the process)

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

Jonas Maebe 14 роки тому
батько
коміт
7117264f96
2 змінених файлів з 23 додано та 3 видалено
  1. 11 0
      compiler/jvm/njvmld.pas
  2. 12 3
      compiler/nld.pas

+ 11 - 0
compiler/jvm/njvmld.pas

@@ -42,6 +42,9 @@ type
   end;
 
   tjvmassignmentnode  = class(tcgassignmentnode)
+   protected
+    function direct_shortstring_assignment: boolean; override;
+   public
     function pass_1: tnode; override;
   end;
 
@@ -65,6 +68,14 @@ uses
 
 { tjvmassignmentnode }
 
+function tjvmassignmentnode.direct_shortstring_assignment: boolean;
+  begin
+    if maybe_find_real_class_definition(right.resultdef,false)=java_jlstring then
+      inserttypeconv_explicit(right,cunicodestringtype);
+    result:=right.resultdef.typ=stringdef;
+  end;
+
+
 function tjvmassignmentnode.pass_1: tnode;
   var
     block: tblocknode;

+ 12 - 3
compiler/nld.pas

@@ -67,6 +67,9 @@ interface
        tassigntype = (at_normal,at_plus,at_minus,at_star,at_slash);
 
        tassignmentnode = class(tbinarynode)
+         protected
+          function direct_shortstring_assignment: boolean; virtual;
+         public
           assigntype : tassigntype;
           constructor create(l,r : tnode);virtual;
           { no checks for validity of assignment }
@@ -474,6 +477,14 @@ implementation
                              TASSIGNMENTNODE
 *****************************************************************************}
 
+    function tassignmentnode.direct_shortstring_assignment: boolean;
+      begin
+        result:=
+          is_char(right.resultdef) or
+          (right.resultdef.typ=stringdef);
+      end;
+
+
     constructor tassignmentnode.create(l,r : tnode);
 
       begin
@@ -603,9 +614,7 @@ implementation
            { insert typeconv, except for chars that are handled in
              secondpass and except for ansi/wide string that can
              be converted immediatly }
-           if (not is_char(right.resultdef) or
-               (target_info.system in systems_managed_vm)) and
-              (right.resultdef.typ<>stringdef) then
+           if not direct_shortstring_assignment then
              inserttypeconv(right,left.resultdef);
            if right.resultdef.typ=stringdef then
             begin