home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2000 February
/
Chip_2000-02_cd.bin
/
zkuste
/
Delphi
/
navody
/
tt
/
objvm.exe
/
UNITS
/
CodeGenStack.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
1998-03-10
|
2KB
|
65 lines
unit CodeGenStack;
interface
uses
Classes,ObjCodeGeneration,Code;
type TCodeGenStack=class
protected
fItems:TList;
public
constructor Create;
function Count:integer;
destructor Destroy;override;
function Top:TObjCodeGeneration;
function Second:TObjCodeGeneration;
procedure Push(a:TObjCodeGeneration);
procedure PopDef;
procedure Pop;
procedure RemoveTop;
end;
implementation
constructor TCodeGenStack.Create;
begin
Inherited Create;
fItems:=TList.Create;
end;
function TCodeGenStack.Count;
begin
result:=fItems.Count;
end;
destructor TCodeGenStack.Destroy;
Var i:Integer;
begin
fItems.Free;
Inherited Destroy;
end;
function TCodeGenStack.Top;
begin
Result:=fItems[Count-1];
end;
function TCodeGenStack.Second;
begin
Result:=fItems[Count-2];
end;
procedure TCodeGenStack.Push;
begin
fItems.Add(a);
end;
procedure TCodeGenStack.PopDef;
begin
Second.cGen(Top);
Pop;
end;
procedure TCodeGenStack.Pop;
begin
Top.Code.Free;
Top.Free;
RemoveTop;
end;
procedure TCodeGenStack.RemoveTop;
begin
fItems.Delete(Count-1);
end;
end.