Ignore:
Timestamp:
Aug 9, 2010, 12:48:14 PM (14 years ago)
Author:
george
Message:

Support for function definition with result type.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/DelphiToC/Visual/USourceTree.pas

    r44 r47  
    1717    procedure AddNodeBeginEnd(Node: TTreeNode; BeginEnd: TBeginEnd);
    1818    procedure AddNodeIfThenElse(Node: TTreeNode; IfThenElse: TIfThenElse);
    19     procedure AddNodeMethodCall(Node: TTreeNode; Method: TMethodCall);
     19    procedure AddNodeMethodCall(Node: TTreeNode; Method: TFunctionCall);
    2020    procedure AddNodeMethodList(Node: TTreeNode; Methods: TFunctionList);
     21    procedure AddNodeParameterList(Node: TTreeNode; Parameters: TParameterList);
    2122    procedure AddNodeTypeList(Node: TTreeNode; Types: TTypeList);
    2223    procedure AddNodeVariableList(Node: TTreeNode; Variables: TVariableList);
     
    8283end;
    8384
    84 procedure TSourceTree.AddNodeMethodCall(Node: TTreeNode; Method: TMethodCall);
    85 var
    86   NewNode: TTreeNode;
    87 begin
    88   NewNode := TreeView.Items.AddChild(Node, Method.Method.Name);
     85procedure TSourceTree.AddNodeMethodCall(Node: TTreeNode; Method: TFunctionCall);
     86var
     87  NewNode: TTreeNode;
     88begin
     89  NewNode := TreeView.Items.AddChild(Node, Method.FunctionRef.Name);
    8990end;
    9091
     
    103104  if Command is TWhileDo then
    104105    AddNodeWhileDo(Node, TWhileDo(Command));
    105   if Command is TMethodCall then
    106     AddNodeMethodCall(Node, TMethodCall(Command));
     106  if Command is TFunctionCall then
     107    AddNodeMethodCall(Node, TFunctionCall(Command));
    107108  if Command is TIfThenElse then
    108109    AddNodeIfThenElse(Node, TIfThenElse(Command));
     
    186187  for I := 0 to Methods.Count - 1 do
    187188  with TFunction(Methods[I]) do begin
    188     NewNode := TreeView.Items.AddChild(Node, 'procedure ' + Name);
     189    if HaveResult then
     190      NewNode := TreeView.Items.AddChild(Node, 'function ' + Name)
     191      else NewNode := TreeView.Items.AddChild(Node, 'procedure ' + Name);
     192    AddNodeParameterList(NewNode, Parameters);
    189193    AddNodeMethodList(NewNode, Methods);
    190194    AddNodeConstantList(NewNode, Constants);
     
    192196    AddNodeTypeList(NewNode, Types);
    193197    AddNodeBeginEnd(NewNode, Code);
     198  end;
     199end;
     200
     201procedure TSourceTree.AddNodeParameterList(Node: TTreeNode;
     202  Parameters: TParameterList);
     203var
     204  I: Integer;
     205  NewNode: TTreeNode;
     206begin
     207  if Parameters.Count > 0 then begin
     208    NewNode := TreeView.Items.AddChild(Node, 'parametery');
     209    for I := 0 to Parameters.Count - 1 do
     210    with TParameter(Parameters[I]) do begin
     211      TreeView.Items.AddChild(NewNode, Name + ': ' + ValueType.Name);
     212    end;
    194213  end;
    195214end;
Note: See TracChangeset for help on using the changeset viewer.