source: branches/virtcpu varint/Forms/UFormAssembler.pas

Last change on this file was 197, checked in by chronos, 5 years ago
  • Modified: All parts of virtual machine have own form in Forms subdirectory.
  • Modified: Main form moved to Forms subdirectory.
  • Modified: TCpu class moved to UCpu unit.
  • Added: Assembler and dissasembler forms.
File size: 1.7 KB
Line 
1unit UFormAssembler;
2
3{$mode delphi}
4
5interface
6
7uses
8 Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, UAssembler;
9
10type
11
12 { TFormAssembler }
13
14 TFormAssembler = class(TForm)
15 ButtonCompile: TButton;
16 ButtonLoadFromFile: TButton;
17 ButtonSaveToFile: TButton;
18 MemoMessages: TMemo;
19 MemoSource: TMemo;
20 OpenDialog1: TOpenDialog;
21 SaveDialog1: TSaveDialog;
22 procedure ButtonCompileClick(Sender: TObject);
23 procedure ButtonLoadFromFileClick(Sender: TObject);
24 procedure ButtonSaveToFileClick(Sender: TObject);
25 procedure FormCreate(Sender: TObject);
26 procedure FormDestroy(Sender: TObject);
27 private
28 procedure DoCompileMessage(Text: string);
29 public
30 Assembler: TAssembler;
31 end;
32
33var
34 FormAssembler: TFormAssembler;
35
36implementation
37
38{$R *.lfm}
39
40{ TFormAssembler }
41
42procedure TFormAssembler.ButtonLoadFromFileClick(Sender: TObject);
43begin
44 if OpenDialog1.Execute then
45 MemoSource.Lines.LoadFromFile(OpenDialog1.FileName);
46end;
47
48procedure TFormAssembler.ButtonCompileClick(Sender: TObject);
49begin
50 Assembler.Source.Assign(MemoSource.Lines);
51 Assembler.Compile;
52end;
53
54procedure TFormAssembler.ButtonSaveToFileClick(Sender: TObject);
55begin
56 if SaveDialog1.Execute then
57 MemoSource.Lines.SaveToFile(SaveDialog1.FileName);
58end;
59
60procedure TFormAssembler.FormCreate(Sender: TObject);
61begin
62 Assembler := TAssembler.Create;
63 Assembler.OnError := DoCompileMessage;
64end;
65
66procedure TFormAssembler.FormDestroy(Sender: TObject);
67begin
68 FreeAndNil(Assembler);
69end;
70
71procedure TFormAssembler.DoCompileMessage(Text: string);
72begin
73 MemoMessages.Lines.Add(Text);
74end;
75
76end.
77
Note: See TracBrowser for help on using the repository browser.