mirror of
https://gitlab.com/freepascal.org/fpc/pas2js.git
synced 2025-04-06 02:27:48 +02:00
pas2js: fixed system.inc()
This commit is contained in:
parent
ca81b87183
commit
a9af2a4169
@ -10841,11 +10841,16 @@ var
|
||||
IsInc: Boolean;
|
||||
AddJS: TJSAdditiveExpression;
|
||||
AssignContext: TAssignContext;
|
||||
aResolver: TPas2JSResolver;
|
||||
begin
|
||||
Result:=nil;
|
||||
IsInc:=CompareText((El.Value as TPrimitiveExpr).Value,'inc')=0;
|
||||
aResolver:=AContext.Resolver;
|
||||
Expr:=aResolver.GetRightMostExpr(El.Value);
|
||||
if not (Expr is TPrimitiveExpr) then
|
||||
RaiseNotSupported(Expr,AContext,20200620113218);
|
||||
IsInc:=CompareText(TPrimitiveExpr(Expr).Value,'inc')=0;
|
||||
Expr:=El.Params[0];
|
||||
AContext.Resolver.ComputeElement(Expr,ExprResolved,[]);
|
||||
aResolver.ComputeElement(Expr,ExprResolved,[]);
|
||||
|
||||
// convert value
|
||||
if length(El.Params)=1 then
|
||||
@ -10897,7 +10902,7 @@ begin
|
||||
end;
|
||||
|
||||
AssignContext:=TAssignContext.Create(Expr,nil,AContext);
|
||||
AContext.Resolver.ComputeElement(Expr,AssignContext.LeftResolved,[rcNoImplicitProc]);
|
||||
aResolver.ComputeElement(Expr,AssignContext.LeftResolved,[rcNoImplicitProc]);
|
||||
SetResolverValueExpr(AssignContext.RightResolved,
|
||||
AssignContext.LeftResolved.BaseType,AssignContext.LeftResolved.LoTypeEl,
|
||||
AssignContext.LeftResolved.HiTypeEl,Expr,[rrfReadable]);
|
||||
|
@ -265,6 +265,7 @@ type
|
||||
Procedure TestIntegerTypecasts;
|
||||
Procedure TestInteger_BitwiseShrNativeInt;
|
||||
Procedure TestInteger_BitwiseShlNativeInt;
|
||||
Procedure TestInteger_SystemFunc;
|
||||
Procedure TestCurrency;
|
||||
Procedure TestForBoolDo;
|
||||
Procedure TestForIntDo;
|
||||
@ -6747,6 +6748,40 @@ begin
|
||||
'']));
|
||||
end;
|
||||
|
||||
procedure TTestModule.TestInteger_SystemFunc;
|
||||
begin
|
||||
StartProgram(true);
|
||||
Add([
|
||||
'var',
|
||||
' i: byte;',
|
||||
' s: string;',
|
||||
'begin',
|
||||
' system.inc(i);',
|
||||
' system.str(i,s);',
|
||||
' s:=system.str(i);',
|
||||
' i:=system.low(i);',
|
||||
' i:=system.high(i);',
|
||||
' i:=system.pred(i);',
|
||||
' i:=system.succ(i);',
|
||||
'']);
|
||||
ConvertProgram;
|
||||
CheckResolverUnexpectedHints;
|
||||
CheckSource('TestInteger_SystemFunc',
|
||||
LinesToStr([
|
||||
'this.i = 0;',
|
||||
'this.s = "";',
|
||||
'']),
|
||||
LinesToStr([
|
||||
'$mod.i += 1;',
|
||||
'$mod.s = "" + $mod.i;',
|
||||
'$mod.s = "" + $mod.i;',
|
||||
'$mod.i = 0;',
|
||||
'$mod.i = 255;',
|
||||
'$mod.i = $mod.i - 1;',
|
||||
'$mod.i = $mod.i + 1;',
|
||||
'']));
|
||||
end;
|
||||
|
||||
procedure TTestModule.TestCurrency;
|
||||
begin
|
||||
StartProgram(false);
|
||||
|
Loading…
Reference in New Issue
Block a user