mirror of
https://gitlab.com/freepascal.org/fpc/pas2js.git
synced 2025-04-06 10:37:49 +02:00
pastojs: pass class var to var argument
This commit is contained in:
parent
8f6a355ec5
commit
e9d041e0d5
@ -7871,16 +7871,18 @@ var
|
||||
var
|
||||
Call: TJSCallExpression;
|
||||
begin
|
||||
if AssignContext=nil then exit;
|
||||
if AssignContext.LeftResolved.LoTypeEl is TPasRecordType then
|
||||
if AssignContext<>nil then
|
||||
begin
|
||||
// aRecord:=right -> aRecord.$assign(right)
|
||||
Call:=CreateCallExpression(El);
|
||||
AssignContext.Call:=Call;
|
||||
Call.Expr:=CreateDotNameExpr(El,Result,TJSString(GetBIName(pbifnRecordAssign)));
|
||||
Call.AddArg(AssignContext.RightSide);
|
||||
AssignContext.RightSide:=nil;
|
||||
Result:=Call;
|
||||
if AssignContext.LeftResolved.LoTypeEl is TPasRecordType then
|
||||
begin
|
||||
// aRecord:=right -> aRecord.$assign(right)
|
||||
Call:=CreateCallExpression(El);
|
||||
AssignContext.Call:=Call;
|
||||
Call.Expr:=CreateDotNameExpr(El,Result,TJSString(GetBIName(pbifnRecordAssign)));
|
||||
Call.AddArg(AssignContext.RightSide);
|
||||
AssignContext.RightSide:=nil;
|
||||
Result:=Call;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -7996,8 +7998,8 @@ begin
|
||||
end;
|
||||
end; // property redirect
|
||||
|
||||
if (AContext.Access=caAssign)
|
||||
and aResolver.IsClassField(Decl) then
|
||||
if aResolver.IsClassField(Decl)
|
||||
and (AContext.Access in [caAssign,caByReference]) then
|
||||
begin
|
||||
// writing a class var -> aClass.VarName
|
||||
PathExpr:=CreateReferencePathExpr(Decl.Parent,AContext);
|
||||
|
@ -11896,7 +11896,7 @@ begin
|
||||
' class var vI: longint;',
|
||||
' class var Sub: TObject;',
|
||||
' constructor Create;',
|
||||
' class function GetIt(Par: longint): tobject;',
|
||||
' class function GetIt(var Par: longint): tobject;',
|
||||
' end;',
|
||||
'constructor tobject.create;',
|
||||
'begin',
|
||||
@ -11904,12 +11904,13 @@ begin
|
||||
' Self.vi:=Self.vi+1;',
|
||||
' inc(vi);',
|
||||
'end;',
|
||||
'class function tobject.getit(par: longint): tobject;',
|
||||
'class function tobject.getit(var par: longint): tobject;',
|
||||
'begin',
|
||||
' vi:=vi+par;',
|
||||
' Self.vi:=Self.vi+par;',
|
||||
' vi:=vi+3;',
|
||||
' Self.vi:=Self.vi+4;',
|
||||
' inc(vi);',
|
||||
' Result:=self.sub;',
|
||||
' GetIt(vi);',
|
||||
'end;',
|
||||
'var Obj: tobject;',
|
||||
'begin',
|
||||
@ -11937,10 +11938,19 @@ begin
|
||||
' };',
|
||||
' this.GetIt = function(Par){',
|
||||
' var Result = null;',
|
||||
' $mod.TObject.vI = this.vI + Par;',
|
||||
' $mod.TObject.vI = this.vI + Par;',
|
||||
' $mod.TObject.vI = this.vI + 3;',
|
||||
' $mod.TObject.vI = this.vI + 4;',
|
||||
' $mod.TObject.vI += 1;',
|
||||
' Result = this.Sub;',
|
||||
' this.GetIt({',
|
||||
' p: $mod.TObject,',
|
||||
' get: function () {',
|
||||
' return this.p.vI;',
|
||||
' },',
|
||||
' set: function (v) {',
|
||||
' this.p.vI = v;',
|
||||
' }',
|
||||
' });',
|
||||
' return Result;',
|
||||
' };',
|
||||
'});',
|
||||
|
Loading…
Reference in New Issue
Block a user