pastojs: currency:=integer becomes c:=i*10000, integer(currency) becomes Math.floor(cur/10000)

git-svn-id: trunk@39944 -
This commit is contained in:
Mattias Gaertner 2018-10-16 07:55:36 +00:00
parent 3f08a6c05c
commit 23fe74416c
2 changed files with 27 additions and 3 deletions

View File

@ -8588,7 +8588,13 @@ begin
begin
// integer to integer -> value
Result:=ConvertElement(Param,AContext);
if to_bt=btCurrency then
if ParamResolved.BaseType=btCurrency then
begin
if to_bt<>btCurrency then
// currency to integer -> Math.floor(value/10000)
Result:=CreateMathFloor(Param,CreateDivideNumber(Param,Result,10000));
end
else if to_bt=btCurrency then
// integer to currency -> value*10000
Result:=CreateMulNumber(Param,Result,10000);
if (to_bt<>btIntDouble) and not (Result is TJSLiteral) then
@ -15240,12 +15246,21 @@ begin
end
else if AssignContext.LeftResolved.BaseType=btCurrency then
begin
if AssignContext.RightResolved.BaseType<>btCurrency then
if AssignContext.RightResolved.BaseType=btCurrency then
// currency := currency
else if AssignContext.RightResolved.BaseType in btAllJSFloats then
begin
// currency := double -> currency := Math.floor(double*10000)
AssignContext.RightSide:=CreateMulNumber(El,AssignContext.RightSide,10000);
AssignContext.RightSide:=CreateMathFloor(El,AssignContext.RightSide);
end;
end
else if AssignContext.RightResolved.BaseType in btAllJSInteger then
begin
// currency := integer -> currency := double*10000
AssignContext.RightSide:=CreateMulNumber(El,AssignContext.RightSide,10000);
end
else
RaiseNotSupported(El,AContext,20181016094542,GetResolverResultDbg(AssignContext.RightResolved));
end
else if AssignContext.RightResolved.BaseType=btCurrency then
begin

View File

@ -5459,8 +5459,13 @@ begin
' c:=a;',
' d:=c;',
' c:=d;',
' c:=currency(c);',
' c:=currency(d);',
' d:=double(c);',
' c:=i;',
' c:=currency(i);',
//' i:=c;', not allowed
' i:=nativeint(c);',
' c:=c+a;',
' c:=-c-a;',
' c:=d+c;',
@ -5522,8 +5527,12 @@ begin
'$mod.c = $mod.a;',
'$mod.d = $mod.c / 10000;',
'$mod.c = Math.floor($mod.d * 10000);',
'$mod.c = $mod.c;',
'$mod.c = $mod.d * 10000;',
'$mod.d = $mod.c / 10000;',
'$mod.c = $mod.i * 10000;',
'$mod.c = $mod.i * 10000;',
'$mod.i = Math.floor($mod.c / 10000);',
'$mod.c = $mod.c + $mod.a;',
'$mod.c = -$mod.c - $mod.a;',
'$mod.c = ($mod.d * 10000) + $mod.c;',