home *** CD-ROM | disk | FTP | other *** search
/ Chip 2000 February / Chip_2000-02_cd.bin / zkuste / Delphi / navody / tt / objvm.exe / update.txt < prev   
Text File  |  1999-01-27  |  5KB  |  164 lines

  1. ìá⌐ñÑ¡¡δÑ íáú¿ ¿ ºá¼Ñτá¡¿∩ ñ½∩:
  2.  
  3.  D1,2,C++ Builder: ü¿í½¿«ΓѬᠬ«¼»«¡Ñ¡Γ ñ½∩ ¬«¼»¿½∩µ¿¿.
  4.                             üѽπú¿¡ îá¬ß¿¼, 20.06.1997, 05.11.1997, 26.02.98
  5.                             FidoNet:2:5020/484.28
  6.                             mailto: belugin@bsd.lanit.ru
  7.                             http://www.geocities.com/SiliconValley/Pines/1605
  8.  
  9. ß«ßΓáó¿Γѽ∞ ïáúπ¡«ó Ç½Ñ¬ßÑ⌐ Ç¡áΓ«½∞Ñó¿τ.
  10.                             mailto: alexs@n10.ft.stavropol.ru
  11.                             FidoNet:2:5064/13.50
  12.  
  13. ä½∩ πßΓá¡ó¬¿ óßÑ󠬫¼»«¡Ñ¡Γ ß«ºñá½ ¡«óδ⌐ »á¬ÑΓ:comp_belugin.dpk 
  14.  
  15. 1.ä½∩ πßΓᡫ󬿠¬«¼»«¡Ñ¡Γ »«ñ Delphi 4.0 ¡πª¡« ñ«íáó¿Γ∞ ß½ÑñπεΘ¿Ñ ßΓ᫬¿
  16.  (¿ß»«½∞ºπÑΓß∩ í¿í½¿«ΓѬá RxLib)
  17.  Σá⌐½ Comped;
  18.   ó ¡áτὫ Σá⌐½á ñ«íáó½∩Ѽ
  19.    {$I RX.INC}
  20.   ßαáºπ »«ß½Ñ ß»¿ß¬á »«ñ¬½ετÑ¡¡δσ ¼«ñπ½Ñ⌐ uses
  21.    {$IFDEF RX_D4}
  22.    type
  23.       TDesigner = IDesigner;
  24.       TFormDesigner = IFormDesigner;
  25.    {$ENDIF}
  26.  Γ«ªÑ ßἫѠñ½∩ Σá⌐½á Execed;
  27.  
  28. 2.ÄíΩÑ¬Γ¡á∩ ó¿αΓπá½∞¡á∩ ¼áΦ¿¡á
  29. Σá⌐½ ObjOps.pas:
  30. ¼ÑΓ«ñ:
  31. function TOrOp.DoOp;
  32.          begin
  33.            Result:=Inherited DoOp(a,b);
  34.            Result.AsBoolean:=a.AsBoolean and b.AsBoolean;
  35.          end;                         // ^^^
  36. »« ¼«Ñ¼π ñ«½ª¡« íδΓ∞
  37. function TOrOp.DoOp;
  38.          begin
  39.            Result:=Inherited DoOp(a,b);
  40.            Result.AsBoolean:=a.AsBoolean or b.AsBoolean; 
  41.          end;                         // ^^
  42.  
  43. 3. é«Γ φΓ« - τΓ«íδ íδßΓαÑ⌐ αáí«ΓὫ
  44. OpList:
  45. function    TOpList.Find;
  46.             Var i:Integer;
  47.             begin
  48.               Result:=nil;
  49.               for i:=0 to fList.Count-1 do
  50.               begin
  51.                 if (fList.Obj[i] as TObjOp).OpCode=OpCode then
  52.                 begin
  53.                   Result:=fList.Obj[i] as TObjOp;
  54.                   exit;//!!! (c) alexs
  55.                 end;
  56.               end;
  57.             end;
  58.  
  59. 4. ùΓ«íδ ºá¬αδóá½áß∞ Σ«α¼á αÑñá¬Γ«αá ¬«¼»¿½∩Γ«αá »α¿ πñá½Ñ¡¿¿ TCompiler-á
  60. ¼«ñπ½∞ Compiler;
  61.  
  62.   {TCompiler provides lexical and grammar parse }
  63.   TCompiler = class(TComponent)
  64.   private
  65.     { Private declarations }
  66.     fLexems:TLexInfLs;
  67.             ....
  68.             ....
  69.             ....
  70.     procedure wrOnCompile(Rule:Integer;a:TRuleEvent);
  71.   public
  72.     fEditWind:TObject;      //(c) alexs
  73.     {}
  74.     procedure write(w:TWRiter);
  75.     procedure read(r:TReader);
  76.  
  77. destructor TCompiler.Destroy;
  78.             begin
  79.               if fEditWind<>nil then //(c) by alexs
  80.                  fEditWind.Free;
  81.  
  82. ¼«ñπ½∞ Comped;
  83. constructor TCompEdForm.Create;
  84.             Var i:Integer;
  85.             begin
  86.               Inherited Create(o);
  87.               Comp.fEditWind:=Self; //(c) alexs
  88.               fComp:=Comp;
  89.             ....
  90.             ....
  91.             ....
  92.  
  93. procedure TCompEdForm.FormDestroy(Sender: TObject);
  94. begin
  95.   Comp.fEditWind:=nil; //(c) alexs
  96. {  Modif;
  97.   ReadRLFromS(fComp.Rules,RulesGrid.Cols[1],fComp.Lexems);
  98.   fErrEd.Destroy;                                         }
  99. end;
  100.  
  101. 5. ùΓ«íδ ó« óαѼ∩ ¬«¼»¿½∩µ¿¿ «Γ«íαáªáΓ∞ »α«úαÑß:
  102.  
  103. óß½Ññ ºá «εΩ∩ó½Ñ¡¿Ñ¼ TCompiler-a «íΩ∩ó¿¼ Γ¿»:
  104.   TCompilerProgress = procedure(Sender: TCompiler; LineNo: Integer) of object;
  105.  
  106. ó »α¿óáΓ¡«⌐ τáßΓ¿ TCompiler óóÑñ±¼ »ÑαѼѡ¡πε
  107.     fOnCompilerProgress:TCompilerProgress;
  108.  
  109. á ó «»πí½¿¬«óá¡¡«⌐ «íΩ∩ó¿¼ ßó«⌐ßΓó«
  110.     property OnCompilerProgress:TCompilerProgress read fOnCompilerProgress write fOnCompilerProgress;
  111.  
  112. »ÑαÑ»¿ΦѼ ¼ÑΓ«ñ TCompiler.AcceptStrings ß½Ññ. «íαẫ¼
  113. function TCompiler.AcceptStrings;
  114.           Var i:integer;
  115.           begin
  116.             for i:=0 to s.COunt-1 do
  117.             begin
  118.               if not AcceptString(LineNo+i,s[i]) then
  119.               begin
  120.                 Result:=False;
  121.                 break;
  122.               end;
  123.               if Assigned(OnCompilerProgress) then //(c) alex
  124.                  OnCompilerProgress(Self, i);
  125.             end;
  126.           end;
  127.  
  128. 6.ê¡«úñá ó«º¡¿¬áÑΓ ¡Ñ«íσ«ñ¿¼«ßΓ∞ »αÑαóáΓ∞ óδ»«½¡Ñ¡¿Ñ ß¬α¿»Γá.
  129. »«φΓ«¼π ßñѽὠ߽ÑñπεΘ¿Ñ ¿º¼Ñ¡Ñ¡¿∩
  130.  
  131. 󠼫ñπ½Ñ uObjVM;
  132.   ½«¬á½∞¡πε »ÑαѼѡ¡πε ¿º ¼ÑΓ«ñá procedure IObjVM.Run 
  133.   »ÑαÑ¿¼Ñ¡«óá½ ó Executor ¿ óδ¡Ñß ó «íΩ∩ó½Ñ¡¿Ñ «íΩѬΓá IObjVM.
  134.  
  135.   é ¡Ñú« ªÑ ñ«íáó¿½ ¡«óδ⌐ ¼ÑΓ«ñ:
  136. procedure IObjVM.Halt;
  137. begin
  138.   Executor.IsEnd:=true;
  139. end;
  140.  
  141. 7.ä«íáó¿½ ó «íΩÑ¬Γ TCode ñóá ¼ÑΓ«ñá (»α«ßΓ« ¼¡Ñ πñ«í¡« ß«σαá¡∩Γ∞ ¬«ñ ó
  142.  ¼Ñ¼«-Σá⌐½, τΓ«íδ ¡Ñ »½«ñ¿Γ∞ ¬πτπ ¼Ñ½¬¿σ Σá⌐½¿¬«ó)
  143. ¼«ñπ½∞ Code;
  144. {Load code from stream}
  145. procedure TCode.LoadFromStream(S:TStream);
  146. var r:TReader;
  147. begin
  148.   r:=TReader.Create(S,1024);
  149.   Size:=r.ReadInteger;
  150.   r.Read(Body^,Size);
  151.   r.Free;
  152. end;
  153.  
  154. {Save code to stream}
  155. procedure TCode.SaveToStream(S:TStream);
  156. var w:TWriter;
  157. begin
  158.   w:=TWriter.Create(S,1024);
  159.   w.writeInteger(Size);
  160.   w.write(Body^,Size);
  161.   w.Free;
  162. end;
  163.  
  164.