Changeset 47 for branches/DelphiToC
- Timestamp:
- Aug 9, 2010, 12:48:14 PM (14 years ago)
- Location:
- branches/DelphiToC
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DelphiToC/Analyze/UPascalParser.pas
r46 r47 424 424 end; 425 425 end; 426 Assign(TExpression(TExpression(Expressions.First).SubItems[1])); 426 if Assigned(TExpression(Expressions.First).SubItems[1]) then 427 Assign(TExpression(TExpression(Expressions.First).SubItems[1])); 427 428 TExpression(Expressions.First).SubItems[1] := nil; 428 429 //ShowMessage(IntToStr(Expressions.Count)); 429 TExpression(Expressions[1]).SubItems[0] := nil; 430 if Expressions.Count > 1 then 431 TExpression(Expressions[1]).SubItems[0] := nil; 430 432 Expressions.Destroy; 431 433 end; … … 473 475 end else 474 476 if Assigned(SourceCode.Methods.Search(FNextToken)) then begin 475 Result := T MethodCall.Create;476 T MethodCall(Result).CommonBlock := SourceCode;477 T MethodCall(Result).Method:= SourceCode.Methods.Search(FNextToken);477 Result := TFunctionCall.Create; 478 TFunctionCall(Result).CommonBlock := SourceCode; 479 TFunctionCall(Result).FunctionRef := SourceCode.Methods.Search(FNextToken); 478 480 ReadCode; 479 // ParseMetVariable(T MethodCall(Result).Target);481 // ParseMetVariable(TFunctionCall(Result).Target); 480 482 end else begin 481 483 Result := nil; … … 560 562 else if FNextToken = 'procedure' then 561 563 ParseFunctionList(Methods) 564 else if FNextToken = 'function' then 565 ParseFunctionList(Methods) 562 566 else begin 563 567 ParseBeginEnd(Code); … … 604 608 with TFunction(Items[Add(TFunction.Create)]) do begin 605 609 Parent := SourceCode.Parent; 606 Expect('procedure'); 610 if FNextToken = 'procedure' then begin 611 Expect('procedure'); 612 HaveResult := False; 613 end else begin 614 Expect('function'); 615 HaveResult := True; 616 end; 607 617 Name := ReadCode; 618 608 619 if FNextToken = '(' then begin 609 620 Expect('('); … … 632 643 end; 633 644 Expect(')'); 645 646 // Parse function result type 647 if HaveResult then begin 648 Expect(':'); 649 TypeName := ReadCode; 650 NewValueType := Parent.Types.Search(TypeName); 651 if not Assigned(NewValueType) then ErrorMessage(STypeNotDefined, [TypeName]) 652 else begin 653 ResultType := NewValueType; 654 with TVariable(Parent.Variables.Items[Parent.Variables.Add(TVariable.Create)]) do begin 655 Name := 'Result'; 656 ValueType := NewValueType; 657 end; 658 end; 659 end; 634 660 end; 635 661 end; 636 662 Expect(';'); 637 ParseCommonBlock(TFunction( Items[Count - 1]));663 ParseCommonBlock(TFunction(Last)); 638 664 end; 639 665 Identifiers.Destroy; -
branches/DelphiToC/DelphiToC.lpi
r46 r47 47 47 <WindowIndex Value="0"/> 48 48 <TopLine Value="4"/> 49 <CursorPos X=" 42" Y="15"/>50 <UsageCount Value="10 4"/>49 <CursorPos X="1" Y="29"/> 50 <UsageCount Value="107"/> 51 51 <Loaded Value="True"/> 52 52 </Unit0> … … 62 62 <TopLine Value="56"/> 63 63 <CursorPos X="1" Y="79"/> 64 <UsageCount Value="10 4"/>64 <UsageCount Value="107"/> 65 65 <Loaded Value="True"/> 66 66 <LoadedDesigner Value="True"/> … … 73 73 <TopLine Value="1"/> 74 74 <CursorPos X="1" Y="1"/> 75 <UsageCount Value="10 4"/>75 <UsageCount Value="107"/> 76 76 </Unit2> 77 77 <Unit3> … … 81 81 <EditorIndex Value="5"/> 82 82 <WindowIndex Value="0"/> 83 <TopLine Value=" 119"/>84 <CursorPos X=" 3" Y="132"/>85 <UsageCount Value="10 4"/>83 <TopLine Value="221"/> 84 <CursorPos X="25" Y="240"/> 85 <UsageCount Value="107"/> 86 86 <Loaded Value="True"/> 87 87 </Unit3> … … 94 94 <TopLine Value="36"/> 95 95 <CursorPos X="1" Y="41"/> 96 <UsageCount Value="10 4"/>96 <UsageCount Value="107"/> 97 97 <Loaded Value="True"/> 98 98 </Unit4> … … 105 105 <TopLine Value="112"/> 106 106 <CursorPos X="48" Y="128"/> 107 <UsageCount Value="10 4"/>107 <UsageCount Value="107"/> 108 108 <Loaded Value="True"/> 109 109 </Unit5> … … 116 116 <TopLine Value="1"/> 117 117 <CursorPos X="15" Y="13"/> 118 <UsageCount Value="10 4"/>118 <UsageCount Value="107"/> 119 119 <Loaded Value="True"/> 120 120 </Unit6> … … 125 125 <EditorIndex Value="10"/> 126 126 <WindowIndex Value="0"/> 127 <TopLine Value="1 30"/>128 <CursorPos X="4 8" Y="144"/>129 <UsageCount Value="10 4"/>127 <TopLine Value="171"/> 128 <CursorPos X="45" Y="175"/> 129 <UsageCount Value="107"/> 130 130 <Loaded Value="True"/> 131 131 </Unit7> … … 134 134 <IsPartOfProject Value="True"/> 135 135 <UnitName Value="UPascalParser"/> 136 <IsVisibleTab Value="True"/> 136 137 <EditorIndex Value="0"/> 137 138 <WindowIndex Value="0"/> 138 <TopLine Value=" 137"/>139 <CursorPos X=" 26" Y="555"/>140 <UsageCount Value="10 4"/>139 <TopLine Value="641"/> 140 <CursorPos X="45" Y="653"/> 141 <UsageCount Value="107"/> 141 142 <Loaded Value="True"/> 142 143 </Unit8> … … 154 155 <EditorIndex Value="6"/> 155 156 <WindowIndex Value="0"/> 156 <TopLine Value=" 68"/>157 <CursorPos X="14" Y="9 0"/>158 <UsageCount Value="5 3"/>157 <TopLine Value="78"/> 158 <CursorPos X="14" Y="91"/> 159 <UsageCount Value="54"/> 159 160 <Loaded Value="True"/> 160 161 </Unit10> … … 173 174 <TopLine Value="61"/> 174 175 <CursorPos X="7" Y="68"/> 175 <UsageCount Value="3 6"/>176 <UsageCount Value="37"/> 176 177 <Loaded Value="True"/> 177 178 </Unit12> … … 182 183 <TopLine Value="139"/> 183 184 <CursorPos X="16" Y="146"/> 184 <UsageCount Value="3 6"/>185 <UsageCount Value="37"/> 185 186 <Loaded Value="True"/> 186 187 </Unit13> … … 205 206 <TopLine Value="153"/> 206 207 <CursorPos X="8" Y="166"/> 207 <UsageCount Value="1 0"/>208 <UsageCount Value="12"/> 208 209 <Loaded Value="True"/> 209 210 </Unit16> … … 214 215 <EditorIndex Value="2"/> 215 216 <WindowIndex Value="0"/> 216 <TopLine Value="1 89"/>217 <CursorPos X=" 1" Y="202"/>218 <UsageCount Value="6 6"/>217 <TopLine Value="178"/> 218 <CursorPos X="67" Y="190"/> 219 <UsageCount Value="69"/> 219 220 <Loaded Value="True"/> 220 221 </Unit17> … … 233 234 <TopLine Value="263"/> 234 235 <CursorPos X="14" Y="276"/> 235 <UsageCount Value="1 0"/>236 <UsageCount Value="12"/> 236 237 <Loaded Value="True"/> 237 238 </Unit19> … … 240 241 <IsPartOfProject Value="True"/> 241 242 <UnitName Value="UProducerPascal"/> 242 <IsVisibleTab Value="True"/>243 243 <EditorIndex Value="8"/> 244 244 <WindowIndex Value="0"/> 245 <TopLine Value="1 73"/>246 <CursorPos X=" 33" Y="192"/>247 <UsageCount Value="2 1"/>245 <TopLine Value="103"/> 246 <CursorPos X="21" Y="116"/> 247 <UsageCount Value="23"/> 248 248 <Loaded Value="True"/> 249 249 </Unit20> 250 250 </Units> 251 <JumpHistory Count="2 7" HistoryIndex="26">251 <JumpHistory Count="29" HistoryIndex="28"> 252 252 <Position1> 253 253 <Filename Value="UPascalSource.pas"/> 254 <Caret Line=" 241" Column="27" TopLine="236"/>254 <Caret Line="441" Column="20" TopLine="429"/> 255 255 </Position1> 256 256 <Position2> 257 <Filename Value=" DelphiToC.lpr"/>258 <Caret Line=" 27" Column="1" TopLine="4"/>257 <Filename Value="UPascalSource.pas"/> 258 <Caret Line="448" Column="49" TopLine="432"/> 259 259 </Position2> 260 260 <Position3> 261 <Filename Value=" UMainForm.pas"/>262 <Caret Line=" 49" Column="40" TopLine="34"/>261 <Filename Value="Analyze\UPascalParser.pas"/> 262 <Caret Line="329" Column="1" TopLine="316"/> 263 263 </Position3> 264 264 <Position4> 265 <Filename Value="U MainForm.pas"/>266 <Caret Line="4 8" Column="40" TopLine="33"/>265 <Filename Value="UPascalSource.pas"/> 266 <Caret Line="435" Column="1" TopLine="430"/> 267 267 </Position4> 268 268 <Position5> 269 <Filename Value="U MainForm.pas"/>270 <Caret Line=" 52" Column="40" TopLine="37"/>269 <Filename Value="UPascalSource.pas"/> 270 <Caret Line="436" Column="1" TopLine="430"/> 271 271 </Position5> 272 272 <Position6> 273 <Filename Value="U MainForm.pas"/>274 <Caret Line=" 51" Column="44" TopLine="38"/>273 <Filename Value="UPascalSource.pas"/> 274 <Caret Line="437" Column="1" TopLine="430"/> 275 275 </Position6> 276 276 <Position7> 277 <Filename Value="U MainForm.pas"/>278 <Caret Line=" 75" Column="11" TopLine="62"/>277 <Filename Value="UPascalSource.pas"/> 278 <Caret Line="438" Column="1" TopLine="430"/> 279 279 </Position7> 280 280 <Position8> 281 <Filename Value="U MainForm.pas"/>282 <Caret Line=" 91" Column="26" TopLine="73"/>281 <Filename Value="UPascalSource.pas"/> 282 <Caret Line="440" Column="1" TopLine="430"/> 283 283 </Position8> 284 284 <Position9> 285 <Filename Value="U MainForm.pas"/>286 <Caret Line=" 89" Column="21" TopLine="74"/>285 <Filename Value="UPascalSource.pas"/> 286 <Caret Line="441" Column="1" TopLine="430"/> 287 287 </Position9> 288 288 <Position10> 289 <Filename Value="U MainForm.pas"/>290 <Caret Line=" 91" Column="21" TopLine="76"/>289 <Filename Value="UPascalSource.pas"/> 290 <Caret Line="442" Column="1" TopLine="430"/> 291 291 </Position10> 292 292 <Position11> 293 <Filename Value=" Produce\UProducerPascal.pas"/>294 <Caret Line=" 15" Column="10" TopLine="5"/>293 <Filename Value="UPascalSource.pas"/> 294 <Caret Line="446" Column="1" TopLine="430"/> 295 295 </Position11> 296 296 <Position12> 297 <Filename Value=" Produce\UProducerPascal.pas"/>298 <Caret Line=" 27" Column="62" TopLine="13"/>297 <Filename Value="UPascalSource.pas"/> 298 <Caret Line="447" Column="1" TopLine="430"/> 299 299 </Position12> 300 300 <Position13> 301 <Filename Value=" Produce\UProducerPascal.pas"/>302 <Caret Line=" 66" Column="1" TopLine="86"/>301 <Filename Value="UPascalSource.pas"/> 302 <Caret Line="448" Column="1" TopLine="430"/> 303 303 </Position13> 304 304 <Position14> 305 <Filename Value=" Produce\UProducerPascal.pas"/>306 <Caret Line=" 59" Column="1" TopLine="50"/>305 <Filename Value="UPascalSource.pas"/> 306 <Caret Line="452" Column="1" TopLine="431"/> 307 307 </Position14> 308 308 <Position15> 309 <Filename Value=" Produce\UProducerPascal.pas"/>310 <Caret Line=" 138" Column="1" TopLine="128"/>309 <Filename Value="UPascalSource.pas"/> 310 <Caret Line="453" Column="1" TopLine="432"/> 311 311 </Position15> 312 312 <Position16> 313 <Filename Value=" Produce\UProducerPascal.pas"/>314 <Caret Line=" 72" Column="16" TopLine="59"/>313 <Filename Value="UPascalSource.pas"/> 314 <Caret Line="455" Column="1" TopLine="434"/> 315 315 </Position16> 316 316 <Position17> 317 <Filename Value=" Produce\UProducerPascal.pas"/>318 <Caret Line=" 134" Column="1" TopLine="119"/>317 <Filename Value="Analyze\UPascalParser.pas"/> 318 <Caret Line="329" Column="1" TopLine="316"/> 319 319 </Position17> 320 320 <Position18> 321 <Filename Value=" Produce\UProducerPascal.pas"/>322 <Caret Line=" 130" Column="14" TopLine="118"/>321 <Filename Value="UPascalSource.pas"/> 322 <Caret Line="448" Column="1" TopLine="436"/> 323 323 </Position18> 324 324 <Position19> 325 <Filename Value=" Produce\UProducerPascal.pas"/>326 <Caret Line=" 17" Column="1" TopLine="4"/>325 <Filename Value="UPascalSource.pas"/> 326 <Caret Line="544" Column="1" TopLine="531"/> 327 327 </Position19> 328 328 <Position20> 329 <Filename Value=" Produce\UProducerPascal.pas"/>330 <Caret Line=" 133" Column="38" TopLine="120"/>329 <Filename Value="UPascalSource.pas"/> 330 <Caret Line="545" Column="1" TopLine="531"/> 331 331 </Position20> 332 332 <Position21> 333 <Filename Value="U MainForm.pas"/>334 <Caret Line=" 11" Column="18" TopLine="1"/>333 <Filename Value="UPascalSource.pas"/> 334 <Caret Line="546" Column="62" TopLine="532"/> 335 335 </Position21> 336 336 <Position22> 337 <Filename Value=" UMainForm.pas"/>338 <Caret Line=" 60" Column="3" TopLine="50"/>337 <Filename Value="Produce\UProducerPascal.pas"/> 338 <Caret Line="154" Column="51" TopLine="139"/> 339 339 </Position22> 340 340 <Position23> 341 <Filename Value=" UMainForm.pas"/>342 <Caret Line=" 55" Column="9" TopLine="50"/>341 <Filename Value="DelphiToC.lpr"/> 342 <Caret Line="15" Column="42" TopLine="4"/> 343 343 </Position23> 344 344 <Position24> 345 <Filename Value="U MainForm.pas"/>346 <Caret Line=" 69" Column="8" TopLine="56"/>345 <Filename Value="UPascalSource.pas"/> 346 <Caret Line="241" Column="20" TopLine="221"/> 347 347 </Position24> 348 348 <Position25> 349 <Filename Value=" UMainForm.pas"/>350 <Caret Line=" 81" Column="18" TopLine="61"/>349 <Filename Value="Analyze\UPascalParser.pas"/> 350 <Caret Line="565" Column="22" TopLine="552"/> 351 351 </Position25> 352 352 <Position26> 353 <Filename Value=" UPascalCompiler.pas"/>354 <Caret Line=" 41" Column="15" TopLine="36"/>353 <Filename Value="Visual\USourceTree.pas"/> 354 <Caret Line="194" Column="57" TopLine="186"/> 355 355 </Position26> 356 356 <Position27> 357 <Filename Value=" UMainForm.pas"/>358 <Caret Line=" 79" Column="1" TopLine="56"/>357 <Filename Value="Produce\UProducerPascal.pas"/> 358 <Caret Line="120" Column="1" TopLine="99"/> 359 359 </Position27> 360 <Position28> 361 <Filename Value="Analyze\UPascalParser.pas"/> 362 <Caret Line="653" Column="28" TopLine="632"/> 363 </Position28> 364 <Position29> 365 <Filename Value="Analyze\UPascalParser.pas"/> 366 <Caret Line="654" Column="40" TopLine="632"/> 367 </Position29> 360 368 </JumpHistory> 361 369 </ProjectOptions> -
branches/DelphiToC/Example.pas
r46 r47 3 3 uses System, Crt; 4 4 5 procedure Pokus(A: Byte);5 function Max(A, B: Byte): Byte; 6 6 var 7 7 S: Byte; 8 8 begin 9 WriteLn;10 WriteLn;9 if A > B then Result := A 10 else Result := B; 11 11 end; 12 12 -
branches/DelphiToC/Produce/UProducerC.pas
r46 r47 29 29 procedure GenerateIfThenElse(IfThenElse: TIfThenElse); 30 30 procedure GenerateAssignment(Assignment: TAssignment); 31 procedure GenerateMethodCall(MethodCall: T MethodCall);31 procedure GenerateMethodCall(MethodCall: TFunctionCall); 32 32 function GenerateExpression(Expression: TExpression): string; 33 33 public … … 158 158 else if Command is TIfThenElse then GenerateIfThenElse(TIfThenElse(Command)) 159 159 else if Command is TAssignment then GenerateAssignment(TAssignment(Command)) 160 else if Command is T MethodCall then GenerateMethodCall(TMethodCall(Command));160 else if Command is TFunctionCall then GenerateMethodCall(TFunctionCall(Command)); 161 161 end; 162 162 … … 171 171 Emit('if(' + GenerateExpression(IfThenElse.Condition) + ')'); 172 172 GenerateCommand(IfThenElse.Command); 173 Emit('else '); 174 GenerateCommand(IfThenElse.ElseCommand); 173 if Assigned(IfThenElse.ElseCommand) then begin 174 Emit('else '); 175 GenerateCommand(IfThenElse.ElseCommand); 176 end; 175 177 end; 176 178 … … 180 182 end; 181 183 182 procedure TCProducer.GenerateMethodCall(MethodCall: T MethodCall);183 begin 184 Emit(MethodCall. Method.Name + '();');184 procedure TCProducer.GenerateMethodCall(MethodCall: TFunctionCall); 185 begin 186 Emit(MethodCall.FunctionRef.Name + '();'); 185 187 end; 186 188 -
branches/DelphiToC/Produce/UProducerPascal.pas
r46 r47 7 7 uses 8 8 SysUtils, Variants, Classes, Graphics, Controls, Forms, 9 Dialogs, StdCtrls,UPascalSource, UCodeProducer, StrUtils;9 Dialogs, UPascalSource, UCodeProducer, StrUtils; 10 10 11 11 type … … 21 21 LabelPrefix: string); 22 22 procedure GenerateProgram(ProgramBlock: TProgram); 23 procedure Generate Methods(Methods: TFunctionList);23 procedure GenerateFunctions(Functions: TFunctionList); 24 24 procedure GenerateBeginEnd(BeginEnd: TBeginEnd); 25 25 procedure GenerateVariableList(Variables: TVariableList); … … 28 28 procedure GenerateIfThenElse(IfThenElse: TIfThenElse); 29 29 procedure GenerateAssignment(Assignment: TAssignment); 30 procedure GenerateMethodCall(MethodCall: T MethodCall);30 procedure GenerateMethodCall(MethodCall: TFunctionCall); 31 31 function GenerateExpression(Expression: TExpression): string; 32 32 public … … 97 97 end; 98 98 99 procedure TProducerPascal.GenerateMethods(Methods: TFunctionList); 100 var 101 I: Integer; 102 begin 103 for I := 0 to Methods.Count - 1 do 104 with TFunction(Methods[I]) do 99 procedure TProducerPascal.GenerateFunctions(Functions: TFunctionList); 100 var 101 I: Integer; 102 P: Integer; 103 Line: string; 104 begin 105 for I := 0 to Functions.Count - 1 do 106 with TFunction(Functions[I]) do 105 107 begin 106 Emit('procedure ' + Name + ''); 108 if HaveResult then 109 Line := 'function ' + Name 110 else Line := 'procedure ' + Name; 111 if Parameters.Count > 0 then begin 112 Line := Line + '('; 113 for P := 0 to Parameters.Count - 1 do begin 114 with TParameter(Parameters[P]) do 115 Line := Line + Name + ': ' + ValueType.Name; 116 if P < (Parameters.Count - 1) then Line := Line + '; '; 117 end; 118 Line := Line + ')'; 119 end; 120 if HaveResult then Line := Line + ': ' + ResultType.Name; 121 Emit(Line + ';'); 107 122 GenerateBeginEnd(Code); 108 123 Emit(''); … … 121 136 122 137 Dec(Indetation); 123 Emit('end ');138 Emit('end;'); 124 139 end; 125 140 … … 141 156 else if Command is TIfThenElse then GenerateIfThenElse(TIfThenElse(Command)) 142 157 else if Command is TAssignment then GenerateAssignment(TAssignment(Command)) 143 else if Command is T MethodCall then GenerateMethodCall(TMethodCall(Command));158 else if Command is TFunctionCall then GenerateMethodCall(TFunctionCall(Command)); 144 159 end; 145 160 … … 154 169 Emit('if ' + GenerateExpression(IfThenElse.Condition) + ' then '); 155 170 GenerateCommand(IfThenElse.Command); 156 Emit('else '); 157 GenerateCommand(IfThenElse.ElseCommand); 171 if Assigned(IfThenElse.ElseCommand) then begin 172 Emit('else '); 173 GenerateCommand(IfThenElse.ElseCommand); 174 end; 158 175 end; 159 176 160 177 procedure TProducerPascal.GenerateAssignment(Assignment: TAssignment); 161 178 begin 162 Emit(Assignment.Target.Name + ' = ' + GenerateExpression(Assignment.Source) + ';');163 end; 164 165 procedure TProducerPascal.GenerateMethodCall(MethodCall: T MethodCall);166 begin 167 Emit(MethodCall. Method.Name + ';');179 Emit(Assignment.Target.Name + ' := ' + GenerateExpression(Assignment.Source) + ';'); 180 end; 181 182 procedure TProducerPascal.GenerateMethodCall(MethodCall: TFunctionCall); 183 begin 184 Emit(MethodCall.FunctionRef.Name + ';'); 168 185 end; 169 186 … … 189 206 begin 190 207 with CommonBlock do begin 191 Generate Methods(Methods);208 GenerateFunctions(Methods); 192 209 Emit('procedure ' + Name + ''); 193 210 GenerateBeginEnd(Code); -
branches/DelphiToC/UPascalSource.pas
r45 r47 57 57 end; 58 58 59 T MethodCall = class(TCommand)60 Method: TFunction;59 TFunctionCall = class(TCommand) 60 FunctionRef: TFunction; 61 61 end; 62 62 … … 185 185 Name: string; 186 186 ValueType: TType; 187 Value: TValue;187 DefaultValue: TValue; 188 188 end; 189 189 … … 194 194 end; 195 195 196 TParameter = class 197 Name: string; 198 ValueType: TType; 199 DafaultValue: TValue; 196 TParameter = class(TVariable) 200 197 end; 201 198 … … 241 238 TFunction = class(TCommonBlock) 242 239 public 240 HaveResult: Boolean; 243 241 Parameters: TParameterList; 244 242 ResultType: TType; … … 439 437 I := 0; 440 438 while (I < Count) and (LowerCase(TVariable(Items[I]).Name) <> LowerCase(Name)) do Inc(I); 441 if I < Count then Result := TVariable(Items[I]) else begin 439 if I < Count then Result := TVariable(Items[I]) else Result := nil; 440 441 if not Assigned(Result) then begin 442 442 if Assigned(Parent.Parent) then 443 443 Result := Parent.Parent.Variables.Search(Name) 444 else Result := nil; 445 end; 446 447 if not Assigned(Result) then begin 448 if Assigned(Parent) and (Parent is TFunction) then 449 Result := TFunction(Parent).Parameters.Search(Name) 450 else Result := nil; 451 end; 452 453 if not Assigned(Result) then begin 454 if Assigned(Parent.Parent) and (Parent.Parent is TFunction) then 455 Result := TFunction(Parent.Parent).Parameters.Search(Name) 444 456 else Result := nil; 445 457 end; … … 533 545 begin 534 546 I := 0; 535 while (I < Count) and ( TParameter(Items[I]).Name<> LowerCase(Name)) do Inc(I);547 while (I < Count) and (LowerCase(TParameter(Items[I]).Name) <> LowerCase(Name)) do Inc(I); 536 548 if I < Count then Result := TParameter(Items[I]) 537 549 else Result := nil; -
branches/DelphiToC/Visual/USourceTree.pas
r44 r47 17 17 procedure AddNodeBeginEnd(Node: TTreeNode; BeginEnd: TBeginEnd); 18 18 procedure AddNodeIfThenElse(Node: TTreeNode; IfThenElse: TIfThenElse); 19 procedure AddNodeMethodCall(Node: TTreeNode; Method: T MethodCall);19 procedure AddNodeMethodCall(Node: TTreeNode; Method: TFunctionCall); 20 20 procedure AddNodeMethodList(Node: TTreeNode; Methods: TFunctionList); 21 procedure AddNodeParameterList(Node: TTreeNode; Parameters: TParameterList); 21 22 procedure AddNodeTypeList(Node: TTreeNode; Types: TTypeList); 22 23 procedure AddNodeVariableList(Node: TTreeNode; Variables: TVariableList); … … 82 83 end; 83 84 84 procedure TSourceTree.AddNodeMethodCall(Node: TTreeNode; Method: T MethodCall);85 var 86 NewNode: TTreeNode; 87 begin 88 NewNode := TreeView.Items.AddChild(Node, Method. Method.Name);85 procedure TSourceTree.AddNodeMethodCall(Node: TTreeNode; Method: TFunctionCall); 86 var 87 NewNode: TTreeNode; 88 begin 89 NewNode := TreeView.Items.AddChild(Node, Method.FunctionRef.Name); 89 90 end; 90 91 … … 103 104 if Command is TWhileDo then 104 105 AddNodeWhileDo(Node, TWhileDo(Command)); 105 if Command is T MethodCall then106 AddNodeMethodCall(Node, T MethodCall(Command));106 if Command is TFunctionCall then 107 AddNodeMethodCall(Node, TFunctionCall(Command)); 107 108 if Command is TIfThenElse then 108 109 AddNodeIfThenElse(Node, TIfThenElse(Command)); … … 186 187 for I := 0 to Methods.Count - 1 do 187 188 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); 189 193 AddNodeMethodList(NewNode, Methods); 190 194 AddNodeConstantList(NewNode, Constants); … … 192 196 AddNodeTypeList(NewNode, Types); 193 197 AddNodeBeginEnd(NewNode, Code); 198 end; 199 end; 200 201 procedure TSourceTree.AddNodeParameterList(Node: TTreeNode; 202 Parameters: TParameterList); 203 var 204 I: Integer; 205 NewNode: TTreeNode; 206 begin 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; 194 213 end; 195 214 end;
Note:
See TracChangeset
for help on using the changeset viewer.