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