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);
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;
var
Node: TCodeTreeNode;
NodeText: String;
AVLNode: TAVLTreeNode;
NodeExt: TCodeTreeNodeExtension;
begin
Node:=Tree.Root;
while Node<>nil do begin
@ -1458,27 +1474,15 @@ var
break;
ctnTypeDefinition, ctnConstDefinition:
begin
if OnlyWrongType then begin
// remember the definition
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;
// remember the definition
UpdateDefinition(GetRedefinitionNodeText(Node),Node);
Node:=Node.NextSkipChilds;
end;
ctnProcedure:
Node:=Node.NextSkipChilds;
begin
//UpdateDefinition(GetRedefinitionNodeText(Node),Node);
Node:=Node.NextSkipChilds;
end;
else
Node:=Node.Next;
end;

View File

@ -26,18 +26,28 @@
</RunParams>
<RequiredPackages Count="2">
<Item1>
<PackageName Value="LCL"/>
<PackageName Value="CodeTools"/>
</Item1>
<Item2>
<PackageName Value="CodeTools"/>
<PackageName Value="LCL"/>
</Item2>
</RequiredPackages>
<Units Count="1">
<Units Count="3">
<Unit0>
<Filename Value="fixdefinitionorder.lpr"/>
<IsPartOfProject Value="True"/>
<UnitName Value="FixDefinitionOrder"/>
</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>
</ProjectOptions>
<CompilerOptions>

View File

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

View File

@ -27,13 +27,17 @@ type
TMyInteger = longint;
PMyRecord = ^TMyRecord;
TMyFunc = procedure(i: integer);
MyNilFunc = TMyFunc(0);
Func2 = MyNilFunc;
Func3 = Func2;
MyNilFunc = TMyFunc(0);// should be changed to const
Func2 = MyNilFunc; // should be changed to const
Func3 = Func2; // should be changed to const
type
MPI_Delete_function = function (_para1:MPI_Comm; _para2:longint; _para3:pointer; _para4:pointer):longint;cdecl;
MPI_NULL_DELETE_FN = MPI_Delete_function(0);
FuncType1 = function (_para2:longint; _para3:pointer; _para4:pointer):longint;cdecl;
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