codetools: started fixing function alias

git-svn-id: trunk@12339 -
This commit is contained in:
mattias 2007-10-05 21:52:42 +00:00
parent 9e80047adf
commit dae7d26d45
4 changed files with 51 additions and 33 deletions

View File

@ -1442,12 +1442,28 @@ var
TreeOfCodeTreeNodeExt.Add(NodeExt); TreeOfCodeTreeNodeExt.Add(NodeExt);
end; end;
procedure UpdateDefinition(const NodeText: string; Node: TCodeTreeNode);
var
AVLNode: TAVLTreeNode;
NodeExt: TCodeTreeNodeExtension;
begin
AVLNode:=FindCodeTreeNodeExtAVLNode(AllNodes,NodeText);
if AVLNode=nil then begin
// add new node
NodeExt:=NodeExtMemManager.NewNode;
NodeExt.Node:=Node;
NodeExt.Txt:=NodeText;
AllNodes.Add(NodeExt);
end else begin
// update node
NodeExt:=TCodeTreeNodeExtension(AVLNode.Data);
NodeExt.Node:=Node;
end;
end;
procedure CollectAllDefinitions; procedure CollectAllDefinitions;
var var
Node: TCodeTreeNode; Node: TCodeTreeNode;
NodeText: String;
AVLNode: TAVLTreeNode;
NodeExt: TCodeTreeNodeExtension;
begin begin
Node:=Tree.Root; Node:=Tree.Root;
while Node<>nil do begin while Node<>nil do begin
@ -1458,27 +1474,15 @@ var
break; break;
ctnTypeDefinition, ctnConstDefinition: ctnTypeDefinition, ctnConstDefinition:
begin begin
if OnlyWrongType then begin // remember the definition
// remember the definition UpdateDefinition(GetRedefinitionNodeText(Node),Node);
NodeText:=GetRedefinitionNodeText(Node);
AVLNode:=FindCodeTreeNodeExtAVLNode(AllNodes,NodeText);
if AVLNode=nil then begin
// add new node
NodeExt:=NodeExtMemManager.NewNode;
NodeExt.Node:=Node;
NodeExt.Txt:=NodeText;
AllNodes.Add(NodeExt);
end else begin
// update node
NodeExt:=TCodeTreeNodeExtension(AVLNode.Data);
NodeExt.Node:=Node;
end;
end;
Node:=Node.NextSkipChilds; Node:=Node.NextSkipChilds;
end; end;
ctnProcedure: ctnProcedure:
Node:=Node.NextSkipChilds; begin
//UpdateDefinition(GetRedefinitionNodeText(Node),Node);
Node:=Node.NextSkipChilds;
end;
else else
Node:=Node.Next; Node:=Node.Next;
end; end;

View File

@ -26,18 +26,28 @@
</RunParams> </RunParams>
<RequiredPackages Count="2"> <RequiredPackages Count="2">
<Item1> <Item1>
<PackageName Value="LCL"/> <PackageName Value="CodeTools"/>
</Item1> </Item1>
<Item2> <Item2>
<PackageName Value="CodeTools"/> <PackageName Value="LCL"/>
</Item2> </Item2>
</RequiredPackages> </RequiredPackages>
<Units Count="1"> <Units Count="3">
<Unit0> <Unit0>
<Filename Value="fixdefinitionorder.lpr"/> <Filename Value="fixdefinitionorder.lpr"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="FixDefinitionOrder"/> <UnitName Value="FixDefinitionOrder"/>
</Unit0> </Unit0>
<Unit1>
<Filename Value="scanexamples/simplefunctions.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="SimpleFunctions"/>
</Unit1>
<Unit2>
<Filename Value="scanexamples/wrongforwarddefinitions.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="WrongForwardDefinitions"/>
</Unit2>
</Units> </Units>
</ProjectOptions> </ProjectOptions>
<CompilerOptions> <CompilerOptions>

View File

@ -47,16 +47,16 @@ begin
if Code=nil then if Code=nil then
raise Exception.Create('loading failed '+Filename); raise Exception.Create('loading failed '+Filename);
{if not CodeToolBoss.FixAllAliasDefinitions(Code) then begin if not CodeToolBoss.FixAllAliasDefinitions(Code) then begin
writeln('FixAllAliasDefinitions failed'); writeln('FixAllAliasDefinitions failed');
exit; exit;
end;} end;
// fix constants // fix constants
if not CodeToolBoss.FixForwardDefinitions(Code) then begin {if not CodeToolBoss.FixForwardDefinitions(Code) then begin
writeln('FixForwardDefinitions failed'); writeln('FixForwardDefinitions failed');
exit; exit;
end; end;}
// write the new source: // write the new source:
writeln('-----------------------------------'); writeln('-----------------------------------');

View File

@ -27,13 +27,17 @@ type
TMyInteger = longint; TMyInteger = longint;
PMyRecord = ^TMyRecord; PMyRecord = ^TMyRecord;
TMyFunc = procedure(i: integer); TMyFunc = procedure(i: integer);
MyNilFunc = TMyFunc(0); MyNilFunc = TMyFunc(0);// should be changed to const
Func2 = MyNilFunc; Func2 = MyNilFunc; // should be changed to const
Func3 = Func2; Func3 = Func2; // should be changed to const
type type
MPI_Delete_function = function (_para1:MPI_Comm; _para2:longint; _para3:pointer; _para4:pointer):longint;cdecl; FuncType1 = function (_para2:longint; _para3:pointer; _para4:pointer):longint;cdecl;
MPI_NULL_DELETE_FN = MPI_Delete_function(0); MPI_NULL_DELETE_FN = MPI_Delete_function(0);// should be changed to const
function ExternalFunc1(_para1:longint; _para2:pointer):longint;cdecl;external name 'ExternalFunc1';
const
ExternalFuncAlias1 = ExternalFunc1;// should be replaced with full declaration
implementation implementation