Ignore:
Timestamp:
Feb 18, 2012, 8:44:10 PM (12 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.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.