diff options
Diffstat (limited to 'packages/fcl-passrc/src/pasresolver.pp')
-rw-r--r-- | packages/fcl-passrc/src/pasresolver.pp | 59 |
1 files changed, 50 insertions, 9 deletions
diff --git a/packages/fcl-passrc/src/pasresolver.pp b/packages/fcl-passrc/src/pasresolver.pp index ed20471c25..b13ffd7baa 100644 --- a/packages/fcl-passrc/src/pasresolver.pp +++ b/packages/fcl-passrc/src/pasresolver.pp @@ -1690,6 +1690,7 @@ type procedure FinishMethodImplHeader(ImplProc: TPasProcedure); virtual; procedure FinishExceptOnExpr; virtual; procedure FinishExceptOnStatement; virtual; + procedure FinishParserSpecializeType(El: TPasSpecializeType); virtual; procedure FinishWithDo(El: TPasImplWithDo); virtual; procedure FinishForLoopHeader(Loop: TPasImplForLoop); virtual; procedure FinishDeclaration(El: TPasElement); virtual; @@ -2153,6 +2154,7 @@ type function PushHelperDotScope(HiType: TPasType): TPasDotBaseScope; function PushTemplateDotScope(TemplType: TPasGenericTemplateType; ErrorEl: TPasElement): TPasDotBaseScope; function PushDotScope(HiType: TPasType): TPasDotBaseScope; + function PushParserSpecializeType(SpecType: TPasSpecializeType): TPasDotBaseScope; function PushWithExprScope(Expr: TPasExpr): TPasWithExprScope; function StashScopes(NewScopeCnt: integer): integer; // returns old StashDepth function StashSubExprScopes: integer; // returns old StashDepth @@ -5238,6 +5240,9 @@ begin begin // El is the first element found -> raise error // ToDo: use the ( as error position + {$IFDEF VerbosePasResolver} + writeln('TPasResolver.OnFindCallElements El=',GetObjPath(El)); + {$ENDIF} RaiseMsg(20170216151525,nIllegalQualifierAfter,sIllegalQualifierAfter, ['(',El.ElementTypeName],Data^.Params); end; @@ -7606,6 +7611,12 @@ begin PopScope; end; +procedure TPasResolver.FinishParserSpecializeType(El: TPasSpecializeType); +begin + if El=nil then ; + PopScope; +end; + procedure TPasResolver.FinishWithDo(El: TPasImplWithDo); begin PopWithScope(El); @@ -18120,6 +18131,13 @@ begin SpecializeElList(GenEl,SpecEl,GenEl.Params,SpecEl.Params,true {$IFDEF CheckPasTreeRefCount},'TPasSpecializeType.Params'{$ENDIF}); + if GenEl.SubType<>nil then + begin + PushParserSpecializeType(SpecEl); + SpecializeElType(GenEl,SpecEl,GenEl.SubType,SpecEl.SubType); + PopScope; + end; + FinishSpecializeType(SpecEl); {$IFDEF VerbosePasResolver} //writeln('TPasResolver.SpecializeSpecializeType ',GetObjName(SpecEl.DestType),' ',GetObjName(SpecEl.CustomData)); @@ -21807,6 +21825,7 @@ end; procedure TPasResolver.BeginScope(ScopeType: TPasScopeType; El: TPasElement); begin case ScopeType of + stSpecializeType: PushParserSpecializeType(El as TPasSpecializeType); stWithExpr: PushWithExprScope(El as TPasExpr); else RaiseMsg(20181210163324,nNotYetImplemented,sNotYetImplemented+' BeginScope',[IntToStr(ord(ScopeType))],nil); @@ -21824,9 +21843,10 @@ begin stResourceString: FinishResourcestring(El as TPasResString); stProcedure: FinishProcedure(El as TPasProcedure); stProcedureHeader: FinishProcedureType(El as TPasProcedureType); + stSpecializeType: FinishParserSpecializeType(El as TPasSpecializeType); + stWithExpr: FinishWithDo(El as TPasImplWithDo); stExceptOnExpr: FinishExceptOnExpr; stExceptOnStatement: FinishExceptOnStatement; - stWithExpr: FinishWithDo(El as TPasImplWithDo); stForLoopHeader: FinishForLoopHeader(El as TPasImplForLoop); stDeclaration: FinishDeclaration(El); stAncestors: FinishAncestors(El as TPasClassType); @@ -22784,6 +22804,12 @@ begin Result:=PushHelperDotScope(HiType); end; +function TPasResolver.PushParserSpecializeType(SpecType: TPasSpecializeType + ): TPasDotBaseScope; +begin + Result:=PushDotScope(SpecType.DestType); +end; + function TPasResolver.PushWithExprScope(Expr: TPasExpr): TPasWithExprScope; var WithEl: TPasImplWithDo; @@ -25520,6 +25546,7 @@ function TPasResolver.ResolvedElIsClassOrRecordInstance( const ResolvedEl: TPasResolverResult): boolean; var TypeEl: TPasType; + C: TClass; begin Result:=false; if ResolvedEl.BaseType<>btContext then exit; @@ -25532,10 +25559,14 @@ begin else if TypeEl.ClassType=TPasRecordType then else exit; - if (ResolvedEl.IdentEl is TPasVariable) - or (ResolvedEl.IdentEl.ClassType=TPasArgument) - or (ResolvedEl.IdentEl.ClassType=TPasResultElement) then - exit(true); + if ResolvedEl.IdentEl<>nil then + begin + C:=ResolvedEl.IdentEl.ClassType; + if C.InheritsFrom(TPasVariable) + or (C=TPasArgument) + or (C=TPasResultElement) then + exit(true); + end; end; function TPasResolver.GetResolver(El: TPasElement): TPasResolver; @@ -27709,7 +27740,9 @@ procedure TPasResolver.ComputeElement(El: TPasElement; out var TypeEl: TPasType; begin - if SpecType.CustomData is TPasSpecializeTypeData then + if SpecType.SubType<>nil then + ComputeElement(SpecType.SubType,ResolvedEl,Flags,StartEl) + else if SpecType.CustomData is TPasSpecializeTypeData then begin TypeEl:=TPasSpecializeTypeData(SpecType.CustomData).SpecializedType; if TypeEl=nil then @@ -28393,6 +28426,7 @@ function TPasResolver.ResolveAliasType(aType: TPasType; SkipTypeAlias: boolean ): TPasType; var C: TClass; + SpecType: TPasSpecializeType; begin while aType<>nil do begin @@ -28406,9 +28440,16 @@ begin aType:=NoNil(TResolvedReference(aType.CustomData).Declaration) as TPasType else if C=TPasSpecializeType then begin - if aType.CustomData is TPasSpecializeTypeData then - exit(TPasSpecializeTypeData(aType.CustomData).SpecializedType); - aType:=TPasSpecializeType(aType).DestType; + SpecType:=TPasSpecializeType(aType); + if SpecType.SubType<>nil then + // e.g. a<b>.c + aType:=SpecType.SubType + else + begin + if SpecType.CustomData is TPasSpecializeTypeData then + exit(TPasSpecializeTypeData(SpecType.CustomData).SpecializedType); + aType:=SpecType.DestType; + end; end else exit(aType); |