* split constsym.value in valueord,valueordptr,valueptr. The valueordptr

is used for holding target platform pointer values. As those can be
    bigger than the source platform.
This commit is contained in:
peter 2001-09-02 21:18:28 +00:00
parent 1f4bac4fd0
commit 915b5cd7a9
9 changed files with 263 additions and 104 deletions

View File

@ -35,13 +35,11 @@ Type
TConstExprUInt = {$ifdef fpc}qword{$else}int64{$endif};
{ this must be an ordinal type with the same size as a pointer }
{ to allow some dirty type casts for example when using }
{ tconstsym.value }
{ Note: must be unsigned!! Otherwise, ugly code like }
{ pointer(-1) will result in a pointer with the value }
{ $fffffffffffffff on a 32bit machine if the compiler uses }
{ int64 constants internally (JM) }
TPointerOrd = cardinal;
TConstPtrUInt = cardinal;
Const
{ Size of native extended type }
@ -52,7 +50,12 @@ Implementation
end.
{
$Log$
Revision 1.3 2001-06-03 20:21:08 peter
Revision 1.4 2001-09-02 21:18:29 peter
* split constsym.value in valueord,valueordptr,valueptr. The valueordptr
is used for holding target platform pointer values. As those can be
bigger than the source platform.
Revision 1.3 2001/06/03 20:21:08 peter
* Kylix fixes, mostly case names of units
Revision 1.2 2001/02/08 13:09:03 jonas

View File

@ -78,6 +78,9 @@ implementation
if assigned(hp) then
begin
p.free;
{ run resulttypepass }
resulttypepass(hp);
{ switch to new node }
p:=hp;
end;
aktlocalswitches:=oldlocalswitches;
@ -92,7 +95,12 @@ implementation
codegenerror:=codegenerror or oldcodegenerror;
end
else
inc(multiresulttypepasscnt);
begin
{ update the codegenerror boolean with the previous result of this node }
if (nf_error in p.flags) then
codegenerror:=true;
inc(multiresulttypepasscnt);
end;
end;
@ -170,7 +178,12 @@ implementation
end.
{
$Log$
Revision 1.16 2001-08-26 13:36:44 florian
Revision 1.17 2001-09-02 21:18:28 peter
* split constsym.value in valueord,valueordptr,valueptr. The valueordptr
is used for holding target platform pointer values. As those can be
bigger than the source platform.
Revision 1.16 2001/08/26 13:36:44 florian
* some cg reorganisation
* some PPC updates

View File

@ -82,17 +82,17 @@ implementation
ordconstn:
begin
if is_constintnode(p) then
hp:=tconstsym.create_typed(name,constint,tordconstnode(p).value,tordconstnode(p).resulttype)
hp:=tconstsym.create_ord_typed(name,constint,tordconstnode(p).value,tordconstnode(p).resulttype)
else if is_constcharnode(p) then
hp:=tconstsym.create(name,constchar,tordconstnode(p).value)
hp:=tconstsym.create_ord(name,constchar,tordconstnode(p).value)
else if is_constboolnode(p) then
hp:=tconstsym.create(name,constbool,tordconstnode(p).value)
hp:=tconstsym.create_ord(name,constbool,tordconstnode(p).value)
else if is_constwidecharnode(p) then
hp:=tconstsym.create(name,constwchar,tordconstnode(p).value)
hp:=tconstsym.create_ord(name,constwchar,tordconstnode(p).value)
else if p.resulttype.def.deftype=enumdef then
hp:=tconstsym.create_typed(name,constord,tordconstnode(p).value,p.resulttype)
hp:=tconstsym.create_ord_typed(name,constord,tordconstnode(p).value,p.resulttype)
else if p.resulttype.def.deftype=pointerdef then
hp:=tconstsym.create_typed(name,constord,tordconstnode(p).value,p.resulttype)
hp:=tconstsym.create_ordptr_typed(name,constpointer,tordconstnode(p).value,p.resulttype)
else internalerror(111);
end;
stringconstn:
@ -105,21 +105,21 @@ implementation
begin
new(pd);
pd^:=trealconstnode(p).value_real;
hp:=tconstsym.create(name,constreal,longint(pd));
hp:=tconstsym.create_ptr(name,constreal,pd);
end;
setconstn :
begin
new(ps);
ps^:=tsetconstnode(p).value_set^;
hp:=tconstsym.create_typed(name,constset,longint(ps),p.resulttype);
hp:=tconstsym.create_ptr_typed(name,constset,ps,p.resulttype);
end;
pointerconstn :
begin
hp:=tconstsym.create_typed(name,constpointer,tordconstnode(p).value,p.resulttype);
hp:=tconstsym.create_ordptr_typed(name,constpointer,tpointerconstnode(p).value,p.resulttype);
end;
niln :
begin
hp:=tconstsym.create_typed(name,constnil,0,p.resulttype);
hp:=tconstsym.create_ord_typed(name,constnil,0,p.resulttype);
end;
else
Message(cg_e_illegal_expression);
@ -595,7 +595,12 @@ implementation
end.
{
$Log$
Revision 1.32 2001-08-30 20:13:53 peter
Revision 1.33 2001-09-02 21:18:28 peter
* split constsym.value in valueord,valueordptr,valueptr. The valueordptr
is used for holding target platform pointer values. As those can be
bigger than the source platform.
Revision 1.32 2001/08/30 20:13:53 peter
* rtti/init table updates
* rttisym for reusable global rtti/init info
* support published for interfaces

View File

@ -56,6 +56,9 @@ interface
implementation
uses
{$ifdef delphi}
SysUtils,
{$endif}
{ common }
cutils,
{ global }
@ -878,7 +881,7 @@ implementation
proc_to_procvar_equal(tprocsym(sym).definition,getprocvardef)
)
)
),again,tcallnode(p1));
),again,p1);
if (block_type=bt_const) and
getprocvar then
handle_procvar(getprocvardef,p1,getaddr);
@ -1158,12 +1161,14 @@ implementation
constint :
begin
{ do a very dirty trick to bootstrap this code }
if (tconstsym(srsym).value>=-(int64(2147483647)+int64(1))) and (tconstsym(srsym).value<=2147483647) then
p1:=cordconstnode.create(tconstsym(srsym).value,s32bittype)
else if (tconstsym(srsym).value > maxlongint) and (tconstsym(srsym).value <= int64(maxlongint)+int64(maxlongint)+1) then
p1:=cordconstnode.create(tconstsym(srsym).value,u32bittype)
if (tconstsym(srsym).valueord>=-(int64(2147483647)+int64(1))) and
(tconstsym(srsym).valueord<=2147483647) then
p1:=cordconstnode.create(tconstsym(srsym).valueord,s32bittype)
else if (tconstsym(srsym).valueord > maxlongint) and
(tconstsym(srsym).valueord <= int64(maxlongint)+int64(maxlongint)+1) then
p1:=cordconstnode.create(tconstsym(srsym).valueord,u32bittype)
else
p1:=cordconstnode.create(tconstsym(srsym).value,cs64bittype);
p1:=cordconstnode.create(tconstsym(srsym).valueord,cs64bittype);
end;
conststring :
begin
@ -1171,22 +1176,22 @@ implementation
if not(cs_ansistrings in aktlocalswitches) and (len>255) then
len:=255;
getmem(pc,len+1);
move(pchar(tpointerord(tconstsym(srsym).value))^,pc^,len);
move(pchar(tconstsym(srsym).valueptr)^,pc^,len);
pc[len]:=#0;
p1:=cstringconstnode.createpchar(pc,len);
end;
constchar :
p1:=cordconstnode.create(tconstsym(srsym).value,cchartype);
p1:=cordconstnode.create(tconstsym(srsym).valueord,cchartype);
constreal :
p1:=crealconstnode.create(pbestreal(tpointerord(tconstsym(srsym).value))^,pbestrealtype^);
p1:=crealconstnode.create(pbestreal(tconstsym(srsym).valueptr)^,pbestrealtype^);
constbool :
p1:=cordconstnode.create(tconstsym(srsym).value,booltype);
p1:=cordconstnode.create(tconstsym(srsym).valueord,booltype);
constset :
p1:=csetconstnode.create(pconstset(tpointerord(tconstsym(srsym).value)),tconstsym(srsym).consttype);
p1:=csetconstnode.create(pconstset(tconstsym(srsym).valueptr),tconstsym(srsym).consttype);
constord :
p1:=cordconstnode.create(tconstsym(srsym).value,tconstsym(srsym).consttype);
p1:=cordconstnode.create(tconstsym(srsym).valueord,tconstsym(srsym).consttype);
constpointer :
p1:=cpointerconstnode.create(tconstsym(srsym).value,tconstsym(srsym).consttype);
p1:=cpointerconstnode.create(tconstsym(srsym).valueordptr,tconstsym(srsym).consttype);
constnil :
p1:=cnilnode.create;
constresourcestring:
@ -2320,7 +2325,12 @@ implementation
end.
{
$Log$
Revision 1.41 2001-08-26 13:36:45 florian
Revision 1.42 2001-09-02 21:18:28 peter
* split constsym.value in valueord,valueordptr,valueptr. The valueordptr
is used for holding target platform pointer values. As those can be
bigger than the source platform.
Revision 1.41 2001/08/26 13:36:45 florian
* some cg reorganisation
* some PPC updates

View File

@ -61,7 +61,7 @@ implementation
var
len,base : longint;
p,hp : tnode;
p,hp,hpstart : tnode;
i,j,l,offset,
strlength : longint;
curconstsegment : TAAsmoutput;
@ -312,16 +312,25 @@ implementation
else
if p.nodetype=addrn then
begin
hp:=taddrnode(p).left;
inserttypeconv(p,t);
{ if a typeconv node was inserted then check if it was an tc_equal. If
true then we remove the node. If not tc_equal then we leave the typeconvn
and the nodetype=loadn will always be false and generate the error (PFV) }
if (p.nodetype=typeconvn) then
begin
if (ttypeconvnode(p).convtype=tc_equal) then
hpstart:=taddrnode(ttypeconvnode(p).left).left
else
hpstart:=p;
end
else
hpstart:=taddrnode(p).left;
hp:=hpstart;
while assigned(hp) and (hp.nodetype in [subscriptn,vecn]) do
hp:=tbinarynode(hp).left;
if (is_equal(tpointerdef(p.resulttype.def).pointertype.def,tpointerdef(t.def).pointertype.def) or
(is_void(tpointerdef(p.resulttype.def).pointertype.def)) or
(is_void(tpointerdef(t.def).pointertype.def))) and
(hp.nodetype=loadn) then
if (hp.nodetype=loadn) then
begin
do_resulttypepass(taddrnode(p).left);
hp:=taddrnode(p).left;
hp:=hpstart;
offset:=0;
while assigned(hp) and (hp.nodetype<>loadn) do
begin
@ -461,7 +470,7 @@ implementation
end
else if is_constresourcestringnode(p) then
begin
strval:=pchar(tpointerord(tconstsym(tloadnode(p).symtableentry).value));
strval:=pchar(tconstsym(tloadnode(p).symtableentry).valueptr);
strlength:=tconstsym(tloadnode(p).symtableentry).len;
end
else
@ -916,7 +925,12 @@ implementation
end.
{
$Log$
Revision 1.31 2001-08-26 13:36:47 florian
Revision 1.32 2001-09-02 21:18:28 peter
* split constsym.value in valueord,valueordptr,valueptr. The valueordptr
is used for holding target platform pointer values. As those can be
bigger than the source platform.
Revision 1.31 2001/08/26 13:36:47 florian
* some cg reorganisation
* some PPC updates

View File

@ -957,7 +957,7 @@ Begin
if tconstsym(sym).consttyp in [constint,constchar,constbool] then
begin
opr.typ:=OPR_CONSTANT;
opr.val:=tconstsym(sym).value;
opr.val:=tconstsym(sym).valueord;
SetupVar:=true;
Exit;
end;
@ -1267,7 +1267,7 @@ Begin
begin
if (tconstsym(srsym).consttyp in [constord,constint,constchar,constbool]) then
Begin
l:=tconstsym(srsym).value;
l:=tconstsym(srsym).valueord;
SearchIConstant:=TRUE;
exit;
end;
@ -1581,7 +1581,12 @@ end;
end.
{
$Log$
Revision 1.23 2001-08-26 13:36:48 florian
Revision 1.24 2001-09-02 21:18:28 peter
* split constsym.value in valueord,valueordptr,valueptr. The valueordptr
is used for holding target platform pointer values. As those can be
bigger than the source platform.
Revision 1.23 2001/08/26 13:36:48 florian
* some cg reorganisation
* some PPC updates

View File

@ -32,7 +32,11 @@ interface
implementation
uses
{$ifdef delphi}
dmisc,
{$else}
dos,
{$endif}
cutils,
version,globtype,globals,systems,
verbose,comphook,
@ -913,7 +917,12 @@ implementation
end.
{
$Log$
Revision 1.7 2001-08-19 11:22:24 peter
Revision 1.8 2001-09-02 21:18:28 peter
* split constsym.value in valueord,valueordptr,valueptr. The valueordptr
is used for holding target platform pointer values. As those can be
bigger than the source platform.
Revision 1.7 2001/08/19 11:22:24 peter
* palmos support from v10 merged
Revision 1.6 2001/08/07 18:47:13 peter

View File

@ -3132,15 +3132,16 @@ implementation
case hpc.consttyp of
conststring,
constresourcestring :
hs:=strpas(pchar(tpointerord(hpc.value)));
hs:=strpas(pchar(hpc.valueptr));
constreal :
str(pbestreal(tpointerord(hpc.value))^,hs);
constord,
str(pbestreal(hpc.valueptr)^,hs);
constord :
hs:=tostr(hpc.valueord);
constpointer :
hs:=tostr(hpc.value);
hs:=tostr(hpc.valueordptr);
constbool :
begin
if hpc.value<>0 then
if hpc.valueord<>0 then
hs:='TRUE'
else
hs:='FALSE';
@ -3148,7 +3149,7 @@ implementation
constnil :
hs:='nil';
constchar :
hs:=chr(hpc.value);
hs:=chr(hpc.valueord);
constset :
hs:='<set>';
end;
@ -3318,7 +3319,8 @@ implementation
parast:=tparasymtable.create;
tparasymtable(parast).load(ppufile);
parast.defowner:=self;
if (pocall_inline in proccalloptions) then
if (pocall_inline in proccalloptions) or
((current_module.flags and uf_local_browser)<>0) then
begin
localst:=tlocalsymtable.create;
tlocalsymtable(localst).load(ppufile);
@ -5394,7 +5396,12 @@ implementation
end.
{
$Log$
Revision 1.46 2001-08-30 20:13:54 peter
Revision 1.47 2001-09-02 21:18:28 peter
* split constsym.value in valueord,valueordptr,valueptr. The valueordptr
is used for holding target platform pointer values. As those can be
bigger than the source platform.
Revision 1.46 2001/08/30 20:13:54 peter
* rtti/init table updates
* rttisym for reusable global rtti/init info
* support published for interfaces

View File

@ -245,13 +245,18 @@ interface
end;
tconstsym = class(tstoredsym)
consttype : ttype;
consttyp : tconsttyp;
consttype : ttype;
consttyp : tconsttyp;
resstrindex, { needed for resource strings }
value : tconstexprint;
len : longint; { len is needed for string length }
constructor create(const n : string;t : tconsttyp;v : tconstexprint);
constructor create_typed(const n : string;t : tconsttyp;v : tconstexprint;const tt:ttype);
valueord : tconstexprint; { used for ordinal values }
valueordptr : TConstPtrUInt; { used for pointer values }
valueptr : pointer; { used for string, set, real values }
len : longint; { len is needed for string length }
constructor create_ord(const n : string;t : tconsttyp;v : tconstexprint);
constructor create_ord_typed(const n : string;t : tconsttyp;v : tconstexprint;const tt:ttype);
constructor create_ordptr_typed(const n : string;t : tconsttyp;v : tconstptruint;const tt:ttype);
constructor create_ptr(const n : string;t : tconsttyp;v : pointer);
constructor create_ptr_typed(const n : string;t : tconsttyp;v : pointer;const tt:ttype);
constructor create_string(const n : string;t : tconsttyp;str:pchar;l:longint);
constructor load(ppufile:tcompilerppufile);
destructor destroy;override;
@ -1797,24 +1802,70 @@ implementation
TCONSTSYM
****************************************************************************}
constructor tconstsym.create(const n : string;t : tconsttyp;v : TConstExprInt);
constructor tconstsym.create_ord(const n : string;t : tconsttyp;v : TConstExprInt);
begin
inherited create(n);
typ:=constsym;
consttyp:=t;
value:=v;
valueord:=v;
valueordptr:=0;
valueptr:=nil;
ResStrIndex:=0;
consttype.reset;
len:=0;
end;
constructor tconstsym.create_typed(const n : string;t : tconsttyp;v : tconstexprint;const tt:ttype);
constructor tconstsym.create_ord_typed(const n : string;t : tconsttyp;v : tconstexprint;const tt:ttype);
begin
inherited create(n);
typ:=constsym;
consttyp:=t;
value:=v;
valueord:=v;
valueordptr:=0;
valueptr:=nil;
ResStrIndex:=0;
consttype:=tt;
len:=0;
end;
constructor tconstsym.create_ordptr_typed(const n : string;t : tconsttyp;v : tconstptruint;const tt:ttype);
begin
inherited create(n);
typ:=constsym;
consttyp:=t;
valueord:=0;
valueordptr:=v;
valueptr:=nil;
ResStrIndex:=0;
consttype:=tt;
len:=0;
end;
constructor tconstsym.create_ptr(const n : string;t : tconsttyp;v : pointer);
begin
inherited create(n);
typ:=constsym;
consttyp:=t;
valueord:=0;
valueordptr:=0;
valueptr:=v;
ResStrIndex:=0;
consttype.reset;
len:=0;
end;
constructor tconstsym.create_ptr_typed(const n : string;t : tconsttyp;v : pointer;const tt:ttype);
begin
inherited create(n);
typ:=constsym;
consttyp:=t;
valueord:=0;
valueordptr:=0;
valueptr:=v;
ResStrIndex:=0;
consttype:=tt;
len:=0;
@ -1826,13 +1877,16 @@ implementation
inherited create(n);
typ:=constsym;
consttyp:=t;
value:=longint(str);
valueord:=0;
valueordptr:=0;
valueptr:=str;
consttype.reset;
len:=l;
if t=constresourcestring then
ResStrIndex:=ResourceStrings.Register(name,pchar(tpointerord(value)),len);
ResStrIndex:=ResourceStrings.Register(name,pchar(valueptr),len);
end;
constructor tconstsym.load(ppufile:tcompilerppufile);
var
pd : pbestreal;
@ -1845,6 +1899,9 @@ implementation
typ:=constsym;
consttype.reset;
consttyp:=tconsttyp(ppufile.getbyte);
valueord:=0;
valueordptr:=0;
valueptr:=nil;
case consttyp of
constint:
if sizeof(tconstexprint)=8 then
@ -1855,19 +1912,18 @@ implementation
{$define Range_check_on}
{$endif opt R+}
{$R- needed here }
value:=qword(l1)+(int64(l2) shl 32);
valueord:=qword(l1)+(int64(l2) shl 32);
{$ifdef Range_check_on}
{$R+}
{$undef Range_check_on}
{$endif Range_check_on}
end
else
value:=ppufile.getlongint;
valueord:=ppufile.getlongint;
constwchar,
constbool,
constchar :
value:=ppufile.getlongint;
constpointer,
valueord:=ppufile.getlongint;
constord :
begin
ppufile.gettype(consttype);
@ -1879,36 +1935,57 @@ implementation
{$define Range_check_on}
{$endif opt R+}
{$R- needed here }
value:=qword(l1)+(int64(l2) shl 32);
valueord:=qword(l1)+(int64(l2) shl 32);
{$ifdef Range_check_on}
{$R+}
{$undef Range_check_on}
{$endif Range_check_on}
end
else
value:=ppufile.getlongint;
valueord:=ppufile.getlongint;
end;
conststring,constresourcestring :
constpointer :
begin
ppufile.gettype(consttype);
if sizeof(TConstPtrUInt)=8 then
begin
l1:=ppufile.getlongint;
l2:=ppufile.getlongint;
{$ifopt R+}
{$define Range_check_on}
{$endif opt R+}
{$R- needed here }
valueordptr:=qword(l1)+(int64(l2) shl 32);
{$ifdef Range_check_on}
{$R+}
{$undef Range_check_on}
{$endif Range_check_on}
end
else
valueordptr:=ppufile.getlongint;
end;
conststring,
constresourcestring :
begin
len:=ppufile.getlongint;
getmem(pc,len+1);
ppufile.getdata(pc^,len);
if consttyp=constresourcestring then
ResStrIndex:=ppufile.getlongint;
value:=tpointerord(pc);
valueptr:=pc;
end;
constreal :
begin
new(pd);
pd^:=ppufile.getreal;
value:=tpointerord(pd);
valueptr:=pd;
end;
constset :
begin
ppufile.gettype(consttype);
new(ps);
ppufile.getnormalset(ps^);
value:=tpointerord(ps);
valueptr:=ps;
end;
constnil : ;
else
@ -1920,12 +1997,13 @@ implementation
destructor tconstsym.destroy;
begin
case consttyp of
conststring,constresourcestring :
freemem(pchar(tpointerord(value)),len+1);
conststring,
constresourcestring :
freemem(pchar(valueptr),len+1);
constreal :
dispose(pbestreal(tpointerord(value)));
dispose(pbestreal(valueptr));
constset :
dispose(pnormalset(tpointerord(value)));
dispose(pnormalset(valueptr));
end;
inherited destroy;
end;
@ -1951,42 +2029,54 @@ implementation
case consttyp of
constnil : ;
constint:
if sizeof(TConstExprInt)=8 then
begin
ppufile.putlongint(longint(lo(value)));
ppufile.putlongint(longint(hi(value)));
end
else
ppufile.putlongint(value);
begin
if sizeof(TConstExprInt)=8 then
begin
ppufile.putlongint(longint(lo(valueord)));
ppufile.putlongint(longint(hi(valueord)));
end
else
ppufile.putlongint(valueord);
end;
constbool,
constchar :
ppufile.putlongint(value);
constpointer,
ppufile.putlongint(valueord);
constord :
begin
ppufile.puttype(consttype);
if sizeof(TConstExprInt)=8 then
begin
ppufile.putlongint(longint(lo(value)));
ppufile.putlongint(longint(hi(value)));
ppufile.putlongint(longint(lo(valueord)));
ppufile.putlongint(longint(hi(valueord)));
end
else
ppufile.putlongint(value);
ppufile.putlongint(valueord);
end;
conststring,constresourcestring :
constpointer :
begin
ppufile.puttype(consttype);
if sizeof(TConstPtrUInt)=8 then
begin
ppufile.putlongint(longint(lo(valueordptr)));
ppufile.putlongint(longint(hi(valueordptr)));
end
else
ppufile.putlongint(valueordptr);
end;
conststring,
constresourcestring :
begin
ppufile.putlongint(len);
ppufile.putdata(pchar(TPointerOrd(value))^,len);
ppufile.putdata(pchar(valueptr)^,len);
if consttyp=constresourcestring then
ppufile.putlongint(ResStrIndex);
end;
constreal :
ppufile.putreal(pbestreal(TPointerOrd(value))^);
ppufile.putreal(pbestreal(valueptr)^);
constset :
begin
ppufile.puttype(consttype);
ppufile.putnormalset(pointer(TPointerOrd(value))^);
ppufile.putnormalset(valueptr^);
end;
else
internalerror(13);
@ -2001,18 +2091,16 @@ implementation
{even GDB v4.16 only now 'i' 'r' and 'e' !!!}
case consttyp of
conststring : begin
{ I had to remove ibm2ascii !! }
st := pstring(TPointerOrd(value))^;
{st := ibm2ascii(pstring(value)^);}
st := 's'''+st+'''';
st := 's'''+strpas(pchar(valueptr))+'''';
end;
constbool,
constint,
constpointer,
constord,
constchar : st := 'i'+int64tostr(value);
constchar : st := 'i'+int64tostr(valueord);
constpointer :
st := 'i'+int64tostr(valueordptr);
constreal : begin
system.str(pbestreal(TPointerOrd(value))^,st);
system.str(pbestreal(valueptr)^,st);
st := 'r'+st;
end;
{ if we don't know just put zero !! }
@ -2392,7 +2480,12 @@ implementation
end.
{
$Log$
Revision 1.20 2001-08-30 20:13:54 peter
Revision 1.21 2001-09-02 21:18:29 peter
* split constsym.value in valueord,valueordptr,valueptr. The valueordptr
is used for holding target platform pointer values. As those can be
bigger than the source platform.
Revision 1.20 2001/08/30 20:13:54 peter
* rtti/init table updates
* rttisym for reusable global rtti/init info
* support published for interfaces