Changeset 114 for trunk/UTarget.pas
- Timestamp:
- May 18, 2019, 12:13:44 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UTarget.pas
r111 r114 22 22 TDebugStep = class 23 23 SourcePosition: Integer; 24 ProgramPosition: Integer; 24 25 TargetPosition: Integer; 25 26 Operation: TStepOperation; … … 30 31 TDebugStepList = class(TFPGObjectList<TDebugStep>) 31 32 function SearchBySourcePos(Pos: Integer): TDebugStep; 33 function SearchByProgramPos(Pos: Integer): TDebugStep; 32 34 function SearchByTargetPos(Pos: Integer): TDebugStep; 35 function SearchIndexByProgramPos(Pos: Integer): Integer; 33 36 procedure AddStep(SourcePos, TargetPos: Integer; Operation: TStepOperation); 34 procedure UpdateTargetPos(Old , New: Integer);37 procedure UpdateTargetPos(OldProgramFrom, OldProgramTo, NewProgram, NewTarget: Integer); 35 38 end; 36 39 … … 233 236 end; 234 237 238 function TDebugStepList.SearchByProgramPos(Pos: Integer): TDebugStep; 239 var 240 I: Integer; 241 begin 242 I := 0; 243 while (I < Count) and (TDebugStep(Items[I]).ProgramPosition < Pos) do Inc(I); 244 if I < Count then Result := TDebugStep(Items[I]) 245 else Result := nil; 246 end; 247 235 248 function TDebugStepList.SearchByTargetPos(Pos: Integer 236 249 ): TDebugStep; … … 244 257 end; 245 258 259 function TDebugStepList.SearchIndexByProgramPos(Pos: Integer): Integer; 260 var 261 I: Integer; 262 begin 263 I := 0; 264 while (I < Count) and (TDebugStep(Items[I]).ProgramPosition < Pos) do Inc(I); 265 if I < Count then Result := I 266 else Result := -1; 267 end; 268 246 269 procedure TDebugStepList.AddStep(SourcePos, TargetPos: Integer; 247 270 Operation: TStepOperation); … … 251 274 NewItem := TDebugStep.Create; 252 275 NewItem.SourcePosition := SourcePos; 276 NewItem.ProgramPosition := TargetPos; 253 277 NewItem.TargetPosition := TargetPos; 254 278 NewItem.Operation := Operation; … … 256 280 end; 257 281 258 procedure TDebugStepList.UpdateTargetPos(Old, New: Integer); 259 var 260 I: Integer; 261 begin 262 I := 0; 263 while (I < Count) do begin 264 if TDebugStep(Items[I]).TargetPosition = Old then 265 TDebugStep(Items[I]).TargetPosition := New; 266 Inc(I); 267 end; 282 procedure TDebugStepList.UpdateTargetPos(OldProgramFrom, OldProgramTo, NewProgram, NewTarget: Integer); 283 var 284 I: Integer; 285 First: Integer; 286 Last: Integer; 287 begin 288 First := SearchIndexByProgramPos(OldProgramFrom); 289 Last := SearchIndexByProgramPos(OldProgramTo); 290 for I := Last downto First + 1 do Delete(I); 291 TDebugStep(Items[First]).ProgramPosition := NewProgram; 292 TDebugStep(Items[First]).TargetPosition := NewTarget; 268 293 end; 269 294
Note:
See TracChangeset
for help on using the changeset viewer.