|
@@ -1824,6 +1824,7 @@ type
|
|
function GetPasPropertyStoredExpr(El: TPasProperty): TPasExpr;
|
|
function GetPasPropertyStoredExpr(El: TPasProperty): TPasExpr;
|
|
function GetPasPropertyDefaultExpr(El: TPasProperty): TPasExpr;
|
|
function GetPasPropertyDefaultExpr(El: TPasProperty): TPasExpr;
|
|
function GetPasClassAncestor(ClassEl: TPasClassType; SkipAlias: boolean): TPasType;
|
|
function GetPasClassAncestor(ClassEl: TPasClassType; SkipAlias: boolean): TPasType;
|
|
|
|
+ function GetParentProcBody(El: TPasElement): TProcedureBody;
|
|
function ProcHasImplElements(Proc: TPasProcedure): boolean; virtual;
|
|
function ProcHasImplElements(Proc: TPasProcedure): boolean; virtual;
|
|
function IndexOfImplementedInterface(ClassEl: TPasClassType; aType: TPasType): integer;
|
|
function IndexOfImplementedInterface(ClassEl: TPasClassType; aType: TPasType): integer;
|
|
function GetLoop(El: TPasElement): TPasImplElement;
|
|
function GetLoop(El: TPasElement): TPasImplElement;
|
|
@@ -2072,8 +2073,8 @@ begin
|
|
dec(Indent,2);
|
|
dec(Indent,2);
|
|
end;
|
|
end;
|
|
Result:=Result+')';
|
|
Result:=Result+')';
|
|
- if El is TPasFunction then
|
|
|
|
- Result:=Result+':'+GetTreeDbg(TPasFunctionType(TPasFunction(El).ProcType).ResultEl,Indent);
|
|
|
|
|
|
+ if (El is TPasProcedure) and (TPasProcedure(El).ProcType is TPasFunctionType) then
|
|
|
|
+ Result:=Result+':'+GetTreeDbg(TPasFunctionType(TPasProcedure(El).ProcType).ResultEl,Indent);
|
|
if TPasProcedureType(El).IsOfObject then
|
|
if TPasProcedureType(El).IsOfObject then
|
|
Result:=Result+' '+ProcTypeModifiers[ptmOfObject];
|
|
Result:=Result+' '+ProcTypeModifiers[ptmOfObject];
|
|
if TPasProcedureType(El).IsNested then
|
|
if TPasProcedureType(El).IsNested then
|
|
@@ -2273,6 +2274,10 @@ begin
|
|
Result:='class procedure'
|
|
Result:='class procedure'
|
|
else if C=TPasClassFunction then
|
|
else if C=TPasClassFunction then
|
|
Result:='class function'
|
|
Result:='class function'
|
|
|
|
+ else if C=TPasAnonymousProcedure then
|
|
|
|
+ Result:='anonymous procedure'
|
|
|
|
+ else if C=TPasAnonymousFunction then
|
|
|
|
+ Result:='anonymous function'
|
|
else if C=TPasMethodResolution then
|
|
else if C=TPasMethodResolution then
|
|
Result:='method resolution'
|
|
Result:='method resolution'
|
|
else if C=TInterfaceSection then
|
|
else if C=TInterfaceSection then
|
|
@@ -5310,13 +5315,17 @@ var
|
|
pm: TProcedureModifier;
|
|
pm: TProcedureModifier;
|
|
ptm: TProcTypeModifier;
|
|
ptm: TProcTypeModifier;
|
|
ObjKind: TPasObjKind;
|
|
ObjKind: TPasObjKind;
|
|
|
|
+ ParentBody: TProcedureBody;
|
|
begin
|
|
begin
|
|
- if (El.Parent is TPasProcedure) and (TPasProcedure(El.Parent).ProcType=El) then
|
|
|
|
|
|
+ if El.Parent is TPasProcedure then
|
|
|
|
+ Proc:=TPasProcedure(El.Parent)
|
|
|
|
+ else
|
|
|
|
+ Proc:=nil;
|
|
|
|
+ if (Proc<>nil) and (Proc.ProcType=El) then
|
|
begin
|
|
begin
|
|
// finished header of a procedure declaration
|
|
// finished header of a procedure declaration
|
|
// -> search the best fitting proc
|
|
// -> search the best fitting proc
|
|
CheckTopScope(FScopeClass_Proc);
|
|
CheckTopScope(FScopeClass_Proc);
|
|
- Proc:=TPasProcedure(El.Parent);
|
|
|
|
{$IFDEF VerbosePasResolver}
|
|
{$IFDEF VerbosePasResolver}
|
|
writeln('TPasResolver.FinishProcedureHeader El=',GetTreeDbg(El),' ',GetElementSourcePosStr(El),' IsForward=',Proc.IsForward,' Parent=',GetObjName(El.Parent));
|
|
writeln('TPasResolver.FinishProcedureHeader El=',GetTreeDbg(El),' ',GetElementSourcePosStr(El),' IsForward=',Proc.IsForward,' Parent=',GetObjName(El.Parent));
|
|
{$ENDIF}
|
|
{$ENDIF}
|
|
@@ -5325,13 +5334,14 @@ begin
|
|
if (proProcTypeWithoutIsNested in Options) and El.IsNested then
|
|
if (proProcTypeWithoutIsNested in Options) and El.IsNested then
|
|
RaiseInvalidProcTypeModifier(20170402120811,El,ptmIsNested,El);
|
|
RaiseInvalidProcTypeModifier(20170402120811,El,ptmIsNested,El);
|
|
|
|
|
|
- if (Proc.Parent.ClassType=TProcedureBody) then
|
|
|
|
|
|
+ ParentBody:=GetParentProcBody(Proc.Parent);
|
|
|
|
+ if (ParentBody<>nil) then
|
|
begin
|
|
begin
|
|
// nested sub proc
|
|
// nested sub proc
|
|
if not (proProcTypeWithoutIsNested in Options) then
|
|
if not (proProcTypeWithoutIsNested in Options) then
|
|
El.IsNested:=true;
|
|
El.IsNested:=true;
|
|
// inherit 'of Object'
|
|
// inherit 'of Object'
|
|
- ParentProc:=Proc.Parent.Parent as TPasProcedure;
|
|
|
|
|
|
+ ParentProc:=ParentBody.Parent as TPasProcedure;
|
|
if ParentProc.ProcType.IsOfObject then
|
|
if ParentProc.ProcType.IsOfObject then
|
|
El.IsOfObject:=true;
|
|
El.IsOfObject:=true;
|
|
end;
|
|
end;
|
|
@@ -5393,7 +5403,7 @@ begin
|
|
end
|
|
end
|
|
else
|
|
else
|
|
begin
|
|
begin
|
|
- // intf proc, forward proc, proc body, method body
|
|
|
|
|
|
+ // intf proc, forward proc, proc body, method body, anonymous proc
|
|
if Proc.IsAbstract then
|
|
if Proc.IsAbstract then
|
|
RaiseInvalidProcModifier(20170216151634,Proc,pmAbstract,Proc);
|
|
RaiseInvalidProcModifier(20170216151634,Proc,pmAbstract,Proc);
|
|
if Proc.IsVirtual then
|
|
if Proc.IsVirtual then
|
|
@@ -5405,8 +5415,12 @@ begin
|
|
if Proc.IsStatic then
|
|
if Proc.IsStatic then
|
|
RaiseInvalidProcTypeModifier(20170216151640,El,ptmStatic,El);
|
|
RaiseInvalidProcTypeModifier(20170216151640,El,ptmStatic,El);
|
|
if (not HasDots)
|
|
if (not HasDots)
|
|
- and (Proc.ClassType<>TPasProcedure)
|
|
|
|
- and (Proc.ClassType<>TPasFunction) then
|
|
|
|
|
|
+ and (Proc.GetProcTypeEnum in [
|
|
|
|
+ ptClassOperator,
|
|
|
|
+ ptConstructor, ptDestructor,
|
|
|
|
+ ptClassProcedure, ptClassFunction,
|
|
|
|
+ ptClassConstructor, ptClassDestructor
|
|
|
|
+ ]) then
|
|
RaiseXExpectedButYFound(20170419232724,'full method name','short name',El);
|
|
RaiseXExpectedButYFound(20170419232724,'full method name','short name',El);
|
|
end;
|
|
end;
|
|
|
|
|
|
@@ -5418,7 +5432,8 @@ begin
|
|
|
|
|
|
// finish interface/implementation/nested procedure/method declaration
|
|
// finish interface/implementation/nested procedure/method declaration
|
|
|
|
|
|
- if not IsValidIdent(ProcName) then
|
|
|
|
|
|
+ if not (Proc.GetProcTypeEnum in [ptAnonymousProcedure,ptAnonymousFunction])
|
|
|
|
+ and not IsValidIdent(ProcName) then
|
|
RaiseNotYetImplemented(20160922163407,El);
|
|
RaiseNotYetImplemented(20160922163407,El);
|
|
|
|
|
|
if El is TPasFunctionType then
|
|
if El is TPasFunctionType then
|
|
@@ -5436,7 +5451,7 @@ begin
|
|
end;
|
|
end;
|
|
|
|
|
|
// finish interface/implementation/nested procedure
|
|
// finish interface/implementation/nested procedure
|
|
- if ProcNeedsBody(Proc) then
|
|
|
|
|
|
+ if (ProcName<>'') and ProcNeedsBody(Proc) then
|
|
begin
|
|
begin
|
|
// check if there is a forward declaration
|
|
// check if there is a forward declaration
|
|
ParentScope:=Scopes[ScopeCount-2];
|
|
ParentScope:=Scopes[ScopeCount-2];
|
|
@@ -5483,13 +5498,16 @@ begin
|
|
StoreScannerFlagsInProc(ProcScope);
|
|
StoreScannerFlagsInProc(ProcScope);
|
|
end;
|
|
end;
|
|
|
|
|
|
- // check for invalid overloads
|
|
|
|
- FindData:=Default(TFindOverloadProcData);
|
|
|
|
- FindData.Proc:=Proc;
|
|
|
|
- FindData.Args:=Proc.ProcType.Args;
|
|
|
|
- FindData.Kind:=fopkProc;
|
|
|
|
- Abort:=false;
|
|
|
|
- IterateElements(ProcName,@OnFindOverloadProc,@FindData,Abort);
|
|
|
|
|
|
+ if ProcName<>'' then
|
|
|
|
+ begin
|
|
|
|
+ // check for invalid overloads
|
|
|
|
+ FindData:=Default(TFindOverloadProcData);
|
|
|
|
+ FindData.Proc:=Proc;
|
|
|
|
+ FindData.Args:=Proc.ProcType.Args;
|
|
|
|
+ FindData.Kind:=fopkProc;
|
|
|
|
+ Abort:=false;
|
|
|
|
+ IterateElements(ProcName,@OnFindOverloadProc,@FindData,Abort);
|
|
|
|
+ end;
|
|
end
|
|
end
|
|
else if El.Name<>'' then
|
|
else if El.Name<>'' then
|
|
begin
|
|
begin
|
|
@@ -6836,12 +6854,12 @@ begin
|
|
else
|
|
else
|
|
RaiseNotYetImplemented(20170203161826,ImplProc);
|
|
RaiseNotYetImplemented(20170203161826,ImplProc);
|
|
end;
|
|
end;
|
|
- if DeclProc is TPasFunction then
|
|
|
|
|
|
+ if DeclProc.ProcType is TPasFunctionType then
|
|
begin
|
|
begin
|
|
// redirect implementation 'Result' to declaration FuncType.ResultEl
|
|
// redirect implementation 'Result' to declaration FuncType.ResultEl
|
|
Identifier:=ImplProcScope.FindLocalIdentifier(ResolverResultVar);
|
|
Identifier:=ImplProcScope.FindLocalIdentifier(ResolverResultVar);
|
|
if Identifier.Element is TPasResultElement then
|
|
if Identifier.Element is TPasResultElement then
|
|
- Identifier.Element:=TPasFunction(DeclProc).FuncType.ResultEl;
|
|
|
|
|
|
+ Identifier.Element:=TPasFunctionType(DeclProc.ProcType).ResultEl;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
@@ -6899,11 +6917,11 @@ begin
|
|
RaiseXExpectedButYFound(20170216151729,DeclProc.TypeName,ImplProc.TypeName,ImplProc);
|
|
RaiseXExpectedButYFound(20170216151729,DeclProc.TypeName,ImplProc.TypeName,ImplProc);
|
|
if ImplProc.CallingConvention<>DeclProc.CallingConvention then
|
|
if ImplProc.CallingConvention<>DeclProc.CallingConvention then
|
|
RaiseMsg(20170216151731,nCallingConventionMismatch,sCallingConventionMismatch,[],ImplProc);
|
|
RaiseMsg(20170216151731,nCallingConventionMismatch,sCallingConventionMismatch,[],ImplProc);
|
|
- if ImplProc is TPasFunction then
|
|
|
|
|
|
+ if ImplProc.ProcType is TPasFunctionType then
|
|
begin
|
|
begin
|
|
// check result type
|
|
// check result type
|
|
- ImplResult:=TPasFunction(ImplProc).FuncType.ResultEl.ResultType;
|
|
|
|
- DeclResult:=TPasFunction(DeclProc).FuncType.ResultEl.ResultType;
|
|
|
|
|
|
+ ImplResult:=TPasFunctionType(ImplProc.ProcType).ResultEl.ResultType;
|
|
|
|
+ DeclResult:=TPasFunctionType(DeclProc.ProcType).ResultEl.ResultType;
|
|
|
|
|
|
if not CheckElTypeCompatibility(ImplResult,DeclResult,prraSimple) then
|
|
if not CheckElTypeCompatibility(ImplResult,DeclResult,prraSimple) then
|
|
RaiseIncompatibleType(20170216151734,nResultTypeMismatchExpectedButFound,
|
|
RaiseIncompatibleType(20170216151734,nResultTypeMismatchExpectedButFound,
|
|
@@ -7827,6 +7845,7 @@ begin
|
|
[],El);
|
|
[],El);
|
|
ResolveRecordValues(TRecordValues(El));
|
|
ResolveRecordValues(TRecordValues(El));
|
|
end
|
|
end
|
|
|
|
+ else if ElClass=TProcedureExpr then
|
|
else
|
|
else
|
|
RaiseNotYetImplemented(20170222184329,El);
|
|
RaiseNotYetImplemented(20170222184329,El);
|
|
|
|
|
|
@@ -7882,7 +7901,7 @@ begin
|
|
begin
|
|
begin
|
|
// examples: funca or @proca or a.funca or @a.funca ...
|
|
// examples: funca or @proca or a.funca or @a.funca ...
|
|
Proc:=TPasProcedure(DeclEl);
|
|
Proc:=TPasProcedure(DeclEl);
|
|
- if (Access=rraAssign) and (Proc is TPasFunction)
|
|
|
|
|
|
+ if (Access=rraAssign) and (Proc.ProcType is TPasFunctionType)
|
|
and (El.ClassType=TPrimitiveExpr)
|
|
and (El.ClassType=TPrimitiveExpr)
|
|
and (El.Parent.ClassType=TPasImplAssign)
|
|
and (El.Parent.ClassType=TPasImplAssign)
|
|
and (TPasImplAssign(El.Parent).left=El) then
|
|
and (TPasImplAssign(El.Parent).left=El) then
|
|
@@ -7895,7 +7914,7 @@ begin
|
|
if El.HasParent(ImplProc) then
|
|
if El.HasParent(ImplProc) then
|
|
begin
|
|
begin
|
|
// "FuncA:=" within FuncA -> redirect to ResultEl
|
|
// "FuncA:=" within FuncA -> redirect to ResultEl
|
|
- Ref.Declaration:=(Proc as TPasFunction).FuncType.ResultEl;
|
|
|
|
|
|
+ Ref.Declaration:=TPasFunctionType(Proc.ProcType).ResultEl;
|
|
exit;
|
|
exit;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
@@ -8499,7 +8518,7 @@ var
|
|
if DeclEl is TPasProcedure then
|
|
if DeclEl is TPasProcedure then
|
|
begin
|
|
begin
|
|
Proc:=TPasProcedure(DeclEl);
|
|
Proc:=TPasProcedure(DeclEl);
|
|
- if (Access=rraAssign) and (Proc is TPasFunction)
|
|
|
|
|
|
+ if (Access=rraAssign) and (Proc.ProcType is TPasFunctionType)
|
|
and (Value.ClassType=TPrimitiveExpr)
|
|
and (Value.ClassType=TPrimitiveExpr)
|
|
and (Params.Parent.ClassType=TPasImplAssign)
|
|
and (Params.Parent.ClassType=TPasImplAssign)
|
|
and (TPasImplAssign(Params.Parent).left=Params) then
|
|
and (TPasImplAssign(Params.Parent).left=Params) then
|
|
@@ -8512,7 +8531,7 @@ var
|
|
if Params.HasParent(ImplProc) then
|
|
if Params.HasParent(ImplProc) then
|
|
begin
|
|
begin
|
|
// "FuncA[]:=" within FuncA -> redirect to ResultEl
|
|
// "FuncA[]:=" within FuncA -> redirect to ResultEl
|
|
- Ref.Declaration:=(Proc as TPasFunction).FuncType.ResultEl;
|
|
|
|
|
|
+ Ref.Declaration:=TPasFunctionType(Proc.ProcType).ResultEl;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
@@ -8930,7 +8949,8 @@ begin
|
|
else if (Access in [rraRead,rraParamToUnknownProc])
|
|
else if (Access in [rraRead,rraParamToUnknownProc])
|
|
and ((C=TPrimitiveExpr)
|
|
and ((C=TPrimitiveExpr)
|
|
or (C=TNilExpr)
|
|
or (C=TNilExpr)
|
|
- or (C=TBoolConstExpr)) then
|
|
|
|
|
|
+ or (C=TBoolConstExpr)
|
|
|
|
+ or (C=TProcedureExpr)) then
|
|
// ok
|
|
// ok
|
|
else if C=TUnaryExpr then
|
|
else if C=TUnaryExpr then
|
|
AccessExpr(TUnaryExpr(Expr).Operand,Access)
|
|
AccessExpr(TUnaryExpr(Expr).Operand,Access)
|
|
@@ -9350,10 +9370,10 @@ begin
|
|
{$ENDIF}
|
|
{$ENDIF}
|
|
if not (TopScope is TPasIdentifierScope) then
|
|
if not (TopScope is TPasIdentifierScope) then
|
|
RaiseInvalidScopeForElement(20160922163522,El);
|
|
RaiseInvalidScopeForElement(20160922163522,El);
|
|
- // Note: El.ProcType is nil !
|
|
|
|
|
|
+ // Note: El.ProcType is nil ! It is parsed later.
|
|
ProcName:=El.Name;
|
|
ProcName:=El.Name;
|
|
HasDot:=Pos('.',ProcName)>1;
|
|
HasDot:=Pos('.',ProcName)>1;
|
|
- if not HasDot then
|
|
|
|
|
|
+ if (not HasDot) and (ProcName<>'') then
|
|
AddIdentifier(TPasIdentifierScope(TopScope),ProcName,El,pikProc);
|
|
AddIdentifier(TPasIdentifierScope(TopScope),ProcName,El,pikProc);
|
|
ProcScope:=TPasProcedureScope(PushScope(El,FScopeClass_Proc));
|
|
ProcScope:=TPasProcedureScope(PushScope(El,FScopeClass_Proc));
|
|
ProcScope.ModeSwitches:=CurrentParser.CurrentModeswitches;
|
|
ProcScope.ModeSwitches:=CurrentParser.CurrentModeswitches;
|
|
@@ -9420,7 +9440,7 @@ begin
|
|
|
|
|
|
ProcScope.VisibilityContext:=CurClassType;
|
|
ProcScope.VisibilityContext:=CurClassType;
|
|
ProcScope.ClassScope:=NoNil(CurClassType.CustomData) as TPasClassScope;
|
|
ProcScope.ClassScope:=NoNil(CurClassType.CustomData) as TPasClassScope;
|
|
- end;
|
|
|
|
|
|
+ end;// HasDot=true
|
|
end;
|
|
end;
|
|
|
|
|
|
procedure TPasResolver.AddArgument(El: TPasArgument);
|
|
procedure TPasResolver.AddArgument(El: TPasArgument);
|
|
@@ -10500,9 +10520,9 @@ begin
|
|
Proc:=TPasProcedure(ResolvedEl.IdentEl);
|
|
Proc:=TPasProcedure(ResolvedEl.IdentEl);
|
|
if rcConstant in Flags then
|
|
if rcConstant in Flags then
|
|
RaiseConstantExprExp(20170216152637,Params);
|
|
RaiseConstantExprExp(20170216152637,Params);
|
|
- if Proc is TPasFunction then
|
|
|
|
|
|
+ if Proc.ProcType is TPasFunctionType then
|
|
// function call => return result
|
|
// function call => return result
|
|
- ComputeElement(TPasFunction(Proc).FuncType.ResultEl,ResolvedEl,
|
|
|
|
|
|
+ ComputeElement(TPasFunctionType(Proc.ProcType).ResultEl,ResolvedEl,
|
|
Flags+[rcNoImplicitProc],StartEl)
|
|
Flags+[rcNoImplicitProc],StartEl)
|
|
else if (Proc.ClassType=TPasConstructor)
|
|
else if (Proc.ClassType=TPasConstructor)
|
|
and (rrfNewInstance in Ref.Flags) then
|
|
and (rrfNewInstance in Ref.Flags) then
|
|
@@ -12498,6 +12518,7 @@ var
|
|
ProcScope: TPasProcedureScope;
|
|
ProcScope: TPasProcedureScope;
|
|
ResultEl: TPasResultElement;
|
|
ResultEl: TPasResultElement;
|
|
Flags: TPasResolverComputeFlags;
|
|
Flags: TPasResolverComputeFlags;
|
|
|
|
+ CtxProc: TPasProcedure;
|
|
begin
|
|
begin
|
|
if (not (Expr is TParamsExpr)) or (length(TParamsExpr(Expr).Params)=0) then
|
|
if (not (Expr is TParamsExpr)) or (length(TParamsExpr(Expr).Params)=0) then
|
|
exit(cExact);
|
|
exit(cExact);
|
|
@@ -12515,14 +12536,15 @@ begin
|
|
begin
|
|
begin
|
|
// first param is function result
|
|
// first param is function result
|
|
ProcScope:=TPasProcedureScope(Scopes[i]);
|
|
ProcScope:=TPasProcedureScope(Scopes[i]);
|
|
- if not (ProcScope.Element is TPasFunction) then
|
|
|
|
|
|
+ CtxProc:=TPasProcedure(ProcScope.Element);
|
|
|
|
+ if not (CtxProc.ProcType is TPasFunctionType) then
|
|
begin
|
|
begin
|
|
if RaiseOnError then
|
|
if RaiseOnError then
|
|
RaiseMsg(20170216152312,nWrongNumberOfParametersForCallTo,
|
|
RaiseMsg(20170216152312,nWrongNumberOfParametersForCallTo,
|
|
sWrongNumberOfParametersForCallTo,['procedure exit'],Params.Params[0]);
|
|
sWrongNumberOfParametersForCallTo,['procedure exit'],Params.Params[0]);
|
|
exit(cIncompatible);
|
|
exit(cIncompatible);
|
|
end;
|
|
end;
|
|
- ResultEl:=(ProcScope.Element as TPasFunction).FuncType.ResultEl;
|
|
|
|
|
|
+ ResultEl:=TPasFunctionType(CtxProc.ProcType).ResultEl;
|
|
ComputeElement(ResultEl,ResultResolved,[rcType]);
|
|
ComputeElement(ResultEl,ResultResolved,[rcType]);
|
|
end
|
|
end
|
|
else
|
|
else
|
|
@@ -12937,9 +12959,9 @@ begin
|
|
begin
|
|
begin
|
|
Expr:=TPasVariable(ParamResolved.IdentEl).Expr;
|
|
Expr:=TPasVariable(ParamResolved.IdentEl).Expr;
|
|
if Expr is TArrayValues then
|
|
if Expr is TArrayValues then
|
|
- Evaluated:=TResEvalInt.CreateValue(length(TArrayValues(Expr).Values)-1)
|
|
|
|
|
|
+ Evaluated:=TResEvalInt.CreateValue(TMaxPrecInt(length(TArrayValues(Expr).Values))-1)
|
|
else if (Expr is TParamsExpr) and (TParamsExpr(Expr).Kind=pekSet) then
|
|
else if (Expr is TParamsExpr) and (TParamsExpr(Expr).Kind=pekSet) then
|
|
- Evaluated:=TResEvalInt.CreateValue(length(TParamsExpr(Expr).Params)-1);
|
|
|
|
|
|
+ Evaluated:=TResEvalInt.CreateValue(TMaxPrecInt(length(TParamsExpr(Expr).Params))-1);
|
|
if Evaluated=nil then
|
|
if Evaluated=nil then
|
|
RaiseXExpectedButYFound(20170601191003,'array constant','expression',Params);
|
|
RaiseXExpectedButYFound(20170601191003,'array constant','expression',Params);
|
|
end
|
|
end
|
|
@@ -13635,8 +13657,9 @@ begin
|
|
aType:=TPasArgument(Decl).ArgType
|
|
aType:=TPasArgument(Decl).ArgType
|
|
else if Decl.ClassType=TPasResultElement then
|
|
else if Decl.ClassType=TPasResultElement then
|
|
aType:=TPasResultElement(Decl).ResultType
|
|
aType:=TPasResultElement(Decl).ResultType
|
|
- else if Decl is TPasFunction then
|
|
|
|
- aType:=TPasFunction(Decl).FuncType.ResultEl.ResultType;
|
|
|
|
|
|
+ else if (Decl is TPasProcedure)
|
|
|
|
+ and (TPasProcedure(Decl).ProcType is TPasFunctionType) then
|
|
|
|
+ aType:=TPasFunctionType(TPasProcedure(Decl).ProcType).ResultEl.ResultType;
|
|
{$IFDEF VerbosePasResolver}
|
|
{$IFDEF VerbosePasResolver}
|
|
{AllowWriteln}
|
|
{AllowWriteln}
|
|
if aType=nil then
|
|
if aType=nil then
|
|
@@ -16446,7 +16469,7 @@ begin
|
|
begin
|
|
begin
|
|
EnumType:=TPasEnumType(LTypeEl);
|
|
EnumType:=TPasEnumType(LTypeEl);
|
|
LRangeValue:=TResEvalRangeInt.CreateValue(revskEnum,EnumType,
|
|
LRangeValue:=TResEvalRangeInt.CreateValue(revskEnum,EnumType,
|
|
- 0,EnumType.Values.Count-1);
|
|
|
|
|
|
+ 0,TMaxPrecInt(EnumType.Values.Count)-1);
|
|
end
|
|
end
|
|
else if C=TPasUnresolvedSymbolRef then
|
|
else if C=TPasUnresolvedSymbolRef then
|
|
begin
|
|
begin
|
|
@@ -17047,7 +17070,15 @@ begin
|
|
if CheckProcTypeCompatibility(TPasProcedureType(LHS.LoTypeEl),
|
|
if CheckProcTypeCompatibility(TPasProcedureType(LHS.LoTypeEl),
|
|
TPasProcedure(RHS.IdentEl).ProcType,true,ErrorEl,RaiseOnIncompatible) then
|
|
TPasProcedure(RHS.IdentEl).ProcType,true,ErrorEl,RaiseOnIncompatible) then
|
|
exit(cExact);
|
|
exit(cExact);
|
|
- end;
|
|
|
|
|
|
+ end
|
|
|
|
+ else if (LHS.LoTypeEl is TPasProcedureType)
|
|
|
|
+ and (RHS.ExprEl is TProcedureExpr) then
|
|
|
|
+ begin
|
|
|
|
+ // for example ProcVar:=anonymous-procedure...
|
|
|
|
+ if CheckProcTypeCompatibility(TPasProcedureType(LHS.LoTypeEl),
|
|
|
|
+ TProcedureExpr(RHS.ExprEl).Proc.ProcType,true,ErrorEl,RaiseOnIncompatible) then
|
|
|
|
+ exit(cExact);
|
|
|
|
+ end
|
|
end
|
|
end
|
|
else if LBT=btPointer then
|
|
else if LBT=btPointer then
|
|
begin
|
|
begin
|
|
@@ -19846,7 +19877,7 @@ begin
|
|
begin
|
|
begin
|
|
TypeEl:=TPasProcedure(El).ProcType;
|
|
TypeEl:=TPasProcedure(El).ProcType;
|
|
SetResolverIdentifier(ResolvedEl,btProc,El,TypeEl,TypeEl,[rrfCanBeStatement]);
|
|
SetResolverIdentifier(ResolvedEl,btProc,El,TypeEl,TypeEl,[rrfCanBeStatement]);
|
|
- if El is TPasFunction then
|
|
|
|
|
|
+ if TPasProcedure(El).ProcType is TPasFunctionType then
|
|
Include(ResolvedEl.Flags,rrfReadable);
|
|
Include(ResolvedEl.Flags,rrfReadable);
|
|
// Note: the readability of TPasConstructor depends on the context
|
|
// Note: the readability of TPasConstructor depends on the context
|
|
// Note: implicit calls are handled in TPrimitiveExpr
|
|
// Note: implicit calls are handled in TPrimitiveExpr
|
|
@@ -19857,6 +19888,11 @@ begin
|
|
TPasProcedureType(El),TPasProcedureType(El),[rrfCanBeStatement]);
|
|
TPasProcedureType(El),TPasProcedureType(El),[rrfCanBeStatement]);
|
|
// Note: implicit calls are handled in TPrimitiveExpr
|
|
// Note: implicit calls are handled in TPrimitiveExpr
|
|
end
|
|
end
|
|
|
|
+ else if ElClass=TProcedureExpr then
|
|
|
|
+ begin
|
|
|
|
+ TypeEl:=TProcedureExpr(El).Proc.ProcType;
|
|
|
|
+ SetResolverValueExpr(ResolvedEl,btProc,TypeEl,TypeEl,TProcedureExpr(El),[rrfReadable]);
|
|
|
|
+ end
|
|
else if ElClass=TPasArrayType then
|
|
else if ElClass=TPasArrayType then
|
|
SetResolverIdentifier(ResolvedEl,btContext,El,TPasArrayType(El),TPasArrayType(El),[])
|
|
SetResolverIdentifier(ResolvedEl,btContext,El,TPasArrayType(El),TPasArrayType(El),[])
|
|
else if ElClass=TArrayValues then
|
|
else if ElClass=TArrayValues then
|
|
@@ -20001,6 +20037,17 @@ begin
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+function TPasResolver.GetParentProcBody(El: TPasElement): TProcedureBody;
|
|
|
|
+begin
|
|
|
|
+ while El<>nil do
|
|
|
|
+ begin
|
|
|
|
+ if El is TProcedureBody then
|
|
|
|
+ exit(TProcedureBody(El));
|
|
|
|
+ El:=El.Parent;
|
|
|
|
+ end;
|
|
|
|
+ Result:=nil;
|
|
|
|
+end;
|
|
|
|
+
|
|
function TPasResolver.ProcHasImplElements(Proc: TPasProcedure): boolean;
|
|
function TPasResolver.ProcHasImplElements(Proc: TPasProcedure): boolean;
|
|
begin
|
|
begin
|
|
Result:=GetProcFirstImplEl(Proc)<>nil;
|
|
Result:=GetProcFirstImplEl(Proc)<>nil;
|
|
@@ -20558,7 +20605,7 @@ begin
|
|
else if C=TPasEnumType then
|
|
else if C=TPasEnumType then
|
|
begin
|
|
begin
|
|
Result:=TResEvalRangeInt.CreateValue(revskEnum,TPasEnumType(Decl),
|
|
Result:=TResEvalRangeInt.CreateValue(revskEnum,TPasEnumType(Decl),
|
|
- 0,TPasEnumType(Decl).Values.Count-1);
|
|
|
|
|
|
+ 0,TMaxPrecInt(TPasEnumType(Decl).Values.Count)-1);
|
|
Result.IdentEl:=Decl;
|
|
Result.IdentEl:=Decl;
|
|
exit;
|
|
exit;
|
|
end
|
|
end
|