mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-12-01 15:07:38 +01:00
deactivated cache for procs
git-svn-id: trunk@4321 -
This commit is contained in:
parent
ebfe3ad006
commit
8aa2da1a71
@ -27,10 +27,15 @@
|
|||||||
|
|
||||||
ToDo:
|
ToDo:
|
||||||
- ignore errors behind cursor (implemented, not tested)
|
- ignore errors behind cursor (implemented, not tested)
|
||||||
|
- high level expression comparison
|
||||||
|
(i.e. at the moment: integer+integer=longint
|
||||||
|
wanted: integer+integer=integer)
|
||||||
|
- caching for procs
|
||||||
- variants
|
- variants
|
||||||
- Get and Set property access parameter lists
|
- 'class of'
|
||||||
- predefined funcs Low, High for arrays
|
|
||||||
- find declaration in dead code
|
- find declaration in dead code
|
||||||
|
- multi pass find declaration
|
||||||
|
- Get and Set property access parameter lists
|
||||||
- make @Proc context sensitive (started, but not complete)
|
- make @Proc context sensitive (started, but not complete)
|
||||||
- operator overloading
|
- operator overloading
|
||||||
- ppu, ppw, dcu files
|
- ppu, ppw, dcu files
|
||||||
@ -143,7 +148,7 @@ type
|
|||||||
fdfExceptionOnNotFound, // raise exception if identifier not found
|
fdfExceptionOnNotFound, // raise exception if identifier not found
|
||||||
// predefined identifiers will not raise
|
// predefined identifiers will not raise
|
||||||
fdfExceptionOnPredefinedIdent,// raise an exception even if the identifier
|
fdfExceptionOnPredefinedIdent,// raise an exception even if the identifier
|
||||||
// is an predefined exception
|
// is an predefined identifier
|
||||||
|
|
||||||
fdfIgnoreClassVisibility,//find inaccessible private+protected fields
|
fdfIgnoreClassVisibility,//find inaccessible private+protected fields
|
||||||
|
|
||||||
@ -156,12 +161,20 @@ type
|
|||||||
fdfFunctionResult, // if function is found, return result type
|
fdfFunctionResult, // if function is found, return result type
|
||||||
|
|
||||||
fdfCollect, // return every reachable identifier
|
fdfCollect, // return every reachable identifier
|
||||||
fdfTopLvlResolving // set, when searching for an identifier of the
|
fdfTopLvlResolving, // set, when searching for an identifier of the
|
||||||
// top lvl variable
|
// top lvl variable
|
||||||
|
fdfDoNotCache // result will not be cached
|
||||||
);
|
);
|
||||||
TFindDeclarationFlags = set of TFindDeclarationFlag;
|
TFindDeclarationFlags = set of TFindDeclarationFlag;
|
||||||
|
|
||||||
const
|
const
|
||||||
|
fdfGlobals = [fdfExceptionOnNotFound, fdfTopLvlResolving];
|
||||||
|
fdfGlobalsSameIdent = fdfGlobals+[fdfExceptionOnPredefinedIdent,
|
||||||
|
fdfIgnoreMissingParams, fdfIgnoreUsedUnits, fdfDoNotCache,
|
||||||
|
fdfOnlyCompatibleProc, fdfSearchInAncestors, fdfCollect];
|
||||||
|
fdfDefaultForExpressions = [fdfSearchInParentNodes, fdfSearchInAncestors,
|
||||||
|
fdfExceptionOnNotFound];
|
||||||
|
|
||||||
// for nicer output
|
// for nicer output
|
||||||
FindDeclarationFlagNames: array[TFindDeclarationFlag] of string = (
|
FindDeclarationFlagNames: array[TFindDeclarationFlag] of string = (
|
||||||
'fdfSearchInAncestors',
|
'fdfSearchInAncestors',
|
||||||
@ -178,19 +191,20 @@ const
|
|||||||
'fdfFindVariable',
|
'fdfFindVariable',
|
||||||
'fdfFunctionResult',
|
'fdfFunctionResult',
|
||||||
'fdfCollect',
|
'fdfCollect',
|
||||||
'fdfTopLvlResolving'
|
'fdfTopLvlResolving',
|
||||||
|
'fdfDoNotCache'
|
||||||
);
|
);
|
||||||
|
|
||||||
type
|
type
|
||||||
// flags/states for result
|
// flags/states for result
|
||||||
TFoundDeclarationFlag = (
|
TFoundDeclarationFlag = (
|
||||||
fdfDoNotCache
|
fodDoNotCache
|
||||||
);
|
);
|
||||||
TFoundDeclarationFlags = set of TFoundDeclarationFlag;
|
TFoundDeclarationFlags = set of TFoundDeclarationFlag;
|
||||||
|
|
||||||
const
|
const
|
||||||
FoundDeclarationFlagNames: array[TFoundDeclarationFlag] of string = (
|
FoundDeclarationFlagNames: array[TFoundDeclarationFlag] of string = (
|
||||||
'fdfDoNotCache'
|
'fodDoNotCache'
|
||||||
);
|
);
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
@ -428,7 +442,7 @@ type
|
|||||||
ProcCompatibility: TTypeCompatibility;
|
ProcCompatibility: TTypeCompatibility;
|
||||||
ParamCompatibilityList: TTypeCompatibilityList);
|
ParamCompatibilityList: TTypeCompatibilityList);
|
||||||
procedure ConvertResultCleanPosToCaretPos;
|
procedure ConvertResultCleanPosToCaretPos;
|
||||||
procedure ClearResult;
|
procedure ClearResult(CopyCacheFlags: boolean);
|
||||||
procedure ClearInput;
|
procedure ClearInput;
|
||||||
procedure ClearFoundProc;
|
procedure ClearFoundProc;
|
||||||
procedure WriteDebugReport;
|
procedure WriteDebugReport;
|
||||||
@ -629,14 +643,6 @@ type
|
|||||||
read FOnGetCodeToolForBuffer write FOnGetCodeToolForBuffer;
|
read FOnGetCodeToolForBuffer write FOnGetCodeToolForBuffer;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
const
|
|
||||||
fdfGlobals = [fdfExceptionOnNotFound, fdfTopLvlResolving];
|
|
||||||
fdfGlobalsSameIdent = fdfGlobals+[fdfExceptionOnPredefinedIdent,
|
|
||||||
fdfIgnoreMissingParams, fdfIgnoreUsedUnits,
|
|
||||||
fdfOnlyCompatibleProc, fdfSearchInAncestors, fdfCollect];
|
|
||||||
fdfDefaultForExpressions = [fdfSearchInParentNodes, fdfSearchInAncestors,
|
|
||||||
fdfExceptionOnNotFound];
|
|
||||||
|
|
||||||
function ExprTypeToString(const ExprType: TExpressionType): string;
|
function ExprTypeToString(const ExprType: TExpressionType): string;
|
||||||
function CreateFindContext(NewTool: TFindDeclarationTool;
|
function CreateFindContext(NewTool: TFindDeclarationTool;
|
||||||
NewNode: TCodeTreeNode): TFindContext;
|
NewNode: TCodeTreeNode): TFindContext;
|
||||||
@ -1679,10 +1685,12 @@ var
|
|||||||
|
|
||||||
procedure CacheResult(Found: boolean);
|
procedure CacheResult(Found: boolean);
|
||||||
begin
|
begin
|
||||||
if Found and ([fdfDoNotCache,fdfCollect]*Params.NewFlags=[])
|
if Found and ([fdfDoNotCache,fdfCollect]*Params.Flags=[])
|
||||||
|
and ([fodDoNotCache]*Params.NewFlags=[])
|
||||||
and (FirstSearchedNode<>nil) then begin
|
and (FirstSearchedNode<>nil) then begin
|
||||||
// cache result
|
// cache result
|
||||||
if (Params.NewNode<>nil) and (Params.NewNode.Desc=ctnProcedure) then begin
|
if (Params.NewNode<>nil) and (Params.NewNode.Desc=ctnProcedure) then begin
|
||||||
|
//writeln('NOTE: TFindDeclarationTool.FindIdentifierInContext.CacheResult Node is proc');
|
||||||
// ToDo:
|
// ToDo:
|
||||||
// The search range is from start to end of search.
|
// The search range is from start to end of search.
|
||||||
// This does not work for overloaded procs.
|
// This does not work for overloaded procs.
|
||||||
@ -3246,8 +3254,14 @@ begin
|
|||||||
FInterfaceIdentifierCache:=TInterfaceIdentifierCache.Create(Self);
|
FInterfaceIdentifierCache:=TInterfaceIdentifierCache.Create(Self);
|
||||||
if Result and (Params.NewCodeTool=Self) then begin
|
if Result and (Params.NewCodeTool=Self) then begin
|
||||||
// identifier exists in interface
|
// identifier exists in interface
|
||||||
if (not (fdfDoNotCache in Params.NewFlags))
|
if ([fdfDoNotCache,fdfCollect]*Params.Flags=[])
|
||||||
and (not (fdfCollect in Params.Flags)) then begin
|
and ([fodDoNotCache]*Params.NewFlags=[]) then begin
|
||||||
|
if (Params.NewNode<>nil) and (Params.NewNode.Desc=ctnProcedure) then begin
|
||||||
|
//writeln('NOTE: TFindDeclarationTool.FindIdentifierInInterface Node is proc');
|
||||||
|
// ToDo: add param list to cache
|
||||||
|
// -> do not cache
|
||||||
|
Result:=false;
|
||||||
|
end else
|
||||||
FInterfaceIdentifierCache.Add(OldInput.Identifier,Params.NewNode,
|
FInterfaceIdentifierCache.Add(OldInput.Identifier,Params.NewNode,
|
||||||
Params.NewCleanPos);
|
Params.NewCleanPos);
|
||||||
end else begin
|
end else begin
|
||||||
@ -3255,7 +3269,7 @@ begin
|
|||||||
Result:=false;
|
Result:=false;
|
||||||
end;
|
end;
|
||||||
end else begin
|
end else begin
|
||||||
// identifier does not exist in interface
|
// identifier does not exist in this interface
|
||||||
FInterfaceIdentifierCache.Add(OldInput.Identifier,nil,-1);
|
FInterfaceIdentifierCache.Add(OldInput.Identifier,nil,-1);
|
||||||
Result:=false;
|
Result:=false;
|
||||||
end;
|
end;
|
||||||
@ -4722,7 +4736,17 @@ begin
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
if FoundContext.Node.Desc=ctnProcedure then begin
|
if FoundContext.Node.Desc=ctnProcedure then begin
|
||||||
// the found node is a proc
|
// the found node is a proc
|
||||||
Include(Params.NewFlags,fdfDoNotCache);
|
|
||||||
|
// 1. the current identifier cache is blind for parameter lists
|
||||||
|
// => proc identifiers can not be identified by the name alone
|
||||||
|
// -> do not cache
|
||||||
|
// 2. Even if there is only one proc. With different search flags,
|
||||||
|
// different routes will be searched and then there can be another proc.
|
||||||
|
// The only solution is to store the param expression list and all flags
|
||||||
|
// in the cache. This is a ToDo
|
||||||
|
Include(Params.Flags,fdfDoNotCache);
|
||||||
|
Include(Params.NewFlags,fodDoNotCache);
|
||||||
|
|
||||||
if (fdfIgnoreOverloadedProcs in Params.Flags) then begin
|
if (fdfIgnoreOverloadedProcs in Params.Flags) then begin
|
||||||
// do not check for overloaded procs -> ident found
|
// do not check for overloaded procs -> ident found
|
||||||
Result:=ifrSuccess;
|
Result:=ifrSuccess;
|
||||||
@ -4732,6 +4756,15 @@ begin
|
|||||||
// Procs can be overloaded, that means there can be several procs with the
|
// Procs can be overloaded, that means there can be several procs with the
|
||||||
// same name, but with different param lists.
|
// same name, but with different param lists.
|
||||||
// The search must go on, and the most compatible proc is returned.
|
// The search must go on, and the most compatible proc is returned.
|
||||||
|
|
||||||
|
if not Params.IdentifierTool.IsPCharInSrc(Params.Identifier) then begin
|
||||||
|
// Params.Identifier is not in the source of this tool
|
||||||
|
// => impossible to check param list, because the context is unknown
|
||||||
|
// -> identifier found
|
||||||
|
Result:=ifrSuccess;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
|
||||||
Result:=ifrProceedSearch;
|
Result:=ifrProceedSearch;
|
||||||
if (Params.FoundProc=nil) then begin
|
if (Params.FoundProc=nil) then begin
|
||||||
// this is the first proc found
|
// this is the first proc found
|
||||||
@ -4740,15 +4773,7 @@ begin
|
|||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// this is another overloaded proc
|
|
||||||
// -> check which one is more compatible
|
// -> check which one is more compatible
|
||||||
if not Params.IdentifierTool.IsPCharInSrc(Params.Identifier) then begin
|
|
||||||
// Params.Identifier is not in the source of this tool
|
|
||||||
// => impossible to check param list, because the context is unknown
|
|
||||||
// -> identifier found
|
|
||||||
Result:=ifrSuccess;
|
|
||||||
end;
|
|
||||||
|
|
||||||
// create the input expression list
|
// create the input expression list
|
||||||
// (the expressions in the brackets are parsed and converted to types)
|
// (the expressions in the brackets are parsed and converted to types)
|
||||||
if Params.FoundProc^.ExprInputList=nil then begin
|
if Params.FoundProc^.ExprInputList=nil then begin
|
||||||
@ -5822,7 +5847,7 @@ end;
|
|||||||
procedure TFindDeclarationParams.Clear;
|
procedure TFindDeclarationParams.Clear;
|
||||||
begin
|
begin
|
||||||
ClearInput;
|
ClearInput;
|
||||||
ClearResult;
|
ClearResult(false);
|
||||||
OnTopLvlIdentifierFound:=nil;
|
OnTopLvlIdentifierFound:=nil;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -5849,7 +5874,7 @@ begin
|
|||||||
Input.FoundProc:=FoundProc;
|
Input.FoundProc:=FoundProc;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TFindDeclarationParams.ClearResult;
|
procedure TFindDeclarationParams.ClearResult(CopyCacheFlags: boolean);
|
||||||
begin
|
begin
|
||||||
NewPos.Code:=nil;
|
NewPos.Code:=nil;
|
||||||
NewPos.X:=-1;
|
NewPos.X:=-1;
|
||||||
@ -5859,11 +5884,13 @@ begin
|
|||||||
NewCleanPos:=-1;
|
NewCleanPos:=-1;
|
||||||
NewCodeTool:=nil;
|
NewCodeTool:=nil;
|
||||||
NewFlags:=[];
|
NewFlags:=[];
|
||||||
|
if CopyCacheFlags and (fdfDoNotCache in Flags) then
|
||||||
|
Include(NewFlags,fodDoNotCache);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TFindDeclarationParams.SetResult(const AFindContext: TFindContext);
|
procedure TFindDeclarationParams.SetResult(const AFindContext: TFindContext);
|
||||||
begin
|
begin
|
||||||
ClearResult;
|
ClearResult(true);
|
||||||
NewCodeTool:=AFindContext.Tool;
|
NewCodeTool:=AFindContext.Tool;
|
||||||
NewNode:=AFindContext.Node;
|
NewNode:=AFindContext.Node;
|
||||||
end;
|
end;
|
||||||
@ -5871,7 +5898,7 @@ end;
|
|||||||
procedure TFindDeclarationParams.SetResult(ANewCodeTool: TFindDeclarationTool;
|
procedure TFindDeclarationParams.SetResult(ANewCodeTool: TFindDeclarationTool;
|
||||||
ANewNode: TCodeTreeNode);
|
ANewNode: TCodeTreeNode);
|
||||||
begin
|
begin
|
||||||
ClearResult;
|
ClearResult(true);
|
||||||
NewCodeTool:=ANewCodeTool;
|
NewCodeTool:=ANewCodeTool;
|
||||||
NewNode:=ANewNode;
|
NewNode:=ANewNode;
|
||||||
end;
|
end;
|
||||||
@ -5879,7 +5906,7 @@ end;
|
|||||||
procedure TFindDeclarationParams.SetResult(ANewCodeTool: TFindDeclarationTool;
|
procedure TFindDeclarationParams.SetResult(ANewCodeTool: TFindDeclarationTool;
|
||||||
ANewNode: TCodeTreeNode; ANewCleanPos: integer);
|
ANewNode: TCodeTreeNode; ANewCleanPos: integer);
|
||||||
begin
|
begin
|
||||||
ClearResult;
|
ClearResult(true);
|
||||||
NewCodeTool:=ANewCodeTool;
|
NewCodeTool:=ANewCodeTool;
|
||||||
NewNode:=ANewNode;
|
NewNode:=ANewNode;
|
||||||
NewCleanPos:=ANewCleanPos;
|
NewCleanPos:=ANewCleanPos;
|
||||||
@ -5998,11 +6025,10 @@ end;
|
|||||||
procedure TFindDeclarationParams.SetResult(
|
procedure TFindDeclarationParams.SetResult(
|
||||||
NodeCacheEntry: PCodeTreeNodeCacheEntry);
|
NodeCacheEntry: PCodeTreeNodeCacheEntry);
|
||||||
begin
|
begin
|
||||||
ClearResult;
|
ClearResult(true);
|
||||||
NewCodeTool:=TFindDeclarationTool(NodeCacheEntry^.NewTool);
|
NewCodeTool:=TFindDeclarationTool(NodeCacheEntry^.NewTool);
|
||||||
NewNode:=NodeCacheEntry^.NewNode;
|
NewNode:=NodeCacheEntry^.NewNode;
|
||||||
NewCleanPos:=NodeCacheEntry^.NewCleanPos;
|
NewCleanPos:=NodeCacheEntry^.NewCleanPos;
|
||||||
NewFlags:=[fdfDoNotCache];
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user