home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2000 February
/
Chip_2000-02_cd.bin
/
zkuste
/
Delphi
/
navody
/
tt
/
objvm.exe
/
update.txt
< prev
Wrap
Text File
|
1999-01-27
|
5KB
|
164 lines
ìá⌐ñÑ¡¡δÑ íáú¿ ¿ ºá¼Ñτá¡¿∩ ñ½∩:
D1,2,C++ Builder: ü¿í½¿«ΓÑ¬á ¬«¼»«¡Ñ¡Γ ñ½∩ ¬«¼»¿½∩µ¿¿.
üѽπú¿¡ îá¬ß¿¼, 20.06.1997, 05.11.1997, 26.02.98
FidoNet:2:5020/484.28
mailto: belugin@bsd.lanit.ru
http://www.geocities.com/SiliconValley/Pines/1605
ß«ßΓáó¿Γѽ∞ ïáúπ¡«ó ǽѬßÑ⌐ Ç¡áΓ«½∞Ñó¿τ.
mailto: alexs@n10.ft.stavropol.ru
FidoNet:2:5064/13.50
ä½∩ πßΓá¡ó¬¿ óßÑσ ¬«¼»«¡Ñ¡Γ ß«ºñá½ ¡«óδ⌐ »á¬ÑΓ:comp_belugin.dpk
1.ä½∩ πßΓá¡«ó¬¿ ¬«¼»«¡Ñ¡Γ »«ñ Delphi 4.0 ¡πª¡« ñ«íáó¿Γ∞ ß½ÑñπεΘ¿Ñ ßΓ᫬¿
(¿ß»«½∞ºπÑΓß∩ í¿í½¿«ΓѬá RxLib)
Σá⌐½ Comped;
ó ¡áτὫ Σá⌐½á ñ«íáó½∩Ѽ
{$I RX.INC}
ßαáºπ »«ß½Ñ ß»¿ß¬á »«ñ¬½ετÑ¡¡δσ ¼«ñπ½Ñ⌐ uses
{$IFDEF RX_D4}
type
TDesigner = IDesigner;
TFormDesigner = IFormDesigner;
{$ENDIF}
Γ«ªÑ ßá¼«Ñ ñ½∩ Σá⌐½á Execed;
2.ÄíΩÑ¬Γ¡á∩ ó¿αΓπá½∞¡á∩ ¼áΦ¿¡á
Σá⌐½ ObjOps.pas:
¼ÑΓ«ñ:
function TOrOp.DoOp;
begin
Result:=Inherited DoOp(a,b);
Result.AsBoolean:=a.AsBoolean and b.AsBoolean;
end; // ^^^
»« ¼«Ñ¼π ñ«½ª¡« íδΓ∞
function TOrOp.DoOp;
begin
Result:=Inherited DoOp(a,b);
Result.AsBoolean:=a.AsBoolean or b.AsBoolean;
end; // ^^
3. é«Γ φΓ« - τΓ«íδ íδßΓαÑ⌐ αáí«ΓὫ
OpList:
function TOpList.Find;
Var i:Integer;
begin
Result:=nil;
for i:=0 to fList.Count-1 do
begin
if (fList.Obj[i] as TObjOp).OpCode=OpCode then
begin
Result:=fList.Obj[i] as TObjOp;
exit;//!!! (c) alexs
end;
end;
end;
4. ùΓ«íδ ºá¬αδóá½áß∞ Σ«α¼á αÑñá¬Γ«αá ¬«¼»¿½∩Γ«αá »α¿ πñá½Ñ¡¿¿ TCompiler-á
¼«ñπ½∞ Compiler;
{TCompiler provides lexical and grammar parse }
TCompiler = class(TComponent)
private
{ Private declarations }
fLexems:TLexInfLs;
....
....
....
procedure wrOnCompile(Rule:Integer;a:TRuleEvent);
public
fEditWind:TObject; //(c) alexs
{}
procedure write(w:TWRiter);
procedure read(r:TReader);
destructor TCompiler.Destroy;
begin
if fEditWind<>nil then //(c) by alexs
fEditWind.Free;
¼«ñπ½∞ Comped;
constructor TCompEdForm.Create;
Var i:Integer;
begin
Inherited Create(o);
Comp.fEditWind:=Self; //(c) alexs
fComp:=Comp;
....
....
....
procedure TCompEdForm.FormDestroy(Sender: TObject);
begin
Comp.fEditWind:=nil; //(c) alexs
{ Modif;
ReadRLFromS(fComp.Rules,RulesGrid.Cols[1],fComp.Lexems);
fErrEd.Destroy; }
end;
5. ùΓ«íδ ó« óαѼ∩ ¬«¼»¿½∩µ¿¿ «Γ«íαáªáΓ∞ »α«úαÑß:
óß½Ññ ºá «εΩ∩ó½Ñ¡¿Ñ¼ TCompiler-a «íΩ∩ó¿¼ Γ¿»:
TCompilerProgress = procedure(Sender: TCompiler; LineNo: Integer) of object;
ó »α¿óáΓ¡«⌐ τáßΓ¿ TCompiler óóÑñ±¼ »ÑαѼѡ¡πε
fOnCompilerProgress:TCompilerProgress;
á ó «»πí½¿¬«óá¡¡«⌐ «íΩ∩ó¿¼ ßó«⌐ßΓó«
property OnCompilerProgress:TCompilerProgress read fOnCompilerProgress write fOnCompilerProgress;
»ÑαÑ»¿ΦѼ ¼ÑΓ«ñ TCompiler.AcceptStrings ß½Ññ. «íαẫ¼
function TCompiler.AcceptStrings;
Var i:integer;
begin
for i:=0 to s.COunt-1 do
begin
if not AcceptString(LineNo+i,s[i]) then
begin
Result:=False;
break;
end;
if Assigned(OnCompilerProgress) then //(c) alex
OnCompilerProgress(Self, i);
end;
end;
6.ê¡«úñá 󫺡¿¬áÑΓ ¡Ñ«íσ«ñ¿¼«ßΓ∞ »αÑαóáΓ∞ óδ»«½¡Ñ¡¿Ñ ß¬α¿»Γá.
»«φΓ«¼π ßñѽὠ߽ÑñπεΘ¿Ñ ¿º¼Ñ¡Ñ¡¿∩
ó ¼«ñπ½Ñ uObjVM;
½«¬á½∞¡πε »ÑαѼѡ¡πε ¿º ¼ÑΓ«ñá procedure IObjVM.Run
»ÑαÑ¿¼Ñ¡«óá½ ó Executor ¿ óδ¡Ñß ó «íΩ∩ó½Ñ¡¿Ñ «íΩѬΓá IObjVM.
é ¡Ñú« ªÑ ñ«íáó¿½ ¡«óδ⌐ ¼ÑΓ«ñ:
procedure IObjVM.Halt;
begin
Executor.IsEnd:=true;
end;
7.ä«íáó¿½ ó «íΩÑ¬Γ TCode ñóá ¼ÑΓ«ñá (»α«ßΓ« ¼¡Ñ πñ«í¡« ß«σαá¡∩Γ∞ ¬«ñ ó
¼Ñ¼«-Σá⌐½, τΓ«íδ ¡Ñ »½«ñ¿Γ∞ ¬πτπ ¼Ñ½¬¿σ Σá⌐½¿¬«ó)
¼«ñπ½∞ Code;
{Load code from stream}
procedure TCode.LoadFromStream(S:TStream);
var r:TReader;
begin
r:=TReader.Create(S,1024);
Size:=r.ReadInteger;
r.Read(Body^,Size);
r.Free;
end;
{Save code to stream}
procedure TCode.SaveToStream(S:TStream);
var w:TWriter;
begin
w:=TWriter.Create(S,1024);
w.writeInteger(Size);
w.write(Body^,Size);
w.Free;
end;