Răsfoiți Sursa

compiler: move ansistring codepage number replacement code from the asm generator to one level up. output both 0 and CP_NONE ansistring constants as constants with codepage 0. codepage 0 means CP_ACP and it will be properly understood of RTL routines while codepage CP_NONE means no codepage. For delphi unicode mode output them in compiler codepage as before.

git-svn-id: trunk@19459 -
paul 14 ani în urmă
părinte
comite
b1b0b2bb1f
2 a modificat fișierele cu 14 adăugiri și 8 ștergeri
  1. 0 4
      compiler/asmutils.pas
  2. 14 4
      compiler/ncgcon.pas

+ 0 - 4
compiler/asmutils.pas

@@ -59,10 +59,6 @@ uses
             current_asmdata.getdatalabel(referencelab);
             list.concat(tai_label.create(referencelab));
           end;
-        if (encoding=0) then
-          encoding:=CP_NONE;
-        if (encoding=CP_NONE) and (m_systemcodepage in current_settings.modeswitches) then
-          encoding:=current_settings.sourcecodepage;
         list.concat(tai_const.create_16bit(encoding));
         list.concat(tai_const.create_16bit(1));
 {$ifdef cpu64bitaddr}

+ 14 - 4
compiler/ncgcon.pas

@@ -258,6 +258,7 @@ implementation
          href: treference;
          pool: THashSet;
          entry: PHashSetItem;
+         cp: tstringencoding;
 
       const
         PoolMap: array[tconststringtype] of TConstPoolType = (
@@ -282,12 +283,21 @@ implementation
               pool := current_asmdata.ConstPools[PoolMap[cst_type]];
 
               if cst_type in [cst_widestring, cst_unicodestring] then
-                entry := pool.FindOrAdd(pcompilerwidestring(value_str)^.data, len*cwidechartype.size)
+                entry := pool.FindOrAdd(pcompilerwidestring(value_str)^.data,len*cwidechartype.size)
               else
               if cst_type = cst_ansistring then
-                entry := PHashSetItem(TTagHashSet(pool).FindOrAdd(value_str, len, tstringdef(resultdef).encoding))
+                begin
+                  cp:=tstringdef(resultdef).encoding;
+                  { force output of RawByteString constants in CP_ACP codepage }
+                  if cp=CP_NONE then
+                    cp:=0;
+                  { for delphiuncode mode output CP_ACP constants in the compiler codepage }
+                  if (cp=0) and (m_systemcodepage in current_settings.modeswitches) then
+                    cp:=current_settings.sourcecodepage;
+                  entry := PHashSetItem(TTagHashSet(pool).FindOrAdd(value_str,len,cp))
+                end
               else
-                entry := pool.FindOrAdd(value_str, len);
+                entry := pool.FindOrAdd(value_str,len);
 
               lab_str := TAsmLabel(entry^.Data);  // is it needed anymore?
 
@@ -300,7 +310,7 @@ implementation
                            if len=0 then
                              InternalError(2008032301)   { empty string should be handled above }
                            else
-                             lastlabel:=emit_ansistring_const(current_asmdata.AsmLists[al_typedconsts],value_str,len,tstringdef(resultdef).encoding);
+                             lastlabel:=emit_ansistring_const(current_asmdata.AsmLists[al_typedconsts],value_str,len,cp);
                         end;
                       cst_unicodestring,
                       cst_widestring: