-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathDummyCollection.pas
More file actions
65 lines (54 loc) · 1.48 KB
/
DummyCollection.pas
File metadata and controls
65 lines (54 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
unit DummyCollection;
interface
uses
Classes, Types, Generics.Collections, Operation, CodeELement, DataType, VarDeclaration, ProcDeclaration;
type
TDummyCollection = class(TObject)
private
FVariable: TVarDeclaration;
FOperation: TOperation;
FDataType: TDataType;
FElements: TObjectList<TCodeElement>;
public
constructor Create();
destructor Destroy(); override;
function GetDummyElement(AType: TCodeElementClass): TCodeElement;
property Operation: TOperation read FOperation;
property Variable: TVarDeclaration read FVariable;
property DataType: TDataType read FDataType;
end;
implementation
{ TDummyCollection }
constructor TDummyCollection.Create;
begin
FElements := TObjectList<TCodeElement>.Create(False);
FDataType := TDataType.Create('?', 2, rtNilType);
FOperation := TOperation.Create('?', rtNilType, rtNilType, 2, 2, FDataType, '');
FVariable := TVarDeclaration.Create('?', FDataType);
FElements.Add(FDataType);
FElements.Add(FVariable);
end;
destructor TDummyCollection.Destroy;
begin
FVariable.Free;
FOperation.Free;
FDataType.Free;
FElements.Free;
inherited;
end;
function TDummyCollection.GetDummyElement(
AType: TCodeElementClass): TCodeElement;
var
LElement: TCodeElement;
begin
Result := nil;
for LElement in FElements do
begin
if LElement.InheritsFrom(AType) then
begin
Result := LElement;
Break;
end;
end;
end;
end.