mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-21 01:09:31 +02:00
pastojs: store if impl proc body is empty
git-svn-id: trunk@39582 -
This commit is contained in:
parent
971c7b45e7
commit
0031588e06
@ -1017,6 +1017,7 @@ type
|
||||
ResultVarName: string; // valid in implementation ProcScope, empty means use ResolverResultVar
|
||||
BodyJS: string; // Option coStoreProcJS: stored in ImplScope
|
||||
GlobalJS: TStringList; // Option coStoreProcJS: stored in ImplScope
|
||||
EmptyJS: boolean; // Option coStoreProcJS: stored in ImplScope, true if Body.Body=nil
|
||||
procedure AddGlobalJS(const JS: string);
|
||||
destructor Destroy; override;
|
||||
end;
|
||||
@ -1245,6 +1246,7 @@ type
|
||||
function GetBaseDescription(const R: TPasResolverResult; AddPath: boolean=
|
||||
false): string; override;
|
||||
function HasTypeInfo(El: TPasType): boolean; override;
|
||||
function ProcHasImplElements(Proc: TPasProcedure): boolean; override;
|
||||
function IsTObjectFreeMethod(El: TPasExpr): boolean; virtual;
|
||||
function IsExternalBracketAccessor(El: TPasElement): boolean;
|
||||
function IsExternalClassConstructor(El: TPasElement): boolean;
|
||||
@ -4492,6 +4494,20 @@ begin
|
||||
Result:=false;
|
||||
end;
|
||||
|
||||
function TPas2JSResolver.ProcHasImplElements(Proc: TPasProcedure): boolean;
|
||||
var
|
||||
Scope: TPas2JSProcedureScope;
|
||||
begin
|
||||
Result:=inherited ProcHasImplElements(Proc);
|
||||
if Result then exit;
|
||||
// no body elements found -> check precompiled
|
||||
Scope:=Proc.CustomData as TPas2JSProcedureScope;
|
||||
if Scope.ImplProc<>nil then
|
||||
Scope:=Scope.ImplProc.CustomData as TPas2JSProcedureScope;
|
||||
if Scope.BodyJS<>'' then
|
||||
Result:=not Scope.EmptyJS;
|
||||
end;
|
||||
|
||||
function TPas2JSResolver.IsTObjectFreeMethod(El: TPasExpr): boolean;
|
||||
var
|
||||
Ref: TResolvedReference;
|
||||
@ -12582,7 +12598,10 @@ begin
|
||||
if (coStoreImplJS in Options) and (aResolver<>nil) then
|
||||
begin
|
||||
if aResolver.GetTopLvlProc(El)=El then
|
||||
begin
|
||||
ImplProcScope.BodyJS:=CreatePrecompiledJS(Result);
|
||||
ImplProcScope.EmptyJS:=BodyPas.Body=nil;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
@ -3771,6 +3771,7 @@ begin
|
||||
Arr.Add(Scope.GlobalJS[i]);
|
||||
end;
|
||||
Obj.Add('Body',Scope.BodyJS);
|
||||
Obj.Add('Empty',Scope.EmptyJS);
|
||||
end;
|
||||
end;
|
||||
if (Scope.BodyJS<>'') and (Scope.ImplProc<>nil) then
|
||||
@ -7347,6 +7348,7 @@ begin
|
||||
RaiseMsg(20180228231511,El);
|
||||
if not ReadString(Obj,'Body',s,El) then
|
||||
RaiseMsg(20180228131232,El);
|
||||
ReadBoolean(Obj,'Empty',ImplScope.EmptyJS,El);
|
||||
ImplScope.BodyJS:=s;
|
||||
if ReadArray(Obj,'Globals',Arr,El) then
|
||||
begin
|
||||
|
Loading…
Reference in New Issue
Block a user