mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-14 00:59:08 +02:00
pastojs: fixed calling Instance.StaticMethod
git-svn-id: trunk@48842 -
(cherry picked from commit ce3edc8c95
)
This commit is contained in:
parent
1b65155079
commit
edc9c0feab
@ -9789,15 +9789,12 @@ begin
|
|||||||
if RightRefDecl is TPasProcedure then
|
if RightRefDecl is TPasProcedure then
|
||||||
begin
|
begin
|
||||||
Proc:=TPasProcedure(RightRefDecl);
|
Proc:=TPasProcedure(RightRefDecl);
|
||||||
if coShortRefGlobals in Options then
|
if not aResolver.ProcHasSelf(Proc) then
|
||||||
begin
|
begin
|
||||||
if not aResolver.ProcHasSelf(Proc) then
|
// a.StaticProc -> pas.unit1.aclass.StaticProc(defaultargs)
|
||||||
begin
|
// ToDo: check if left side has only types (no call nor field)
|
||||||
// a.StaticProc -> $lp(defaultargs)
|
Result:=ConvertIdentifierExpr(RightEl,TPrimitiveExpr(RightEl).Value,aContext);
|
||||||
// ToDo: check if left side has only types (no call nor field)
|
exit;
|
||||||
Result:=ConvertIdentifierExpr(RightEl,TPrimitiveExpr(RightEl).Value,aContext);
|
|
||||||
exit;
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -170,8 +170,8 @@ begin
|
|||||||
'']),
|
'']),
|
||||||
LinesToStr([ // $mod.$main
|
LinesToStr([ // $mod.$main
|
||||||
'$mod.TPoint$G1.x = $mod.p.x + 10;',
|
'$mod.TPoint$G1.x = $mod.p.x + 10;',
|
||||||
'$mod.p.Fly();',
|
'$mod.TPoint$G1.Fly();',
|
||||||
'$mod.p.Fly();',
|
'$mod.TPoint$G1.Fly();',
|
||||||
'']));
|
'']));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -757,7 +757,7 @@ begin
|
|||||||
' $mod.TPoint$G1.x = this.x + 5;',
|
' $mod.TPoint$G1.x = this.x + 5;',
|
||||||
' $mod.TPoint$G1.x = $mod.TPoint$G1.x + 6;',
|
' $mod.TPoint$G1.x = $mod.TPoint$G1.x + 6;',
|
||||||
' this.Fly();',
|
' this.Fly();',
|
||||||
' $mod.TPoint$G1.Fly();',
|
' this.Fly();',
|
||||||
' this.Run();',
|
' this.Run();',
|
||||||
' $mod.TPoint$G1.Run();',
|
' $mod.TPoint$G1.Run();',
|
||||||
' };',
|
' };',
|
||||||
|
@ -12136,9 +12136,9 @@ begin
|
|||||||
'$mod.TRec.SetInt($mod.TRec.GetInt() + 2);',
|
'$mod.TRec.SetInt($mod.TRec.GetInt() + 2);',
|
||||||
'$mod.TRec.SetInt($mod.TRec.Fx);',
|
'$mod.TRec.SetInt($mod.TRec.Fx);',
|
||||||
'$mod.TRec.Fy = $mod.r.Fx + 1;',
|
'$mod.TRec.Fy = $mod.r.Fx + 1;',
|
||||||
'if ($mod.r.GetInt() === 2) ;',
|
'if ($mod.TRec.GetInt() === 2) ;',
|
||||||
'$mod.r.SetInt($mod.r.GetInt() + 2);',
|
'$mod.TRec.SetInt($mod.TRec.GetInt() + 2);',
|
||||||
'$mod.r.SetInt($mod.r.Fx);',
|
'$mod.TRec.SetInt($mod.r.Fx);',
|
||||||
'']));
|
'']));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -12602,8 +12602,8 @@ begin
|
|||||||
' $mod.TPoint.Fly();',
|
' $mod.TPoint.Fly();',
|
||||||
'})();',
|
'})();',
|
||||||
'$mod.TPoint.x = $mod.r.x + 10;',
|
'$mod.TPoint.x = $mod.r.x + 10;',
|
||||||
'$mod.r.Fly();',
|
'$mod.TPoint.Fly();',
|
||||||
'$mod.r.Fly();',
|
'$mod.TPoint.Fly();',
|
||||||
'']));
|
'']));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -13521,36 +13521,58 @@ end;
|
|||||||
|
|
||||||
procedure TTestModule.TestClass_CallClassMethodStatic;
|
procedure TTestModule.TestClass_CallClassMethodStatic;
|
||||||
begin
|
begin
|
||||||
exit;
|
|
||||||
|
|
||||||
StartProgram(false);
|
StartProgram(false);
|
||||||
Add([
|
Add([
|
||||||
'type',
|
'type',
|
||||||
' TObject = class',
|
' TObject = class',
|
||||||
' public',
|
' public',
|
||||||
' class var w: word;',
|
' class function Fly: tobject; static;',
|
||||||
' class function GetIt: tobject; static;',
|
|
||||||
' end;',
|
' end;',
|
||||||
'class function tobject.getit: tobject;',
|
'class function tobject.Fly: tobject;',
|
||||||
'begin',
|
'begin',
|
||||||
' Result.GetIt;',
|
' Result.Fly;',
|
||||||
' w:=3;',
|
' Result.Fly();',
|
||||||
' w:=w+3;',
|
' Fly;',
|
||||||
|
' Fly();',
|
||||||
|
' Fly.Fly;',
|
||||||
|
' Fly.Fly();',
|
||||||
'end;',
|
'end;',
|
||||||
'var Obj: tobject;',
|
'var Obj: tobject;',
|
||||||
'begin',
|
'begin',
|
||||||
' obj.GetIt;',
|
' obj.Fly;',
|
||||||
' obj.w:=obj.w+4;',
|
' obj.Fly();',
|
||||||
' with obj do begin',
|
' with obj do begin',
|
||||||
' w:=w-5;',
|
' Fly;',
|
||||||
|
' Fly();',
|
||||||
' end;',
|
' end;',
|
||||||
'']);
|
'']);
|
||||||
ConvertProgram;
|
ConvertProgram;
|
||||||
CheckSource('TestClass_CallClassMethodStatic',
|
CheckSource('TestClass_CallClassMethodStatic',
|
||||||
LinesToStr([ // statements
|
LinesToStr([ // statements
|
||||||
|
'rtl.createClass(this, "TObject", null, function () {',
|
||||||
|
' this.$init = function () {',
|
||||||
|
' };',
|
||||||
|
' this.$final = function () {',
|
||||||
|
' };',
|
||||||
|
' this.Fly = function () {',
|
||||||
|
' var Result = null;',
|
||||||
|
' $mod.TObject.Fly();',
|
||||||
|
' $mod.TObject.Fly();',
|
||||||
|
' $mod.TObject.Fly();',
|
||||||
|
' $mod.TObject.Fly();',
|
||||||
|
' $mod.TObject.Fly();',
|
||||||
|
' $mod.TObject.Fly();',
|
||||||
|
' return Result;',
|
||||||
|
' };',
|
||||||
|
'});',
|
||||||
'this.Obj = null;'
|
'this.Obj = null;'
|
||||||
]),
|
]),
|
||||||
LinesToStr([ // $mod.$main
|
LinesToStr([ // $mod.$main
|
||||||
|
'$mod.TObject.Fly();',
|
||||||
|
'$mod.TObject.Fly();',
|
||||||
|
'var $with = $mod.Obj;',
|
||||||
|
'$with.Fly();',
|
||||||
|
'$with.Fly();',
|
||||||
'']));
|
'']));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -22690,21 +22712,21 @@ begin
|
|||||||
'this.c = null;',
|
'this.c = null;',
|
||||||
'']),
|
'']),
|
||||||
LinesToStr([ // $mod.$main
|
LinesToStr([ // $mod.$main
|
||||||
'$mod.b.SetSpeed($mod.b.GetSpeed() + 12);',
|
'$mod.TObject.SetSpeed($mod.TObject.GetSpeed() + 12);',
|
||||||
'$mod.TObjHelper.SetLeft($mod.TObjHelper.GetLeft() + 13);',
|
'$mod.TObjHelper.SetLeft($mod.TObjHelper.GetLeft() + 13);',
|
||||||
'$mod.TObjHelper.SetLeft($mod.TObjHelper.GetLeft() + 14);',
|
'$mod.TObjHelper.SetLeft($mod.TObjHelper.GetLeft() + 14);',
|
||||||
'var $with = $mod.b;',
|
'var $with = $mod.b;',
|
||||||
'$with.SetSpeed($with.GetSpeed() + 32);',
|
'$with.SetSpeed($with.GetSpeed() + 32);',
|
||||||
'$mod.TObjHelper.SetLeft($mod.TObjHelper.GetLeft() + 33);',
|
'$mod.TObjHelper.SetLeft($mod.TObjHelper.GetLeft() + 33);',
|
||||||
'$mod.TObjHelper.SetLeft($mod.TObjHelper.GetLeft() + 34);',
|
'$mod.TObjHelper.SetLeft($mod.TObjHelper.GetLeft() + 34);',
|
||||||
'$mod.c.SetSpeed($mod.c.GetSpeed() + 12);',
|
'$mod.TObject.SetSpeed($mod.TObject.GetSpeed() + 12);',
|
||||||
'$mod.TObjHelper.SetLeft($mod.TObjHelper.GetLeft() + 13);',
|
'$mod.TObjHelper.SetLeft($mod.TObjHelper.GetLeft() + 13);',
|
||||||
'$mod.TObjHelper.SetLeft($mod.TObjHelper.GetLeft() + 14);',
|
'$mod.TObjHelper.SetLeft($mod.TObjHelper.GetLeft() + 14);',
|
||||||
'var $with1 = $mod.c;',
|
'var $with1 = $mod.c;',
|
||||||
'$with1.SetSpeed($with1.GetSpeed() + 32);',
|
'$with1.SetSpeed($with1.GetSpeed() + 32);',
|
||||||
'$mod.TObjHelper.SetLeft($mod.TObjHelper.GetLeft() + 33);',
|
'$mod.TObjHelper.SetLeft($mod.TObjHelper.GetLeft() + 33);',
|
||||||
'$mod.TObjHelper.SetLeft($mod.TObjHelper.GetLeft() + 34);',
|
'$mod.TObjHelper.SetLeft($mod.TObjHelper.GetLeft() + 34);',
|
||||||
'$mod.TBird.SetSpeed($mod.TBird.GetSpeed() + 12);',
|
'$mod.TObject.SetSpeed($mod.TObject.GetSpeed() + 12);',
|
||||||
'$mod.TObjHelper.SetLeft($mod.TObjHelper.GetLeft() + 13);',
|
'$mod.TObjHelper.SetLeft($mod.TObjHelper.GetLeft() + 13);',
|
||||||
'$mod.TObjHelper.SetLeft($mod.TObjHelper.GetLeft() + 14);',
|
'$mod.TObjHelper.SetLeft($mod.TObjHelper.GetLeft() + 14);',
|
||||||
'var $with2 = $mod.TBird;',
|
'var $with2 = $mod.TBird;',
|
||||||
@ -24490,7 +24512,7 @@ begin
|
|||||||
'']),
|
'']),
|
||||||
LinesToStr([ // $mod.$main
|
LinesToStr([ // $mod.$main
|
||||||
'$mod.THelper.Fly.call({',
|
'$mod.THelper.Fly.call({',
|
||||||
' p: $mod.o.GetField(),',
|
' p: $mod.TObject.GetField(),',
|
||||||
' get: function () {',
|
' get: function () {',
|
||||||
' return this.p;',
|
' return this.p;',
|
||||||
' },',
|
' },',
|
||||||
@ -24508,7 +24530,7 @@ begin
|
|||||||
' this.p = v;',
|
' this.p = v;',
|
||||||
' }',
|
' }',
|
||||||
'}, 12);',
|
'}, 12);',
|
||||||
'var $with1 = $mod.o.GetField();',
|
'var $with1 = $mod.TObject.GetField();',
|
||||||
'$mod.THelper.Fly.call({',
|
'$mod.THelper.Fly.call({',
|
||||||
' get: function () {',
|
' get: function () {',
|
||||||
' return $with1;',
|
' return $with1;',
|
||||||
|
Loading…
Reference in New Issue
Block a user