Changeset 133 for trunk/UTarget.pas
- Timestamp:
- Mar 4, 2022, 10:57:08 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UTarget.pas
r128 r133 16 16 TTargetCapabilities = set of TTargetCapability; 17 17 18 TRunState = (rsStopped, rsPaused, rsRunning );18 TRunState = (rsStopped, rsPaused, rsRunning, rsCompiling); 19 19 20 20 TStepOperation = (soNormal, soStepIn, soStepOut); … … 27 27 end; 28 28 29 { TDebugStep List}30 31 TDebugStep List= class(TFPGObjectList<TDebugStep>)29 { TDebugSteps } 30 31 TDebugSteps = class(TFPGObjectList<TDebugStep>) 32 32 function SearchBySourcePos(Pos: Integer): TDebugStep; 33 33 function SearchByProgramPos(Pos: Integer): TDebugStep; … … 44 44 end; 45 45 46 { TBreakPoint List}47 48 TBreakPoint List= class(TFPGObjectList<TBreakPoint>)46 { TBreakPoints } 47 48 TBreakPoints = class(TFPGObjectList<TBreakPoint>) 49 49 procedure AddItem(TargetAddress: Integer); 50 50 procedure SetSystem(TargetAddress: Integer); … … 59 59 end; 60 60 61 { TMessage List}62 63 TMessage List= class(TFPGObjectList<TMessage>)61 { TMessages } 62 63 TMessages = class(TFPGObjectList<TMessage>) 64 64 private 65 65 FOnChange: TNotifyEvent; … … 72 72 73 73 TLogEvent = procedure (Lines: TStrings) of object; 74 TMessageEvent = procedure (Text: string) of object; 74 75 75 76 { TTarget } … … 78 79 private 79 80 FOnLog: TLogEvent; 81 FOnMessage: TMessageEvent; 80 82 protected 83 FCompiledExtension: string; 84 FRunExtension: string; 85 FSourceExtension: string; 86 FName: string; 87 FImageIndex: Integer; 88 FCapabilities: TTargetCapabilities; 81 89 FCompiled: Boolean; 82 90 function SourceReadNext: Char; … … 96 104 procedure SetState(AValue: TRunState); virtual; 97 105 public 98 Name: string;99 106 ProgramName: string; 100 ImageIndex: Integer;101 107 OptimizationLevel: TCompilerOptimization; 102 108 CompilerPath: string; 103 109 ExecutorPath: string; 104 SourceExtension: string;105 RunExtension: string;106 CompiledExtension: string;107 110 ProjectFileName: string; 108 Capabilities: TTargetCapabilities; 109 BreakPoints: TBreakPointList; 110 DebugSteps: TDebugStepList; 111 BreakPoints: TBreakPoints; 112 DebugSteps: TDebugSteps; 111 113 DebugEnabled: Boolean; 112 Messages: TMessageList;114 Selected: Boolean; 113 115 constructor Create; virtual; 114 116 destructor Destroy; override; … … 127 129 procedure LoadFromRegistry(Context: TRegistryContext); virtual; 128 130 procedure SaveToRegistry(Context: TRegistryContext); virtual; 131 property SourceExtension: string read FSourceExtension; 132 property RunExtension: string read FRunExtension; 133 property CompiledExtension: string read FCompiledExtension; 134 property Name: string read FName; 135 property ImageIndex: Integer read FImageIndex; 129 136 property State: TRunState read FState write SetState; 130 137 property SourceCode: string write SetSourceCode; … … 132 139 property Compiled: Boolean read FCompiled write FCompiled; 133 140 property ExecutionPosition: Integer read GetExecutionPosition; 141 property Capabilities: TTargetCapabilities read FCapabilities; 134 142 property OnChangeState: TNotifyEvent read FOnChangeState write FOnChangeState; 135 143 property OnLog: TLogEvent read FOnLog write FOnLog; 136 end; 137 138 { TTargetList } 139 140 TTargetList = class(TFPGObjectList<TTarget>) 144 property OnMessage: TMessageEvent read FOnMessage write FOnMessage; 145 end; 146 147 { TTargets } 148 149 TTargets = class(TFPGObjectList<TTarget>) 141 150 procedure LoadFromRegistry(Context: TRegistryContext); 142 151 procedure SaveToRegistry(Context: TRegistryContext); … … 146 155 end; 147 156 157 const 158 RunStateText: array[TRunState] of string = ('Stopped', 'Paused', 'Running', 159 'Compiling'); 160 148 161 149 162 resourcestring … … 155 168 implementation 156 169 157 { TMessage List}158 159 procedure TMessage List.DoChange;170 { TMessages } 171 172 procedure TMessages.DoChange; 160 173 begin 161 174 if Assigned(FOnChange) then FOnChange(Self); 162 175 end; 163 176 164 procedure TMessage List.AddMessage(Text: string);177 procedure TMessages.AddMessage(Text: string); 165 178 var 166 179 NewItem: TMessage; … … 172 185 end; 173 186 174 procedure TMessage List.AppendMessage(Text: string);187 procedure TMessages.AppendMessage(Text: string); 175 188 begin 176 189 if Count > 0 then begin … … 180 193 end; 181 194 182 { TBreakPoint List}183 184 procedure TBreakPoint List.AddItem(TargetAddress: Integer);195 { TBreakPoints } 196 197 procedure TBreakPoints.AddItem(TargetAddress: Integer); 185 198 var 186 199 NewItem: TBreakPoint; … … 191 204 end; 192 205 193 procedure TBreakPoint List.SetSystem(TargetAddress: Integer);206 procedure TBreakPoints.SetSystem(TargetAddress: Integer); 194 207 begin 195 208 ClearSystem; … … 197 210 end; 198 211 199 procedure TBreakPoint List.AddSystem(TargetAddress: Integer);212 procedure TBreakPoints.AddSystem(TargetAddress: Integer); 200 213 var 201 214 NewItem: TBreakPoint; … … 207 220 end; 208 221 209 procedure TBreakPoint List.ClearSystem;222 procedure TBreakPoints.ClearSystem; 210 223 var 211 224 I: Integer; … … 215 228 end; 216 229 217 function TBreakPoint List.SearchByTargetPos(Pos: Integer): TBreakPoint;230 function TBreakPoints.SearchByTargetPos(Pos: Integer): TBreakPoint; 218 231 var 219 232 I: Integer; … … 225 238 end; 226 239 227 { TDebugStep List}228 229 function TDebugStep List.SearchBySourcePos(Pos: Integer240 { TDebugSteps } 241 242 function TDebugSteps.SearchBySourcePos(Pos: Integer 230 243 ): TDebugStep; 231 244 var … … 238 251 end; 239 252 240 function TDebugStep List.SearchByProgramPos(Pos: Integer): TDebugStep;253 function TDebugSteps.SearchByProgramPos(Pos: Integer): TDebugStep; 241 254 var 242 255 I: Integer; … … 248 261 end; 249 262 250 function TDebugStep List.SearchByTargetPos(Pos: Integer263 function TDebugSteps.SearchByTargetPos(Pos: Integer 251 264 ): TDebugStep; 252 265 var … … 259 272 end; 260 273 261 function TDebugStep List.SearchIndexByProgramPos(Pos: Integer): Integer;274 function TDebugSteps.SearchIndexByProgramPos(Pos: Integer): Integer; 262 275 var 263 276 I: Integer; … … 269 282 end; 270 283 271 procedure TDebugStep List.AddStep(SourcePos, TargetPos: Integer;284 procedure TDebugSteps.AddStep(SourcePos, TargetPos: Integer; 272 285 Operation: TStepOperation); 273 286 var … … 282 295 end; 283 296 284 procedure TDebugStep List.UpdateTargetPos(OldProgramFrom, OldProgramTo, NewProgramFrom,297 procedure TDebugSteps.UpdateTargetPos(OldProgramFrom, OldProgramTo, NewProgramFrom, 285 298 NewProgramTo: Integer; NewTarget: Integer = 0); 286 299 var … … 311 324 end; 312 325 313 { TTarget List}314 315 procedure TTarget List.LoadFromRegistry(Context: TRegistryContext);326 { TTargets } 327 328 procedure TTargets.LoadFromRegistry(Context: TRegistryContext); 316 329 var 317 330 I: Integer; … … 327 340 end; 328 341 329 procedure TTarget List.SaveToRegistry(Context: TRegistryContext);342 procedure TTargets.SaveToRegistry(Context: TRegistryContext); 330 343 var 331 344 I: Integer; … … 342 355 end; 343 356 344 function TTarget List.FindByName(Name: string): TTarget;357 function TTargets.FindByName(Name: string): TTarget; 345 358 var 346 359 I: Integer; … … 352 365 end; 353 366 354 procedure TTarget List.LoadToMenuItem(MenuItem: TMenuItem; Action: TNotifyEvent367 procedure TTargets.LoadToMenuItem(MenuItem: TMenuItem; Action: TNotifyEvent 355 368 ; CurrentTarget: TTarget); 356 369 var … … 359 372 begin 360 373 if Assigned(MenuItem) then begin 361 MenuItem.Clear; 374 while MenuItem.Count > Count do 375 MenuItem.Delete(MenuItem.Count - 1); 376 while MenuItem.Count < Count do begin 377 NewMenuItem := TMenuItem.Create(MenuItem); 378 MenuItem.Add(NewMenuItem); 379 end; 362 380 for I := 0 to Count - 1 do begin 363 NewMenuItem := TMenuItem.Create(MenuItem); 364 NewMenuItem.Caption := Items[I].Name; 365 NewMenuItem.OnClick := Action; 366 NewMenuItem.ImageIndex := Items[I].ImageIndex; 367 if Items[I] = CurrentTarget then NewMenuItem.Checked := True; 368 MenuItem.Add(NewMenuItem); 381 MenuItem.Items[I].Caption := Items[I].Name; 382 MenuItem.Items[I].OnClick := Action; 383 MenuItem.Items[I].ImageIndex := Items[I].ImageIndex; 384 if Items[I] = CurrentTarget then MenuItem.Items[I].Checked := True; 369 385 end; 370 386 end; … … 414 430 inherited; 415 431 OptimizationLevel := coNormal; 416 BreakPoints := TBreakPointList.Create; 417 DebugSteps := TDebugStepList.Create; 418 Messages := TMessageList.Create; 432 BreakPoints := TBreakPoints.Create; 433 DebugSteps := TDebugSteps.Create; 419 434 end; 420 435 421 436 destructor TTarget.Destroy; 422 437 begin 423 FreeAndNil(Messages);424 438 FreeAndNil(DebugSteps); 425 439 FreeAndNil(BreakPoints); … … 429 443 procedure TTarget.Reset; 430 444 begin 431 Messages.Clear;432 445 end; 433 446 … … 551 564 CompilerPath := ReadStringWithDefault('CompilerPath', CompilerPath); 552 565 ExecutorPath := ReadStringWithDefault('ExecutorPath', ExecutorPath); 566 Selected := ReadBoolWithDefault('Selected', Selected); 553 567 finally 554 568 Free; … … 561 575 try 562 576 CurrentContext := Context; 563 if CompilerPath <> '' then WriteString('CompilerPath', CompilerPath) 564 else DeleteValue('CompilerPath'); 565 if ExecutorPath <> '' then WriteString('ExecutorPath', ExecutorPath) 566 else DeleteValue('ExecutorPath'); 577 WriteString('CompilerPath', CompilerPath); 578 WriteString('ExecutorPath', ExecutorPath); 579 WriteBool('Selected', Selected); 567 580 finally 568 581 Free;
Note:
See TracChangeset
for help on using the changeset viewer.