Changeset 222 for branches/interpreter2/Forms
- Timestamp:
- Nov 25, 2020, 12:18:45 AM (4 years ago)
- Location:
- branches/interpreter2/Forms
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/interpreter2/Forms/UFormMain.lfm
r221 r222 48 48 end 49 49 object MainMenu1: TMainMenu 50 Left = 7 9051 Top = 7 5350 Left = 760 51 Top = 760 52 52 object MenuItemFile: TMenuItem 53 53 Caption = 'File' … … 99 99 Caption = 'Run' 100 100 OnExecute = ARunExecute 101 ShortCut = 120 101 102 end 102 103 object ACompile: TAction 103 104 Caption = 'Compile' 104 105 OnExecute = ACompileExecute 106 ShortCut = 16497 105 107 end 106 108 object AExit: TAction -
branches/interpreter2/Forms/UFormMain.pas
r221 r222 7 7 uses 8 8 Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, Menus, 9 ActnList, ExtCtrls, SynHighlighterPas, SynEdit, USource, UOptimizer; 9 ActnList, ExtCtrls, SynHighlighterPas, SynEdit, USource, UOptimizer, 10 UGenerator; 10 11 11 12 type … … 52 53 Prog: TProgram; 53 54 Initialized: Boolean; 55 procedure Generate(GeneratorClass: TGeneratorClass); 54 56 procedure ExecutorOutput(Text: string); 55 57 procedure InterpreterError(Pos: TPoint; Text: string); … … 90 92 procedure TFormMain.FormDestroy(Sender: TObject); 91 93 begin 92 if Assigned(Prog) then Prog.Free;94 if Assigned(Prog) then FreeAndNil(Prog); 93 95 end; 94 96 … … 99 101 DockForm(FormOutput, PanelOutput); 100 102 UpdateInterface; 103 end; 104 105 procedure TFormMain.Generate(GeneratorClass: TGeneratorClass); 106 var 107 Generator: TGenerator; 108 TargetFileName: string; 109 begin 110 Generator := GeneratorClass.Create; 111 try 112 Generator.Prog := Prog; 113 Generator.Generate; 114 FormOutput.SetText(Generator.Output); 115 TargetFileName := 'Generated' + DirectorySeparator + 116 Generator.Name + DirectorySeparator + 'Test' + Generator.FileExt; 117 ForceDirectories(ExtractFileDir(TargetFileName)); 118 FormOutput.SynEditOutput.Lines.SaveToFile(TargetFileName); 119 finally 120 Generator.Free; 121 end; 101 122 end; 102 123 … … 122 143 123 144 procedure TFormMain.AGenerateCSharpExecute(Sender: TObject); 124 var125 Generator: TGeneratorCSharp;126 145 begin 127 146 ACompile.Execute; … … 130 149 FormOutput.Clear; 131 150 if Assigned(Prog) then begin 132 Generator := TGeneratorCSharp.Create; 133 Generator.Prog := Prog; 134 Generator.Generate; 135 FormOutput.SetText(Generator.Output); 136 Generator.Free; 137 FormOutput.SynEditOutput.Lines.SaveToFile('Generated' + DirectorySeparator + 'Test.cs'); 151 Generate(TGeneratorCSharp); 138 152 end; 139 153 end; 140 154 141 155 procedure TFormMain.AGeneratePascalExecute(Sender: TObject); 142 var143 Generator: TGeneratorPascal;144 156 begin 145 157 ACompile.Execute; … … 147 159 FormOutput.SynEditOutput.Lines.Clear; 148 160 if Assigned(Prog) then begin 149 Generator := TGeneratorPascal.Create; 150 Generator.Prog := Prog; 151 Generator.Generate; 152 FormOutput.SynEditOutput.Lines.Text := Generator.Output; 153 Generator.Free; 154 FormOutput.SynEditOutput.Lines.SaveToFile('Generated' + DirectorySeparator + 'Test.pas'); 161 Generate(TGeneratorPascal); 155 162 end; 156 163 end; 157 164 158 165 procedure TFormMain.AGeneratePhpExecute(Sender: TObject); 159 var160 Generator: TGeneratorPhp;161 166 begin 162 167 ACompile.Execute; … … 165 170 FormOutput.SynEditOutput.Lines.Clear; 166 171 if Assigned(Prog) then begin 167 Generator := TGeneratorPhp.Create; 168 Generator.Prog := Prog; 169 Generator.Generate; 170 FormOutput.SynEditOutput.Lines.Text := Generator.Output; 171 Generator.Free; 172 FormOutput.SynEditOutput.Lines.SaveToFile('Generated' + DirectorySeparator + 'Test.php'); 172 Generate(TGeneratorPhp); 173 173 end; 174 174 end; 175 175 176 176 procedure TFormMain.AGenerateXmlExecute(Sender: TObject); 177 var178 Generator: TGeneratorXml;179 177 begin 180 178 ACompile.Execute; … … 182 180 FormOutput.SynEditOutput.Lines.Clear; 183 181 if Assigned(Prog) then begin 184 Generator := TGeneratorXml.Create; 185 Generator.Prog := Prog; 186 Generator.Generate; 187 FormOutput.SynEditOutput.Lines.Text := Generator.Output; 188 Generator.Free; 189 FormOutput.SynEditOutput.Lines.SaveToFile('Generated' + DirectorySeparator + 'Test.xml'); 182 Generate(TGeneratorXml); 190 183 end; 191 184 end;
Note:
See TracChangeset
for help on using the changeset viewer.