home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2000 February
/
Chip_2000-02_cd.bin
/
zkuste
/
Delphi
/
navody
/
tt
/
objvm.exe
/
UNITS
/
LangVariable.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
1998-06-27
|
2KB
|
66 lines
unit LangVariable;
interface
uses LangValue;
type
{ Variable for language }
TLangVariable=class(ILangValue)
protected
function rdValues(const s:string):ILangValue;override;
public
Value:ILangValue;
constructor Create;
destructor Destroy;override;
procedure Exec(S:IValStack;MustReturn:boolean);override;
function HasValue(const s:string):boolean;override;
function CreateEqu:ILangValue;override;
end;
implementation
uses VarLangValue,SysUtils,LangRef;
const cRef='Ref';
function TLangVariable.rdValues;
begin
if S=cRef then
Result:=TLangRef.Create(Self)
else
Result:=Value.Values[s];
end;
procedure TLangVariable.Exec;
begin
if S.FrameCount>1 then
raise Exception.Create('Try to assign more than 1 value');
if S.FrameCount>0 then
begin
Value.Free;
Value:=s.FrameValues[0].CreateEqu;
end;
s.DropFrame;
if MustReturn then
begin
S.Push(Value.CreateEqu);
end;
end;
function TLangVariable.HasValue;
begin
if s=cRef
then
Result:=true
else
Result:=Value.HasValue(s);
end;
function TLangVariable.CreateEqu;
begin
Result:=nil;
end;
constructor TLangVariable.Create;
begin
inherited Create(nil);
Value:=TVarLangValue.Create(nil);
end;
destructor TLangVariable.Destroy;
begin
Value.Free;
inherited Destroy;
end;
end.