Changeset 30 for trunk/Target


Ignore:
Timestamp:
Feb 18, 2012, 7:49:17 PM (13 years ago)
Author:
chronos
Message:
  • Renamed: Compilers renamed to Targets. Interpretter will be one of possible targets.
Location:
trunk/Target
Files:
4 deleted
4 copied
2 moved

Legend:

Unmodified
Added
Removed
  • trunk/Target/UTarget.pas

    r29 r30  
    1 unit UCompiler;
     1unit UTarget;
    22
    33{$mode Delphi}{$H+}
     
    1212  TCompilerOptimization = (coNone, coNormal);
    1313
    14   { TBrainFuckCompiler }
     14  { TTarget }
    1515
    16   TBrainFuckCompiler = class
     16  TTarget = class
    1717  protected
    1818    Indent: Integer;
     
    3636  end;
    3737
    38   { TCompilerList }
     38  { TTargetList }
    3939
    40   TCompilerList = class(TListObject)
     40  TTargetList = class(TListObject)
    4141    procedure LoadFromRegistry(Root: HKEY; Key: string);
    4242    procedure SaveToRegistry(Root: HKEY; Key: string);
     
    5252
    5353
    54 { TCompilerList }
     54{ TTargetList }
    5555
    56 procedure TCompilerList.LoadFromRegistry(Root: HKEY; Key: string);
     56procedure TTargetList.LoadFromRegistry(Root: HKEY; Key: string);
    5757var
    5858  I: Integer;
     
    6363    OpenKey(Key + '\Compiler', True);
    6464    for I := 0 to Count - 1 do
    65     with TBrainFuckCompiler(Items[I]) do
     65    with TTarget(Items[I]) do
    6666      if ValueExists(Name) then CompilerPath := ReadString(Name);
    6767  finally
     
    7070end;
    7171
    72 procedure TCompilerList.SaveToRegistry(Root: HKEY; Key: string);
     72procedure TTargetList.SaveToRegistry(Root: HKEY; Key: string);
    7373var
    7474  I: Integer;
     
    7979    OpenKey(Key + '\Compiler', True);
    8080    for I := 0 to Count - 1 do
    81     with TBrainFuckCompiler(Items[I]) do
     81    with TTarget(Items[I]) do
    8282      if CompilerPath <> '' then WriteString(Name, CompilerPath)
    8383        else DeleteValue(Name);
     
    8787end;
    8888
    89 { TBrainFuckCompiler }
     89{ TTarget }
    9090
    91 procedure TBrainFuckCompiler.AddLine(Text: string);
     91procedure TTarget.AddLine(Text: string);
    9292begin
    9393  Output := Output + DupeString('  ', Indent) + Text + LineEnding;
    9494end;
    9595
    96 function TBrainFuckCompiler.LongFileName(FileName: string): string;
     96function TTarget.LongFileName(FileName: string): string;
    9797begin
    9898  Result := FileName;
     
    105105end;
    106106
    107 constructor TBrainFuckCompiler.Create;
     107constructor TTarget.Create;
    108108begin
    109109  Optimization := coNormal;
    110110end;
    111111
    112 procedure TBrainFuckCompiler.OptimizeSource;
     112procedure TTarget.OptimizeSource;
    113113begin
    114114  // Remove redundand code
     
    116116end;
    117117
    118 procedure TBrainFuckCompiler.Compile;
     118procedure TTarget.Compile;
    119119begin
    120120
    121121end;
    122122
    123 procedure TBrainFuckCompiler.CompileToFile;
     123procedure TTarget.CompileToFile;
    124124var
    125125  Process: TProcess;
     
    149149end;
    150150
    151 procedure TBrainFuckCompiler.Run;
     151procedure TTarget.Run;
    152152var
    153153  CompiledFile: string;
  • trunk/Target/UTargetC.pas

    r29 r30  
    1 unit UCompilerC;
     1unit UTargetC;
    22
    33{$mode Delphi}{$H+}
     
    66
    77uses
    8   Classes, SysUtils, FileUtil, UCompiler, Process, Dialogs;
     8  Classes, SysUtils, FileUtil, UTarget, Process, Dialogs;
    99
    1010type
    1111
    12   { TBrainFuckCompilerC }
     12  { TTargetC }
    1313
    14   TBrainFuckCompilerC = class(TBrainFuckCompiler)
     14  TTargetC = class(TTarget)
    1515    constructor Create; override;
    1616    procedure Compile; override;
     
    2121implementation
    2222
    23 { TBrainFuckCompilerC }
     23{ TTargetC }
    2424
    25 constructor TBrainFuckCompilerC.Create;
     25constructor TTargetC.Create;
    2626begin
    2727  inherited Create;
     
    3737end;
    3838
    39 procedure TBrainFuckCompilerC.Compile;
     39procedure TTargetC.Compile;
    4040var
    4141  I: Integer;
     
    104104end;
    105105
    106 procedure TBrainFuckCompilerC.CompileToFile;
     106procedure TTargetC.CompileToFile;
    107107var
    108108  Process: TProcess;
     
    133133end;
    134134
    135 procedure TBrainFuckCompilerC.Run;
     135procedure TTargetC.Run;
    136136begin
    137137  inherited Run;
  • trunk/Target/UTargetDelphi.pas

    r29 r30  
    1 unit UCompilerDelphi;
     1unit UTargetDelphi;
    22
    33{$mode Delphi}{$H+}
     
    66
    77uses
    8   Classes, SysUtils, UCompiler;
     8  Classes, SysUtils, UTarget;
    99
    1010type
    1111
    12   { TBrainFuckCompilerDelphi }
     12  { TTargetDelphi }
    1313
    14   TBrainFuckCompilerDelphi = class(TBrainFuckCompiler)
     14  TTargetDelphi = class(TTarget)
    1515    constructor Create; override;
    1616    procedure Compile; override;
     
    1919implementation
    2020
    21 { TBrainFuckCompilerDelphi }
     21{ TTargetDelphi }
    2222
    23 constructor TBrainFuckCompilerDelphi.Create;
     23constructor TTargetDelphi.Create;
    2424begin
    2525  inherited Create;
     
    3232end;
    3333
    34 procedure TBrainFuckCompilerDelphi.Compile;
     34procedure TTargetDelphi.Compile;
    3535var
    3636  I: Integer;
  • trunk/Target/UTargetInterpretter.pas

    r29 r30  
    1 unit UBrainFuck;
     1unit UTargetInterpretter;
    22
    33{$mode Delphi}{$H+}
     
    99
    1010type
    11   TBrainFuckInterpretter = class;
     11  TTargetInterpretter = class;
    1212
    1313
    1414  TRunState = (rsStopped, rsPaused, rsRunning);
    1515
    16   { TBrainFuckInterpretterThread }
    17 
    18   TBrainFuckInterpretterThread = class(TThread)
    19     Parent: TBrainFuckInterpretter;
     16  { TTargetInterpretterThread }
     17
     18  TTargetInterpretterThread = class(TThread)
     19    Parent: TTargetInterpretter;
    2020    procedure Execute; override;
    2121  end;
     
    2626  TCommandHandler = procedure of object;
    2727
    28   { TBrainFuckInterpretter }
    29 
    30   TBrainFuckInterpretter = class
     28  { TTargetInterpretter }
     29
     30  TTargetInterpretter = class
    3131  private
    3232    FCellSize: Integer;
     
    3434    FState: TRunState;
    3535    FThreadState: Boolean;
    36     FThread: TBrainFuckInterpretterThread;
     36    FThread: TTargetInterpretterThread;
    3737    FStepCount: Integer;
    3838    FCommandTable: array[TBrainFuckCommand] of TCommandHandler;
     
    8888  SMemoryCellOutOfRange = 'Memory cell %s value out of range';
    8989
    90 { TBrainFuckInterpretterThread }
    91 
    92 procedure TBrainFuckInterpretterThread.Execute;
     90{ TTargetInterpretterThread }
     91
     92procedure TTargetInterpretterThread.Execute;
    9393begin
    9494  repeat
     
    103103end;
    104104
    105 { TBrainFuckInterpretter }
    106 
    107 procedure TBrainFuckInterpretter.SetState(AValue: TRunState);
     105{ TTargetInterpretter }
     106
     107procedure TTargetInterpretter.SetState(AValue: TRunState);
    108108begin
    109109  if FState = AValue then Exit;
     
    112112end;
    113113
    114 function TBrainFuckInterpretter.GetMemorySize: Integer;
     114function TTargetInterpretter.GetMemorySize: Integer;
    115115begin
    116116  Result := Length(Memory);
    117117end;
    118118
    119 procedure TBrainFuckInterpretter.SetMemorySize(AValue: Integer);
     119procedure TTargetInterpretter.SetMemorySize(AValue: Integer);
    120120begin
    121121  SetLength(Memory, AValue);
    122122end;
    123123
    124 procedure TBrainFuckInterpretter.SetSource(AValue: string);
     124procedure TTargetInterpretter.SetSource(AValue: string);
    125125var
    126126  I: Integer;
     
    146146end;
    147147
    148 procedure TBrainFuckInterpretter.SetThread(State: Boolean);
     148procedure TTargetInterpretter.SetThread(State: Boolean);
    149149begin
    150150  if FThreadState = State then Exit;
    151151  FThreadState := State;
    152152  if State then begin
    153     FThread := TBrainFuckInterpretterThread.Create(True);
     153    FThread := TTargetInterpretterThread.Create(True);
    154154    FThread.Parent := Self;
    155155    FThread.FreeOnTerminate := False;
     
    160160end;
    161161
    162 procedure TBrainFuckInterpretter.PrepareJumpTable;
     162procedure TTargetInterpretter.PrepareJumpTable;
    163163var
    164164  Loop: array of Integer;
     
    188188end;
    189189
    190 procedure TBrainFuckInterpretter.CommandInc;
     190procedure TTargetInterpretter.CommandInc;
    191191begin
    192192  Memory[MemoryPosition] := ((Memory[MemoryPosition] + 1) mod CellSize);
    193193end;
    194194
    195 procedure TBrainFuckInterpretter.CommandDec;
     195procedure TTargetInterpretter.CommandDec;
    196196begin
    197197  Memory[MemoryPosition] := ((Memory[MemoryPosition] - 1) mod CellSize);
    198198end;
    199199
    200 procedure TBrainFuckInterpretter.CommandPointerInc;
     200procedure TTargetInterpretter.CommandPointerInc;
    201201begin
    202202  if MemoryPosition < MemorySize then Inc(MemoryPosition)
     
    204204end;
    205205
    206 procedure TBrainFuckInterpretter.CommandPointerDec;
     206procedure TTargetInterpretter.CommandPointerDec;
    207207begin
    208208  if MemoryPosition > 0 then Dec(MemoryPosition)
     
    210210end;
    211211
    212 procedure TBrainFuckInterpretter.CommandInput;
     212procedure TTargetInterpretter.CommandInput;
    213213begin
    214214  while (InputPosition > Length(Input)) and (FState <> rsStopped) do begin
     
    221221end;
    222222
    223 procedure TBrainFuckInterpretter.CommandOutput;
     223procedure TTargetInterpretter.CommandOutput;
    224224begin
    225225  if OutputPosition > Length(Output) then
     
    229229end;
    230230
    231 procedure TBrainFuckInterpretter.CommandLoopStart;
     231procedure TTargetInterpretter.CommandLoopStart;
    232232begin
    233233  if Memory[MemoryPosition] = 0 then
     
    235235end;
    236236
    237 procedure TBrainFuckInterpretter.CommandLoopEnd;
     237procedure TTargetInterpretter.CommandLoopEnd;
    238238begin
    239239  if Memory[MemoryPosition] > 0 then
     
    241241end;
    242242
    243 procedure TBrainFuckInterpretter.Reset;
     243procedure TTargetInterpretter.Reset;
    244244var
    245245  I: Integer;
     
    257257end;
    258258
    259 procedure TBrainFuckInterpretter.SingleStep;
     259procedure TTargetInterpretter.SingleStep;
    260260begin
    261261  FCommandTable[FSource[SourcePosition]];
     
    264264end;
    265265
    266 procedure TBrainFuckInterpretter.Run;
     266procedure TTargetInterpretter.Run;
    267267begin
    268268  SetState(rsRunning);
     
    272272end;
    273273
    274 procedure TBrainFuckInterpretter.Pause;
     274procedure TTargetInterpretter.Pause;
    275275begin
    276276  if State = rsRunning then SetState(rsPaused);
    277277end;
    278278
    279 procedure TBrainFuckInterpretter.Stop;
     279procedure TTargetInterpretter.Stop;
    280280begin
    281281  SetState(rsStopped);
    282282end;
    283283
    284 constructor TBrainFuckInterpretter.Create;
     284constructor TTargetInterpretter.Create;
    285285begin
    286286  MemorySize := 30000;
     
    296296end;
    297297
    298 destructor TBrainFuckInterpretter.Destroy;
     298destructor TTargetInterpretter.Destroy;
    299299begin
    300300  FState := rsStopped;
  • trunk/Target/UTargetPHP.pas

    r29 r30  
    1 unit UCompilerPHP;
     1unit UTargetPHP;
    22
    33{$mode Delphi}{$H+}
     
    66
    77uses
    8   Classes, SysUtils, UCompiler;
     8  Classes, SysUtils, UTarget;
    99
    1010type
    1111
    12   { TBrainFuckCompilerPHP }
     12  { TTargetPHP }
    1313
    14   TBrainFuckCompilerPHP = class(TBrainFuckCompiler)
     14  TTargetPHP = class(TTarget)
    1515    constructor Create; override;
    1616    procedure Compile; override;
     
    2121implementation
    2222
    23 { TBrainFuckCompilerPHP }
     23{ TTargetPHP }
    2424
    25 constructor TBrainFuckCompilerPHP.Create;
     25constructor TTargetPHP.Create;
    2626begin
    2727  inherited Create;
     
    3636end;
    3737
    38 procedure TBrainFuckCompilerPHP.Compile;
     38procedure TTargetPHP.Compile;
    3939var
    4040  I: Integer;
     
    9393end;
    9494
    95 procedure TBrainFuckCompilerPHP.Run;
     95procedure TTargetPHP.Run;
    9696begin
    9797  inherited Run;
Note: See TracChangeset for help on using the changeset viewer.