mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-17 07:19:14 +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
|
ResultVarName: string; // valid in implementation ProcScope, empty means use ResolverResultVar
|
||||||
BodyJS: string; // Option coStoreProcJS: stored in ImplScope
|
BodyJS: string; // Option coStoreProcJS: stored in ImplScope
|
||||||
GlobalJS: TStringList; // 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);
|
procedure AddGlobalJS(const JS: string);
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
end;
|
end;
|
||||||
@ -1245,6 +1246,7 @@ type
|
|||||||
function GetBaseDescription(const R: TPasResolverResult; AddPath: boolean=
|
function GetBaseDescription(const R: TPasResolverResult; AddPath: boolean=
|
||||||
false): string; override;
|
false): string; override;
|
||||||
function HasTypeInfo(El: TPasType): boolean; override;
|
function HasTypeInfo(El: TPasType): boolean; override;
|
||||||
|
function ProcHasImplElements(Proc: TPasProcedure): boolean; override;
|
||||||
function IsTObjectFreeMethod(El: TPasExpr): boolean; virtual;
|
function IsTObjectFreeMethod(El: TPasExpr): boolean; virtual;
|
||||||
function IsExternalBracketAccessor(El: TPasElement): boolean;
|
function IsExternalBracketAccessor(El: TPasElement): boolean;
|
||||||
function IsExternalClassConstructor(El: TPasElement): boolean;
|
function IsExternalClassConstructor(El: TPasElement): boolean;
|
||||||
@ -4492,6 +4494,20 @@ begin
|
|||||||
Result:=false;
|
Result:=false;
|
||||||
end;
|
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;
|
function TPas2JSResolver.IsTObjectFreeMethod(El: TPasExpr): boolean;
|
||||||
var
|
var
|
||||||
Ref: TResolvedReference;
|
Ref: TResolvedReference;
|
||||||
@ -12582,7 +12598,10 @@ begin
|
|||||||
if (coStoreImplJS in Options) and (aResolver<>nil) then
|
if (coStoreImplJS in Options) and (aResolver<>nil) then
|
||||||
begin
|
begin
|
||||||
if aResolver.GetTopLvlProc(El)=El then
|
if aResolver.GetTopLvlProc(El)=El then
|
||||||
|
begin
|
||||||
ImplProcScope.BodyJS:=CreatePrecompiledJS(Result);
|
ImplProcScope.BodyJS:=CreatePrecompiledJS(Result);
|
||||||
|
ImplProcScope.EmptyJS:=BodyPas.Body=nil;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -3771,6 +3771,7 @@ begin
|
|||||||
Arr.Add(Scope.GlobalJS[i]);
|
Arr.Add(Scope.GlobalJS[i]);
|
||||||
end;
|
end;
|
||||||
Obj.Add('Body',Scope.BodyJS);
|
Obj.Add('Body',Scope.BodyJS);
|
||||||
|
Obj.Add('Empty',Scope.EmptyJS);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
if (Scope.BodyJS<>'') and (Scope.ImplProc<>nil) then
|
if (Scope.BodyJS<>'') and (Scope.ImplProc<>nil) then
|
||||||
@ -7347,6 +7348,7 @@ begin
|
|||||||
RaiseMsg(20180228231511,El);
|
RaiseMsg(20180228231511,El);
|
||||||
if not ReadString(Obj,'Body',s,El) then
|
if not ReadString(Obj,'Body',s,El) then
|
||||||
RaiseMsg(20180228131232,El);
|
RaiseMsg(20180228131232,El);
|
||||||
|
ReadBoolean(Obj,'Empty',ImplScope.EmptyJS,El);
|
||||||
ImplScope.BodyJS:=s;
|
ImplScope.BodyJS:=s;
|
||||||
if ReadArray(Obj,'Globals',Arr,El) then
|
if ReadArray(Obj,'Globals',Arr,El) then
|
||||||
begin
|
begin
|
||||||
|
Loading…
Reference in New Issue
Block a user