pas2js: merged handling of (i*i).helperfunc

This commit is contained in:
mattias 2020-04-26 20:51:44 +00:00
parent 5e22bdf07d
commit f874a25f75
2 changed files with 17 additions and 14 deletions

View File

@ -1,6 +1,6 @@
{ {
This file is part of the Free Component Library (FCL) This file is part of the Free Component Library (FCL)
Copyright (c) 2018 by Michael Van Canneyt Copyright (c) 2020 by Michael Van Canneyt
Pascal to Javascript converter class. Pascal to Javascript converter class.
@ -6798,6 +6798,7 @@ var
ModeSwitches: TModeSwitches; ModeSwitches: TModeSwitches;
aResolver: TPas2JSResolver; aResolver: TPas2JSResolver;
LeftTypeEl, RightTypeEl: TPasType; LeftTypeEl, RightTypeEl: TPasType;
OldAccess: TCtxAccess;
begin begin
Result:=Nil; Result:=Nil;
aResolver:=AContext.Resolver; aResolver:=AContext.Resolver;
@ -6816,14 +6817,8 @@ begin
end; end;
end; end;
if AContext.Access<>caRead then OldAccess:=AContext.Access;
begin AContext.Access:=caRead;
{$IFDEF VerbosePas2JS}
writeln('TPasToJSConverter.ConvertBinaryExpression OpCode=',El.OpCode,' AContext.Access=',AContext.Access);
{$ENDIF}
DoError(20170209152633,nVariableIdentifierExpected,sVariableIdentifierExpected,[],El);
end;
Call:=nil; Call:=nil;
A:=ConvertExpression(El.left,AContext); A:=ConvertExpression(El.left,AContext);
B:=nil; B:=nil;
@ -7065,6 +7060,7 @@ begin
end; end;
finally finally
AContext.Access:=OldAccess;
if Result=nil then if Result=nil then
begin begin
A.Free; A.Free;
@ -21638,10 +21634,17 @@ begin
end end
else else
begin begin
{$IFDEF VerbosePas2JS} // getter is the result of an operation
writeln('TPasToJSConverter.CreateProcCallArgRef FullGetter=',GetObjName(FullGetter),' Setter=',GetObjName(ParamContext.Setter));
{$ENDIF} // create "p:FullGetter"
RaiseNotSupported(El,AContext,20170213230336); AddVar(TempRefParamName,FullGetter);
FullGetter:=nil;
// GetExpr "this.a"
GetExpr:=CreatePrimitiveDotExpr('this.'+TempRefParamName,El);
// SetExpr "raise EPropReadOnly"
SetExpr:=CreateRaisePropReadOnly(El);
end; end;
{$IFDEF VerbosePas2JS} {$IFDEF VerbosePas2JS}

View File

@ -23493,7 +23493,7 @@ begin
'begin', 'begin',
' DoIt(i.toStr);', ' DoIt(i.toStr);',
' DoIt(i.toStr());', ' DoIt(i.toStr());',
//' (i*i).toStr;', ' (i*i).toStr;',
' DoIt((i*i).toStr);', ' DoIt((i*i).toStr);',
'']); '']);
ConvertProgram; ConvertProgram;