Răsfoiți Sursa

* fixed wrongly written system.$unicodetype type definition
* improved code generation for unicodestrings

git-svn-id: trunk@11776 -

florian 17 ani în urmă
părinte
comite
2e89b30e86
2 a modificat fișierele cu 20 adăugiri și 13 ștergeri
  1. 19 12
      compiler/nadd.pas
  2. 1 1
      compiler/psystem.pas

+ 19 - 12
compiler/nadd.pas

@@ -829,14 +829,22 @@ implementation
             end;
          end;
 
+        { If both operands are constant and there is a unicodestring
+          or unicodestring then convert everything to unicodestring }
+        if is_constnode(right) and is_constnode(left) and
+           (is_unicodestring(right.resultdef) or
+            is_unicodestring(left.resultdef)) then
+          begin
+            inserttypeconv(right,cunicodestringtype);
+            inserttypeconv(left,cunicodestringtype);
+          end;
+
         { If both operands are constant and there is a widechar
           or widestring then convert everything to widestring. This
           allows constant folding like char+widechar }
         if is_constnode(right) and is_constnode(left) and
            (is_widestring(right.resultdef) or
             is_widestring(left.resultdef) or
-            is_unicodestring(right.resultdef) or
-            is_unicodestring(left.resultdef) or
             is_widechar(right.resultdef) or
             is_widechar(left.resultdef)) then
           begin
@@ -1423,14 +1431,13 @@ implementation
               begin
                 { Is there a unicodestring? }
                 if is_unicodestring(rd) or is_unicodestring(ld) then
-                  strtype:= st_unicodestring
+                  strtype:=st_unicodestring
                 else
                 { Is there a widestring? }
-                if is_widestring(rd) or is_widestring(ld) or
-                   is_unicodestring(rd) or is_unicodestring(ld) or
-                   is_pwidechar(rd) or is_widechararray(rd) or is_widechar(rd) or is_open_widechararray(rd) or
-                   is_pwidechar(ld) or is_widechararray(ld) or is_widechar(ld) or is_open_widechararray(ld) then
-                  strtype:= st_widestring
+                  if is_widestring(rd) or is_widestring(ld) or
+                     is_pwidechar(rd) or is_widechararray(rd) or is_widechar(rd) or is_open_widechararray(rd) or
+                     is_pwidechar(ld) or is_widechararray(ld) or is_widechar(ld) or is_open_widechararray(ld) then
+                    strtype:=st_widestring
                 else
                   if is_ansistring(rd) or is_ansistring(ld) or
                      ((cs_ansistrings in current_settings.localswitches) and
@@ -1440,10 +1447,10 @@ implementation
                        is_pchar(ld) or (is_chararray(ld) and (ld.size > 255)) or is_open_chararray(ld)
                       )
                      ) then
-                    strtype:= st_ansistring
+                    strtype:=st_ansistring
                 else
                   if is_longstring(rd) or is_longstring(ld) then
-                    strtype:= st_longstring
+                    strtype:=st_longstring
                 else
                   begin
                     { TODO: todo: add a warning/hint here if one converting a too large array}
@@ -1753,9 +1760,9 @@ implementation
                   begin
                     { for strings, return is always a 255 char string }
                     if is_shortstring(left.resultdef) then
-                     resultdef:=cshortstringtype
+                      resultdef:=cshortstringtype
                     else
-                     resultdef:=left.resultdef;
+                      resultdef:=left.resultdef;
                   end;
                 else
                   resultdef:=left.resultdef;

+ 1 - 1
compiler/psystem.pas

@@ -308,7 +308,7 @@ implementation
         addtype('$longstring',clongstringtype);
         addtype('$ansistring',cansistringtype);
         addtype('$widestring',cwidestringtype);
-        addtype('$unicodestring',cwidestringtype);
+        addtype('$unicodestring',cunicodestringtype);
         addtype('$openshortstring',openshortstringtype);
         addtype('$boolean',booltype);
         addtype('$boolean8',bool8type);