find declaration type of constructor

git-svn-id: trunk@3681 -
This commit is contained in:
mattias 2002-12-01 23:01:42 +00:00
parent 69f89ff72b
commit 5c93adce8a
2 changed files with 13 additions and 7 deletions

View File

@ -3615,6 +3615,7 @@ var
IdentFound: boolean;
begin
// for example 'AnObject[3]'
// check special identifiers 'Result' and 'Self'
IdentFound:=false;
if (ExprType.Context.Node<>nil)
@ -3684,8 +3685,12 @@ var
// search ...
Params.SetIdentifier(Self,@Src[CurAtom.StartPos],@CheckSrcIdentifier);
if ExprType.Context.Tool.FindIdentifierInContext(Params) then begin
ExprType.Desc:=xtContext;
ExprType.Context:=CreateFindContext(Params);
if not Params.NewCodeTool.NodeIsConstructor(Params.NewNode) then begin
ExprType.Desc:=xtContext;
ExprType.Context:=CreateFindContext(Params);
end else begin
// it's a constructor -> keep the class
end;
end else begin
// predefined identifier
ExprType:=FindExpressionTypeOfPredefinedIdentifier(CurAtom.StartPos,
@ -4018,8 +4023,8 @@ begin
Result:=ExprType;
if (Result.Desc=xtContext) and (not (fdfFindVariable in StartFlags)) then
Result:=Result.Context.Tool.ConvertNodeToExpressionType(Result.Context.Node,
Params);
Result:=Result.Context.Tool.ConvertNodeToExpressionType(
Result.Context.Node,Params);
{$IFDEF ShowExprEval}
writeln(' FindExpressionTypeOfVariable Result=',ExprTypeToString(Result));
{$ENDIF}
@ -5492,7 +5497,6 @@ begin
xtContext:
begin
writeln('BBB1 ',ExprType.Context.Node.DescAsString);
Params.Flags:=[fdfSearchInParentNodes,fdfSearchInAncestors,
fdfTopLvlResolving,fdfFunctionResult]
+fdfAllClassVisibilities;

View File

@ -3623,10 +3623,12 @@ end;
function TPascalParserTool.NodeIsConstructor(ProcNode: TCodeTreeNode): boolean;
begin
Result:=false;
if (ProcNode=nil) or (ProcNode.Desc<>ctnProcedure) then exit;
if (ProcNode=nil) then exit;
if ProcNode.Desc=ctnProcedureHead then
ProcNode:=ProcNode.Parent;
if ProcNode.Desc<>ctnProcedure then exit;
MoveCursorToNodeStart(ProcNode);
ReadNextAtom;
if UpAtomIs('CLASS') then ReadNextAtom;
Result:=UpAtomIs('CONSTRUCTOR');
end;