mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-14 21:59:47 +02:00
* emit all resource strings and internal dynamic string data using the
def representing that string type, instead of using p(wide)char o these string types are represented the same in llvm as p(wide)char, but this way we can check whether the emitted data type matches the expected one in the future git-svn-id: trunk@32715 -
This commit is contained in:
parent
787caf4dda
commit
f83f9168ee
@ -299,6 +299,7 @@ type
|
||||
protected
|
||||
procedure maybe_emit_tail_padding(def: tdef); virtual;
|
||||
function emit_string_const_common(stringtype: tstringtype; len: asizeint; encoding: tstringencoding; var startlab: tasmlabel):tasmlabofs;
|
||||
function get_dynstring_def_for_type(stringtype: tstringtype; winlikewidestring: boolean): tstringdef;
|
||||
procedure begin_aggregate_internal(def: tdef; anonymous: boolean); virtual;
|
||||
procedure end_aggregate_internal(def: tdef; anonymous: boolean); virtual;
|
||||
{ when building an anonymous record, we cannot immediately insert the
|
||||
@ -1280,6 +1281,21 @@ implementation
|
||||
end;
|
||||
|
||||
|
||||
function ttai_typedconstbuilder.get_dynstring_def_for_type(stringtype: tstringtype; winlikewidestring: boolean): tstringdef;
|
||||
begin
|
||||
if stringtype=st_ansistring then
|
||||
result:=tstringdef(cansistringtype)
|
||||
else if (stringtype=st_unicodestring) or
|
||||
((stringtype=st_widestring) and
|
||||
not winlikewidestring) then
|
||||
result:=tstringdef(cunicodestringtype)
|
||||
else if stringtype=st_widestring then
|
||||
result:=tstringdef(cwidestringtype)
|
||||
else
|
||||
internalerror(2015122101);
|
||||
end;
|
||||
|
||||
|
||||
procedure ttai_typedconstbuilder.begin_aggregate_internal(def: tdef; anonymous: boolean);
|
||||
var
|
||||
info: taggregateinformation;
|
||||
@ -1468,7 +1484,7 @@ implementation
|
||||
|
||||
procedure ttai_typedconstbuilder.emit_string_offset(const ll: tasmlabofs; const strlength: longint; const st: tstringtype; const winlikewidestring: boolean; const charptrdef: tdef);
|
||||
begin
|
||||
emit_tai(Tai_const.Create_sym_offset(ll.lab,ll.ofs),charptrdef);
|
||||
emit_tai(Tai_const.Create_sym_offset(ll.lab,ll.ofs),get_dynstring_def_for_type(st,winlikewidestring));
|
||||
end;
|
||||
|
||||
|
||||
|
@ -147,8 +147,8 @@ uses
|
||||
tcb.maybe_begin_aggregate(resstrdef);
|
||||
namelab:=tcb.emit_ansistring_const(current_asmdata.asmlists[al_const],@current_module.localsymtable.name^[1],length(current_module.localsymtable.name^),getansistringcodepage);
|
||||
tcb.emit_string_offset(namelab,length(current_module.localsymtable.name^),st_ansistring,false,charpointertype);
|
||||
tcb.emit_tai(tai_const.create_nil_dataptr,voidpointertype);
|
||||
tcb.emit_tai(tai_const.create_nil_dataptr,voidpointertype);
|
||||
tcb.emit_tai(tai_const.create_nil_dataptr,cansistringtype);
|
||||
tcb.emit_tai(tai_const.create_nil_dataptr,cansistringtype);
|
||||
tcb.emit_ord_const(0,u32inttype);
|
||||
tcb.maybe_end_aggregate(resstrdef);
|
||||
current_asmdata.asmlists[al_resourcestrings].concatList(
|
||||
|
@ -322,6 +322,7 @@ implementation
|
||||
srsym : tsym;
|
||||
srsymtable: tsymtable;
|
||||
strrecdef : trecorddef;
|
||||
strdef: tdef;
|
||||
offset: pint;
|
||||
field: tfieldvarsym;
|
||||
dataptrdef: tdef;
|
||||
@ -349,7 +350,10 @@ implementation
|
||||
field:=trecordsymtable(strrecdef.symtable).findfieldbyoffset(offset);
|
||||
{ pointerdef to the string data array }
|
||||
dataptrdef:=cpointerdef.getreusable(field.vardef);
|
||||
queue_init(charptrdef);
|
||||
{ the fields of the resourcestring record are declared as ansistring }
|
||||
strdef:=get_dynstring_def_for_type(st,winlikewidestring);
|
||||
queue_init(strdef);
|
||||
queue_typeconvn(charptrdef,strdef);
|
||||
queue_subscriptn(strrecdef,field);
|
||||
queue_emit_asmsym(ll.lab,strrecdef);
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user