Changeset 32 for trunk/Forms
- Timestamp:
- Feb 18, 2012, 8:44:10 PM (13 years ago)
- Location:
- trunk/Forms
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/UInterpretterForm.pas
r24 r32 64 64 65 65 uses 66 UMainForm ;66 UMainForm, UTargetInterpretter; 67 67 68 68 {$R *.lfm} … … 75 75 procedure TInterpreterForm.Timer1Timer(Sender: TObject); 76 76 begin 77 LabelProgramPointer.Caption := IntToStr(MainForm.BrainFuckInterpreter.SourcePosition); 78 LabelMemoryPointer.Caption := IntToStr(MainForm.BrainFuckInterpreter.MemoryPosition); 79 LabelStepCounter.Caption := IntToStr(MainForm.BrainFuckInterpreter.StepCount); 80 LabelStepSpeed.Caption := IntToStr(MainForm.BrainFuckInterpreter.StepCount - LastStepCounter) + SStepsPerSecond; 81 LastStepCounter := MainForm.BrainFuckInterpreter.StepCount; 77 if MainForm.CurrentTarget is TTargetInterpretter then 78 with TTargetInterpretter(MainForm.CurrentTarget) do begin 79 LabelProgramPointer.Caption := IntToStr(SourcePosition); 80 LabelMemoryPointer.Caption := IntToStr(MemoryPosition); 81 LabelStepCounter.Caption := IntToStr(StepCount); 82 LabelStepSpeed.Caption := IntToStr(StepCount - LastStepCounter) + SStepsPerSecond; 83 LastStepCounter := StepCount; 84 MemoOutput.Lines.Text := Output; 85 end; 82 86 RefreshListViewMemory; 83 MemoOutput.Lines.Text := MainForm.BrainFuckInterpreter.Output;84 87 end; 85 88 86 89 procedure TInterpreterForm.RefreshListViewMemory; 87 90 begin 88 ListViewMemory.Items.Count := Trunc(Length(MainForm.BrainFuckInterpreter.Memory) / RowSize); 89 ListViewMemory.Refresh; 91 if MainForm.CurrentTarget is TTargetInterpretter then 92 with TTargetInterpretter(MainForm.CurrentTarget) do begin 93 ListViewMemory.Items.Count := Trunc(Length(Memory) / RowSize); 94 ListViewMemory.Refresh; 95 end; 90 96 end; 91 97 … … 100 106 I: Integer; 101 107 begin 102 with MainForm.BrainFuckInterpreter do 108 if MainForm.CurrentTarget is TTargetInterpretter then 109 with TTargetInterpretter(MainForm.CurrentTarget) do 103 110 if (Item.Index >= 0) and (Item.Index < Trunc(Length(Memory) / RowSize)) then begin 104 111 Item.Caption := IntToHex(Item.Index * RowSize, 8); … … 122 129 procedure TInterpreterForm.MemoInputKeyPress(Sender: TObject; var Key: char); 123 130 begin 124 with MainForm.BrainFuckInterpreter do Input := Input + Key; 131 if MainForm.CurrentTarget is TTargetInterpretter then 132 with TTargetInterpretter(MainForm.CurrentTarget) do 133 Input := Input + Key; 125 134 end; 126 135 -
trunk/Forms/UMainForm.lfm
r30 r32 92 92 Left = 126 93 93 Top = 2 94 Action = A Compile94 Action = AProgramCompile 95 95 end 96 96 object ToolButton8: TToolButton … … 394 394 Caption = 'Program' 395 395 object MenuItem11: TMenuItem 396 Action = A Compile396 Action = AProgramCompile 397 397 Bitmap.Data = { 398 398 36040000424D3604000000000000360000002800000010000000100000000100 … … 562 562 end 563 563 object MenuItem33: TMenuItem 564 Action = AProgramSt opOver564 Action = AProgramStepOver 565 565 end 566 566 object MenuItem34: TMenuItem … … 761 761 ShortCut = 32883 762 762 end 763 object A Compile: TAction763 object AProgramCompile: TAction 764 764 Category = 'Program' 765 765 Caption = 'Compile' 766 766 ImageIndex = 8 767 OnExecute = A CompileExecute767 OnExecute = AProgramCompileExecute 768 768 ShortCut = 16504 769 769 end … … 814 814 ShortCut = 118 815 815 end 816 object AProgramSt opOver: TAction816 object AProgramStepOver: TAction 817 817 Category = 'Program' 818 818 Caption = 'Step over' -
trunk/Forms/UMainForm.lrt
r30 r32 19 19 TMAINFORM.APROJECTNEW.CAPTION=New 20 20 TMAINFORM.AEXIT.CAPTION=Exit 21 TMAINFORM.A COMPILE.CAPTION=Compile21 TMAINFORM.APROGRAMCOMPILE.CAPTION=Compile 22 22 TMAINFORM.ACOMPILEANDRUN.CAPTION=Compile and run 23 23 TMAINFORM.APROGRAMRUN.CAPTION=Run … … 29 29 TMAINFORM.AVIEWCOMPILED.CAPTION=Compiled 30 30 TMAINFORM.APROGRAMSTEPINTO.CAPTION=Step into 31 TMAINFORM.APROGRAMST OPOVER.CAPTION=Step over31 TMAINFORM.APROGRAMSTEPOVER.CAPTION=Step over 32 32 TMAINFORM.APROGRAMRUNTOCURSOR.CAPTION=Run to cursor 33 33 TMAINFORM.APROGRAMSTEPOUT.CAPTION=Step out -
trunk/Forms/UMainForm.pas
r31 r32 18 18 19 19 TMainForm = class(TForm) 20 A Compile: TAction;20 AProgramCompile: TAction; 21 21 AAbout: TAction; 22 22 ABreakpointToggle: TAction; … … 29 29 AProgramStepOut: TAction; 30 30 AProgramRunToCursor: TAction; 31 AProgramSt opOver: TAction;31 AProgramStepOver: TAction; 32 32 AProgramStepInto: TAction; 33 33 AViewCompiled: TAction; … … 108 108 procedure ABreakpointToggleExecute(Sender: TObject); 109 109 procedure ACompileAndRunExecute(Sender: TObject); 110 procedure A CompileExecute(Sender: TObject);110 procedure AProgramCompileExecute(Sender: TObject); 111 111 procedure AExitExecute(Sender: TObject); 112 112 procedure AFormatSourceExecute(Sender: TObject); … … 138 138 Shift: TShiftState; X, Y: Integer); 139 139 private 140 FCurrentTarget: TTarget; 140 141 procedure AProjectOpenRecentExecute(Sender: TObject); 141 142 procedure BrainFuckInterpreterChangeState(Sender: TObject); 142 143 procedure MenuItemTargetClick(Sender: TObject); 143 144 procedure ProjectOpen(FileName: string); 145 procedure SetCurrentTarget(AValue: TTarget); 144 146 public 145 147 Modified: Boolean; 146 CompilerIndex: Integer;147 148 ProjectFileName: string; 148 BrainFuckCompiler: TTarget;149 BrainFuckInterpreter: TTargetInterpretter;150 149 BreakPoints: TListInteger; 151 150 Targets: TTargetList; … … 157 156 procedure UpdateStatusBar; 158 157 procedure UpdateTargetList; 158 property CurrentTarget: TTarget read FCurrentTarget write SetCurrentTarget; 159 159 end; 160 160 … … 222 222 begin 223 223 with TMenuItem(Sender) do begin 224 C ompilerIndex := MenuIndex;224 CurrentTarget := TTarget(Targets[MenuIndex]); 225 225 Checked := True; 226 226 for I := 0 to Parent.Count - 1 do 227 if Parent.Items[I].MenuIndex <> MenuIndex then Parent.Items[I].Checked := False 227 if Parent.Items[I].MenuIndex <> MenuIndex then Parent.Items[I].Checked := False; 228 228 end; 229 229 end; … … 238 238 end; 239 239 240 procedure TMainForm.SetCurrentTarget(AValue: TTarget); 241 var 242 I: Integer; 243 begin 244 if FCurrentTarget = AValue then Exit; 245 FCurrentTarget := AValue; 246 for I := 0 to Targets.Count - 1 do 247 TTarget(Targets[I]).OnChangeState := nil; 248 FCurrentTarget.OnChangeState := BrainFuckInterpreterChangeState; 249 end; 250 240 251 procedure TMainForm.LoadFromRegistry(Root: HKEY; Key: string); 252 var 253 TargetName: string; 241 254 begin 242 255 with TRegistryEx.Create do … … 245 258 OpenKey(Key, True); 246 259 OpenProjectOnStart := ReadBoolWithDefault('OpenProjectOnStart', True); 247 BrainFuckInterpreter.CellSize := ReadIntegerWithDefault('CellSize', 256);248 BrainFuckInterpreter.MemorySize := ReadIntegerWithDefault('MemorySize', 30000);249 260 if ValueExists('LanguageCode') then 250 261 CoolTranslator1.Language := CoolTranslator1.Languages.SearchByCode(ReadStringWithDefault('LanguageCode', '')) 251 262 else CoolTranslator1.Language := CoolTranslator1.Languages.SearchByCode(''); 252 CompilerIndex := ReadIntegerWithDefault('SelectedCompiler', 0); 263 TargetName := ReadStringWithDefault('TargetName', 'Interpretter'); 264 CurrentTarget := Targets.FindByName(TargetName); 265 if not Assigned(CurrentTarget) then CurrentTarget := TTarget(Targets[0]); 253 266 finally 254 267 Free; … … 267 280 OpenKey(Key, True); 268 281 WriteBool('OpenProjectOnStart', OpenProjectOnStart); 269 WriteInteger('CellSize', BrainFuckInterpreter.CellSize);270 WriteInteger('MemorySize', BrainFuckInterpreter.MemorySize);271 282 if Assigned(CoolTranslator1.Language) and (CoolTranslator1.Language.Code <> '') then 272 283 WriteString('LanguageCode', CoolTranslator1.Language.Code) 273 284 else DeleteValue('LanguageCode'); 274 Write Integer('SelectedCompiler', CompilerIndex);285 WriteString('TargetName', CurrentTarget.Name); 275 286 finally 276 287 Free; … … 289 300 MemoSource.Enabled := ProjectFileName <> ''; 290 301 AProjectClose.Enabled := ProjectFileName <> ''; 291 AProgramRun.Enabled := (ProjectFileName <> '') and (BrainFuckInterpreter.State = rsStopped); 292 AProgramPause.Enabled := (ProjectFileName <> '') and (BrainFuckInterpreter.State = rsRunning); 293 AProgramStop.Enabled := (ProjectFileName <> '') and (BrainFuckInterpreter.State <> rsStopped); 294 ACompile.Enabled := ProjectFileName <> ''; 302 AProgramRun.Enabled := (tcRun in CurrentTarget.Capabilities) and 303 (ProjectFileName <> '') and (CurrentTarget.State = rsStopped); 304 AProgramPause.Enabled := (tcPause in CurrentTarget.Capabilities) and 305 (ProjectFileName <> '') and (CurrentTarget.State = rsRunning); 306 AProgramStop.Enabled := (tcStop in CurrentTarget.Capabilities) and 307 (ProjectFileName <> '') and (CurrentTarget.State <> rsStopped); 308 AProgramCompile.Enabled := (tcCompile in CurrentTarget.Capabilities) and (ProjectFileName <> ''); 309 AProgramStepInto.Enabled := (tcStepInto in CurrentTarget.Capabilities) and (ProjectFileName <> ''); 310 AProgramStepOut.Enabled := (tcStepOut in CurrentTarget.Capabilities) and (ProjectFileName <> ''); 311 AProgramRunToCursor.Enabled := (tcRunToCursor in CurrentTarget.Capabilities) and (ProjectFileName <> ''); 312 AProgramStepOver.Enabled := (tcStepOver in CurrentTarget.Capabilities) and (ProjectFileName <> ''); 295 313 UpdateStatusBar; 296 314 UpdateTargetList; … … 312 330 NewMenuItem.Caption := TTarget(Targets[I]).Name; 313 331 NewMenuItem.OnClick := MenuItemTargetClick; 314 if I = CompilerIndexthen NewMenuItem.Checked := True;332 if TTarget(Targets[I]) = CurrentTarget then NewMenuItem.Checked := True; 315 333 MenuItemTarget.Add(NewMenuItem); 316 334 end; … … 320 338 begin 321 339 BreakPoints := TListInteger.Create; 322 BrainFuckInterpreter := TTargetInterpretter.Create;323 BrainFuckInterpreter.OnChangeState := BrainFuckInterpreterChangeState;324 BrainFuckCompiler := TTarget.Create;325 340 Targets := TTargetList.Create; 326 341 Targets.Add(TTargetInterpretter.Create); … … 340 355 LastOpenedList.Free; 341 356 Targets.Free; 342 BrainFuckCompiler.Free;343 BrainFuckInterpreter.Free;344 357 BreakPoints.Free; 345 358 end; … … 349 362 InterpreterForm.LastStepCounter := 0; 350 363 InterpreterForm.Show; 351 BrainFuckInterpreter.Input := InterpreterForm.MemoInput.Lines.Text; 352 BrainFuckInterpreter.Source := MemoSource.Text; 353 BrainFuckInterpreter.Run; 364 if CurrentTarget is TTargetInterpretter then 365 TTargetInterpretter(CurrentTarget).Input := InterpreterForm.MemoInput.Lines.Text; 366 CurrentTarget.Source := MemoSource.Text; 367 CurrentTarget.Run; 354 368 end; 355 369 … … 442 456 procedure TMainForm.AOptionsExecute(Sender: TObject); 443 457 begin 444 OptionsForm.LoadFromInterpretter(BrainFuckInterpreter);458 //OptionsForm.LoadFromInterpretter(CurrentTarget); 445 459 if OptionsForm.ShowModal = mrOK then begin 446 OptionsForm.SaveToInterpretter(BrainFuckInterpreter);447 end; 448 end; 449 450 procedure TMainForm.A CompileExecute(Sender: TObject);451 begin 452 with TTarget(Targets[CompilerIndex])do begin460 //OptionsForm.SaveToInterpretter(CurrentTarget); 461 end; 462 end; 463 464 procedure TMainForm.AProgramCompileExecute(Sender: TObject); 465 begin 466 with CurrentTarget do begin 453 467 Optimization := coNormal; 454 468 Source := MemoSource.Text; … … 467 481 procedure TMainForm.ACompileAndRunExecute(Sender: TObject); 468 482 begin 469 with TTarget(Targets[CompilerIndex])do begin483 with CurrentTarget do begin 470 484 Optimization := coNormal; 471 485 Source := MemoSource.Text; … … 480 494 procedure TMainForm.AProgramPauseExecute(Sender: TObject); 481 495 begin 482 MainForm.BrainFuckInterpreter.Pause496 CurrentTarget.Pause 483 497 end; 484 498 485 499 procedure TMainForm.AProgramStopExecute(Sender: TObject); 486 500 begin 487 MainForm.BrainFuckInterpreter.Stop;501 CurrentTarget.Stop; 488 502 end; 489 503
Note:
See TracChangeset
for help on using the changeset viewer.