-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathMain.pas
More file actions
94 lines (80 loc) · 2.28 KB
/
Main.pas
File metadata and controls
94 lines (80 loc) · 2.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
unit Main;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, SynEdit, SynHighlighterAsm, SynEditHighlighter,
SynHighlighterPas, ComCtrls, ToolWin, Compiler, CompilerDefines, ImgList, ExtCtrls, SiAuto, SmartInspect;
type
TForm2 = class(TForm)
Log: TSynEdit;
ToolBar1: TToolBar;
btnCompile: TToolButton;
ToolImages: TImageList;
Panel1: TPanel;
cbOptimize: TCheckBox;
OpenDialog: TOpenDialog;
cbAssemble: TCheckBox;
cbModule: TCheckBox;
cbUseBigEndian: TCheckBox;
procedure btnCompileClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure cbAssembleClick(Sender: TObject);
private
{ Private declarations }
FErrors: Integer;
procedure OnMessage(AMessage, AUnit: string; ALine: Integer; ALevel: TMessageLevel);
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
uses
HeaderMessage, D16Assembler, CompilerUtil;
{$R *.dfm}
procedure TForm2.btnCompileClick(Sender: TObject);
begin
if not OpenDialog.Execute then
begin
Exit;
end;
Log.Clear;
CompileFile(OpenDialog.FileName, cbOptimize.Checked, cbAssemble.Checked,
cbModule.Checked, cbUseBigEndian.Checked, OnMessage);
end;
procedure TForm2.cbAssembleClick(Sender: TObject);
begin
cbModule.Enabled := cbAssemble.Checked;
cbUseBigEndian.Enabled := cbAssemble.Checked;
end;
procedure TForm2.FormCreate(Sender: TObject);
//var
// LCompiler: TCompiler;
begin
Log.Text := CWelcomeMessage;
// Log.Clear;
// Log.Gutter.ShowLineNumbers := True;
// LCompiler := TCompiler.Create();
// LCompiler.OnMessage := OnMessage;
// LCompiler.SearchPath.Add('E:\Git\D16Pascal\DemoSource\');
// LCompiler.CompileFile('Demo.pas');
// Log.Lines.Text := Trim(LCompiler.GetDCPUSource());
// RefreshTargetIdent(Log.Lines);
// LCompiler.Free;
end;
procedure TForm2.OnMessage(AMessage, AUnit: string; ALine: Integer;
ALevel: TMessageLevel);
begin
if ALevel = mlNone then
begin
Log.Lines.Add(AMessage);
end
else
begin
Log.Lines.Add('Error in ' + QuotedStr(AUnit) + ' line ' + IntToStr(ALine) + ': ' + AMessage);
Inc(FErrors);
end;
end;
initialization
Si.Enabled := True;
end.