Changeset 35 for trunk/Target
- Timestamp:
- Feb 19, 2012, 12:03:21 AM (13 years ago)
- Location:
- trunk/Target
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Target/UTarget.pas
r34 r35 49 49 procedure AddLine(Text: string); 50 50 function LongFileName(FileName: string): string; 51 function GetExecutionPosition: Integer; virtual; 51 52 public 52 53 Name: string; … … 58 59 ProjectFileName: string; 59 60 Capabilities: TTargetCapabilities; 60 BreakPoint ers: TListInteger;61 BreakPoints: TListInteger; 61 62 DebugSteps: TDebugStepList; 62 63 constructor Create; virtual; … … 71 72 procedure StepInto; virtual; 72 73 procedure StepOut; virtual; 73 procedure RunToCursor ; virtual;74 procedure RunToCursor(Pos: Integer); virtual; 74 75 procedure LoadFromRegistry(Root: HKEY; Key: string); virtual; 75 76 procedure SaveToRegistry(Root: HKEY; Key: string); virtual; … … 79 80 property TargetCode: string read GetTargetCode; 80 81 property Compiled: Boolean read FCompiled write FCompiled; 82 property ExecutionPosition: Integer read GetExecutionPosition; 81 83 end; 82 84 … … 184 186 begin 185 187 Result := FTargetCode; 188 end; 189 190 function TTarget.GetExecutionPosition: Integer; 191 begin 192 186 193 end; 187 194 … … 211 218 inherited; 212 219 Optimization := coNormal; 213 BreakPoint ers := TListInteger.Create;220 BreakPoints := TListInteger.Create; 214 221 DebugSteps := TDebugStepList.Create; 215 222 end; … … 218 225 begin 219 226 DebugSteps.Free;; 220 BreakPoint ers.Free;227 BreakPoints.Free; 221 228 inherited Destroy; 222 229 end; … … 303 310 end; 304 311 305 procedure TTarget.RunToCursor ;312 procedure TTarget.RunToCursor(Pos: Integer); 306 313 begin 307 314 -
trunk/Target/UTargetC.pas
r34 r35 57 57 58 58 begin 59 inherited; 59 60 Indent := 0; 60 61 FTargetCode := ''; -
trunk/Target/UTargetDelphi.pas
r34 r35 52 52 53 53 begin 54 inherited; 54 55 Indent := 0; 55 56 FTargetCode := ''; -
trunk/Target/UTargetInterpretter.pas
r33 r35 45 45 procedure CommandLoopStart; 46 46 procedure CommandLoopEnd; 47 procedure SingleStep;48 47 procedure Reset; 48 procedure PrepareBreakPoints; 49 49 protected 50 50 function GetTargetCode: string; override; 51 function GetExecutionPosition: Integer; override; 51 52 public 52 53 FProgram: array of TBrainFuckCommand; 54 FProgramBreakpoints: array of Boolean; 53 55 SourceJump: array of Integer; 54 56 SourcePosition: Integer; … … 64 66 procedure Pause; override; 65 67 procedure Stop; override; 68 procedure StepInto; override; 69 procedure StepOver; override; 70 procedure StepOut; override; 71 procedure RunToCursor(Pos: Integer); override; 66 72 constructor Create; override; 67 73 destructor Destroy; override; … … 92 98 procedure TTargetInterpretterThread.Execute; 93 99 begin 100 with Parent do 94 101 repeat 95 while (Parent.SourcePosition < Length(Parent.FProgram)) and (Parent.State <> rsStopped) do begin 96 Parent.SingleStep; 97 while Parent.State = rsPaused do begin 98 Sleep(1); 99 end; 102 while (SourcePosition < Length(FProgram)) and (State <> rsStopped) do begin 103 if State = rsRunning then begin 104 if FProgramBreakpoints[SourcePosition] then begin 105 FProgramBreakpoints[SourcePosition] := False; 106 SetState(rsPaused); 107 end else begin 108 FCommandTable[FProgram[SourcePosition]]; 109 Inc(SourcePosition); 110 Inc(FStepCount); 111 end; 112 end else 113 if State = rsPaused then Sleep(1); 100 114 end; 101 Parent.SetState(rsStopped);102 until Terminated or ( Parent.State = rsStopped);115 SetState(rsStopped); 116 until Terminated or (State = rsStopped); 103 117 end; 104 118 … … 127 141 Pos: Integer; 128 142 begin 143 inherited; 129 144 DebugSteps.Clear; 130 145 SetLength(FProgram, Length(FSourceCode)); … … 282 297 end; 283 298 299 procedure TTargetInterpretter.PrepareBreakPoints; 300 var 301 I: Integer; 302 begin 303 SetLength(FProgramBreakpoints, Length(FProgram)); 304 for I := 0 to High(FProgramBreakpoints) do 305 FProgramBreakpoints[I] := False; 306 for I := 0 to BreakPoints.Count - 1 do 307 FProgramBreakpoints[BreakPoints[I]] := True; 308 end; 309 284 310 function TTargetInterpretter.GetTargetCode: string; 285 311 var … … 291 317 end; 292 318 293 procedure TTargetInterpretter.SingleStep; 294 begin 295 FCommandTable[FProgram[SourcePosition]]; 296 Inc(SourcePosition); 297 Inc(FStepCount); 319 function TTargetInterpretter.GetExecutionPosition: Integer; 320 begin 321 Result := SourcePosition; 298 322 end; 299 323 … … 302 326 SetState(rsRunning); 303 327 Reset; 328 PrepareBreakPoints; 304 329 SetThread(False); 305 330 SetThread(True); … … 314 339 begin 315 340 SetState(rsStopped); 341 end; 342 343 procedure TTargetInterpretter.StepInto; 344 var 345 Step: TDebugStep; 346 begin 347 Step := DebugSteps.SearchByTargetPos(SourcePosition); 348 FProgramBreakpoints[Step.TargetPosition + 1] := True; 349 end; 350 351 procedure TTargetInterpretter.StepOver; 352 var 353 Step: TDebugStep; 354 begin 355 end; 356 357 procedure TTargetInterpretter.StepOut; 358 begin 359 inherited StepOut; 360 end; 361 362 procedure TTargetInterpretter.RunToCursor(Pos: Integer); 363 begin 364 FProgramBreakpoints[Pos] := True; 316 365 end; 317 366 -
trunk/Target/UTargetPHP.pas
r34 r35 55 55 56 56 begin 57 inherited; 57 58 Indent := 0; 58 59 FTargetCode := '';
Note:
See TracChangeset
for help on using the changeset viewer.