* support nf_internal to ignore currency conversion adjustments also on

platforms that implement currency using a floating point type

git-svn-id: trunk@43817 -
This commit is contained in:
Jonas Maebe 2019-12-30 15:05:02 +00:00
parent 9bd33f7a45
commit 67dbd0cdb3
2 changed files with 35 additions and 20 deletions

View File

@ -141,7 +141,8 @@ function tllvmtypeconvnode.first_real_to_real: tnode;
currency/comp to be compatible with the regular code generators -> currency/comp to be compatible with the regular code generators ->
call round() instead } call round() instead }
if (tfloatdef(resultdef).floattype in [s64currency,s64comp]) and if (tfloatdef(resultdef).floattype in [s64currency,s64comp]) and
not(tfloatdef(left.resultdef).floattype in [s64currency,s64comp]) then not(tfloatdef(left.resultdef).floattype in [s64currency,s64comp]) and
not(nf_internal in flags) then
begin begin
result:=ccallnode.createinternfromunit('SYSTEM','ROUND', result:=ccallnode.createinternfromunit('SYSTEM','ROUND',
ccallparanode.create(left,nil)); ccallparanode.create(left,nil));

View File

@ -1580,6 +1580,8 @@ implementation
if not is_currency(resultdef) then if not is_currency(resultdef) then
internalerror(200304221); internalerror(200304221);
result:=nil; result:=nil;
if not(nf_internal in flags) then
begin
left:=caddnode.create(muln,left,crealconstnode.create(10000.0,left.resultdef)); left:=caddnode.create(muln,left,crealconstnode.create(10000.0,left.resultdef));
include(left.flags,nf_is_currency); include(left.flags,nf_is_currency);
{ Convert constants directly, else call Round() } { Convert constants directly, else call Round() }
@ -1591,6 +1593,13 @@ implementation
{ Internal type cast to currency } { Internal type cast to currency }
result:=ctypeconvnode.create_internal(result,s64currencytype); result:=ctypeconvnode.create_internal(result,s64currencytype);
left:=nil; left:=nil;
end
end
else
begin
include(left.flags,nf_is_currency);
result:=left;
left:=nil;
end; end;
end; end;
@ -1598,6 +1607,8 @@ implementation
function ttypeconvnode.typecheck_real_to_real : tnode; function ttypeconvnode.typecheck_real_to_real : tnode;
begin begin
result:=nil; result:=nil;
if not(nf_internal in flags) then
begin
if is_currency(left.resultdef) and not(is_currency(resultdef)) then if is_currency(left.resultdef) and not(is_currency(resultdef)) then
begin begin
left:=caddnode.create(slashn,left,crealconstnode.create(10000.0,left.resultdef)); left:=caddnode.create(slashn,left,crealconstnode.create(10000.0,left.resultdef));
@ -1612,6 +1623,9 @@ implementation
include(flags,nf_is_currency); include(flags,nf_is_currency);
typecheckpass(left); typecheckpass(left);
end; end;
end
else
include(flags,nf_is_currency);
end; end;