From 2e89b30e86e71065228406addd6830a27bfe7728 Mon Sep 17 00:00:00 2001 From: florian Date: Sun, 14 Sep 2008 15:22:32 +0000 Subject: [PATCH] * fixed wrongly written system.$unicodetype type definition * improved code generation for unicodestrings git-svn-id: trunk@11776 - --- compiler/nadd.pas | 31 +++++++++++++++++++------------ compiler/psystem.pas | 2 +- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/compiler/nadd.pas b/compiler/nadd.pas index a7a3ad30f3..33053366a6 100644 --- a/compiler/nadd.pas +++ b/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; diff --git a/compiler/psystem.pas b/compiler/psystem.pas index b7f1f9b271..7ea530292a 100644 --- a/compiler/psystem.pas +++ b/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);