Ignore:
Timestamp:
Feb 18, 2012, 11:08:44 PM (13 years ago)
Author:
chronos
Message:
  • Modified: CompiledForm replaced by compiled source tab in PageControl on MainForm.
  • Added: Function for switching position between source code and target code.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Target/UTarget.pas

    r32 r33  
    1818  TRunState = (rsStopped, rsPaused, rsRunning);
    1919
     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
    2036  { TTarget }
    2137
    2238  TTarget = class
    2339  private
     40    FCompiled: Boolean;
    2441  protected
    25     FSource: string;
     42    FSourceCode: string;
     43    FTargetCode: string;
    2644    Indent: Integer;
    2745    FState: TRunState;
    2846    FOnChangeState: TNotifyEvent;
    29     procedure SetSource(AValue: string); virtual;
     47    procedure SetSourceCode(AValue: string); virtual;
     48    function GetTargetCode: string; virtual;
    3049    procedure AddLine(Text: string);
    3150    function LongFileName(FileName: string): string;
     
    3352    Name: string;
    3453    ProgramName: string;
    35     Output: string;
    3654    Optimization: TCompilerOptimization;
    3755    CompilerPath: string;
     
    4058    ProjectFileName: string;
    4159    Capabilities: TTargetCapabilities;
     60    BreakPointers: TListInteger;
     61    DebugSteps: TDebugStepList;
    4262    constructor Create; virtual;
     63    destructor Destroy; override;
    4364    procedure OptimizeSource;
    4465    procedure Compile; virtual;
     
    5576    property State: TRunState read FState;
    5677    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;
    5881  end;
    5982
     
    7396
    7497implementation
     98
     99{ TDebugStepList }
     100
     101function TDebugStepList.SearchBySourcePos(Pos: Integer
     102  ): TDebugStep;
     103var
     104  I: Integer;
     105begin
     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;
     110end;
     111
     112function TDebugStepList.SearchByTargetPos(Pos: Integer
     113  ): TDebugStep;
     114var
     115  I: Integer;
     116begin
     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;
     121end;
     122
     123procedure TDebugStepList.AddStep(SourcePos, TargetPos: Integer;
     124  Operation: TStepOperation);
     125var
     126  NewItem: TDebugStep;
     127begin
     128  NewItem := TDebugStep.Create;
     129  NewItem.SourcePosition := SourcePos;
     130  NewItem.TargetPosition := TargetPos;
     131  NewItem.Operation := Operation;
     132  Add(NewItem);
     133end;
    75134
    76135
     
    122181{ TTarget }
    123182
    124 procedure TTarget.SetSource(AValue: string);
    125 begin
    126   FSource := AValue;
     183function TTarget.GetTargetCode: string;
     184begin
     185  Result := FTargetCode;
     186end;
     187
     188procedure TTarget.SetSourceCode(AValue: string);
     189begin
     190  FSourceCode := AValue;
    127191end;
    128192
    129193procedure TTarget.AddLine(Text: string);
    130194begin
    131   Output := Output + DupeString('  ', Indent) + Text + LineEnding;
     195  FTargetCode := FTargetCode + DupeString('  ', Indent) + Text + LineEnding;
    132196end;
    133197
     
    145209constructor TTarget.Create;
    146210begin
     211  inherited;
    147212  Optimization := coNormal;
     213  BreakPointers := TListInteger.Create;
     214  DebugSteps := TDebugStepList.Create;
     215end;
     216
     217destructor TTarget.Destroy;
     218begin
     219  DebugSteps.Free;;
     220  BreakPointers.Free;
     221  inherited Destroy;
    148222end;
    149223
     
    156230procedure TTarget.Compile;
    157231begin
    158 
     232  Compiled := True;
    159233end;
    160234
     
    170244  with TStringList.Create do
    171245  try
    172     Text := Output;
     246    Text := FTargetCode;
    173247    SaveToFile(CompiledFile);
    174248  finally
Note: See TracChangeset for help on using the changeset viewer.