Changeset 133 for trunk/UTarget.pas


Ignore:
Timestamp:
Mar 4, 2022, 10:57:08 PM (3 years ago)
Author:
chronos
Message:
  • Added: Compile multiple action for compilation of code with mutliple compilers at once.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UTarget.pas

    r128 r133  
    1616  TTargetCapabilities = set of TTargetCapability;
    1717
    18   TRunState = (rsStopped, rsPaused, rsRunning);
     18  TRunState = (rsStopped, rsPaused, rsRunning, rsCompiling);
    1919
    2020  TStepOperation = (soNormal, soStepIn, soStepOut);
     
    2727  end;
    2828
    29   { TDebugStepList }
    30 
    31   TDebugStepList = class(TFPGObjectList<TDebugStep>)
     29  { TDebugSteps }
     30
     31  TDebugSteps = class(TFPGObjectList<TDebugStep>)
    3232    function SearchBySourcePos(Pos: Integer): TDebugStep;
    3333    function SearchByProgramPos(Pos: Integer): TDebugStep;
     
    4444  end;
    4545
    46   { TBreakPointList }
    47 
    48   TBreakPointList = class(TFPGObjectList<TBreakPoint>)
     46  { TBreakPoints }
     47
     48  TBreakPoints = class(TFPGObjectList<TBreakPoint>)
    4949    procedure AddItem(TargetAddress: Integer);
    5050    procedure SetSystem(TargetAddress: Integer);
     
    5959  end;
    6060
    61   { TMessageList }
    62 
    63   TMessageList = class(TFPGObjectList<TMessage>)
     61  { TMessages }
     62
     63  TMessages = class(TFPGObjectList<TMessage>)
    6464  private
    6565    FOnChange: TNotifyEvent;
     
    7272
    7373  TLogEvent = procedure (Lines: TStrings) of object;
     74  TMessageEvent = procedure (Text: string) of object;
    7475
    7576  { TTarget }
     
    7879  private
    7980    FOnLog: TLogEvent;
     81    FOnMessage: TMessageEvent;
    8082  protected
     83    FCompiledExtension: string;
     84    FRunExtension: string;
     85    FSourceExtension: string;
     86    FName: string;
     87    FImageIndex: Integer;
     88    FCapabilities: TTargetCapabilities;
    8189    FCompiled: Boolean;
    8290    function SourceReadNext: Char;
     
    96104    procedure SetState(AValue: TRunState); virtual;
    97105  public
    98     Name: string;
    99106    ProgramName: string;
    100     ImageIndex: Integer;
    101107    OptimizationLevel: TCompilerOptimization;
    102108    CompilerPath: string;
    103109    ExecutorPath: string;
    104     SourceExtension: string;
    105     RunExtension: string;
    106     CompiledExtension: string;
    107110    ProjectFileName: string;
    108     Capabilities: TTargetCapabilities;
    109     BreakPoints: TBreakPointList;
    110     DebugSteps: TDebugStepList;
     111    BreakPoints: TBreakPoints;
     112    DebugSteps: TDebugSteps;
    111113    DebugEnabled: Boolean;
    112     Messages: TMessageList;
     114    Selected: Boolean;
    113115    constructor Create; virtual;
    114116    destructor Destroy; override;
     
    127129    procedure LoadFromRegistry(Context: TRegistryContext); virtual;
    128130    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;
    129136    property State: TRunState read FState write SetState;
    130137    property SourceCode: string write SetSourceCode;
     
    132139    property Compiled: Boolean read FCompiled write FCompiled;
    133140    property ExecutionPosition: Integer read GetExecutionPosition;
     141    property Capabilities: TTargetCapabilities read FCapabilities;
    134142    property OnChangeState: TNotifyEvent read FOnChangeState write FOnChangeState;
    135143    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>)
    141150    procedure LoadFromRegistry(Context: TRegistryContext);
    142151    procedure SaveToRegistry(Context: TRegistryContext);
     
    146155  end;
    147156
     157const
     158  RunStateText: array[TRunState] of string = ('Stopped', 'Paused', 'Running',
     159    'Compiling');
     160
    148161
    149162resourcestring
     
    155168implementation
    156169
    157 { TMessageList }
    158 
    159 procedure TMessageList.DoChange;
     170{ TMessages }
     171
     172procedure TMessages.DoChange;
    160173begin
    161174  if Assigned(FOnChange) then FOnChange(Self);
    162175end;
    163176
    164 procedure TMessageList.AddMessage(Text: string);
     177procedure TMessages.AddMessage(Text: string);
    165178var
    166179  NewItem: TMessage;
     
    172185end;
    173186
    174 procedure TMessageList.AppendMessage(Text: string);
     187procedure TMessages.AppendMessage(Text: string);
    175188begin
    176189  if Count > 0 then begin
     
    180193end;
    181194
    182 { TBreakPointList }
    183 
    184 procedure TBreakPointList.AddItem(TargetAddress: Integer);
     195{ TBreakPoints }
     196
     197procedure TBreakPoints.AddItem(TargetAddress: Integer);
    185198var
    186199  NewItem: TBreakPoint;
     
    191204end;
    192205
    193 procedure TBreakPointList.SetSystem(TargetAddress: Integer);
     206procedure TBreakPoints.SetSystem(TargetAddress: Integer);
    194207begin
    195208  ClearSystem;
     
    197210end;
    198211
    199 procedure TBreakPointList.AddSystem(TargetAddress: Integer);
     212procedure TBreakPoints.AddSystem(TargetAddress: Integer);
    200213var
    201214  NewItem: TBreakPoint;
     
    207220end;
    208221
    209 procedure TBreakPointList.ClearSystem;
     222procedure TBreakPoints.ClearSystem;
    210223var
    211224  I: Integer;
     
    215228end;
    216229
    217 function TBreakPointList.SearchByTargetPos(Pos: Integer): TBreakPoint;
     230function TBreakPoints.SearchByTargetPos(Pos: Integer): TBreakPoint;
    218231var
    219232  I: Integer;
     
    225238end;
    226239
    227 { TDebugStepList }
    228 
    229 function TDebugStepList.SearchBySourcePos(Pos: Integer
     240{ TDebugSteps }
     241
     242function TDebugSteps.SearchBySourcePos(Pos: Integer
    230243  ): TDebugStep;
    231244var
     
    238251end;
    239252
    240 function TDebugStepList.SearchByProgramPos(Pos: Integer): TDebugStep;
     253function TDebugSteps.SearchByProgramPos(Pos: Integer): TDebugStep;
    241254var
    242255  I: Integer;
     
    248261end;
    249262
    250 function TDebugStepList.SearchByTargetPos(Pos: Integer
     263function TDebugSteps.SearchByTargetPos(Pos: Integer
    251264  ): TDebugStep;
    252265var
     
    259272end;
    260273
    261 function TDebugStepList.SearchIndexByProgramPos(Pos: Integer): Integer;
     274function TDebugSteps.SearchIndexByProgramPos(Pos: Integer): Integer;
    262275var
    263276  I: Integer;
     
    269282end;
    270283
    271 procedure TDebugStepList.AddStep(SourcePos, TargetPos: Integer;
     284procedure TDebugSteps.AddStep(SourcePos, TargetPos: Integer;
    272285  Operation: TStepOperation);
    273286var
     
    282295end;
    283296
    284 procedure TDebugStepList.UpdateTargetPos(OldProgramFrom, OldProgramTo, NewProgramFrom,
     297procedure TDebugSteps.UpdateTargetPos(OldProgramFrom, OldProgramTo, NewProgramFrom,
    285298    NewProgramTo: Integer; NewTarget: Integer = 0);
    286299var
     
    311324end;
    312325
    313 { TTargetList }
    314 
    315 procedure TTargetList.LoadFromRegistry(Context: TRegistryContext);
     326{ TTargets }
     327
     328procedure TTargets.LoadFromRegistry(Context: TRegistryContext);
    316329var
    317330  I: Integer;
     
    327340end;
    328341
    329 procedure TTargetList.SaveToRegistry(Context: TRegistryContext);
     342procedure TTargets.SaveToRegistry(Context: TRegistryContext);
    330343var
    331344  I: Integer;
     
    342355end;
    343356
    344 function TTargetList.FindByName(Name: string): TTarget;
     357function TTargets.FindByName(Name: string): TTarget;
    345358var
    346359  I: Integer;
     
    352365end;
    353366
    354 procedure TTargetList.LoadToMenuItem(MenuItem: TMenuItem; Action: TNotifyEvent
     367procedure TTargets.LoadToMenuItem(MenuItem: TMenuItem; Action: TNotifyEvent
    355368  ; CurrentTarget: TTarget);
    356369var
     
    359372begin
    360373  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;
    362380    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;
    369385    end;
    370386  end;
     
    414430  inherited;
    415431  OptimizationLevel := coNormal;
    416   BreakPoints := TBreakPointList.Create;
    417   DebugSteps := TDebugStepList.Create;
    418   Messages := TMessageList.Create;
     432  BreakPoints := TBreakPoints.Create;
     433  DebugSteps := TDebugSteps.Create;
    419434end;
    420435
    421436destructor TTarget.Destroy;
    422437begin
    423   FreeAndNil(Messages);
    424438  FreeAndNil(DebugSteps);
    425439  FreeAndNil(BreakPoints);
     
    429443procedure TTarget.Reset;
    430444begin
    431   Messages.Clear;
    432445end;
    433446
     
    551564    CompilerPath := ReadStringWithDefault('CompilerPath', CompilerPath);
    552565    ExecutorPath := ReadStringWithDefault('ExecutorPath', ExecutorPath);
     566    Selected := ReadBoolWithDefault('Selected', Selected);
    553567  finally
    554568    Free;
     
    561575  try
    562576    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);
    567580  finally
    568581    Free;
Note: See TracChangeset for help on using the changeset viewer.