|
@@ -169,7 +169,8 @@ const
|
|
|
'ExternalClass',
|
|
|
'PrefixedAttributes',
|
|
|
'IgnoreAttributes',
|
|
|
- 'OmitRTTI'
|
|
|
+ 'OmitRTTI',
|
|
|
+ 'MultipleScopeHelpers'
|
|
|
);
|
|
|
|
|
|
PCUDefaultBoolSwitches: TBoolSwitches = [
|
|
@@ -2636,6 +2637,9 @@ begin
|
|
|
WriteIdentifierScope(Obj,Scope,aContext);
|
|
|
|
|
|
// not needed: Scope ElevatedLocals
|
|
|
+ // not needed: Scope Helpers
|
|
|
+ if (length(Scope.Helpers)>0) and not (Scope.Element is TInterfaceSection) then
|
|
|
+ RaiseMsg(20190119122007,Section);
|
|
|
|
|
|
WriteDeclarations(Obj,Section,aContext);
|
|
|
if Section is TInterfaceSection then
|
|
@@ -3711,7 +3715,7 @@ begin
|
|
|
RaiseMsg(20180219135933,Scope.Element);
|
|
|
AddReferenceToObj(Obj,'ImplProc',Scope.ImplProc);
|
|
|
AddReferenceToObj(Obj,'Overridden',Scope.OverriddenProc);
|
|
|
- // ClassScope: TPasClassScope; auto derived
|
|
|
+ // ClassOrRecordScope: TPasClassScope; auto derived
|
|
|
if Scope.SelfArg<>nil then
|
|
|
RaiseMsg(20180211180457,Scope.Element); // SelfArg only valid for method implementation
|
|
|
// Mode: TModeSwitch: auto derived
|
|
@@ -3733,8 +3737,7 @@ begin
|
|
|
WritePasElement(Obj,El,aContext);
|
|
|
Scope:=El.CustomData as TPas2JSProcedureScope;
|
|
|
//writeln('TPCUWriter.WriteProcedure ',GetObjName(El),' ',GetObjName(Scope),' ',Resolver.GetElementSourcePosStr(El));
|
|
|
- // BEWARE: Scope can be nil for ignored methods of an interface (msIgnoreInterfaces)
|
|
|
- if (Scope=nil) or (Scope.DeclarationProc=nil) then
|
|
|
+ if Scope.DeclarationProc=nil then
|
|
|
begin
|
|
|
WriteElementProperty(Obj,El,'ProcType',El.ProcType,aContext);
|
|
|
WriteExpr(Obj,El,'Public',El.PublicName,aContext);
|
|
@@ -3752,12 +3755,6 @@ begin
|
|
|
if El.MessageType<>pmtInteger then
|
|
|
Obj.Add('MessageType',PCUProcedureMessageTypeNames[El.MessageType]);
|
|
|
end;
|
|
|
-
|
|
|
- if Scope=nil then
|
|
|
- begin
|
|
|
- Obj.Add('Scope',false); // msIgnoreInterfaces
|
|
|
- exit;
|
|
|
- end;
|
|
|
WriteProcedureScope(Obj,Scope,aContext);
|
|
|
end
|
|
|
else
|
|
@@ -5401,6 +5398,7 @@ procedure TPCUReader.ReadSectionScope(Obj: TJSONObject;
|
|
|
begin
|
|
|
ReadIdentifierScope(Obj,Scope,aContext);
|
|
|
// not needed: Scope ElevatedLocals
|
|
|
+ // not needed: Scope Helpers, autogenerated in ReadClassType
|
|
|
Scope.BoolSwitches:=ReadBoolSwitches(Obj,Scope.Element,'BoolSwitches',aContext.BoolSwitches);
|
|
|
Scope.ModeSwitches:=ReadModeSwitches(Obj,Scope.Element,'ModeSwitches',aContext.ModeSwitches);
|
|
|
end;
|
|
@@ -6925,6 +6923,8 @@ var
|
|
|
Data: TJSONData;
|
|
|
Scope: TPas2JSClassScope;
|
|
|
Ref: TResolvedReference;
|
|
|
+ Parent: TPasElement;
|
|
|
+ SectionScope: TPasSectionScope;
|
|
|
begin
|
|
|
ReadBoolean(Obj,'Forward',El.IsForward,El);
|
|
|
|
|
@@ -6986,6 +6986,22 @@ begin
|
|
|
begin
|
|
|
ReadClassScopeAbstractProcs(Obj,Scope);
|
|
|
ReadClassScopeInterfaces(Obj,Scope);
|
|
|
+
|
|
|
+ if El.ObjKind in okAllHelpers then
|
|
|
+ begin
|
|
|
+ // restore cached helpers in interface
|
|
|
+ Parent:=El.Parent;
|
|
|
+ while Parent<>nil do
|
|
|
+ begin
|
|
|
+ if Parent.ClassType=TInterfaceSection then
|
|
|
+ begin
|
|
|
+ SectionScope:=Parent.CustomData as TPasSectionScope;
|
|
|
+ Resolver.AddHelper(El,SectionScope.Helpers);
|
|
|
+ break;
|
|
|
+ end;
|
|
|
+ Parent:=Parent.Parent;
|
|
|
+ end;
|
|
|
+ end;
|
|
|
end;
|
|
|
end;
|
|
|
|
|
@@ -7328,8 +7344,9 @@ begin
|
|
|
ReadElementReference(Obj,Scope,'ImplProc',@Set_ProcedureScope_ImplProc);
|
|
|
ReadElementReference(Obj,Scope,'Overridden',@Set_ProcedureScope_Overridden);
|
|
|
if Proc.Parent is TPasMembersType then
|
|
|
- Scope.ClassOrRecordScope:=Proc.Parent.CustomData as TPasClassOrRecordScope; // no AddRef
|
|
|
- // ClassScope: TPasClassScope; auto derived
|
|
|
+ Scope.ClassRecScope:=Proc.Parent.CustomData as TPasClassOrRecordScope // no AddRef
|
|
|
+ else
|
|
|
+ ; // set via Set_ProcedureScope_ImplProc
|
|
|
// Scope.SelfArg only valid for method implementation
|
|
|
|
|
|
Scope.Flags:=ReadProcScopeFlags(Obj,Proc,'SFlags',[]);
|
|
@@ -7346,8 +7363,8 @@ var
|
|
|
DeclProc: TPasProcedure;
|
|
|
begin
|
|
|
// Note: the References are stored in the scope object of the declaration proc,
|
|
|
- // OTOH in the JSON they are stored in the scope of the implementation
|
|
|
- // proc, so that all references can be resolved immediately.
|
|
|
+ // But TPCUWriter stores them in the implementation scope, so that all
|
|
|
+ // references can be resolved immediately.
|
|
|
if ImplScope.ImplProc<>nil then
|
|
|
RaiseMsg(20180318212631,ImplScope.Element);
|
|
|
DeclProc:=ImplScope.DeclarationProc;
|