浏览代码

compiler: manual merge some cpstrnew changes which was impossible to merge using regular tools due to the merge conflicts

git-svn-id: trunk@19131 -
paul 14 年之前
父节点
当前提交
aba0106366
共有 5 个文件被更改,包括 31 次插入11 次删除
  1. 19 6
      compiler/asmutils.pas
  2. 3 3
      compiler/cresstr.pas
  3. 2 1
      compiler/ncgcon.pas
  4. 2 1
      compiler/ptconst.pas
  5. 5 0
      compiler/symdef.pas

+ 19 - 6
compiler/asmutils.pas

@@ -26,26 +26,26 @@ interface
 {$i fpcdefs.inc}
 {$i fpcdefs.inc}
 
 
 uses
 uses
+  globtype,
   aasmbase,
   aasmbase,
   aasmdata;
   aasmdata;
 
 
 
 
-    function emit_ansistring_const(list:TAsmList;data:PChar;len:LongInt;NewSection:Boolean=True):TAsmLabel;
-    function emit_unicodestring_const(list:TAsmList;data:Pointer;Winlike:Boolean):TAsmLabel;
+    function emit_ansistring_const(list:TAsmList;data:PChar;len:LongInt;encoding:tstringencoding;NewSection:Boolean=True):TAsmLabel;
+    function emit_unicodestring_const(list:TAsmList;data:Pointer;encoding:tstringencoding;Winlike:Boolean):TAsmLabel;
 
 
 
 
 implementation
 implementation
 
 
 uses
 uses
   globals,
   globals,
-  globtype,
   systems,
   systems,
   verbose,
   verbose,
   aasmtai,
   aasmtai,
   widestr,
   widestr,
   symdef;
   symdef;
 
 
-    function emit_ansistring_const(list:TAsmList;data:PChar;len:LongInt;NewSection:Boolean): TAsmLabel;
+    function emit_ansistring_const(list:TAsmList;data:PChar;len:LongInt;encoding:tstringencoding;NewSection:Boolean): TAsmLabel;
       var
       var
         referencelab: TAsmLabel;
         referencelab: TAsmLabel;
         s: PChar;
         s: PChar;
@@ -59,6 +59,12 @@ uses
             current_asmdata.getdatalabel(referencelab);
             current_asmdata.getdatalabel(referencelab);
             list.concat(tai_label.create(referencelab));
             list.concat(tai_label.create(referencelab));
           end;
           end;
+        list.concat(tai_const.create_16bit(encoding));
+        list.concat(tai_const.create_16bit(1));
+{$ifdef cpu64bitaddr}
+        { dummy for alignment }
+        list.concat(tai_const.create_32bit(0));
+{$endif cpu64bitaddr}
         list.concat(tai_const.create_pint(-1));
         list.concat(tai_const.create_pint(-1));
         list.concat(tai_const.create_pint(len));
         list.concat(tai_const.create_pint(len));
         { make sure the string doesn't get dead stripped if the header is referenced }
         { make sure the string doesn't get dead stripped if the header is referenced }
@@ -75,7 +81,8 @@ uses
         list.concat(tai_string.create_pchar(s,len+1)); { terminating zero included }
         list.concat(tai_string.create_pchar(s,len+1)); { terminating zero included }
       end;
       end;
 
 
-    function emit_unicodestring_const(list:TAsmList;data:Pointer;Winlike:Boolean):TAsmLabel;
+
+    function emit_unicodestring_const(list:TAsmList;data:Pointer;encoding:tstringencoding;Winlike:Boolean):TAsmLabel;
       var
       var
         referencelab: TAsmLabel;
         referencelab: TAsmLabel;
         i, strlength: SizeInt;
         i, strlength: SizeInt;
@@ -89,8 +96,14 @@ uses
             list.concat(tai_label.create(referencelab));
             list.concat(tai_label.create(referencelab));
           end;
           end;
         strlength := getlengthwidestring(pcompilerwidestring(data));
         strlength := getlengthwidestring(pcompilerwidestring(data));
+        list.concat(tai_const.create_16bit(encoding));
+        list.concat(tai_const.create_16bit(2));
+{$ifdef cpu64bitaddr}
+        { dummy for alignment }
+        list.concat(Tai_const.Create_32bit(0));
+{$endif cpu64bitaddr}
         if Winlike then
         if Winlike then
-           list.concat(Tai_const.Create_32bit(strlength*cwidechartype.size))
+          list.concat(Tai_const.Create_32bit(strlength*cwidechartype.size))
         else
         else
           begin
           begin
             list.concat(Tai_const.Create_pint(-1));
             list.concat(Tai_const.Create_pint(-1));

+ 3 - 3
compiler/cresstr.pas

@@ -146,7 +146,7 @@ uses
           make_mangledname('RESSTR',current_module.localsymtable,'START'),AT_DATA,0));
           make_mangledname('RESSTR',current_module.localsymtable,'START'),AT_DATA,0));
 
 
         { Write unitname entry }
         { Write unitname entry }
-        namelab:=emit_ansistring_const(current_asmdata.asmlists[al_const],@current_module.localsymtable.name^[1],length(current_module.localsymtable.name^),False);
+        namelab:=emit_ansistring_const(current_asmdata.asmlists[al_const],@current_module.localsymtable.name^[1],length(current_module.localsymtable.name^),DefaultSystemCodePage,False);
         current_asmdata.asmlists[al_resourcestrings].concat(tai_const.create_sym(namelab));
         current_asmdata.asmlists[al_resourcestrings].concat(tai_const.create_sym(namelab));
         current_asmdata.asmlists[al_resourcestrings].concat(tai_const.create_sym(nil));
         current_asmdata.asmlists[al_resourcestrings].concat(tai_const.create_sym(nil));
         current_asmdata.asmlists[al_resourcestrings].concat(tai_const.create_sym(nil));
         current_asmdata.asmlists[al_resourcestrings].concat(tai_const.create_sym(nil));
@@ -162,12 +162,12 @@ uses
             new_section(current_asmdata.asmlists[al_const],sec_rodata,make_mangledname('RESSTR',current_module.localsymtable,'d_'+r.name),sizeof(pint));
             new_section(current_asmdata.asmlists[al_const],sec_rodata,make_mangledname('RESSTR',current_module.localsymtable,'d_'+r.name),sizeof(pint));
             { Write default value }
             { Write default value }
             if assigned(R.value) and (R.len<>0) then
             if assigned(R.value) and (R.len<>0) then
-              valuelab:=emit_ansistring_const(current_asmdata.asmlists[al_const],R.Value,R.Len,False)
+              valuelab:=emit_ansistring_const(current_asmdata.asmlists[al_const],R.Value,R.Len,DefaultSystemCodePage,False)
             else
             else
               valuelab:=nil;
               valuelab:=nil;
             { Append the name as a ansistring. }
             { Append the name as a ansistring. }
             current_asmdata.asmlists[al_const].concat(cai_align.Create(const_align(sizeof(pint))));
             current_asmdata.asmlists[al_const].concat(cai_align.Create(const_align(sizeof(pint))));
-            namelab:=emit_ansistring_const(current_asmdata.asmlists[al_const],@R.Name[1],length(R.name),False);
+            namelab:=emit_ansistring_const(current_asmdata.asmlists[al_const],@R.Name[1],length(R.name),DefaultSystemCodePage,False);
 
 
             {
             {
               Resourcestring index:
               Resourcestring index:

+ 2 - 1
compiler/ncgcon.pas

@@ -304,7 +304,7 @@ implementation
                            if len=0 then
                            if len=0 then
                              InternalError(2008032301)   { empty string should be handled above }
                              InternalError(2008032301)   { empty string should be handled above }
                            else
                            else
-                             lastlabel:=emit_ansistring_const(current_asmdata.AsmLists[al_typedconsts],value_str,len);
+                             lastlabel:=emit_ansistring_const(current_asmdata.AsmLists[al_typedconsts],value_str,len,tstringdef(resultdef).encoding);
                         end;
                         end;
                       cst_unicodestring,
                       cst_unicodestring,
                       cst_widestring:
                       cst_widestring:
@@ -314,6 +314,7 @@ implementation
                            else
                            else
                              lastlabel := emit_unicodestring_const(current_asmdata.AsmLists[al_typedconsts],
                              lastlabel := emit_unicodestring_const(current_asmdata.AsmLists[al_typedconsts],
                                              value_str,
                                              value_str,
+                                             tstringdef(resultdef).encoding,
                                              (cst_type=cst_widestring) and (tf_winlikewidestring in target_info.flags));
                                              (cst_type=cst_widestring) and (tf_winlikewidestring in target_info.flags));
                         end;
                         end;
                       cst_shortstring:
                       cst_shortstring:

+ 2 - 1
compiler/ptconst.pas

@@ -754,7 +754,7 @@ implementation
                      if (strlength=0) then
                      if (strlength=0) then
                        ll := nil
                        ll := nil
                      else
                      else
-                       ll := emit_ansistring_const(current_asmdata.asmlists[al_const],strval,strlength);
+                       ll := emit_ansistring_const(current_asmdata.asmlists[al_const],strval,strlength,def.encoding);
                      hr.list.concat(Tai_const.Create_sym(ll));
                      hr.list.concat(Tai_const.Create_sym(ll));
                   end;
                   end;
                 st_unicodestring,
                 st_unicodestring,
@@ -768,6 +768,7 @@ implementation
                        winlike := (def.stringtype=st_widestring) and (tf_winlikewidestring in target_info.flags);
                        winlike := (def.stringtype=st_widestring) and (tf_winlikewidestring in target_info.flags);
                        ll := emit_unicodestring_const(current_asmdata.asmlists[al_const],
                        ll := emit_unicodestring_const(current_asmdata.asmlists[al_const],
                               strval,
                               strval,
+                              def.encoding,
                               winlike);
                               winlike);
 
 
                        { Collect Windows widestrings that need initialization at startup.
                        { Collect Windows widestrings that need initialization at startup.

+ 5 - 0
compiler/symdef.pas

@@ -1411,6 +1411,7 @@ implementation
       begin
       begin
          inherited create(stringdef);
          inherited create(stringdef);
          stringtype:=st_shortstring;
          stringtype:=st_shortstring;
+         encoding:=0;
          len:=l;
          len:=l;
          savesize:=len+1;
          savesize:=len+1;
       end;
       end;
@@ -1420,6 +1421,7 @@ implementation
       begin
       begin
          inherited ppuload(stringdef,ppufile);
          inherited ppuload(stringdef,ppufile);
          stringtype:=st_shortstring;
          stringtype:=st_shortstring;
+         encoding:=0;
          len:=ppufile.getbyte;
          len:=ppufile.getbyte;
          savesize:=len+1;
          savesize:=len+1;
       end;
       end;
@@ -1429,6 +1431,7 @@ implementation
       begin
       begin
          inherited create(stringdef);
          inherited create(stringdef);
          stringtype:=st_longstring;
          stringtype:=st_longstring;
+         encoding:=0;
          len:=l;
          len:=l;
          savesize:=sizeof(pint);
          savesize:=sizeof(pint);
       end;
       end;
@@ -1438,6 +1441,7 @@ implementation
       begin
       begin
          inherited ppuload(stringdef,ppufile);
          inherited ppuload(stringdef,ppufile);
          stringtype:=st_longstring;
          stringtype:=st_longstring;
+         encoding:=0;
          len:=ppufile.getasizeint;
          len:=ppufile.getasizeint;
          savesize:=sizeof(pint);
          savesize:=sizeof(pint);
       end;
       end;
@@ -1477,6 +1481,7 @@ implementation
       begin
       begin
          inherited ppuload(stringdef,ppufile);
          inherited ppuload(stringdef,ppufile);
          stringtype:=st_widestring;
          stringtype:=st_widestring;
+         encoding:=CP_UTF16;
          len:=ppufile.getaint;
          len:=ppufile.getaint;
          savesize:=sizeof(pint);
          savesize:=sizeof(pint);
       end;
       end;