From eb248f3684aed9fdd9db91bd8a4d16117a861d22 Mon Sep 17 00:00:00 2001 From: mattias Date: Mon, 31 Oct 2005 01:21:28 +0000 Subject: [PATCH] implemented searching for TVarData on array of const git-svn-id: trunk@8010 - --- components/codetools/codetree.pas | 3 +- components/codetools/finddeclarationtool.pas | 46 +++++++++++++++----- components/codetools/pascalparsertool.pas | 4 +- 3 files changed, 39 insertions(+), 14 deletions(-) diff --git a/components/codetools/codetree.pas b/components/codetools/codetree.pas index 860f264e4c..e28724c00c 100644 --- a/components/codetools/codetree.pas +++ b/components/codetools/codetree.pas @@ -333,6 +333,7 @@ begin ctnIdentifier: Result:='Identifier'; ctnOpenArrayType: Result:='Open Array Type'; + ctnOfConstType: Result:='Of Const'; ctnRangedArrayType: Result:='Ranged Array Type'; ctnRecordType: Result:='Record Type'; ctnRecordCase: Result:='Record Case'; @@ -355,7 +356,7 @@ begin ctnCaseStatement: Result:='Case Statement'; else - Result:='invalid descriptor'; + Result:='invalid descriptor ('+IntToStr(Desc)+')'; end; end; diff --git a/components/codetools/finddeclarationtool.pas b/components/codetools/finddeclarationtool.pas index 011f422e93..9b88619416 100644 --- a/components/codetools/finddeclarationtool.pas +++ b/components/codetools/finddeclarationtool.pas @@ -3879,11 +3879,11 @@ begin if ClassNode.Desc=ctnClass then begin // if this class is not TObject, TObject is class ancestor SearchBaseClass:= - not CompareSrcIdentifier(ClassIdentNode.StartPos,'TObject'); + not CompareSrcIdentifier(ClassIdentNode.StartPos,'TObject'); end else begin // if this class is not IInterface, IInterface is ancestor SearchBaseClass:= - not CompareSrcIdentifier(ClassIdentNode.StartPos,'IInterface'); + not CompareSrcIdentifier(ClassIdentNode.StartPos,'IInterface'); end; if not SearchBaseClass then exit; end; @@ -5136,12 +5136,13 @@ var procedure ResolveEdgedBracketOpen; { for example: a[] this could be: - 1. ranged array - 2. dynamic array - 3. indexed pointer - 4. default property - 5. indexed property - 6. string character + 1. ranged array e.g. array[1..2] of + 2. dynamic array e.g. array of integer + 3. variant array e.g. array of const + 4. indexed pointer e.g. PInteger[1] + 5. default property e.g. Items[Index: integer] + 6. indexed property e.g. Items[Index: integer] + 7. string character e.g. string[3] } procedure RaiseTypeIdentNotFound; @@ -5176,13 +5177,36 @@ var ExprType.Context.Node:=nil; exit; end; + + //debugln('ResolveEdgedBracketOpen A ',ExprType.Context.Node.DescAsString); case ExprType.Context.Node.Desc of ctnOpenArrayType,ctnRangedArrayType: - // the array type is the last child node - ExprType.Context:=ExprType.Context.Tool.FindBaseTypeOfNode(Params, - ExprType.Context.Node.LastChild); + begin + // the array type is the last child node + //debugln('ResolveEdgedBracketOpen Open/RangedArray LastChild=',ExprType.Context.Node.LastChild.DescAsString); + if ExprType.Context.Node.LastChild.Desc=ctnOfConstType then begin + // 'array of const'; the array type is 'TVarData' + // => search 'TVarData' + Params.Save(OldInput); + Params.Flags:=[fdfSearchInParentNodes,fdfIgnoreCurContextNode, + fdfExceptionOnNotFound] + +fdfGlobals*Params.Flags + -[fdfTopLvlResolving]; + // special identifier for TVarData + Params.SetIdentifier(Self,'tvardata',nil); + Params.ContextNode:=ExprType.Context.Node; + ExprType.Context.Tool.FindIdentifierInContext(Params); + ExprType.Context:=Params.NewCodeTool.FindBaseTypeOfNode(Params, + Params.NewNode); + Params.Load(OldInput); + end else begin + ExprType.Context:=ExprType.Context.Tool.FindBaseTypeOfNode(Params, + ExprType.Context.Node.LastChild); + end; + end; + ctnPointerType: // the pointer type is the only child node ExprType.Context:=ExprType.Context.Tool.FindBaseTypeOfNode(Params, diff --git a/components/codetools/pascalparsertool.pas b/components/codetools/pascalparsertool.pas index 973f3858b5..fb074302c1 100644 --- a/components/codetools/pascalparsertool.pas +++ b/components/codetools/pascalparsertool.pas @@ -2896,7 +2896,7 @@ function TPascalParserTool.KeyWordFuncTypeArray: boolean; } begin CreateChildNode; - // first set the type to open arrar (an array type without brackets) + // first set the type to open array (an array type without brackets) CurNode.Desc:=ctnOpenArrayType; ReadNextAtom; if (CurPos.Flag=cafEdgedBracketOpen) then begin @@ -2919,7 +2919,7 @@ begin RaiseStringExpectedButAtomFound('"of"'); ReadNextAtom; Result:=TypeKeyWordFuncList.DoItUpperCase(UpperSrc,CurPos.StartPos, - CurPos.EndPos-CurPos.StartPos); + CurPos.EndPos-CurPos.StartPos); CurNode.EndPos:=CurPos.StartPos; EndChildNode; Result:=true;