summaryrefslogtreecommitdiff
path: root/avx512-0037785/packages/fcl-passrc/src/pasresolver.pp
diff options
context:
space:
mode:
Diffstat (limited to 'avx512-0037785/packages/fcl-passrc/src/pasresolver.pp')
-rw-r--r--avx512-0037785/packages/fcl-passrc/src/pasresolver.pp125
1 files changed, 89 insertions, 36 deletions
diff --git a/avx512-0037785/packages/fcl-passrc/src/pasresolver.pp b/avx512-0037785/packages/fcl-passrc/src/pasresolver.pp
index 9fe78b10ff..54f9110705 100644
--- a/avx512-0037785/packages/fcl-passrc/src/pasresolver.pp
+++ b/avx512-0037785/packages/fcl-passrc/src/pasresolver.pp
@@ -3937,10 +3937,16 @@ end;
{ EPasResolve }
procedure EPasResolve.SetPasElement(AValue: TPasElement);
+var
+ Old: TPasElement;
begin
if FPasElement=AValue then Exit;
- if PasElement<>nil then
+ Old:=FPasElement;
+ if Old<>nil then
+ begin
+ Old:=nil;
PasElement.Release{$IFDEF CheckPasTreeRefCount}('EPasResolve.SetPasElement'){$ENDIF};
+ end;
FPasElement:=AValue;
if PasElement<>nil then
PasElement.AddRef{$IFDEF CheckPasTreeRefCount}('EPasResolve.SetPasElement'){$ENDIF};
@@ -7526,11 +7532,13 @@ procedure TPasResolver.FinishExceptOnExpr;
var
El: TPasImplExceptOn;
ResolvedType: TPasResolverResult;
+ TypeEl: TPasType;
begin
CheckTopScope(TPasExceptOnScope);
El:=TPasImplExceptOn(FTopScope.Element);
- ComputeElement(El.TypeEl,ResolvedType,[rcType]);
- CheckIsClass(El.TypeEl,ResolvedType);
+ TypeEl:=El.TypeEl;
+ ComputeElement(TypeEl,ResolvedType,[rcType]);
+ CheckIsClass(TypeEl,ResolvedType);
end;
procedure TPasResolver.FinishExceptOnStatement;
@@ -9049,7 +9057,7 @@ begin
CurEl:=nil;
if not SameText(RightStr(AttrName,length('Attribute')),'Attribute') then
begin
- // first search AttrName+'Attibute'
+ // first search AttrName+'Attribute'
CurEl:=FindFirstEl(AttrName+'Attribute',Data,NameExpr);
end;
// then search the name
@@ -9164,12 +9172,14 @@ var
FindData: TPRFindData;
Ref: TResolvedReference;
ResolvedEl: TPasResolverResult;
+ Section: TPasSection;
+ Scope: TPasIdentifierScope;
+ ScopeIdent: TPasIdentifier;
begin
Expr:=El.NameExpr;
if Expr<>nil then
begin
ResolveExpr(Expr,rraRead);
- //ResolveGlobalSymbol(Expr);
ComputeElement(Expr,ResolvedEl,[rcConstant]);
DeclEl:=ResolvedEl.IdentEl;
if DeclEl=nil then
@@ -9189,9 +9199,21 @@ begin
CheckFoundElement(FindData,Ref);
end;
+ if DeclEl is TPasProcedure then
+ begin
+ Section:=DeclEl.Parent as TPasSection;
+ Scope:=Section.CustomData as TPasIdentifierScope;
+ ScopeIdent:=Scope.FindLocalIdentifier(DeclEl.Name);
+ if (ScopeIdent=nil) then
+ RaiseNotYetImplemented(20210106103001,El,GetObjPath(DeclEl));
+ if ScopeIdent.NextSameIdentifier<>nil then
+ RaiseMsg(20210106103320,nCantDetermineWhichOverloadedFunctionToCall,
+ sCantDetermineWhichOverloadedFunctionToCall,[],El);
+ end;
+
// check index and name
CheckConstExpr(El.ExportIndex,[revkInt,revkUInt],'integer');
- CheckConstExpr(El.ExportName,[revkString,revkUnicodeString],'string');
+ CheckConstExpr(El.ExportName,revkAllStrings,'string');
end;
procedure TPasResolver.FinishProcParamAccess(ProcType: TPasProcedureType;
@@ -12243,6 +12265,7 @@ begin
writeln('TPasResolver.AddExportSymbol ',GetObjName(El));
{$ENDIF}
// Note: export symbol is not added to scope
+ if El=nil then ;
end;
procedure TPasResolver.AddEnumType(El: TPasEnumType);
@@ -18740,54 +18763,67 @@ function TPasResolver.BI_InExclude_OnGetCallCompatibility(
// check params of built in proc 'include'
var
Params: TParamsExpr;
- Param: TPasExpr;
- ParamResolved: TPasResolverResult;
+ Param0, Param1: TPasExpr;
+ Param0Resolved, Param1Resolved: TPasResolverResult;
EnumType: TPasEnumType;
C: TClass;
+ LoTypeEl: TPasType;
+ RgType: TPasRangeType;
begin
if not CheckBuiltInMinParamCount(Proc,Expr,2,RaiseOnError) then
exit(cIncompatible);
Params:=TParamsExpr(Expr);
- // first param: set variable
+ // first Param0: set variable
// todo set of int, set of char, set of bool
- Param:=Params.Params[0];
- ComputeElement(Param,ParamResolved,[rcNoImplicitProc]);
+ Param0:=Params.Params[0];
+ ComputeElement(Param0,Param0Resolved,[rcNoImplicitProc]);
+ Param1:=Params.Params[1];
+ ComputeElement(Param1,Param1Resolved,[]);
+
EnumType:=nil;
- if ([rrfReadable,rrfWritable]*ParamResolved.Flags=[rrfReadable,rrfWritable])
- and (ParamResolved.IdentEl<>nil) then
+ RgType:=nil;
+ if ([rrfReadable,rrfWritable]*Param0Resolved.Flags=[rrfReadable,rrfWritable])
+ and (Param0Resolved.IdentEl<>nil) then
begin
- C:=ParamResolved.IdentEl.ClassType;
+ C:=Param0Resolved.IdentEl.ClassType;
if (C.InheritsFrom(TPasVariable)
or (C=TPasArgument)
or (C=TPasResultElement)) then
begin
- if (ParamResolved.BaseType=btSet)
- and (ParamResolved.LoTypeEl is TPasEnumType) then
- EnumType:=TPasEnumType(ParamResolved.LoTypeEl);
+ if Param0Resolved.BaseType=btSet then
+ begin
+ LoTypeEl:=Param0Resolved.LoTypeEl;
+ if LoTypeEl.ClassType=TPasEnumType then
+ begin
+ EnumType:=TPasEnumType(LoTypeEl);
+ if (not (rrfReadable in Param0Resolved.Flags))
+ or (Param0Resolved.LoTypeEl<>EnumType) then
+ begin
+ if RaiseOnError then
+ RaiseIncompatibleType(20210201225926,nIncompatibleTypeArgNo,
+ ['2'],Param0Resolved.LoTypeEl,EnumType,Param0);
+ exit(cIncompatible);
+ end;
+ end
+ else if LoTypeEl.ClassType=TPasRangeType then
+ begin
+ RgType:=TPasRangeType(LoTypeEl);
+ ComputeElement(RgType.RangeExpr.left,Param0Resolved,[]);
+ Result:=CheckAssignResCompatibility(Param0Resolved,Param1Resolved,Param1,RaiseOnError);
+ end;
+ end;
end;
end;
- if EnumType=nil then
+ if (EnumType=nil) and (RgType=nil) then
begin
{$IFDEF VerbosePasResolver}
- writeln('TPasResolver.OnGetCallCompatibility_InExclude ',GetResolverResultDbg(ParamResolved));
+ writeln('TPasResolver.OnGetCallCompatibility_InExclude ',GetResolverResultDbg(Param0Resolved));
{$ENDIF}
- exit(CheckRaiseTypeArgNo(20170216152301,1,Param,ParamResolved,
+ exit(CheckRaiseTypeArgNo(20170216152301,1,Param0,Param0Resolved,
'variable of set of enumtype',RaiseOnError));
end;
- // second param: enum
- Param:=Params.Params[1];
- ComputeElement(Param,ParamResolved,[]);
- if (not (rrfReadable in ParamResolved.Flags))
- or (ParamResolved.LoTypeEl<>EnumType) then
- begin
- if RaiseOnError then
- RaiseIncompatibleType(20170216152302,nIncompatibleTypeArgNo,
- ['2'],ParamResolved.LoTypeEl,EnumType,Param);
- exit(cIncompatible);
- end;
-
Result:=CheckBuiltInMaxParamCount(Proc,Params,2,RaiseOnError);
end;
@@ -19113,19 +19149,19 @@ begin
exit(cIncompatible);
Params:=TParamsExpr(Expr);
- // first param: bool, enum or char
+ // first param: bool, integer, enum or char
Param:=Params.Params[0];
ComputeElement(Param,ParamResolved,[]);
Result:=cIncompatible;
if rrfReadable in ParamResolved.Flags then
begin
- if ParamResolved.BaseType in (btAllBooleans+btAllChars) then
+ if ParamResolved.BaseType in btArrayRangeTypes then
Result:=cExact
else if (ParamResolved.BaseType=btContext) and (ParamResolved.LoTypeEl is TPasEnumType) then
Result:=cExact
else if ParamResolved.BaseType=btRange then
begin
- if ParamResolved.SubType in btAllBooleans+btAllChars then
+ if ParamResolved.SubType in btArrayRangeTypes then
Result:=cExact
else if ParamResolved.SubType=btContext then
begin
@@ -21318,7 +21354,7 @@ procedure TPasResolver.CheckFoundElement(
// Call this method after finding an element by searching the scopes.
function IsFieldInheritingConst(aRef: TResolvedReference): boolean;
- // returns true of aRef is a TPasVariable that inherits its const from parent.
+ // returns true if aRef is a TPasVariable that inherits its const from parent.
// For example
// type TRecord = record
// a: word; // inherits const
@@ -27564,6 +27600,21 @@ procedure TPasResolver.ComputeElement(El: TPasElement; out
end;
end;
+ procedure ComputeExportSymbol(ExpSymbol: TPasExportSymbol);
+ var
+ Ref: TResolvedReference;
+ begin
+ if ExpSymbol.CustomData is TResolvedReference then
+ begin
+ Ref:=TResolvedReference(El.CustomData);
+ ComputeElement(Ref.Declaration,ResolvedEl,Flags+[rcNoImplicitProc],StartEl);
+ end
+ else if ExpSymbol.NameExpr<>nil then
+ ComputeElement(ExpSymbol.NameExpr,ResolvedEl,Flags,StartEl)
+ else
+ RaiseNotYetImplemented(20210106225512,ExpSymbol);
+ end;
+
var
DeclEl: TPasElement;
ElClass: TClass;
@@ -27946,6 +27997,8 @@ begin
ComputeSpecializeType(TPasSpecializeType(El))
else if ElClass=TInlineSpecializeExpr then
ComputeElement(TInlineSpecializeExpr(El).NameExpr,ResolvedEl,Flags,StartEl)
+ else if ElClass=TPasExportSymbol then
+ ComputeExportSymbol(TPasExportSymbol(El))
else
RaiseNotYetImplemented(20160922163705,El);
{$IF defined(nodejs) and defined(VerbosePasResolver)}