home *** CD-ROM | disk | FTP | other *** search
/ Chip 2000 February / Chip_2000-02_cd.bin / zkuste / Delphi / navody / tt / objvm.exe / UNITS / ObjVM.pas < prev    next >
Pascal/Delphi Source File  |  1998-06-27  |  2KB  |  55 lines

  1. unit ObjVM;
  2.  
  3. interface
  4. uses uObjVM,
  5.      Classes,ObjOp,OpList,RootValue,Code,uExecution,LangVariables,
  6.      ObjOps,ConstValues,LangValue;
  7. type
  8.        { TObjVM is a virtual machine for "objective" languages }
  9.      TObjVM=class(IObjVM)
  10.      public
  11.        Constants:TConstValues;
  12.        function StartExecution(c:TCode):IExecution;override;
  13.      published
  14.        constructor Create(o:TComponent);override;
  15.        destructor  Destroy;override;
  16.        procedure   AddValue(const Name:string;a:ILangValue);override;
  17.        procedure   RemoveValue(a:ILangValue);override;
  18.      end;
  19. implementation
  20. uses Execution,ProxyValue;
  21. function TObjVM.StartExecution;
  22.          Var e:TExecution;
  23.          begin
  24.            e:=TExecution.Create(Self,c);
  25.            e.Root.Add(TProxyValue.CreateFrom(Root));
  26.            e.Root.Add(TLangVariables.Create);
  27.            result:=e;
  28.          end;
  29. constructor TObjVM.Create;
  30.          begin
  31.            Inherited Create(o);
  32.            Root:=TRootValue.Create;
  33.            Ops:=TOpList.Create;
  34.            Constants:=TConstValues.Create;
  35.            Constants.AddValue('Common',TLangVariables.Create);
  36.            Root.Add(Constants);
  37.            ObjOps.Register(Ops);
  38.          end;
  39. destructor  TObjVM.Destroy;
  40.          begin
  41.            Ops.Free;
  42.            Root.Free;
  43.            Inherited Destroy;
  44.          end;
  45. procedure   TObjVM.AddValue;
  46.             begin
  47.               Constants.AddValue(Name,a)
  48.             end;
  49. procedure   TObjVM.RemoveValue;
  50.             begin
  51.               Constants.RemoveValue(a);
  52.             end;
  53.  
  54. end.
  55.