pastojs: filer: fixed restoring overload names of specialized methods

This commit is contained in:
mattias 2020-12-03 10:44:57 +00:00
parent cc7c15f35e
commit 758492a59c
3 changed files with 21 additions and 2 deletions

View File

@ -1872,7 +1872,7 @@ type
procedure SpecializeElArray(GenEl, SpecEl: TPasElement;
GenList: TPasElementArray; var SpecList: TPasElementArray; AllowReferences: boolean
{$IFDEF CheckPasTreeRefCount}; const RefId: string{$ENDIF});
procedure SpecializeProcedure(GenEl, SpecEl: TPasProcedure; SpecializedItem: TPRSpecializedItem);
procedure SpecializeProcedure(GenEl, SpecEl: TPasProcedure; SpecializedItem: TPRSpecializedItem); virtual;
procedure SpecializeOperator(GenEl, SpecEl: TPasOperator);
procedure SpecializeProcedureType(GenEl, SpecEl: TPasProcedureType; SpecializedItem: TPRSpecializedItem);
procedure SpecializeProcedureBody(GenEl, SpecEl: TProcedureBody);

View File

@ -1557,6 +1557,8 @@ type
override;
procedure SpecializeGenericImpl(SpecializedItem: TPRSpecializedItem);
override;
procedure SpecializeProcedure(GenEl, SpecEl: TPasProcedure;
SpecializedItem: TPRSpecializedItem); override;
function SpecializeParamsNeedDelay(SpecializedItem: TPRSpecializedItem): TPasElement; virtual;
function IsSpecializedNonStaticMethod(ProcType: TPasProcedureType): boolean;
protected
@ -5260,6 +5262,22 @@ begin
end;
end;
procedure TPas2JSResolver.SpecializeProcedure(GenEl, SpecEl: TPasProcedure;
SpecializedItem: TPRSpecializedItem);
var
GenProcScope, SpecProcScope: TPas2JSProcedureScope;
begin
GenProcScope:=GenEl.CustomData as TPas2JSProcedureScope;
SpecProcScope:=SpecEl.CustomData as TPas2JSProcedureScope;
if SpecializedItem=nil then
begin
SpecProcScope.OverloadName:=GenProcScope.OverloadName;
SpecProcScope.JSName:=GenProcScope.JSName;
// SpecProcScope.ResultVarName is set on demand
end;
inherited SpecializeProcedure(GenEl, SpecEl, SpecializedItem);
end;
function TPas2JSResolver.SpecializeParamsNeedDelay(
SpecializedItem: TPRSpecializedItem): TPasElement;
// finds first specialize param defined later than the generic

View File

@ -4589,6 +4589,7 @@ var
OldInGeneric: Boolean;
begin
WritePasElement(Obj,El,aContext);
Scope:=El.CustomData as TPas2JSProcedureScope;
//writeln('TPCUWriter.WriteProcedure ',GetObjName(El),' ',GetObjName(Scope),' ',Resolver.GetElementSourcePosStr(El));
@ -6675,7 +6676,7 @@ begin
if not ReadInteger(Obj,'Id',Id,GenEl) then
RaiseMsg(20200531085133,GenEl);
if not ReadString(Obj,'SpecName',SpecName,GenEl) then
RaiseMsg(20200531085133,GenEl);
RaiseMsg(20200531085134,GenEl);
PendSpec:=PromiseSpecialize(Id,SpecName,nil,GenEl);
PendSpec.Obj:=Obj;