Changeset 230 for branches/xpascal/Source.pas
- Timestamp:
- Jun 26, 2023, 12:08:45 PM (17 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/xpascal/Source.pas
r224 r230 4 4 5 5 uses 6 Classes, SysUtils, Contnrs;6 Classes, SysUtils, Generics.Collections; 7 7 8 8 type … … 24 24 end; 25 25 26 TFields = class(TObjectList )26 TFields = class(TObjectList<TField>) 27 27 end; 28 28 … … 50 50 end; 51 51 52 { TSourceNode s}53 54 TSourceNode s= class(TSourceNode)52 { TSourceNodeList } 53 54 TSourceNodeList<T> = class(TSourceNode) 55 55 private 56 56 Parent: TSourceNode; 57 57 function GetCount: Integer; 58 function GetItem(Index: Integer): T Object;59 procedure SetItem(Index: Integer; AValue: T Object);60 public 61 List: TObjectList ;58 function GetItem(Index: Integer): T; 59 procedure SetItem(Index: Integer; AValue: T); 60 public 61 List: TObjectList<TSourceNode>; 62 62 procedure Clear; 63 function Add(AObject: T Object): Integer;63 function Add(AObject: T): Integer; 64 64 constructor Create; 65 65 destructor Destroy; override; 66 property Items[Index: Integer]: T Objectread GetItem write SetItem; default;66 property Items[Index: Integer]: T read GetItem write SetItem; default; 67 67 property Count: Integer read GetCount; 68 68 end; … … 115 115 { TTypes } 116 116 117 TTypes = class(TSourceNode s)117 TTypes = class(TSourceNodeList<TType>) 118 118 function SearchByName(Name: string): TType; 119 119 function AddNew(Name: string): TType; … … 136 136 { TVariables } 137 137 138 TVariables = class(TSourceNode s)138 TVariables = class(TSourceNodeList<TVariable>) 139 139 function SearchByName(Name: string): TVariable; 140 140 end; … … 157 157 { TConstants } 158 158 159 TConstants = class(TSourceNode s)159 TConstants = class(TSourceNodeList<TConstant>) 160 160 function SearchByName(Name: string): TConstant; 161 161 function AddNew(Name: string): TConstant; 162 162 end; 163 164 TFunctionParamKind = (pkNormal, pkVar, pkConst); 163 165 164 166 TFunctionParameter = class(TSourceNode) 165 167 Name: string; 166 168 TypeRef: TType; 169 Kind: TFunctionParamKind; 167 170 end; 168 171 169 172 { TFunctionParameters } 170 173 171 TFunctionParameters = class(TSourceNode s)174 TFunctionParameters = class(TSourceNodeList<TFunctionParameter>) 172 175 function SearchByName(Name: string): TFunctionParameter; 173 176 function AddNew(Name: string; TypeRef: TType): TFunctionParameter; … … 195 198 { TFunctions } 196 199 197 TFunctions = class(TSourceNode s)200 TFunctions = class(TSourceNodeList<TFunction>) 198 201 ParentType: TType; 199 202 function SearchByName(Name: string): TFunction; … … 204 207 end; 205 208 206 TCommands = class(TSourceNode s)209 TCommands = class(TSourceNodeList<TCommand>) 207 210 end; 208 211 … … 302 305 end; 303 306 304 TExpressions = class(TSourceNode s)307 TExpressions = class(TSourceNodeList<TExpression>) 305 308 end; 306 309 … … 565 568 end; 566 569 567 { TSourceNode s}568 569 function TSourceNode s.GetCount: Integer;570 { TSourceNodeList } 571 572 function TSourceNodeList<T>.GetCount: Integer; 570 573 begin 571 574 Result := List.Count; 572 575 end; 573 576 574 function TSourceNode s.GetItem(Index: Integer): TObject;575 begin 576 Result := List[Index];577 end; 578 579 procedure TSourceNode s.SetItem(Index: Integer; AValue: TObject);577 function TSourceNodeList<T>.GetItem(Index: Integer): T; 578 begin 579 Result := T(List[Index]); 580 end; 581 582 procedure TSourceNodeList<T>.SetItem(Index: Integer; AValue: T); 580 583 begin 581 584 List[Index] := AValue; 582 585 end; 583 586 584 procedure TSourceNode s.Clear;587 procedure TSourceNodeList<T>.Clear; 585 588 begin 586 589 List.Clear; 587 590 end; 588 591 589 function TSourceNode s.Add(AObject: TObject): Integer;592 function TSourceNodeList<T>.Add(AObject: T): Integer; 590 593 begin 591 594 Result := List.Add(AObject); 592 595 end; 593 596 594 constructor TSourceNode s.Create;595 begin 596 List := TObjectList .Create;597 end; 598 599 destructor TSourceNode s.Destroy;597 constructor TSourceNodeList<T>.Create; 598 begin 599 List := TObjectList<TSourceNode>.Create; 600 end; 601 602 destructor TSourceNodeList<T>.Destroy; 600 603 begin 601 604 FreeAndNil(List); … … 1095 1098 procedure TExpressionOperation.SetValue(Index: Integer; var Value); 1096 1099 begin 1097 Items[Index] := T Object(Value);1100 Items[Index] := TExpression(Value); 1098 1101 end; 1099 1102
Note:
See TracChangeset
for help on using the changeset viewer.