* added support for very big/small currency constants for non x86 CPUs.

git-svn-id: trunk@5937 -
This commit is contained in:
yury 2007-01-13 12:12:20 +00:00
parent e5dd51c95b
commit bcd86ef782
5 changed files with 18 additions and 2 deletions

View File

@ -54,6 +54,7 @@ interface
typedef : tdef; typedef : tdef;
typedefderef : tderef; typedefderef : tderef;
value_real : bestreal; value_real : bestreal;
value_currency : currency;
lab_real : tasmlabel; lab_real : tasmlabel;
constructor create(v : bestreal;def:tdef);virtual; constructor create(v : bestreal;def:tdef);virtual;
constructor ppuload(t:tnodetype;ppufile:tcompilerppufile);override; constructor ppuload(t:tnodetype;ppufile:tcompilerppufile);override;
@ -472,14 +473,19 @@ implementation
inherited create(realconstn); inherited create(realconstn);
typedef:=def; typedef:=def;
value_real:=v; value_real:=v;
value_currency:=v;
lab_real:=nil; lab_real:=nil;
end; end;
constructor trealconstnode.ppuload(t:tnodetype;ppufile:tcompilerppufile); constructor trealconstnode.ppuload(t:tnodetype;ppufile:tcompilerppufile);
var
i : int64;
begin begin
inherited ppuload(t,ppufile); inherited ppuload(t,ppufile);
ppufile.getderef(typedefderef); ppufile.getderef(typedefderef);
value_real:=ppufile.getreal; value_real:=ppufile.getreal;
i:=ppufile.getint64;
value_currency:=PCurrency(@i)^;
lab_real:=tasmlabel(ppufile.getasmsymbol); lab_real:=tasmlabel(ppufile.getasmsymbol);
end; end;
@ -489,6 +495,7 @@ implementation
inherited ppuwrite(ppufile); inherited ppuwrite(ppufile);
ppufile.putderef(typedefderef); ppufile.putderef(typedefderef);
ppufile.putreal(value_real); ppufile.putreal(value_real);
ppufile.putint64(PInt64(@value_currency)^);
ppufile.putasmsymbol(lab_real); ppufile.putasmsymbol(lab_real);
end; end;
@ -513,6 +520,7 @@ implementation
begin begin
n:=trealconstnode(inherited dogetcopy); n:=trealconstnode(inherited dogetcopy);
n.value_real:=value_real; n.value_real:=value_real;
n.value_currency:=value_currency;
n.lab_real:=lab_real; n.lab_real:=lab_real;
dogetcopy:=n; dogetcopy:=n;
end; end;

View File

@ -605,6 +605,7 @@ implementation
if is_constrealnode(left) then if is_constrealnode(left) then
begin begin
trealconstnode(left).value_real:=-trealconstnode(left).value_real; trealconstnode(left).value_real:=-trealconstnode(left).value_real;
trealconstnode(left).value_currency:=-trealconstnode(left).value_currency;
result:=left; result:=left;
left:=nil; left:=nil;
exit; exit;

View File

@ -2198,6 +2198,7 @@ implementation
pd : tprocdef; pd : tprocdef;
hclassdef : tobjectdef; hclassdef : tobjectdef;
d : bestreal; d : bestreal;
cur : currency;
hs,hsorg : string; hs,hsorg : string;
hdef : tdef; hdef : tdef;
filepos : tfileposinfo; filepos : tfileposinfo;
@ -2446,6 +2447,11 @@ implementation
else else
{$endif FPC_REAL2REAL_FIXED} {$endif FPC_REAL2REAL_FIXED}
p1:=crealconstnode.create(d,pbestrealtype^); p1:=crealconstnode.create(d,pbestrealtype^);
{$ifdef FPC_HAS_STR_CURRENCY}
val(pattern,cur,code);
if code=0 then
trealconstnode(p1).value_currency:=cur;
{$endif FPC_HAS_STR_CURRENCY}
end; end;
_STRING : _STRING :
@ -2595,6 +2601,7 @@ implementation
else if tbinarynode(p1).left.nodetype=realconstn then else if tbinarynode(p1).left.nodetype=realconstn then
begin begin
trealconstnode(tbinarynode(p1).left).value_real:=-trealconstnode(tbinarynode(p1).left).value_real; trealconstnode(tbinarynode(p1).left).value_real:=-trealconstnode(tbinarynode(p1).left).value_real;
trealconstnode(tbinarynode(p1).left).value_currency:=-trealconstnode(tbinarynode(p1).left).value_currency;
p1:=cunaryminusnode.create(p1); p1:=cunaryminusnode.create(p1);
end end
else else

View File

@ -43,7 +43,7 @@ type
{$endif Test_Double_checksum} {$endif Test_Double_checksum}
const const
CurrentPPUVersion=72; CurrentPPUVersion=73;
{ buffer sizes } { buffer sizes }
maxentrysize = 1024; maxentrysize = 1024;

View File

@ -131,7 +131,7 @@ implementation
intvalue := tordconstnode(n).value intvalue := tordconstnode(n).value
{ allow bootstrapping } { allow bootstrapping }
else if is_constrealnode(n) then else if is_constrealnode(n) then
intvalue:=round(trealconstnode(n).value_real*10000) intvalue:=PInt64(@trealconstnode(n).value_currency)^
else else
begin begin
intvalue:=0; intvalue:=0;