* initialize tguid typed constants by searching for the named fields we need,

rather than assuming they appear in a fixed order in the symtable (so that
    adding e.g. record methods doesn't mess things up)

git-svn-id: trunk@35190 -
This commit is contained in:
Jonas Maebe 2016-12-23 20:17:09 +00:00
parent 7f375ac7bc
commit a0c50336f3

View File

@ -1679,21 +1679,23 @@ implementation
procedure ttai_typedconstbuilder.emit_guid_const(const guid: tguid); procedure ttai_typedconstbuilder.emit_guid_const(const guid: tguid);
var var
i: longint; i: longint;
field: tfieldvarsym;
begin begin
maybe_begin_aggregate(rec_tguid); maybe_begin_aggregate(rec_tguid);
{ variant record -> must specify which fields get initialised } { variant record -> must specify which fields get initialised }
next_field:=tfieldvarsym(rec_tguid.symtable.symlist[0]); next_field:=tfieldvarsym(rec_tguid.symtable.Find('DATA1'));
emit_tai(Tai_const.Create_32bit(longint(guid.D1)),u32inttype); emit_tai(Tai_const.Create_32bit(longint(guid.D1)),u32inttype);
next_field:=tfieldvarsym(rec_tguid.symtable.symlist[1]); next_field:=tfieldvarsym(rec_tguid.symtable.Find('DATA2'));
emit_tai(Tai_const.Create_16bit(guid.D2),u16inttype); emit_tai(Tai_const.Create_16bit(guid.D2),u16inttype);
next_field:=tfieldvarsym(rec_tguid.symtable.symlist[2]); next_field:=tfieldvarsym(rec_tguid.symtable.Find('DATA3'));
emit_tai(Tai_const.Create_16bit(guid.D3),u16inttype); emit_tai(Tai_const.Create_16bit(guid.D3),u16inttype);
next_field:=tfieldvarsym(rec_tguid.symtable.symlist[3]); field:=tfieldvarsym(rec_tguid.symtable.Find('DATA4'));
next_field:=field;
{ the array } { the array }
maybe_begin_aggregate(tfieldvarsym(rec_tguid.symtable.symlist[3]).vardef); maybe_begin_aggregate(field.vardef);
for i:=Low(guid.D4) to High(guid.D4) do for i:=Low(guid.D4) to High(guid.D4) do
emit_tai(Tai_const.Create_8bit(guid.D4[i]),u8inttype); emit_tai(Tai_const.Create_8bit(guid.D4[i]),u8inttype);
maybe_end_aggregate(tfieldvarsym(rec_tguid.symtable.symlist[3]).vardef); maybe_end_aggregate(field.vardef);
maybe_end_aggregate(rec_tguid); maybe_end_aggregate(rec_tguid);
end; end;