Ignore:
Timestamp:
Feb 19, 2012, 12:03:21 AM (13 years ago)
Author:
chronos
Message:
  • Added: Function to show execution point in code if program is paused.
  • Added: Some partial stepping implementation.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UMainForm.pas

    r34 r35  
    1818
    1919  TMainForm = class(TForm)
     20    AProgramShowExecutionPoint: TAction;
    2021    AShowSourcePosition: TAction;
    2122    AShowTargetPosition: TAction;
     
    7273    MenuItem29: TMenuItem;
    7374    MenuItem30: TMenuItem;
     75    MenuItem31: TMenuItem;
    7476    MenuItem32: TMenuItem;
    7577    MenuItem33: TMenuItem;
     
    111113    ToolButton9: TToolButton;
    112114    procedure ABreakpointToggleExecute(Sender: TObject);
    113     procedure AProgramCompileExecute(Sender: TObject);
    114115    procedure AExitExecute(Sender: TObject);
    115116    procedure AFormatSourceExecute(Sender: TObject);
    116117    procedure AGenerateNumberExecute(Sender: TObject);
    117118    procedure AOptionsExecute(Sender: TObject);
     119    procedure AProgramCompileExecute(Sender: TObject);
    118120    procedure AProgramPauseExecute(Sender: TObject);
     121    procedure AProgramRunToCursorExecute(Sender: TObject);
     122    procedure AProgramShowExecutionPointExecute(Sender: TObject);
     123    procedure AProgramStepIntoExecute(Sender: TObject);
     124    procedure AProgramStepOutExecute(Sender: TObject);
     125    procedure AProgramStepOverExecute(Sender: TObject);
    119126    procedure AProgramStopExecute(Sender: TObject);
    120127    procedure AProjectCloseExecute(Sender: TObject);
     
    144151    FCurrentTarget: TTarget;
    145152    procedure AProjectOpenRecentExecute(Sender: TObject);
    146     procedure BrainFuckInterpreterChangeState(Sender: TObject);
     153    procedure TargetStateChanged(Sender: TObject);
    147154    procedure MenuItemTargetClick(Sender: TObject);
    148155    procedure ProjectOpen(FileName: string);
     
    218225end;
    219226
    220 procedure TMainForm.BrainFuckInterpreterChangeState(Sender: TObject);
    221 begin
     227procedure TMainForm.TargetStateChanged(Sender: TObject);
     228var
     229  DebugStep: TDebugStep;
     230begin
     231  if CurrentTarget.State = rsPaused then
     232    AProgramShowExecutionPoint.Execute;
    222233  UpdateInterface;
    223234end;
     
    253264  for I := 0 to Targets.Count - 1 do
    254265    TTarget(Targets[I]).OnChangeState := nil;
    255   FCurrentTarget.OnChangeState := BrainFuckInterpreterChangeState;
     266  FCurrentTarget.OnChangeState := TargetStateChanged;
    256267  UpdateInterface;
    257268end;
     
    309320  AProjectClose.Enabled := ProjectFileName <> '';
    310321  AProgramRun.Enabled := (tcRun in CurrentTarget.Capabilities) and
    311     (ProjectFileName <> '') and (CurrentTarget.State = rsStopped);
     322    (ProjectFileName <> '') and (CurrentTarget.State = rsStopped) or (CurrentTarget.State = rsPaused);
    312323  AProgramPause.Enabled := (tcPause in CurrentTarget.Capabilities) and
    313324    (ProjectFileName <> '') and (CurrentTarget.State = rsRunning);
    314325  AProgramStop.Enabled := (tcStop in CurrentTarget.Capabilities) and
    315326    (ProjectFileName <> '') and (CurrentTarget.State <> rsStopped);
    316   AProgramCompile.Enabled := (tcCompile in CurrentTarget.Capabilities) and (ProjectFileName <> '');
    317   AProgramStepInto.Enabled := (tcStepInto in CurrentTarget.Capabilities) and (ProjectFileName <> '');
    318   AProgramStepOut.Enabled := (tcStepOut in CurrentTarget.Capabilities) and (ProjectFileName <> '');
    319   AProgramRunToCursor.Enabled := (tcRunToCursor in CurrentTarget.Capabilities) and (ProjectFileName <> '');
    320   AProgramStepOver.Enabled := (tcStepOver in CurrentTarget.Capabilities) and (ProjectFileName <> '');
     327  AProgramCompile.Enabled := (tcCompile in CurrentTarget.Capabilities);
     328  AProgramStepInto.Enabled := (tcStepInto in CurrentTarget.Capabilities) and
     329    (ProjectFileName <> '') and (CurrentTarget.State = rsPaused);
     330  AProgramStepOut.Enabled := (tcStepOut in CurrentTarget.Capabilities) and
     331    (ProjectFileName <> '') and (CurrentTarget.State = rsPaused);
     332  AProgramRunToCursor.Enabled := (tcRunToCursor in CurrentTarget.Capabilities) and
     333    (ProjectFileName <> '') and (CurrentTarget.State = rsPaused);
     334  AProgramStepOver.Enabled := (tcStepOver in CurrentTarget.Capabilities) and
     335    (ProjectFileName <> '') and (CurrentTarget.State = rsPaused);
     336  AProgramShowExecutionPoint.Enabled := (tcPause in CurrentTarget.Capabilities) and
     337    (ProjectFileName <> '') and (CurrentTarget.State = rsPaused);
     338  AShowSourcePosition.Enabled := CurrentTarget.Compiled;
     339  AShowTargetPosition.Enabled := CurrentTarget.Compiled;
    321340  UpdateStatusBar;
    322341  UpdateTargetList;
     
    373392    TTargetInterpretter(CurrentTarget).Input := InterpreterForm.MemoInput.Lines.Text;
    374393  CurrentTarget.SourceCode := MemoSource.Text;
    375   if not CurrentTarget.Compiled then CurrentTarget.Compile;
     394  if not CurrentTarget.Compiled then AProgramCompile.Execute;
    376395  CurrentTarget.Run;
    377396end;
     
    381400  DebugStep: TDebugStep;
    382401begin
    383   DebugStep := CurrentTarget.DebugSteps.SearchByTargetPos(MemoSource.SelStart);
    384   MemoTarget.SelStart := DebugStep.SourcePosition;
    385   PageControl1.TabIndex := 0;
     402  DebugStep := CurrentTarget.DebugSteps.SearchByTargetPos(MemoTarget.SelStart);
     403  if Assigned(DebugStep) then begin
     404    MemoSource.SelStart := DebugStep.SourcePosition;
     405    PageControl1.TabIndex := 0;
     406  end;
    386407end;
    387408
     
    391412begin
    392413  DebugStep := CurrentTarget.DebugSteps.SearchBySourcePos(MemoSource.SelStart);
    393   MemoTarget.SelStart := DebugStep.TargetPosition;
    394   PageControl1.TabIndex := 1;
     414  if Assigned(DebugStep) then begin
     415    MemoTarget.SelStart := DebugStep.TargetPosition;
     416    PageControl1.TabIndex := 1;
     417  end;
    395418end;
    396419
     
    487510begin
    488511  with CurrentTarget do begin
     512    Stop;
    489513    Optimization := coNormal;
    490514    SourceCode := MemoSource.Text;
     
    492516    Compile;
    493517    MemoTarget.Text := TargetCode;
     518    UpdateInterface;
    494519  end;
    495520end;
     
    503528begin
    504529  CurrentTarget.Pause
     530end;
     531
     532procedure TMainForm.AProgramRunToCursorExecute(Sender: TObject);
     533var
     534  DebugStep: TDebugStep;
     535begin
     536  DebugStep := CurrentTarget.DebugSteps.SearchBySourcePos(MemoSource.SelStart);
     537  CurrentTarget.RunToCursor(DebugStep.TargetPosition);
     538end;
     539
     540procedure TMainForm.AProgramShowExecutionPointExecute(Sender: TObject);
     541var
     542  DebugStep: TDebugStep;
     543begin
     544  DebugStep := CurrentTarget.DebugSteps.SearchByTargetPos(CurrentTarget.ExecutionPosition);
     545  MemoSource.SelStart := DebugStep.SourcePosition;
     546  MemoTarget.SelStart := DebugStep.TargetPosition;
     547end;
     548
     549procedure TMainForm.AProgramStepIntoExecute(Sender: TObject);
     550begin
     551  CurrentTarget.StepInto;
     552end;
     553
     554procedure TMainForm.AProgramStepOutExecute(Sender: TObject);
     555begin
     556  CurrentTarget.StepOut;
     557end;
     558
     559procedure TMainForm.AProgramStepOverExecute(Sender: TObject);
     560begin
     561  CurrentTarget.StepOver;
    505562end;
    506563
Note: See TracChangeset for help on using the changeset viewer.