-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCILStack.pas
More file actions
81 lines (68 loc) · 1.18 KB
/
Copy pathCILStack.pas
File metadata and controls
81 lines (68 loc) · 1.18 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
unit CILStack;
interface
uses
SysUtils,
Variants,
Classes,
CILExpr;
type
TCILStack = class(TList)
private
//FItems: array of TCILExpr;
//FCnt : integer;
public
constructor Create;
procedure PushExpr(FReg: TCILExpr);
function PopExpr: TCILExpr;
function PeekExpr: TCILExpr;
procedure Clear;
function GetCount: integer;
destructor Destroy;
end;
implementation
constructor TCILStack.Create;
begin
inherited Create;
end;
procedure TCILStack.PushExpr(FReg: TCILExpr);
begin
Add(FReg.AddRef);
end;
function TCILStack.PopExpr: TCILExpr;
begin
if Count<1 then begin
Result:= TCILLabel.Create('A');
Exit;
end;
//TCILExpr(Items[Count-1]).RmRef;
Result:= TCILExpr(Items[Count-1]);
Delete(Count-1);
end;
function TCILStack.PeekExpr: TCILExpr;
begin
if Count<1 then
Exit;
Result:= TCILExpr(Items[Count-1]);
end;
function TCILStack.GetCount: integer;
begin
Result:= Count;
end;
procedure TCILStack.Clear;
var
i: integer;
begin
for i:=0 to Count-1 do begin
TCILExpr(Items[i]).Free;
end;
end;
destructor TCILStack.Destroy;
var
i: integer;
begin
for i:=0 to Count-1 do begin
TCILExpr(Items[i]).Free;
end;
inherited Destroy;
end;
end.