Changeset 20 for branches/DelphiToC/UPascalSource.pas
- Timestamp:
- Sep 8, 2009, 2:01:55 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DelphiToC/UPascalSource.pas
r19 r20 43 43 44 44 TCommand = class 45 45 Parent: TObject; 46 47 end; 48 49 TAssignment = class(TCommand) 50 Target: TVariable; 51 Source: TExpression; 52 constructor Create; 53 destructor Destroy; override; 54 end; 55 56 TMethodCall = class(TCommand) 57 Method: TMethod; 46 58 end; 47 59 48 60 TBeginEnd = class(TCommand) 49 61 Commands: TCommandList; 62 procedure Clear; 63 constructor Create; 64 destructor Destroy; override; 50 65 end; 51 66 … … 53 68 Condition: TExpression; 54 69 Command: TCommand; 55 end; 56 57 WithDo = class(TCommand) 70 constructor Create; 71 destructor Destroy; override; 72 end; 73 74 TWithDo = class(TCommand) 58 75 Context: TContext; 59 76 Command: TCommand; 60 77 end; 61 78 62 RepeatUntil = class(TCommand)79 TRepeatUntil = class(TCommand) 63 80 Block: TCommandList; 64 81 Condition: TExpression; 65 82 end; 66 83 67 ForToDo = class(TCommand)84 TForToDo = class(TCommand) 68 85 ControlVariable: TVariable; 69 86 Start: TExpression; … … 72 89 end; 73 90 74 IfThenElse = class(TCommand)91 TIfThenElse = class(TCommand) 75 92 Condition: TExpression; 76 93 Command: TCommand; … … 83 100 end; 84 101 85 CaseOfEnd = class(TCommand)102 TCaseOfEnd = class(TCommand) 86 103 Expression: TExpression; 87 104 Branches: TList; // TList<TCaseOfEndBranche> … … 89 106 end; 90 107 91 T ryFinally = class(TCommand)108 TTryFinally = class(TCommand) 92 109 Block: TCommandList; 93 110 FinallyBlock: TCommandList; 94 111 end; 95 112 96 T ryExcept = class(TCommand)113 TTryExcept = class(TCommand) 97 114 Block: TCommandList; 98 115 ExceptBlock: TCommandList; 99 116 end; 100 101 102 117 103 118 TCommandList = class(TList) … … 112 127 Variables: TVariableList; 113 128 Methods: TFunctionList; 114 Operations: TOperationList;129 Code: TBeginEnd; 115 130 constructor Create; virtual; 116 131 destructor Destroy; override; 117 procedure CheckReferences;132 // procedure CheckReferences; 118 133 end; 119 134 … … 166 181 Parent: TCommonBlock; 167 182 function Search(Name: string): TVariable; 183 destructor Destroy; override; 184 end; 185 186 TParameter = class 187 Name: string; 188 ValueType: TType; 189 DafaultValue: TValue; 190 end; 191 192 TParameterList = class(TList) 193 Parent: TFunction; 194 function Search(Name: string): TParameter; 168 195 destructor Destroy; override; 169 196 end; … … 200 227 TFunction = class(TCommonBlock) 201 228 public 202 Parameters: TList; // TList<T Parameter>229 Parameters: TList; // TList<TVariable> 203 230 ResultType: TType; 204 231 constructor Create; override; … … 246 273 begin 247 274 inherited; 248 Parameters := TList.Create; 249 ResultType := TType.Create; 275 Parameters := TParameterList.Create; 276 TParameterList(Parameters).Parent := Self; 277 //ResultType := TType.Create; 250 278 end; 251 279 … … 253 281 begin 254 282 Parameters.Free; 255 ResultType.Free;283 // ResultType.Free; 256 284 inherited; 257 285 end; … … 310 338 Constants.Clear; 311 339 Methods.Clear; 312 Operations.Clear;340 Code.Clear; 313 341 end; 314 342 … … 325 353 end; 326 354 355 (* 327 356 procedure TCommonBlock.CheckReferences; 328 357 var … … 335 364 end; 336 365 end; 366 *) 337 367 338 368 constructor TCommonBlock.Create; … … 346 376 Methods := TFunctionList.Create; 347 377 Methods.Parent := Self; 348 Operations := TOperationList.Create;378 Code := TBeginEnd.Create; 349 379 end; 350 380 … … 355 385 Variables.Destroy; 356 386 Methods.Destroy; 357 Operations.Destroy;387 Code.Destroy; 358 388 inherited; 359 389 end; … … 483 513 end; 484 514 515 { TParameterList } 516 517 destructor TParameterList.Destroy; 518 var 519 I: Integer; 520 begin 521 for I := 0 to Count - 1 do 522 TParameter(Items[I]).Free; 523 inherited; 524 end; 525 526 function TParameterList.Search(Name: string): TParameter; 527 var 528 I: Integer; 529 begin 530 I := 0; 531 while (I < Count) and (TParameter(Items[I]).Name <> Name) do Inc(I); 532 if I < Count then Result := Items[I] else Result := nil; 533 end; 534 535 { TBeginEnd } 536 537 procedure TBeginEnd.Clear; 538 begin 539 540 end; 541 542 constructor TBeginEnd.Create; 543 begin 544 Commands := TCommandList.Create; 545 end; 546 547 destructor TBeginEnd.Destroy; 548 begin 549 Commands.Free; 550 inherited; 551 end; 552 553 { TAssignment } 554 555 constructor TAssignment.Create; 556 begin 557 // Source := TExpression.Create; 558 end; 559 560 destructor TAssignment.Destroy; 561 begin 562 Source.Free; 563 inherited; 564 end; 565 566 { TWhileDo } 567 568 constructor TWhileDo.Create; 569 begin 570 Condition := TExpression.Create; 571 Command := TCommand.Create; 572 end; 573 574 destructor TWhileDo.Destroy; 575 begin 576 Condition.Free; 577 Command.Free; 578 inherited; 579 end; 580 485 581 end. 486 582
Note:
See TracChangeset
for help on using the changeset viewer.