mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-17 21:49:18 +02:00
+ tdataconstnode, implemented for usage in dispatch stuff
git-svn-id: trunk@5208 -
This commit is contained in:
parent
43ed587de0
commit
a7b317aa96
@ -30,6 +30,10 @@ interface
|
|||||||
node,ncon;
|
node,ncon;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
tcgdataconstnode = class(tdataconstnode)
|
||||||
|
procedure pass_generate_code;override;
|
||||||
|
end;
|
||||||
|
|
||||||
tcgrealconstnode = class(trealconstnode)
|
tcgrealconstnode = class(trealconstnode)
|
||||||
procedure pass_generate_code;override;
|
procedure pass_generate_code;override;
|
||||||
end;
|
end;
|
||||||
@ -71,6 +75,30 @@ implementation
|
|||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
|
{*****************************************************************************
|
||||||
|
TCGREALCONSTNODE
|
||||||
|
*****************************************************************************}
|
||||||
|
|
||||||
|
procedure tcgdataconstnode.pass_generate_code;
|
||||||
|
var
|
||||||
|
l : tasmlabel;
|
||||||
|
i : aint;
|
||||||
|
b : byte;
|
||||||
|
begin
|
||||||
|
location_reset(location,LOC_CREFERENCE,OS_NO);
|
||||||
|
current_asmdata.getdatalabel(l);
|
||||||
|
maybe_new_object_file(current_asmdata.asmlists[al_typedconsts]);
|
||||||
|
new_section(current_asmdata.asmlists[al_typedconsts],sec_rodata,l.name,const_align(maxalign));
|
||||||
|
current_asmdata.asmlists[al_typedconsts].concat(Tai_label.Create(l));
|
||||||
|
data.seek(0);
|
||||||
|
for i:=0 to data.size-1 do
|
||||||
|
begin
|
||||||
|
data.read(b,1);
|
||||||
|
current_asmdata.asmlists[al_typedconsts].concat(Tai_const.Create_8bit(b));
|
||||||
|
end;
|
||||||
|
location.reference.symbol:=l;
|
||||||
|
end;
|
||||||
|
|
||||||
{*****************************************************************************
|
{*****************************************************************************
|
||||||
TCGREALCONSTNODE
|
TCGREALCONSTNODE
|
||||||
*****************************************************************************}
|
*****************************************************************************}
|
||||||
@ -617,6 +645,7 @@ implementation
|
|||||||
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
cdataconstnode:=tcgdataconstnode;
|
||||||
crealconstnode:=tcgrealconstnode;
|
crealconstnode:=tcgrealconstnode;
|
||||||
cordconstnode:=tcgordconstnode;
|
cordconstnode:=tcgordconstnode;
|
||||||
cpointerconstnode:=tcgpointerconstnode;
|
cpointerconstnode:=tcgpointerconstnode;
|
||||||
|
@ -27,11 +27,29 @@ interface
|
|||||||
|
|
||||||
uses
|
uses
|
||||||
globtype,widestr,
|
globtype,widestr,
|
||||||
|
cclasses,
|
||||||
node,
|
node,
|
||||||
aasmbase,aasmtai,aasmdata,cpuinfo,globals,
|
aasmbase,aasmtai,aasmdata,cpuinfo,globals,
|
||||||
symconst,symtype,symdef,symsym;
|
symconst,symtype,symdef,symsym;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
tdataconstnode = class(tnode)
|
||||||
|
data : tdynamicarray;
|
||||||
|
maxalign : word;
|
||||||
|
constructor create;virtual;
|
||||||
|
constructor ppuload(t:tnodetype;ppufile:tcompilerppufile);override;
|
||||||
|
destructor destroy;override;
|
||||||
|
procedure ppuwrite(ppufile:tcompilerppufile);override;
|
||||||
|
function dogetcopy : tnode;override;
|
||||||
|
function pass_1 : tnode;override;
|
||||||
|
function pass_typecheck:tnode;override;
|
||||||
|
function docompare(p: tnode) : boolean; override;
|
||||||
|
procedure printnodedata(var t:text);override;
|
||||||
|
procedure append(const d;len : aint);inline;
|
||||||
|
procedure align(value : word);inline;
|
||||||
|
end;
|
||||||
|
tdataconstnodeclass = class of tdataconstnode;
|
||||||
|
|
||||||
trealconstnode = class(tnode)
|
trealconstnode = class(tnode)
|
||||||
typedef : tdef;
|
typedef : tdef;
|
||||||
typedefderef : tderef;
|
typedefderef : tderef;
|
||||||
@ -156,6 +174,7 @@ interface
|
|||||||
tguidconstnodeclass = class of tguidconstnode;
|
tguidconstnodeclass = class of tguidconstnode;
|
||||||
|
|
||||||
var
|
var
|
||||||
|
cdataconstnode : tdataconstnodeclass;
|
||||||
crealconstnode : trealconstnodeclass;
|
crealconstnode : trealconstnodeclass;
|
||||||
cordconstnode : tordconstnodeclass;
|
cordconstnode : tordconstnodeclass;
|
||||||
cpointerconstnode : tpointerconstnodeclass;
|
cpointerconstnode : tpointerconstnodeclass;
|
||||||
@ -262,6 +281,184 @@ implementation
|
|||||||
genconstsymtree:=p1;
|
genconstsymtree:=p1;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
{*****************************************************************************
|
||||||
|
TDATACONSTNODE
|
||||||
|
*****************************************************************************}
|
||||||
|
|
||||||
|
constructor tdataconstnode.create;
|
||||||
|
begin
|
||||||
|
inherited create(dataconstn);
|
||||||
|
data:=tdynamicarray.create(128);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
constructor tdataconstnode.ppuload(t:tnodetype;ppufile:tcompilerppufile);
|
||||||
|
var
|
||||||
|
len : aint;
|
||||||
|
buf : array[0..255] of byte;
|
||||||
|
begin
|
||||||
|
inherited ppuload(t,ppufile);
|
||||||
|
len:=ppufile.getaint;
|
||||||
|
if len<4096 then
|
||||||
|
data:=tdynamicarray.create(len)
|
||||||
|
else
|
||||||
|
data:=tdynamicarray.create(4096);
|
||||||
|
while len>0 do
|
||||||
|
begin
|
||||||
|
if len>sizeof(buf) then
|
||||||
|
begin
|
||||||
|
ppufile.getdata(buf,sizeof(buf));
|
||||||
|
data.write(buf,sizeof(buf));
|
||||||
|
dec(len,sizeof(buf));
|
||||||
|
end
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
ppufile.getdata(buf,len);
|
||||||
|
data.write(buf,len);
|
||||||
|
len:=0;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
destructor tdataconstnode.destroy;
|
||||||
|
begin
|
||||||
|
data.free;
|
||||||
|
inherited destroy;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure tdataconstnode.ppuwrite(ppufile:tcompilerppufile);
|
||||||
|
var
|
||||||
|
len : aint;
|
||||||
|
buf : array[0..255] of byte;
|
||||||
|
begin
|
||||||
|
inherited ppuwrite(ppufile);
|
||||||
|
len:=data.size;
|
||||||
|
ppufile.putaint(len);
|
||||||
|
data.seek(0);
|
||||||
|
while len>0 do
|
||||||
|
begin
|
||||||
|
if len>sizeof(buf) then
|
||||||
|
begin
|
||||||
|
data.read(buf,sizeof(buf));
|
||||||
|
ppufile.putdata(buf,sizeof(buf));
|
||||||
|
dec(len,sizeof(buf));
|
||||||
|
end
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
data.read(buf,len);
|
||||||
|
ppufile.putdata(buf,len);
|
||||||
|
len:=0;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
function tdataconstnode.dogetcopy : tnode;
|
||||||
|
var
|
||||||
|
n : tdataconstnode;
|
||||||
|
len : aint;
|
||||||
|
buf : array[0..255] of byte;
|
||||||
|
begin
|
||||||
|
n:=tdataconstnode(inherited dogetcopy);
|
||||||
|
len:=data.size;
|
||||||
|
if len<4096 then
|
||||||
|
n.data:=tdynamicarray.create(len)
|
||||||
|
else
|
||||||
|
n.data:=tdynamicarray.create(4096);
|
||||||
|
data.seek(0);
|
||||||
|
while len>0 do
|
||||||
|
begin
|
||||||
|
if len>sizeof(buf) then
|
||||||
|
begin
|
||||||
|
data.read(buf,sizeof(buf));
|
||||||
|
n.data.write(buf,sizeof(buf));
|
||||||
|
dec(len,sizeof(buf));
|
||||||
|
end
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
data.read(buf,len);
|
||||||
|
n.data.write(buf,len);
|
||||||
|
len:=0;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
function tdataconstnode.pass_1 : tnode;
|
||||||
|
begin
|
||||||
|
result:=nil;
|
||||||
|
expectloc:=LOC_CREFERENCE;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
function tdataconstnode.pass_typecheck:tnode;
|
||||||
|
begin
|
||||||
|
result:=nil;
|
||||||
|
resultdef:=voidpointertype;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
function tdataconstnode.docompare(p: tnode) : boolean;
|
||||||
|
var
|
||||||
|
b1,b2 : byte;
|
||||||
|
I : aint;
|
||||||
|
begin
|
||||||
|
docompare :=
|
||||||
|
inherited docompare(p) and (data.size=tdataconstnode(p).data.size);
|
||||||
|
if docompare then
|
||||||
|
begin
|
||||||
|
data.seek(0);
|
||||||
|
tdataconstnode(p).data.seek(0);
|
||||||
|
for i:=0 to data.size-1 do
|
||||||
|
begin
|
||||||
|
data.read(b1,1);
|
||||||
|
tdataconstnode(p).data.read(b2,1);
|
||||||
|
if b1<>b2 then
|
||||||
|
begin
|
||||||
|
docompare:=false;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure tdataconstnode.printnodedata(var t:text);
|
||||||
|
var
|
||||||
|
i : aint;
|
||||||
|
b : byte;
|
||||||
|
begin
|
||||||
|
inherited printnodedata(t);
|
||||||
|
write(t,printnodeindention,'data size = ',data.size,' data = ');
|
||||||
|
data.seek(0);
|
||||||
|
for i:=0 to data.size-1 do
|
||||||
|
begin
|
||||||
|
data.read(b,1);
|
||||||
|
if i=data.size-1 then
|
||||||
|
writeln(t,b)
|
||||||
|
else
|
||||||
|
write(t,b,',');
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure tdataconstnode.append(const d;len : aint);inline;
|
||||||
|
begin
|
||||||
|
data.seek(data.size);
|
||||||
|
data.write(data,len);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure tdataconstnode.align(value : word);
|
||||||
|
begin
|
||||||
|
if value>maxalign then
|
||||||
|
maxalign:=value;
|
||||||
|
data.align(value);
|
||||||
|
end;
|
||||||
|
|
||||||
{*****************************************************************************
|
{*****************************************************************************
|
||||||
TREALCONSTNODE
|
TREALCONSTNODE
|
||||||
*****************************************************************************}
|
*****************************************************************************}
|
||||||
@ -310,10 +507,8 @@ implementation
|
|||||||
|
|
||||||
|
|
||||||
function trealconstnode.dogetcopy : tnode;
|
function trealconstnode.dogetcopy : tnode;
|
||||||
|
|
||||||
var
|
var
|
||||||
n : trealconstnode;
|
n : trealconstnode;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
n:=trealconstnode(inherited dogetcopy);
|
n:=trealconstnode(inherited dogetcopy);
|
||||||
n.value_real:=value_real;
|
n.value_real:=value_real;
|
||||||
|
@ -108,7 +108,8 @@ interface
|
|||||||
loadvmtaddrn, { Load the address of the VMT of a class/object}
|
loadvmtaddrn, { Load the address of the VMT of a class/object}
|
||||||
guidconstn, { A GUID COM Interface constant }
|
guidconstn, { A GUID COM Interface constant }
|
||||||
rttin, { Rtti information so they can be accessed in result/firstpass}
|
rttin, { Rtti information so they can be accessed in result/firstpass}
|
||||||
loadparentfpn { Load the framepointer of the parent for nested procedures }
|
loadparentfpn, { Load the framepointer of the parent for nested procedures }
|
||||||
|
dataconstn { node storing some binary data }
|
||||||
);
|
);
|
||||||
|
|
||||||
tnodetypeset = set of tnodetype;
|
tnodetypeset = set of tnodetype;
|
||||||
@ -189,7 +190,8 @@ interface
|
|||||||
'loadvmtaddrn',
|
'loadvmtaddrn',
|
||||||
'guidconstn',
|
'guidconstn',
|
||||||
'rttin',
|
'rttin',
|
||||||
'loadparentfpn');
|
'loadparentfpn',
|
||||||
|
'dataconstn');
|
||||||
|
|
||||||
type
|
type
|
||||||
{ all boolean field of ttree are now collected in flags }
|
{ all boolean field of ttree are now collected in flags }
|
||||||
|
Loading…
Reference in New Issue
Block a user