Ignore:
Timestamp:
Feb 11, 2012, 9:32:25 PM (13 years ago)
Author:
chronos
Message:
  • Modified: Optimalized execution of BrainFuck commands using array of methods instead of case statement. This can scale better for future additional commands.
  • Added: Interpretter form show speed in steps per second.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UInterpreterForm.pas

    r12 r18  
    2222    Label4: TLabel;
    2323    Label6: TLabel;
     24    Label7: TLabel;
    2425    LabelStepCounter: TLabel;
    2526    LabelProgramPointer: TLabel;
    2627    Label5: TLabel;
    2728    LabelMemoryPointer: TLabel;
     29    LabelStepSpeed: TLabel;
    2830    ListViewMemory: TListView;
    2931    MemoInput: TMemo;
     
    4446    ToolButton6: TToolButton;
    4547    ToolButton7: TToolButton;
     48    procedure FormHide(Sender: TObject);
     49    procedure FormShow(Sender: TObject);
    4650    procedure ListViewMemoryData(Sender: TObject; Item: TListItem);
    4751    procedure MemoInputKeyPress(Sender: TObject; var Key: char);
    4852    procedure Timer1Timer(Sender: TObject);
    4953  private
    50     { private declarations }
     54    LastStepCounter: Integer;
    5155  public
    5256    procedure RefreshListViewMemory;
     
    6468{$R *.lfm}
    6569
     70resourcestring
     71  SStepsPerSecond = ' steps/s';
     72
    6673{ TInterpreterForm }
    6774
     
    7178  LabelMemoryPointer.Caption := IntToStr(MainForm.BrainFuckInterpreter.MemoryPosition);
    7279  LabelStepCounter.Caption := IntToStr(MainForm.BrainFuckInterpreter.StepCount);
     80  LabelStepSpeed.Caption := IntToStr(MainForm.BrainFuckInterpreter.StepCount - LastStepCounter) + SStepsPerSecond;
     81  LastStepCounter := MainForm.BrainFuckInterpreter.StepCount;
    7382  RefreshListViewMemory;
    7483  MemoOutput.Lines.Text := MainForm.BrainFuckInterpreter.Output;
     
    101110end;
    102111
     112procedure TInterpreterForm.FormHide(Sender: TObject);
     113begin
     114  Timer1.Enabled := False;
     115end;
     116
     117procedure TInterpreterForm.FormShow(Sender: TObject);
     118begin
     119  Timer1.Enabled := True;
     120end;
     121
    103122procedure TInterpreterForm.MemoInputKeyPress(Sender: TObject; var Key: char);
    104123begin
Note: See TracChangeset for help on using the changeset viewer.