mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-13 13:29:27 +02:00
compiler: manual merge some cpstrnew changes which was impossible to merge using regular tools due to the merge conflicts
git-svn-id: trunk@19131 -
This commit is contained in:
parent
f238c9161b
commit
aba0106366
@ -26,26 +26,26 @@ interface
|
||||
{$i fpcdefs.inc}
|
||||
|
||||
uses
|
||||
globtype,
|
||||
aasmbase,
|
||||
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
|
||||
|
||||
uses
|
||||
globals,
|
||||
globtype,
|
||||
systems,
|
||||
verbose,
|
||||
aasmtai,
|
||||
widestr,
|
||||
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
|
||||
referencelab: TAsmLabel;
|
||||
s: PChar;
|
||||
@ -59,6 +59,12 @@ uses
|
||||
current_asmdata.getdatalabel(referencelab);
|
||||
list.concat(tai_label.create(referencelab));
|
||||
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(len));
|
||||
{ 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 }
|
||||
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
|
||||
referencelab: TAsmLabel;
|
||||
i, strlength: SizeInt;
|
||||
@ -89,8 +96,14 @@ uses
|
||||
list.concat(tai_label.create(referencelab));
|
||||
end;
|
||||
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
|
||||
list.concat(Tai_const.Create_32bit(strlength*cwidechartype.size))
|
||||
list.concat(Tai_const.Create_32bit(strlength*cwidechartype.size))
|
||||
else
|
||||
begin
|
||||
list.concat(Tai_const.Create_pint(-1));
|
||||
|
@ -146,7 +146,7 @@ uses
|
||||
make_mangledname('RESSTR',current_module.localsymtable,'START'),AT_DATA,0));
|
||||
|
||||
{ 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(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));
|
||||
{ Write default value }
|
||||
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
|
||||
valuelab:=nil;
|
||||
{ Append the name as a ansistring. }
|
||||
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:
|
||||
|
@ -304,7 +304,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);
|
||||
lastlabel:=emit_ansistring_const(current_asmdata.AsmLists[al_typedconsts],value_str,len,tstringdef(resultdef).encoding);
|
||||
end;
|
||||
cst_unicodestring,
|
||||
cst_widestring:
|
||||
@ -314,6 +314,7 @@ implementation
|
||||
else
|
||||
lastlabel := emit_unicodestring_const(current_asmdata.AsmLists[al_typedconsts],
|
||||
value_str,
|
||||
tstringdef(resultdef).encoding,
|
||||
(cst_type=cst_widestring) and (tf_winlikewidestring in target_info.flags));
|
||||
end;
|
||||
cst_shortstring:
|
||||
|
@ -754,7 +754,7 @@ implementation
|
||||
if (strlength=0) then
|
||||
ll := nil
|
||||
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));
|
||||
end;
|
||||
st_unicodestring,
|
||||
@ -768,6 +768,7 @@ implementation
|
||||
winlike := (def.stringtype=st_widestring) and (tf_winlikewidestring in target_info.flags);
|
||||
ll := emit_unicodestring_const(current_asmdata.asmlists[al_const],
|
||||
strval,
|
||||
def.encoding,
|
||||
winlike);
|
||||
|
||||
{ Collect Windows widestrings that need initialization at startup.
|
||||
|
@ -1411,6 +1411,7 @@ implementation
|
||||
begin
|
||||
inherited create(stringdef);
|
||||
stringtype:=st_shortstring;
|
||||
encoding:=0;
|
||||
len:=l;
|
||||
savesize:=len+1;
|
||||
end;
|
||||
@ -1420,6 +1421,7 @@ implementation
|
||||
begin
|
||||
inherited ppuload(stringdef,ppufile);
|
||||
stringtype:=st_shortstring;
|
||||
encoding:=0;
|
||||
len:=ppufile.getbyte;
|
||||
savesize:=len+1;
|
||||
end;
|
||||
@ -1429,6 +1431,7 @@ implementation
|
||||
begin
|
||||
inherited create(stringdef);
|
||||
stringtype:=st_longstring;
|
||||
encoding:=0;
|
||||
len:=l;
|
||||
savesize:=sizeof(pint);
|
||||
end;
|
||||
@ -1438,6 +1441,7 @@ implementation
|
||||
begin
|
||||
inherited ppuload(stringdef,ppufile);
|
||||
stringtype:=st_longstring;
|
||||
encoding:=0;
|
||||
len:=ppufile.getasizeint;
|
||||
savesize:=sizeof(pint);
|
||||
end;
|
||||
@ -1477,6 +1481,7 @@ implementation
|
||||
begin
|
||||
inherited ppuload(stringdef,ppufile);
|
||||
stringtype:=st_widestring;
|
||||
encoding:=CP_UTF16;
|
||||
len:=ppufile.getaint;
|
||||
savesize:=sizeof(pint);
|
||||
end;
|
||||
|
Loading…
Reference in New Issue
Block a user