Changeset 83 for branches/Transpascal/Compiler/USourceCode.pas
- Timestamp:
- Oct 31, 2010, 9:40:18 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/Transpascal/Compiler/USourceCode.pas
r82 r83 2 2 3 3 {$MODE Delphi} 4 {$MACRO ON} 4 5 5 6 interface 6 7 7 8 uses 8 SysUtils, Variants, Classes, Dialogs , ListObject;9 SysUtils, Variants, Classes, Dialogs; 9 10 10 11 type … … 55 56 end; 56 57 58 // TListExpression = TGObjectList<Integer, TExpression> 59 {$DEFINE TGObjectListIndex := Integer} 60 {$DEFINE TGObjectListItem := TExpression} 61 {$DEFINE TGObjectListList := TObjectListExpression} 62 {$DEFINE TGObjectList := TListExpression} 63 {$DEFINE TGObjectListSortCompare := TObjectListSortCompareExpression} 64 {$DEFINE TGObjectListStringConverter := TObjectListStringConverterExpression} 65 {$DEFINE INTERFACE} 66 {$I 'GenericObjectList.inc'} 67 57 68 { TFunctionCall } 58 69 59 70 TFunctionCall = class(TCommand) 60 71 FunctionRef: TFunction; 61 ParameterExpression: TList Object; // TListObject<TExpression>72 ParameterExpression: TListExpression; 62 73 constructor Create; 63 74 destructor Destroy; override; … … 115 126 end; 116 127 128 // TListCaseOfEndBranche = TGObjectList<Integer, TCaseOfEndBranche> 129 {$DEFINE TGObjectListIndex := Integer} 130 {$DEFINE TGObjectListItem := TCaseOfEndBranche} 131 {$DEFINE TGObjectListList := TObjectListCaseOfEndBranche} 132 {$DEFINE TGObjectList := TListCaseOfEndBranche} 133 {$DEFINE TGObjectListSortCompare := TObjectListSortCompareCaseOfEndBranche} 134 {$DEFINE TGObjectListStringConverter := TObjectListStringConverterCaseOfEndBranche} 135 {$DEFINE INTERFACE} 136 {$I 'GenericObjectList.inc'} 137 117 138 TCaseOfEnd = class(TCommand) 118 139 Expression: TExpression; 119 Branches: TList Object; // TListObject<TCaseOfEndBranche>140 Branches: TListCaseOfEndBranche; 120 141 ElseCommand: TCommand; 121 142 constructor Create; … … 133 154 end; 134 155 135 TCommandList = class(TListObject) 136 137 end; 156 // TCommandList = TGObjectList<Integer, TCommand> 157 {$DEFINE TGObjectListIndex := Integer} 158 {$DEFINE TGObjectListItem := TCommand} 159 {$DEFINE TGObjectListList := TObjectListCommand} 160 {$DEFINE TGObjectList := TCommandList} 161 {$DEFINE TGObjectListSortCompare := TObjectListSortCompareCommand} 162 {$DEFINE TGObjectListStringConverter := TObjectListStringConverterCommand} 163 {$DEFINE INTERFACE} 164 {$I 'GenericObjectList.inc'} 138 165 139 166 TCommonBlock = class … … 161 188 end; 162 189 190 // TListType = TGObjectList<Integer, TType> 191 {$DEFINE TGObjectListIndex := Integer} 192 {$DEFINE TGObjectListItem := TType} 193 {$DEFINE TGObjectListList := TObjectListType} 194 {$DEFINE TGObjectList := TListType} 195 {$DEFINE TGObjectListSortCompare := TObjectListSortCompareType} 196 {$DEFINE TGObjectListStringConverter := TObjectListStringConverterType} 197 {$DEFINE INTERFACE} 198 {$I 'GenericObjectList.inc'} 199 200 TTypeList = class(TListType) 201 Parent: TCommonBlock; 202 function Search(Name: string; Exported: Boolean = False): TType; 203 destructor Destroy; override; 204 end; 205 163 206 TTypeInherited = class(TType) 164 207 end; … … 188 231 end; 189 232 233 // TListEnumItem = TGObjectList<Integer, TEnumItem> 234 {$DEFINE TGObjectListIndex := Integer} 235 {$DEFINE TGObjectListItem := TEnumItem} 236 {$DEFINE TGObjectListList := TObjectListEnumItem} 237 {$DEFINE TGObjectList := TListEnumItem} 238 {$DEFINE TGObjectListSortCompare := TObjectListSortCompareEnumItem} 239 {$DEFINE TGObjectListStringConverter := TObjectListStringConverterEnumItem} 240 {$DEFINE INTERFACE} 241 {$I 'GenericObjectList.inc'} 242 190 243 TTypeEnumeration = class(TType) 191 Items: TList Object; // TListObject<TEnumItem>244 Items: TListEnumItem; 192 245 constructor Create; 193 246 destructor Destroy; override; … … 197 250 198 251 TTypeClass = class(TType) 199 Items: TListObject; // TListObject<TType> 200 constructor Create; 201 destructor Destroy; override; 202 end; 203 204 TTypeList = class(TListObject) 205 Parent: TCommonBlock; 206 function Search(Name: string; Exported: Boolean = False): TType; 252 Items: TListType; 253 constructor Create; 207 254 destructor Destroy; override; 208 255 end; … … 216 263 end; 217 264 218 TConstantList = class(TListObject) 265 // TListConstant = TGObjectList<Integer, TConstant> 266 {$DEFINE TGObjectListIndex := Integer} 267 {$DEFINE TGObjectListItem := TConstant} 268 {$DEFINE TGObjectListList := TObjectListConstant} 269 {$DEFINE TGObjectList := TListConstant} 270 {$DEFINE TGObjectListSortCompare := TObjectListSortCompareConstant} 271 {$DEFINE TGObjectListStringConverter := TObjectListStringConverterConstant} 272 {$DEFINE INTERFACE} 273 {$I 'GenericObjectList.inc'} 274 275 TConstantList = class(TListConstant) 219 276 Parent: TCommonBlock; 220 277 function Search(Name: string): TConstant; … … 229 286 end; 230 287 231 TVariableList = class(TListObject) 288 // TListVariable = TGObjectList<Integer, TVariable> 289 {$DEFINE TGObjectListIndex := Integer} 290 {$DEFINE TGObjectListItem := TVariable} 291 {$DEFINE TGObjectListList := TObjectListVariable} 292 {$DEFINE TGObjectList := TListVariable} 293 {$DEFINE TGObjectListSortCompare := TObjectListSortCompareVariable} 294 {$DEFINE TGObjectListStringConverter := TObjectListStringConverterVariable} 295 {$DEFINE INTERFACE} 296 {$I 'GenericObjectList.inc'} 297 298 TVariableList = class(TListVariable) 232 299 Parent: TCommonBlock; 233 300 function Search(Name: string; Exported: Boolean = False): TVariable; … … 238 305 end; 239 306 240 TParameterList = class(TListObject) 307 // TListParameter = TGObjectList<Integer, TParameter> 308 {$DEFINE TGObjectListIndex := Integer} 309 {$DEFINE TGObjectListItem := TParameter} 310 {$DEFINE TGObjectListList := TObjectListParameter} 311 {$DEFINE TGObjectList := TListParameter} 312 {$DEFINE TGObjectListSortCompare := TObjectListSortCompareParameter} 313 {$DEFINE TGObjectListStringConverter := TObjectListStringConverterParameter} 314 {$DEFINE INTERFACE} 315 {$I 'GenericObjectList.inc'} 316 317 TParameterList = class(TListParameter) 241 318 Parent: TFunction; 242 319 function Search(Name: string): TParameter; … … 261 338 end; 262 339 263 TExpressionList = class(TList Object)340 TExpressionList = class(TListExpression) 264 341 destructor Destroy; override; 265 342 end; … … 278 355 end; 279 356 280 TFunctionList = class(TListObject) 357 // TListFunction = TGObjectList<Integer, TFunction> 358 {$DEFINE TGObjectListIndex := Integer} 359 {$DEFINE TGObjectListItem := TFunction} 360 {$DEFINE TGObjectListList := TObjectListFunction} 361 {$DEFINE TGObjectList := TListFunction} 362 {$DEFINE TGObjectListSortCompare := TObjectListSortCompareFunction} 363 {$DEFINE TGObjectListStringConverter := TObjectListStringConverterFunction} 364 {$DEFINE INTERFACE} 365 {$I 'GenericObjectList.inc'} 366 367 TFunctionList = class(TListFunction) 281 368 Parent: TCommonBlock; 282 369 function Search(Name: string; Exported: Boolean = False): TFunction; … … 291 378 end; 292 379 293 TUsedModuleList = class(TListObject) 380 // TListUsedModule = TGObjectList<Integer, TUsedModule> 381 {$DEFINE TGObjectListIndex := Integer} 382 {$DEFINE TGObjectListItem := TUsedModule} 383 {$DEFINE TGObjectListList := TObjectListUsedModule} 384 {$DEFINE TGObjectList := TListUsedModule} 385 {$DEFINE TGObjectListSortCompare := TObjectListSortCompareUsedModule} 386 {$DEFINE TGObjectListStringConverter := TObjectListStringConverterUsedModule} 387 {$DEFINE INTERFACE} 388 {$I 'GenericObjectList.inc'} 389 390 TUsedModuleList = class(TListUsedModule) 294 391 ParentModule: TModule; 295 392 end; … … 332 429 end; 333 430 431 // TListModule = TGObjectList<Integer, TModule> 432 {$DEFINE TGObjectListIndex := Integer} 433 {$DEFINE TGObjectListItem := TModule} 434 {$DEFINE TGObjectListList := TObjectListModule} 435 {$DEFINE TGObjectList := TListModule} 436 {$DEFINE TGObjectListSortCompare := TObjectListSortCompareModule} 437 {$DEFINE TGObjectListStringConverter := TObjectListStringConverterModule} 438 {$DEFINE INTERFACE} 439 {$I 'GenericObjectList.inc'} 440 334 441 { TModuleList } 335 442 336 TModuleList = class(TList Object)443 TModuleList = class(TListModule) 337 444 function Search(Name: string): TModule; 338 445 end; … … 358 465 implementation 359 466 467 {$DEFINE IMPLEMENTATION_USES} 468 {$I 'GenericObjectList.inc'} 469 470 // TListExpression = TGObjectList<Integer, TExpression> 471 {$DEFINE TGObjectListIndex := Integer} 472 {$DEFINE TGObjectListItem := TExpression} 473 {$DEFINE TGObjectListList := TObjectListExpression} 474 {$DEFINE TGObjectList := TListExpression} 475 {$DEFINE TGObjectListSortCompare := TObjectListSortCompareExpression} 476 {$DEFINE TGObjectListStringConverter := TObjectListStringConverterExpression} 477 {$DEFINE IMPLEMENTATION} 478 {$I 'GenericObjectList.inc'} 479 480 // TListCaseOfEndBranche = TGObjectList<Integer, TCaseOfEndBranche> 481 {$DEFINE TGObjectListIndex := Integer} 482 {$DEFINE TGObjectListItem := TCaseOfEndBranche} 483 {$DEFINE TGObjectListList := TObjectListCaseOfEndBranche} 484 {$DEFINE TGObjectList := TListCaseOfEndBranche} 485 {$DEFINE TGObjectListSortCompare := TObjectListSortCompareCaseOfEndBranche} 486 {$DEFINE TGObjectListStringConverter := TObjectListStringConverterCaseOfEndBranche} 487 {$DEFINE IMPLEMENTATION} 488 {$I 'GenericObjectList.inc'} 489 490 // TCommandList = TGObjectList<Integer, TCommand> 491 {$DEFINE TGObjectListIndex := Integer} 492 {$DEFINE TGObjectListItem := TCommand} 493 {$DEFINE TGObjectListList := TObjectListCommand} 494 {$DEFINE TGObjectList := TCommandList} 495 {$DEFINE TGObjectListSortCompare := TObjectListSortCompareCommand} 496 {$DEFINE TGObjectListStringConverter := TObjectListStringConverterCommand} 497 {$DEFINE IMPLEMENTATION} 498 {$I 'GenericObjectList.inc'} 499 500 // TListEnumItem = TGObjectList<Integer, TEnumItem> 501 {$DEFINE TGObjectListIndex := Integer} 502 {$DEFINE TGObjectListItem := TEnumItem} 503 {$DEFINE TGObjectListList := TObjectListEnumItem} 504 {$DEFINE TGObjectList := TListEnumItem} 505 {$DEFINE TGObjectListSortCompare := TObjectListSortCompareEnumItem} 506 {$DEFINE TGObjectListStringConverter := TObjectListStringConverterEnumItem} 507 {$DEFINE IMPLEMENTATION} 508 {$I 'GenericObjectList.inc'} 509 510 // TListType = TGObjectList<Integer, TType> 511 {$DEFINE TGObjectListIndex := Integer} 512 {$DEFINE TGObjectListItem := TType} 513 {$DEFINE TGObjectListList := TObjectListType} 514 {$DEFINE TGObjectList := TListType} 515 {$DEFINE TGObjectListSortCompare := TObjectListSortCompareType} 516 {$DEFINE TGObjectListStringConverter := TObjectListStringConverterType} 517 {$DEFINE IMPLEMENTATION} 518 {$I 'GenericObjectList.inc'} 519 520 // TListConstant = TGObjectList<Integer, TConstant> 521 {$DEFINE TGObjectListIndex := Integer} 522 {$DEFINE TGObjectListItem := TConstant} 523 {$DEFINE TGObjectListList := TObjectListConstant} 524 {$DEFINE TGObjectList := TListConstant} 525 {$DEFINE TGObjectListSortCompare := TObjectListSortCompareConstant} 526 {$DEFINE TGObjectListStringConverter := TObjectListStringConverterConstant} 527 {$DEFINE IMPLEMENTATION} 528 {$I 'GenericObjectList.inc'} 529 530 // TListVariable = TGObjectList<Integer, TVariable> 531 {$DEFINE TGObjectListIndex := Integer} 532 {$DEFINE TGObjectListItem := TVariable} 533 {$DEFINE TGObjectListList := TObjectListVariable} 534 {$DEFINE TGObjectList := TListVariable} 535 {$DEFINE TGObjectListSortCompare := TObjectListSortCompareVariable} 536 {$DEFINE TGObjectListStringConverter := TObjectListStringConverterVariable} 537 {$DEFINE IMPLEMENTATION} 538 {$I 'GenericObjectList.inc'} 539 540 // TListParameter = TGObjectList<Integer, TParameter> 541 {$DEFINE TGObjectListIndex := Integer} 542 {$DEFINE TGObjectListItem := TParameter} 543 {$DEFINE TGObjectListList := TObjectListParameter} 544 {$DEFINE TGObjectList := TListParameter} 545 {$DEFINE TGObjectListSortCompare := TObjectListSortCompareParameter} 546 {$DEFINE TGObjectListStringConverter := TObjectListStringConverterParameter} 547 {$DEFINE IMPLEMENTATION} 548 {$I 'GenericObjectList.inc'} 549 550 // TListFunction = TGObjectList<Integer, TFunction> 551 {$DEFINE TGObjectListIndex := Integer} 552 {$DEFINE TGObjectListItem := TFunction} 553 {$DEFINE TGObjectListList := TObjectListFunction} 554 {$DEFINE TGObjectList := TListFunction} 555 {$DEFINE TGObjectListSortCompare := TObjectListSortCompareFunction} 556 {$DEFINE TGObjectListStringConverter := TObjectListStringConverterFunction} 557 {$DEFINE IMPLEMENTATION} 558 {$I 'GenericObjectList.inc'} 559 560 // TListUsedModule = TGObjectList<Integer, TUsedModule> 561 {$DEFINE TGObjectListIndex := Integer} 562 {$DEFINE TGObjectListItem := TUsedModule} 563 {$DEFINE TGObjectListList := TObjectListUsedModule} 564 {$DEFINE TGObjectList := TListUsedModule} 565 {$DEFINE TGObjectListSortCompare := TObjectListSortCompareUsedModule} 566 {$DEFINE TGObjectListStringConverter := TObjectListStringConverterUsedModule} 567 {$DEFINE IMPLEMENTATION} 568 {$I 'GenericObjectList.inc'} 569 570 // TListModule = TGObjectList<Integer, TModule> 571 {$DEFINE TGObjectListIndex := Integer} 572 {$DEFINE TGObjectListItem := TModule} 573 {$DEFINE TGObjectListList := TObjectListModule} 574 {$DEFINE TGObjectList := TListModule} 575 {$DEFINE TGObjectListSortCompare := TObjectListSortCompareModule} 576 {$DEFINE TGObjectListStringConverter := TObjectListStringConverterModule} 577 {$DEFINE IMPLEMENTATION} 578 {$I 'GenericObjectList.inc'} 579 360 580 { TFunction } 361 581 … … 404 624 begin 405 625 I := 0; 406 while (I < Count) and (LowerCase( TConstant(Items[I]).Name) <> LowerCase(Name)) do Inc(I);407 if I < Count then Result := TConstant(Items[I])else begin626 while (I < Count) and (LowerCase(Items[I].Name) <> LowerCase(Name)) do Inc(I); 627 if I < Count then Result := Items[I] else begin 408 628 if Assigned(Parent.Parent) then Result := Parent.Parent.Constants.Search(Name) 409 629 else begin … … 482 702 // Search in own list 483 703 I := 0; 484 while (I < Count) and (LowerCase( TType(Items[I]).Name) <> LowerCase(Name)) do Inc(I);485 if I < Count then Result := TType(Items[I])else Result := nil;704 while (I < Count) and (LowerCase(Items[I].Name) <> LowerCase(Name)) do Inc(I); 705 if I < Count then Result := Items[I] else Result := nil; 486 706 487 707 // Search in parent … … 508 728 // Search in own list 509 729 I := 0; 510 while (I < Count) and (LowerCase( TVariable(Items[I]).Name) <> LowerCase(Name)) do Inc(I);730 while (I < Count) and (LowerCase(Items[I].Name) <> LowerCase(Name)) do Inc(I); 511 731 if I < Count then Result := TVariable(Items[I]) else Result := nil; 512 732 … … 553 773 // Search in own list 554 774 I := 0; 555 while (I < Count) and (LowerCase( TFunction(Items[I]).Name) <> LowerCase(Name)) do Inc(I);556 if I < Count then Result := TFunction(Items[I])else Result := nil;775 while (I < Count) and (LowerCase(Items[I].Name) <> LowerCase(Name)) do Inc(I); 776 if I < Count then Result := Items[I] else Result := nil; 557 777 558 778 // Search parent block list … … 611 831 begin 612 832 I := 0; 613 while (I < Count) and (LowerCase( TParameter(Items[I]).Name) <> LowerCase(Name)) do Inc(I);614 if I < Count then Result := TParameter(Items[I])833 while (I < Count) and (LowerCase(Items[I].Name) <> LowerCase(Name)) do Inc(I); 834 if I < Count then Result := Items[I] 615 835 else Result := nil; 616 836 end; … … 668 888 begin 669 889 inherited; 670 Branches := TList Object.Create890 Branches := TListCaseOfEndBranche.Create 671 891 end; 672 892 … … 695 915 begin 696 916 inherited; 697 ParameterExpression := TList Object.Create;917 ParameterExpression := TListExpression.Create; 698 918 end; 699 919 … … 741 961 begin 742 962 I := 0; 743 while (I < Count) and (LowerCase( TModule(Items[I]).Name) <> LowerCase(Name)) do Inc(I);744 if I < Count then Result := TModule(Items[I])else Result := nil;963 while (I < Count) and (LowerCase(Items[I].Name) <> LowerCase(Name)) do Inc(I); 964 if I < Count then Result := Items[I] else Result := nil; 745 965 end; 746 966 … … 756 976 I := 0; 757 977 while (I < UsedModules.Count) and (not Assigned(Result)) do begin 758 Result := TUsedModule(UsedModules[I]).Module.SearchVariable(Name, False);978 Result := UsedModules[I].Module.SearchVariable(Name, False); 759 979 Inc(I); 760 980 end; … … 776 996 I := 0; 777 997 while (I < UsedModules.Count) and (not Assigned(Result)) do begin 778 with TUsedModule(UsedModules[I])do998 with UsedModules[I] do 779 999 if Assigned(Module) then 780 1000 with Module do … … 794 1014 I := 0; 795 1015 while (I < UsedModules.Count) and (not Assigned(Result)) do begin 796 if Assigned( TUsedModule(UsedModules[I]).Module) then797 Result := TUsedModule(UsedModules[I]).Module.SearchFunction(Name, False);1016 if Assigned(UsedModules[I].Module) then 1017 Result := UsedModules[I].Module.SearchFunction(Name, False); 798 1018 Inc(I); 799 1019 end; … … 829 1049 begin 830 1050 inherited; 831 Items := TList Object.Create;1051 Items := TListEnumItem.Create; 832 1052 end; 833 1053 … … 842 1062 constructor TTypeClass.Create; 843 1063 begin 844 Items := TList Object.Create;1064 Items := TListType.Create; 845 1065 end; 846 1066
Note:
See TracChangeset
for help on using the changeset viewer.