Changeset 20 for trunk/UMainForm.pas


Ignore:
Timestamp:
Feb 11, 2012, 10:56:03 PM (13 years ago)
Author:
chronos
Message:
  • Added: Action to shrink source code by remove all non printable characters.
  • Added: Optimalization for generated code by Delphi and PHP compiler. All same language commands laying side by side will be converted to single generated operation.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UMainForm.pas

    r19 r20  
    1818    AAbout: TAction;
    1919    ABreakpointToggle: TAction;
     20    AShrinkSource: TAction;
    2021    AFormatSource: TAction;
    2122    AOptions: TAction;
     
    5455    MenuItem2: TMenuItem;
    5556    MenuItem20: TMenuItem;
     57    MenuItem21: TMenuItem;
    5658    MenuItem22: TMenuItem;
    5759    MenuItem23: TMenuItem;
     
    5961    MenuItem25: TMenuItem;
    6062    MenuItem26: TMenuItem;
     63    MenuItem27: TMenuItem;
    6164    MenuItemTarget: TMenuItem;
    62     MenuItem21: TMenuItem;
    6365    MenuItem3: TMenuItem;
    6466    MenuItem4: TMenuItem;
     
    7577    ToolBar1: TToolBar;
    7678    ToolButton1: TToolButton;
     79    ToolButton10: TToolButton;
     80    ToolButton11: TToolButton;
    7781    ToolButton2: TToolButton;
    7882    ToolButton3: TToolButton;
     
    96100    procedure AProjectSaveExecute(Sender: TObject);
    97101    procedure AProgramRunExecute(Sender: TObject);
     102    procedure AShrinkSourceExecute(Sender: TObject);
    98103    procedure AViewCompiledExecute(Sender: TObject);
    99104    procedure AViewInterpretterExecute(Sender: TObject);
     
    115120  public
    116121    Modified: Boolean;
     122    CompilerIndex: Integer;
    117123    ProjectFileName: string;
    118124    BrainFuckCompiler: TBrainFuckCompiler;
     
    180186begin
    181187  with TMenuItem(Sender) do begin
     188    CompilerIndex := MenuIndex;
    182189    Checked := True;
    183190    for I := 0 to Parent.Count - 1 do
     
    219226    NewMenuItem.Caption := TBrainFuckCompiler(Compilers[I]).Name;
    220227    NewMenuItem.OnClick := MenuItemTargetClick;
    221     if I = 0 then NewMenuItem.Checked := True;
     228    if I = CompilerIndex then NewMenuItem.Checked := True;
    222229    MenuItemTarget.Add(NewMenuItem);
    223230  end;
     
    251258  BrainFuckInterpreter.Source := MemoSource.Text;
    252259  BrainFuckInterpreter.Run;
     260end;
     261
     262procedure TMainForm.AShrinkSourceExecute(Sender: TObject);
     263var
     264  Source: string;
     265  Pos: Integer;
     266  I: Integer;
     267begin
     268  Source := MemoSource.Text;
     269  Pos := 1;
     270  for I := 1 to Length(Source) do begin
     271    if Source[I] > ' ' then begin
     272      Source[Pos] := Source[I];
     273      Inc(Pos);
     274    end;
     275  end;
     276  SetLength(Source, Pos - 1);
     277  MemoSource.Text := Source;
    253278end;
    254279
     
    310335
    311336procedure TMainForm.ACompileExecute(Sender: TObject);
    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
     337begin
     338  with TBrainFuckCompiler(Compilers[CompilerIndex]) do begin
     339    Optimization := coNormal;
    318340    Source := MemoSource.Text;
    319341    ProgramName := ExtractFileNameOnly(ProjectFileName);
Note: See TracChangeset for help on using the changeset viewer.