implemented searching for TVarData on array of const

git-svn-id: trunk@8010 -
This commit is contained in:
mattias 2005-10-31 01:21:28 +00:00
parent 937eb5fe69
commit eb248f3684
3 changed files with 39 additions and 14 deletions

View File

@ -333,6 +333,7 @@ begin
ctnIdentifier: Result:='Identifier'; ctnIdentifier: Result:='Identifier';
ctnOpenArrayType: Result:='Open Array Type'; ctnOpenArrayType: Result:='Open Array Type';
ctnOfConstType: Result:='Of Const';
ctnRangedArrayType: Result:='Ranged Array Type'; ctnRangedArrayType: Result:='Ranged Array Type';
ctnRecordType: Result:='Record Type'; ctnRecordType: Result:='Record Type';
ctnRecordCase: Result:='Record Case'; ctnRecordCase: Result:='Record Case';
@ -355,7 +356,7 @@ begin
ctnCaseStatement: Result:='Case Statement'; ctnCaseStatement: Result:='Case Statement';
else else
Result:='invalid descriptor'; Result:='invalid descriptor ('+IntToStr(Desc)+')';
end; end;
end; end;

View File

@ -5136,12 +5136,13 @@ var
procedure ResolveEdgedBracketOpen; procedure ResolveEdgedBracketOpen;
{ for example: a[] { for example: a[]
this could be: this could be:
1. ranged array 1. ranged array e.g. array[1..2] of
2. dynamic array 2. dynamic array e.g. array of integer
3. indexed pointer 3. variant array e.g. array of const
4. default property 4. indexed pointer e.g. PInteger[1]
5. indexed property 5. default property e.g. Items[Index: integer]
6. string character 6. indexed property e.g. Items[Index: integer]
7. string character e.g. string[3]
} }
procedure RaiseTypeIdentNotFound; procedure RaiseTypeIdentNotFound;
@ -5176,12 +5177,35 @@ var
ExprType.Context.Node:=nil; ExprType.Context.Node:=nil;
exit; exit;
end; end;
//debugln('ResolveEdgedBracketOpen A ',ExprType.Context.Node.DescAsString);
case ExprType.Context.Node.Desc of case ExprType.Context.Node.Desc of
ctnOpenArrayType,ctnRangedArrayType: ctnOpenArrayType,ctnRangedArrayType:
begin
// the array type is the last child node // 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:=ExprType.Context.Tool.FindBaseTypeOfNode(Params,
ExprType.Context.Node.LastChild); ExprType.Context.Node.LastChild);
end;
end;
ctnPointerType: ctnPointerType:
// the pointer type is the only child node // the pointer type is the only child node

View File

@ -2896,7 +2896,7 @@ function TPascalParserTool.KeyWordFuncTypeArray: boolean;
} }
begin begin
CreateChildNode; 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; CurNode.Desc:=ctnOpenArrayType;
ReadNextAtom; ReadNextAtom;
if (CurPos.Flag=cafEdgedBracketOpen) then begin if (CurPos.Flag=cafEdgedBracketOpen) then begin