Changeset 32 for trunk/Target


Ignore:
Timestamp:
Feb 18, 2012, 8:44:10 PM (13 years ago)
Author:
chronos
Message:
  • Modified: Target specific options is maintained by target class in registry.
  • Modified: Integer index TargetIndex replaced by object reference CurrentTarget.
Location:
trunk/Target
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Target/UTarget.pas

    r31 r32  
    1212  TCompilerOptimization = (coNone, coNormal);
    1313
    14   TTargetCapability = (tcRun, tcPause, tcStop, tcStepOut, tsStepOver, tsStepInto,
    15     tsRunToCursor, tcCompile, tcBreakpoint);
     14  TTargetCapability = (tcRun, tcPause, tcStop, tcStepOut, tcStepOver, tcStepInto,
     15    tcRunToCursor, tcCompile, tcBreakpoint);
    1616  TTargetCapabilities = set of TTargetCapability;
    1717
     18  TRunState = (rsStopped, rsPaused, rsRunning);
     19
    1820  { TTarget }
    1921
    2022  TTarget = class
     23  private
    2124  protected
     25    FSource: string;
    2226    Indent: Integer;
     27    FState: TRunState;
     28    FOnChangeState: TNotifyEvent;
     29    procedure SetSource(AValue: string); virtual;
    2330    procedure AddLine(Text: string);
    2431    function LongFileName(FileName: string): string;
     
    2633    Name: string;
    2734    ProgramName: string;
    28     Source: string;
    2935    Output: string;
    3036    Optimization: TCompilerOptimization;
     
    4551    procedure StepOut; virtual;
    4652    procedure RunToCursor; virtual;
     53    procedure LoadFromRegistry(Root: HKEY; Key: string); virtual;
     54    procedure SaveToRegistry(Root: HKEY; Key: string); virtual;
     55    property State: TRunState read FState;
     56    property OnChangeState: TNotifyEvent read FOnChangeState write FOnChangeState;
     57    property Source: string write SetSource;
    4758  end;
    4859
     
    5263    procedure LoadFromRegistry(Root: HKEY; Key: string);
    5364    procedure SaveToRegistry(Root: HKEY; Key: string);
     65    function FindByName(Name: string): TTarget;
    5466  end;
    5567
     
    98110end;
    99111
     112function TTargetList.FindByName(Name: string): TTarget;
     113var
     114  I: Integer;
     115begin
     116  I := 0;
     117  while (I < Count) and (TTarget(Items[I]).Name <> Name) do Inc(I);
     118  if I < Count then Result := TTarget(Items[I])
     119    else Result := nil;
     120end;
     121
    100122{ TTarget }
     123
     124procedure TTarget.SetSource(AValue: string);
     125begin
     126  FSource := AValue;
     127end;
    101128
    102129procedure TTarget.AddLine(Text: string);
     
    209236end;
    210237
     238procedure TTarget.LoadFromRegistry(Root: HKEY; Key: string);
     239begin
     240
     241end;
     242
     243procedure TTarget.SaveToRegistry(Root: HKEY; Key: string);
     244begin
     245
     246end;
     247
    211248end.
    212249
  • trunk/Target/UTargetC.pas

    r31 r32  
    1313
    1414  TTargetC = class(TTarget)
     15  private
     16  public
    1517    constructor Create; override;
    1618    procedure Compile; override;
     
    4850  Result := 1;
    4951  if Optimization = coNormal then
    50   while ((I + 1) <= Length(Source)) and (Source[I + 1] = C) do begin
     52  while ((I + 1) <= Length(FSource)) and (FSource[I + 1] = C) do begin
    5153    Inc(Result);
    5254    Inc(I)
     
    6971  AddLine('Pos = 0;');
    7072  I := 1;
    71   while (I <= Length(Source)) do begin
    72     case Source[I] of
     73  while (I <= Length(FSource)) do begin
     74    case FSource[I] of
    7375      '>': begin
    7476        Sum := CheckOccurence('>');
  • trunk/Target/UTargetDelphi.pas

    r31 r32  
    1313
    1414  TTargetDelphi = class(TTarget)
     15  private
     16  public
    1517    constructor Create; override;
    1618    procedure Compile; override;
     
    4244  Result := 1;
    4345  if Optimization = coNormal then
    44   while ((I + 1) <= Length(Source)) and (Source[I + 1] = C) do begin
     46  while ((I + 1) <= Length(FSource)) and (FSource[I + 1] = C) do begin
    4547    Inc(Result);
    4648    Inc(I)
     
    6466  AddLine('Pos := 0;');
    6567  I := 1;
    66   while (I <= Length(Source)) do begin
    67     case Source[I] of
     68  while (I <= Length(FSource)) do begin
     69    case FSource[I] of
    6870      '>': begin
    6971        Sum := CheckOccurence('>');
  • trunk/Target/UTargetInterpretter.pas

    r31 r32  
    66
    77uses
    8   Classes, SysUtils, Dialogs, Forms, StrUtils, UTarget;
     8  Classes, SysUtils, Dialogs, Forms, StrUtils, UTarget, Registry, URegistry;
    99
    1010type
    1111  TTargetInterpretter = class;
    12 
    13 
    14   TRunState = (rsStopped, rsPaused, rsRunning);
    1512
    1613  { TTargetInterpretterThread }
     
    3128  private
    3229    FCellSize: Integer;
    33     FOnChangeState: TNotifyEvent;
    34     FState: TRunState;
    3530    FThreadState: Boolean;
    3631    FThread: TTargetInterpretterThread;
     
    3934    function GetMemorySize: Integer;
    4035    procedure SetMemorySize(AValue: Integer);
    41     procedure SetSource(AValue: string);
    4236    procedure SetState(AValue: TRunState);
    4337    procedure SetThread(State: Boolean);
     
    5145    procedure CommandLoopStart;
    5246    procedure CommandLoopEnd;
     47  protected
     48    procedure SetSource(AValue: string); override;
    5349  public
    5450    FSource: array of TBrainFuckCommand;
     
    6763    procedure Pause; override;
    6864    procedure Stop; override;
    69     constructor Create;
     65    constructor Create; override;
    7066    destructor Destroy; override;
    71     property State: TRunState read FState;
    72     property OnChangeState: TNotifyEvent read FOnChangeState write FOnChangeState;
     67    procedure LoadFromRegistry(Root: HKEY; Key: string); override;
     68    procedure SaveToRegistry(Root: HKEY; Key: string); override;
    7369    property StepCount: Integer read FStepCount;
    74     property Source: string write SetSource;
    7570    property MemorySize: Integer read GetMemorySize write SetMemorySize;
    7671    property CellSize: Integer read FCellSize write FCellSize;
     
    284279constructor TTargetInterpretter.Create;
    285280begin
     281  inherited;
    286282  Name := 'Interpretter';
    287283  Capabilities := [tcRun, tcPause, tcStop];
     
    305301end;
    306302
     303procedure TTargetInterpretter.LoadFromRegistry(Root: HKEY; Key: string);
     304begin
     305  inherited LoadFromRegistry(Root, Key);
     306  with TRegistryEx.Create do
     307  try
     308    RootKey := Root;
     309    OpenKey(Key, True);
     310    CellSize := ReadIntegerWithDefault('CellSize', 256);
     311    MemorySize := ReadIntegerWithDefault('MemorySize', 30000);
     312  finally
     313    Free;
     314  end;
     315end;
     316
     317procedure TTargetInterpretter.SaveToRegistry(Root: HKEY; Key: string);
     318begin
     319  inherited SaveToRegistry(Root, Key);
     320  with TRegistryEx.Create do
     321  try
     322    RootKey := Root;
     323    OpenKey(Key, True);
     324    WriteInteger('CellSize', CellSize);
     325    WriteInteger('MemorySize', MemorySize);
     326  finally
     327    Free;
     328  end;
     329end;
     330
    307331end.
    308332
  • trunk/Target/UTargetPHP.pas

    r31 r32  
    1313
    1414  TTargetPHP = class(TTarget)
     15  private
     16  public
    1517    constructor Create; override;
    1618    procedure Compile; override;
     
    4648  Result := 1;
    4749  if Optimization = coNormal then
    48   while ((I + 1) <= Length(Source)) and (Source[I + 1] = C) do begin
     50  while ((I + 1) <= Length(FSource)) and (FSource[I + 1] = C) do begin
    4951    Inc(Result);
    5052    Inc(I)
     
    6062  AddLine('$Memory = str_repeat("\0", 30000);');
    6163  AddLine('$Position = 0;');
    62   for I := 1 to Length(Source) do begin
    63     case Source[I] of
     64  for I := 1 to Length(FSource) do begin
     65    case FSource[I] of
    6466      '>': begin
    6567        Sum := CheckOccurence('>');
Note: See TracChangeset for help on using the changeset viewer.