Changeset 35 for trunk/Forms/UMainForm.pas
- Timestamp:
- Feb 19, 2012, 12:03:21 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/UMainForm.pas
r34 r35 18 18 19 19 TMainForm = class(TForm) 20 AProgramShowExecutionPoint: TAction; 20 21 AShowSourcePosition: TAction; 21 22 AShowTargetPosition: TAction; … … 72 73 MenuItem29: TMenuItem; 73 74 MenuItem30: TMenuItem; 75 MenuItem31: TMenuItem; 74 76 MenuItem32: TMenuItem; 75 77 MenuItem33: TMenuItem; … … 111 113 ToolButton9: TToolButton; 112 114 procedure ABreakpointToggleExecute(Sender: TObject); 113 procedure AProgramCompileExecute(Sender: TObject);114 115 procedure AExitExecute(Sender: TObject); 115 116 procedure AFormatSourceExecute(Sender: TObject); 116 117 procedure AGenerateNumberExecute(Sender: TObject); 117 118 procedure AOptionsExecute(Sender: TObject); 119 procedure AProgramCompileExecute(Sender: TObject); 118 120 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); 119 126 procedure AProgramStopExecute(Sender: TObject); 120 127 procedure AProjectCloseExecute(Sender: TObject); … … 144 151 FCurrentTarget: TTarget; 145 152 procedure AProjectOpenRecentExecute(Sender: TObject); 146 procedure BrainFuckInterpreterChangeState(Sender: TObject);153 procedure TargetStateChanged(Sender: TObject); 147 154 procedure MenuItemTargetClick(Sender: TObject); 148 155 procedure ProjectOpen(FileName: string); … … 218 225 end; 219 226 220 procedure TMainForm.BrainFuckInterpreterChangeState(Sender: TObject); 221 begin 227 procedure TMainForm.TargetStateChanged(Sender: TObject); 228 var 229 DebugStep: TDebugStep; 230 begin 231 if CurrentTarget.State = rsPaused then 232 AProgramShowExecutionPoint.Execute; 222 233 UpdateInterface; 223 234 end; … … 253 264 for I := 0 to Targets.Count - 1 do 254 265 TTarget(Targets[I]).OnChangeState := nil; 255 FCurrentTarget.OnChangeState := BrainFuckInterpreterChangeState;266 FCurrentTarget.OnChangeState := TargetStateChanged; 256 267 UpdateInterface; 257 268 end; … … 309 320 AProjectClose.Enabled := ProjectFileName <> ''; 310 321 AProgramRun.Enabled := (tcRun in CurrentTarget.Capabilities) and 311 (ProjectFileName <> '') and (CurrentTarget.State = rsStopped) ;322 (ProjectFileName <> '') and (CurrentTarget.State = rsStopped) or (CurrentTarget.State = rsPaused); 312 323 AProgramPause.Enabled := (tcPause in CurrentTarget.Capabilities) and 313 324 (ProjectFileName <> '') and (CurrentTarget.State = rsRunning); 314 325 AProgramStop.Enabled := (tcStop in CurrentTarget.Capabilities) and 315 326 (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; 321 340 UpdateStatusBar; 322 341 UpdateTargetList; … … 373 392 TTargetInterpretter(CurrentTarget).Input := InterpreterForm.MemoInput.Lines.Text; 374 393 CurrentTarget.SourceCode := MemoSource.Text; 375 if not CurrentTarget.Compiled then CurrentTarget.Compile;394 if not CurrentTarget.Compiled then AProgramCompile.Execute; 376 395 CurrentTarget.Run; 377 396 end; … … 381 400 DebugStep: TDebugStep; 382 401 begin 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; 386 407 end; 387 408 … … 391 412 begin 392 413 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; 395 418 end; 396 419 … … 487 510 begin 488 511 with CurrentTarget do begin 512 Stop; 489 513 Optimization := coNormal; 490 514 SourceCode := MemoSource.Text; … … 492 516 Compile; 493 517 MemoTarget.Text := TargetCode; 518 UpdateInterface; 494 519 end; 495 520 end; … … 503 528 begin 504 529 CurrentTarget.Pause 530 end; 531 532 procedure TMainForm.AProgramRunToCursorExecute(Sender: TObject); 533 var 534 DebugStep: TDebugStep; 535 begin 536 DebugStep := CurrentTarget.DebugSteps.SearchBySourcePos(MemoSource.SelStart); 537 CurrentTarget.RunToCursor(DebugStep.TargetPosition); 538 end; 539 540 procedure TMainForm.AProgramShowExecutionPointExecute(Sender: TObject); 541 var 542 DebugStep: TDebugStep; 543 begin 544 DebugStep := CurrentTarget.DebugSteps.SearchByTargetPos(CurrentTarget.ExecutionPosition); 545 MemoSource.SelStart := DebugStep.SourcePosition; 546 MemoTarget.SelStart := DebugStep.TargetPosition; 547 end; 548 549 procedure TMainForm.AProgramStepIntoExecute(Sender: TObject); 550 begin 551 CurrentTarget.StepInto; 552 end; 553 554 procedure TMainForm.AProgramStepOutExecute(Sender: TObject); 555 begin 556 CurrentTarget.StepOut; 557 end; 558 559 procedure TMainForm.AProgramStepOverExecute(Sender: TObject); 560 begin 561 CurrentTarget.StepOver; 505 562 end; 506 563
Note:
See TracChangeset
for help on using the changeset viewer.