Changeset 33 for trunk/Target/UTarget.pas
- Timestamp:
- Feb 18, 2012, 11:08:44 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Target/UTarget.pas
r32 r33 18 18 TRunState = (rsStopped, rsPaused, rsRunning); 19 19 20 TStepOperation = (soNormal, soStepIn, soStepOut); 21 22 TDebugStep = class 23 SourcePosition: Integer; 24 TargetPosition: Integer; 25 Operation: TStepOperation; 26 end; 27 28 { TDebugStepList } 29 30 TDebugStepList = class(TListObject) 31 function SearchBySourcePos(Pos: Integer): TDebugStep; 32 function SearchByTargetPos(Pos: Integer): TDebugStep; 33 procedure AddStep(SourcePos, TargetPos: Integer; Operation: TStepOperation); 34 end; 35 20 36 { TTarget } 21 37 22 38 TTarget = class 23 39 private 40 FCompiled: Boolean; 24 41 protected 25 FSource: string; 42 FSourceCode: string; 43 FTargetCode: string; 26 44 Indent: Integer; 27 45 FState: TRunState; 28 46 FOnChangeState: TNotifyEvent; 29 procedure SetSource(AValue: string); virtual; 47 procedure SetSourceCode(AValue: string); virtual; 48 function GetTargetCode: string; virtual; 30 49 procedure AddLine(Text: string); 31 50 function LongFileName(FileName: string): string; … … 33 52 Name: string; 34 53 ProgramName: string; 35 Output: string;36 54 Optimization: TCompilerOptimization; 37 55 CompilerPath: string; … … 40 58 ProjectFileName: string; 41 59 Capabilities: TTargetCapabilities; 60 BreakPointers: TListInteger; 61 DebugSteps: TDebugStepList; 42 62 constructor Create; virtual; 63 destructor Destroy; override; 43 64 procedure OptimizeSource; 44 65 procedure Compile; virtual; … … 55 76 property State: TRunState read FState; 56 77 property OnChangeState: TNotifyEvent read FOnChangeState write FOnChangeState; 57 property Source: string write SetSource; 78 property SourceCode: string write SetSourceCode; 79 property TargetCode: string read GetTargetCode; 80 property Compiled: Boolean read FCompiled write FCompiled; 58 81 end; 59 82 … … 73 96 74 97 implementation 98 99 { TDebugStepList } 100 101 function TDebugStepList.SearchBySourcePos(Pos: Integer 102 ): TDebugStep; 103 var 104 I: Integer; 105 begin 106 I := 0; 107 while (I < Count) and (TDebugStep(Items[I]).SourcePosition < Pos) do Inc(I); 108 if I < Count then Result := TDebugStep(Items[I]) 109 else Result := nil; 110 end; 111 112 function TDebugStepList.SearchByTargetPos(Pos: Integer 113 ): TDebugStep; 114 var 115 I: Integer; 116 begin 117 I := 0; 118 while (I < Count) and (TDebugStep(Items[I]).TargetPosition < Pos) do Inc(I); 119 if I < Count then Result := TDebugStep(Items[I]) 120 else Result := nil; 121 end; 122 123 procedure TDebugStepList.AddStep(SourcePos, TargetPos: Integer; 124 Operation: TStepOperation); 125 var 126 NewItem: TDebugStep; 127 begin 128 NewItem := TDebugStep.Create; 129 NewItem.SourcePosition := SourcePos; 130 NewItem.TargetPosition := TargetPos; 131 NewItem.Operation := Operation; 132 Add(NewItem); 133 end; 75 134 76 135 … … 122 181 { TTarget } 123 182 124 procedure TTarget.SetSource(AValue: string); 125 begin 126 FSource := AValue; 183 function TTarget.GetTargetCode: string; 184 begin 185 Result := FTargetCode; 186 end; 187 188 procedure TTarget.SetSourceCode(AValue: string); 189 begin 190 FSourceCode := AValue; 127 191 end; 128 192 129 193 procedure TTarget.AddLine(Text: string); 130 194 begin 131 Output := Output+ DupeString(' ', Indent) + Text + LineEnding;195 FTargetCode := FTargetCode + DupeString(' ', Indent) + Text + LineEnding; 132 196 end; 133 197 … … 145 209 constructor TTarget.Create; 146 210 begin 211 inherited; 147 212 Optimization := coNormal; 213 BreakPointers := TListInteger.Create; 214 DebugSteps := TDebugStepList.Create; 215 end; 216 217 destructor TTarget.Destroy; 218 begin 219 DebugSteps.Free;; 220 BreakPointers.Free; 221 inherited Destroy; 148 222 end; 149 223 … … 156 230 procedure TTarget.Compile; 157 231 begin 158 232 Compiled := True; 159 233 end; 160 234 … … 170 244 with TStringList.Create do 171 245 try 172 Text := Output;246 Text := FTargetCode; 173 247 SaveToFile(CompiledFile); 174 248 finally
Note:
See TracChangeset
for help on using the changeset viewer.