Changeset 19
- Timestamp:
- Feb 11, 2012, 10:18:19 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Languages/LazFuckIDE.cs.po
r18 r19 189 189 msgstr "Nástroje" 190 190 191 #: tmainform.menuitem40.caption192 msgid "Target"193 msgstr "CÃl"194 195 191 #: tmainform.menuitem5.caption 196 192 msgctxt "tmainform.menuitem5.caption" … … 202 198 msgstr "Program" 203 199 200 #: tmainform.menuitemtarget.caption 201 msgctxt "tmainform.menuitemtarget.caption" 202 msgid "Target" 203 msgstr "CÃl" 204 204 205 #: tmainform.toolbutton5.caption 205 206 msgid "ToolButton5" -
trunk/Languages/LazFuckIDE.po
r18 r19 180 180 msgstr "" 181 181 182 #: tmainform.menuitem40.caption183 msgid "Target"184 msgstr ""185 186 182 #: tmainform.menuitem5.caption 187 183 msgctxt "tmainform.menuitem5.caption" … … 193 189 msgstr "" 194 190 191 #: tmainform.menuitemtarget.caption 192 msgctxt "TMAINFORM.MENUITEMTARGET.CAPTION" 193 msgid "Target" 194 msgstr "" 195 195 196 #: tmainform.toolbutton5.caption 196 197 msgid "ToolButton5" -
trunk/LazFuckIDE.lpi
r18 r19 85 85 </Item5> 86 86 </RequiredPackages> 87 <Units Count=" 7">87 <Units Count="10"> 88 88 <Unit0> 89 89 <Filename Value="LazFuckIDE.lpr"/> … … 129 129 <UnitName Value="UOptionsForm"/> 130 130 </Unit6> 131 <Unit7> 132 <Filename Value="Compiler\UCompiler.pas"/> 133 <IsPartOfProject Value="True"/> 134 <UnitName Value="UCompiler"/> 135 </Unit7> 136 <Unit8> 137 <Filename Value="Compiler\UCompilerDelphi.pas"/> 138 <IsPartOfProject Value="True"/> 139 <UnitName Value="UCompilerDelphi"/> 140 </Unit8> 141 <Unit9> 142 <Filename Value="Compiler\UCompilerPHP.pas"/> 143 <IsPartOfProject Value="True"/> 144 <UnitName Value="UCompilerPHP"/> 145 </Unit9> 131 146 </Units> 132 147 </ProjectOptions> … … 139 154 <SearchPaths> 140 155 <IncludeFiles Value="$(ProjOutDir)"/> 156 <OtherUnitFiles Value="Compiler"/> 141 157 <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/> 142 158 </SearchPaths> -
trunk/LazFuckIDE.lpr
r15 r19 9 9 {$ENDIF} 10 10 Interfaces, // this includes the LCL widgetset 11 Forms, UMainForm, UBrainFuck, UInterpreterForm, UApplicationInfo, 12 UCompiledForm, UOptionsForm, CoolTranslator, Common, TemplateGenerics 11 Forms, UMainForm, UBrainFuck, UInterpreterForm, UApplicationInfo, 12 UCompiledForm, UOptionsForm, CoolTranslator, Common, TemplateGenerics, 13 UCompiler, UCompilerDelphi, UCompilerPHP 13 14 { you can add units after this }; 14 15 -
trunk/UBrainFuck.pas
r18 r19 11 11 TBrainFuckInterpretter = class; 12 12 13 TCompilerTarget = (ctDelphi);14 TCompilerOptimization = (coNone, coNormal);15 16 { TBrainFuckCompiler }17 18 TBrainFuckCompiler = class19 private20 Indent: Integer;21 procedure AddLine(Text: string);22 public23 ProgramName: string;24 Source: string;25 Output: string;26 Target: TCompilerTarget;27 Optimization: TCompilerOptimization;28 procedure OptimizeSource;29 procedure Compile;30 end;31 13 32 14 TRunState = (rsStopped, rsPaused, rsRunning); … … 321 303 end; 322 304 323 { TBrainFuckCompiler }324 325 procedure TBrainFuckCompiler.AddLine(Text: string);326 begin327 Output := Output + DupeString(' ', Indent) + Text + LineEnding;328 end;329 330 procedure TBrainFuckCompiler.OptimizeSource;331 begin332 // Remove redundand code333 334 end;335 336 procedure TBrainFuckCompiler.Compile;337 var338 I: Integer;339 begin340 Indent := 0;341 Output := '';342 343 AddLine('program ' + ProgramName + ';');344 AddLine('');345 AddLine('{$APPTYPE CONSOLE}');346 AddLine('');347 AddLine('var');348 AddLine(' Memory: array[0..30000] of Char;');349 AddLine(' Position: Integer;');350 AddLine('begin');351 Inc(Indent);352 for I := 1 to Length(Source) do begin353 case Source[I] of354 '>': AddLine('Inc(Position);');355 '<': AddLine('Dec(Position);');356 '+': AddLine('Memory[Position] := Succ(Memory[Position]);');357 '-': AddLine('Memory[Position] := Pred(Memory[Position]);');358 '.': AddLine('Write(Memory[Position]);');359 ',': AddLine('Read(Memory[Position]);');360 '[': begin361 AddLine('while Memory[Position] <> #0 do begin');362 Inc(Indent);363 end;364 ']': begin365 Dec(Indent);366 AddLine('end;');367 end;368 end;369 end;370 Dec(Indent);371 AddLine('end.');372 end;373 374 305 end. 375 306 -
trunk/UMainForm.lfm
r18 r19 400 400 } 401 401 end 402 object MenuItem 40: TMenuItem402 object MenuItemTarget: TMenuItem 403 403 Caption = 'Target' 404 404 object MenuItem21: TMenuItem -
trunk/UMainForm.lrt
r16 r19 4 4 TMAINFORM.MENUITEM5.CAPTION=- 5 5 TMAINFORM.MENUITEM9.CAPTION=Program 6 TMAINFORM.MENUITEM 40.CAPTION=Target6 TMAINFORM.MENUITEMTARGET.CAPTION=Target 7 7 TMAINFORM.MENUITEM21.CAPTION=New Item21 8 8 TMAINFORM.MENUITEM17.CAPTION=- -
trunk/UMainForm.pas
r18 r19 8 8 Classes, SysUtils, FileUtil, SynEdit, Forms, Controls, Graphics, Dialogs, 9 9 Menus, ActnList, StdCtrls, ComCtrls, UBrainFuck, UCoolTranslator, StrUtils, 10 SpecializedList ;10 SpecializedList, UCompiler; 11 11 12 12 type … … 59 59 MenuItem25: TMenuItem; 60 60 MenuItem26: TMenuItem; 61 MenuItem 40: TMenuItem;61 MenuItemTarget: TMenuItem; 62 62 MenuItem21: TMenuItem; 63 63 MenuItem3: TMenuItem; … … 112 112 private 113 113 procedure BrainFuckInterpreterChangeState(Sender: TObject); 114 procedure MenuItemTargetClick(Sender: TObject); 114 115 public 115 116 Modified: Boolean; … … 118 119 BrainFuckInterpreter: TBrainFuckInterpretter; 119 120 BreakPoints: TListInteger; 121 Compilers: TListObject; // TListObject<TCompiler> 120 122 procedure UpdateInterface; 121 123 procedure UpdateStatusBar; 124 procedure UpdateTergetList; 122 125 end; 123 126 … … 130 133 131 134 uses 132 UInterpreterForm, UApplicationInfo, UCompiledForm, UOptionsForm; 135 UInterpreterForm, UApplicationInfo, UCompiledForm, UOptionsForm, 136 UCompilerDelphi, UCompilerPHP; 133 137 134 138 { TMainForm } … … 169 173 begin 170 174 UpdateInterface; 175 end; 176 177 procedure TMainForm.MenuItemTargetClick(Sender: TObject); 178 var 179 I: Integer; 180 begin 181 with TMenuItem(Sender) do begin 182 Checked := True; 183 for I := 0 to Parent.Count - 1 do 184 if Parent.Items[I].MenuIndex <> MenuIndex then Parent.Items[I].Checked := False 185 end; 171 186 end; 172 187 … … 194 209 end; 195 210 211 procedure TMainForm.UpdateTergetList; 212 var 213 I: Integer; 214 NewMenuItem: TMenuItem; 215 begin 216 MenuItemTarget.Clear; 217 for I := 0 to Compilers.Count - 1 do begin 218 NewMenuItem := TMenuItem.Create(MenuItemTarget); 219 NewMenuItem.Caption := TBrainFuckCompiler(Compilers[I]).Name; 220 NewMenuItem.OnClick := MenuItemTargetClick; 221 if I = 0 then NewMenuItem.Checked := True; 222 MenuItemTarget.Add(NewMenuItem); 223 end; 224 end; 225 196 226 procedure TMainForm.FormCreate(Sender: TObject); 197 227 begin … … 201 231 BrainFuckCompiler := TBrainFuckCompiler.Create; 202 232 CoolTranslator1.Language := CoolTranslator1.Languages.SearchByCode('cs'); 233 Compilers := TListObject.Create; 234 Compilers.Add(TBrainFuckCompilerDelphi.Create); 235 Compilers.Add(TBrainFuckCompilerPHP.Create); 236 UpdateTergetList; 203 237 end; 204 238 205 239 procedure TMainForm.FormDestroy(Sender: TObject); 206 240 begin 241 Compilers.Free; 207 242 BrainFuckCompiler.Free; 208 243 BrainFuckInterpreter.Free; … … 275 310 276 311 procedure TMainForm.ACompileExecute(Sender: TObject); 277 begin 278 BrainFuckCompiler.Source := MemoSource.Text; 279 BrainFuckCompiler.ProgramName := ExtractFileNameOnly(ProjectFileName); 280 BrainFuckCompiler.Compile; 281 CompiledForm.MemoCompiled.Text := BrainFuckCompiler.Output; 282 CompiledForm.Show; 312 var 313 I: Integer; 314 begin 315 I := 0; 316 while (I < MenuItemTarget.Count) and (not MenuItemTarget.Items[I].Checked) do Inc(I); 317 with TBrainFuckCompiler(Compilers[I]) do begin 318 Source := MemoSource.Text; 319 ProgramName := ExtractFileNameOnly(ProjectFileName); 320 Compile; 321 CompiledForm.MemoCompiled.Text := Output; 322 CompiledForm.Show; 323 end; 283 324 end; 284 325
Note:
See TracChangeset
for help on using the changeset viewer.