Changeset 42 for branches/DelphiToC/Visual/USourceTree.pas
- Timestamp:
- Aug 5, 2010, 3:13:03 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DelphiToC/Visual/USourceTree.pas
r41 r42 14 14 TSourceTree = class 15 15 private 16 procedure AddNodeAssignment(Node: TTreeNode; Assignment: TAssignment); 16 17 procedure AddNodeBeginEnd(Node: TTreeNode; BeginEnd: TBeginEnd); 18 procedure AddNodeIfThenElse(Node: TTreeNode; IfThenElse: TIfThenElse); 19 procedure AddNodeMethodCall(Node: TTreeNode; Method: TMethodCall); 17 20 procedure AddNodeMethodList(Node: TTreeNode; Methods: TFunctionList); 18 21 procedure AddNodeTypeList(Node: TTreeNode; Types: TTypeList); … … 60 63 end; 61 64 65 procedure TSourceTree.AddNodeIfThenElse(Node: TTreeNode; IfThenElse: TIfThenElse); 66 var 67 NewNode: TTreeNode; 68 NewNode2: TTreeNode; 69 NewNode3: TTreeNode; 70 I: Integer; 71 begin 72 NewNode := TreeView.Items.AddChild(Node, 'if'); 73 NewNode2 := TreeView.Items.AddChild(NewNode, 'condition'); 74 AddNodeExpression(NewNode2, IfThenElse.Condition); 75 NewNode2 := TreeView.Items.AddChild(NewNode, 'then'); 76 AddNodeCommand(NewNode2, IfThenElse.Command); 77 if Assigned(IfThenElse.ElseCommand) then begin 78 NewNode2 := TreeView.Items.AddChild(NewNode, 'else'); 79 AddNodeCommand(NewNode2, IfThenElse.ElseCommand); 80 end; 81 end; 82 83 procedure TSourceTree.AddNodeMethodCall(Node: TTreeNode; Method: TMethodCall); 84 var 85 NewNode: TTreeNode; 86 begin 87 NewNode := TreeView.Items.AddChild(Node, Method.Method.Name); 88 end; 89 90 procedure TSourceTree.AddNodeAssignment(Node: TTreeNode; Assignment: TAssignment); 91 var 92 NewNode: TTreeNode; 93 begin 94 NewNode := TreeView.Items.AddChild(Node, Assignment.Target.Name + ' := '); 95 AddNodeExpression(NewNode, Assignment.Source); 96 end; 97 62 98 procedure TSourceTree.AddNodeCommand(Node: TTreeNode; Command: TCommand); 63 99 begin … … 66 102 if Command is TWhileDo then 67 103 AddNodeWhileDo(Node, TWhileDo(Command)); 104 if Command is TMethodCall then 105 AddNodeMethodCall(Node, TMethodCall(Command)); 106 if Command is TIfThenElse then 107 AddNodeIfThenElse(Node, TIfThenElse(Command)); 108 if Command is TAssignment then 109 AddNodeAssignment(Node, TAssignment(Command)); 68 110 end; 69 111 70 112 procedure TSourceTree.AddNodeExpression(Node: TTreeNode; Expression: TExpression 71 113 ); 72 begin 73 114 var 115 NewNode: TTreeNode; 116 begin 117 case Expression.NodeType of 118 ntConstant: NewNode := TreeView.Items.AddChild(Node, Expression.Value); 119 ntVariable: NewNode := TreeView.Items.AddChild(Node, Expression.Variable.Name); 120 ntFunction: NewNode := TreeView.Items.AddChild(Node, Expression.Method.Name); 121 ntOperator: begin 122 NewNode := TreeView.Items.AddChild(Node, Expression.OperatorName); 123 AddNodeExpression(NewNode, TExpression(Expression.SubItems.First)); 124 AddNodeExpression(NewNode, TExpression(Expression.SubItems.Last)); 125 end; 126 ntNone: ; 127 end; 74 128 end; 75 129
Note:
See TracChangeset
for help on using the changeset viewer.