Changeset 32


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
Files:
2 deleted
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UInterpretterForm.pas

    r24 r32  
    6464
    6565uses
    66   UMainForm;
     66  UMainForm, UTargetInterpretter;
    6767
    6868{$R *.lfm}
     
    7575procedure TInterpreterForm.Timer1Timer(Sender: TObject);
    7676begin
    77   LabelProgramPointer.Caption := IntToStr(MainForm.BrainFuckInterpreter.SourcePosition);
    78   LabelMemoryPointer.Caption := IntToStr(MainForm.BrainFuckInterpreter.MemoryPosition);
    79   LabelStepCounter.Caption := IntToStr(MainForm.BrainFuckInterpreter.StepCount);
    80   LabelStepSpeed.Caption := IntToStr(MainForm.BrainFuckInterpreter.StepCount - LastStepCounter) + SStepsPerSecond;
    81   LastStepCounter := MainForm.BrainFuckInterpreter.StepCount;
     77  if MainForm.CurrentTarget is TTargetInterpretter then
     78  with TTargetInterpretter(MainForm.CurrentTarget) do begin
     79    LabelProgramPointer.Caption := IntToStr(SourcePosition);
     80    LabelMemoryPointer.Caption := IntToStr(MemoryPosition);
     81    LabelStepCounter.Caption := IntToStr(StepCount);
     82    LabelStepSpeed.Caption := IntToStr(StepCount - LastStepCounter) + SStepsPerSecond;
     83    LastStepCounter := StepCount;
     84    MemoOutput.Lines.Text := Output;
     85  end;
    8286  RefreshListViewMemory;
    83   MemoOutput.Lines.Text := MainForm.BrainFuckInterpreter.Output;
    8487end;
    8588
    8689procedure TInterpreterForm.RefreshListViewMemory;
    8790begin
    88   ListViewMemory.Items.Count := Trunc(Length(MainForm.BrainFuckInterpreter.Memory) / RowSize);
    89   ListViewMemory.Refresh;
     91  if MainForm.CurrentTarget is TTargetInterpretter then
     92  with TTargetInterpretter(MainForm.CurrentTarget) do begin
     93    ListViewMemory.Items.Count := Trunc(Length(Memory) / RowSize);
     94    ListViewMemory.Refresh;
     95  end;
    9096end;
    9197
     
    100106  I: Integer;
    101107begin
    102   with MainForm.BrainFuckInterpreter do
     108  if MainForm.CurrentTarget is TTargetInterpretter then
     109  with TTargetInterpretter(MainForm.CurrentTarget) do
    103110  if (Item.Index >= 0) and (Item.Index < Trunc(Length(Memory) / RowSize)) then begin
    104111    Item.Caption := IntToHex(Item.Index * RowSize, 8);
     
    122129procedure TInterpreterForm.MemoInputKeyPress(Sender: TObject; var Key: char);
    123130begin
    124   with MainForm.BrainFuckInterpreter do Input := Input + Key;
     131  if MainForm.CurrentTarget is TTargetInterpretter then
     132  with TTargetInterpretter(MainForm.CurrentTarget) do
     133    Input := Input + Key;
    125134end;
    126135
  • trunk/Forms/UMainForm.lfm

    r30 r32  
    9292      Left = 126
    9393      Top = 2
    94       Action = ACompile
     94      Action = AProgramCompile
    9595    end
    9696    object ToolButton8: TToolButton
     
    394394      Caption = 'Program'
    395395      object MenuItem11: TMenuItem
    396         Action = ACompile
     396        Action = AProgramCompile
    397397        Bitmap.Data = {
    398398          36040000424D3604000000000000360000002800000010000000100000000100
     
    562562      end
    563563      object MenuItem33: TMenuItem
    564         Action = AProgramStopOver
     564        Action = AProgramStepOver
    565565      end
    566566      object MenuItem34: TMenuItem
     
    761761      ShortCut = 32883
    762762    end
    763     object ACompile: TAction
     763    object AProgramCompile: TAction
    764764      Category = 'Program'
    765765      Caption = 'Compile'
    766766      ImageIndex = 8
    767       OnExecute = ACompileExecute
     767      OnExecute = AProgramCompileExecute
    768768      ShortCut = 16504
    769769    end
     
    814814      ShortCut = 118
    815815    end
    816     object AProgramStopOver: TAction
     816    object AProgramStepOver: TAction
    817817      Category = 'Program'
    818818      Caption = 'Step over'
  • trunk/Forms/UMainForm.lrt

    r30 r32  
    1919TMAINFORM.APROJECTNEW.CAPTION=New
    2020TMAINFORM.AEXIT.CAPTION=Exit
    21 TMAINFORM.ACOMPILE.CAPTION=Compile
     21TMAINFORM.APROGRAMCOMPILE.CAPTION=Compile
    2222TMAINFORM.ACOMPILEANDRUN.CAPTION=Compile and run
    2323TMAINFORM.APROGRAMRUN.CAPTION=Run
     
    2929TMAINFORM.AVIEWCOMPILED.CAPTION=Compiled
    3030TMAINFORM.APROGRAMSTEPINTO.CAPTION=Step into
    31 TMAINFORM.APROGRAMSTOPOVER.CAPTION=Step over
     31TMAINFORM.APROGRAMSTEPOVER.CAPTION=Step over
    3232TMAINFORM.APROGRAMRUNTOCURSOR.CAPTION=Run to cursor
    3333TMAINFORM.APROGRAMSTEPOUT.CAPTION=Step out
  • trunk/Forms/UMainForm.pas

    r31 r32  
    1818
    1919  TMainForm = class(TForm)
    20     ACompile: TAction;
     20    AProgramCompile: TAction;
    2121    AAbout: TAction;
    2222    ABreakpointToggle: TAction;
     
    2929    AProgramStepOut: TAction;
    3030    AProgramRunToCursor: TAction;
    31     AProgramStopOver: TAction;
     31    AProgramStepOver: TAction;
    3232    AProgramStepInto: TAction;
    3333    AViewCompiled: TAction;
     
    108108    procedure ABreakpointToggleExecute(Sender: TObject);
    109109    procedure ACompileAndRunExecute(Sender: TObject);
    110     procedure ACompileExecute(Sender: TObject);
     110    procedure AProgramCompileExecute(Sender: TObject);
    111111    procedure AExitExecute(Sender: TObject);
    112112    procedure AFormatSourceExecute(Sender: TObject);
     
    138138      Shift: TShiftState; X, Y: Integer);
    139139  private
     140    FCurrentTarget: TTarget;
    140141    procedure AProjectOpenRecentExecute(Sender: TObject);
    141142    procedure BrainFuckInterpreterChangeState(Sender: TObject);
    142143    procedure MenuItemTargetClick(Sender: TObject);
    143144    procedure ProjectOpen(FileName: string);
     145    procedure SetCurrentTarget(AValue: TTarget);
    144146  public
    145147    Modified: Boolean;
    146     CompilerIndex: Integer;
    147148    ProjectFileName: string;
    148     BrainFuckCompiler: TTarget;
    149     BrainFuckInterpreter: TTargetInterpretter;
    150149    BreakPoints: TListInteger;
    151150    Targets: TTargetList;
     
    157156    procedure UpdateStatusBar;
    158157    procedure UpdateTargetList;
     158    property CurrentTarget: TTarget read FCurrentTarget write SetCurrentTarget;
    159159  end;
    160160
     
    222222begin
    223223  with TMenuItem(Sender) do begin
    224     CompilerIndex := MenuIndex;
     224    CurrentTarget := TTarget(Targets[MenuIndex]);
    225225    Checked := True;
    226226    for I := 0 to Parent.Count - 1 do
    227       if Parent.Items[I].MenuIndex <> MenuIndex then Parent.Items[I].Checked := False
     227      if Parent.Items[I].MenuIndex <> MenuIndex then Parent.Items[I].Checked := False;
    228228  end;
    229229end;
     
    238238end;
    239239
     240procedure TMainForm.SetCurrentTarget(AValue: TTarget);
     241var
     242  I: Integer;
     243begin
     244  if FCurrentTarget = AValue then Exit;
     245  FCurrentTarget := AValue;
     246  for I := 0 to Targets.Count - 1 do
     247    TTarget(Targets[I]).OnChangeState := nil;
     248  FCurrentTarget.OnChangeState := BrainFuckInterpreterChangeState;
     249end;
     250
    240251procedure TMainForm.LoadFromRegistry(Root: HKEY; Key: string);
     252var
     253  TargetName: string;
    241254begin
    242255  with TRegistryEx.Create do
     
    245258    OpenKey(Key, True);
    246259    OpenProjectOnStart := ReadBoolWithDefault('OpenProjectOnStart', True);
    247     BrainFuckInterpreter.CellSize := ReadIntegerWithDefault('CellSize', 256);
    248     BrainFuckInterpreter.MemorySize := ReadIntegerWithDefault('MemorySize', 30000);
    249260    if ValueExists('LanguageCode') then
    250261      CoolTranslator1.Language := CoolTranslator1.Languages.SearchByCode(ReadStringWithDefault('LanguageCode', ''))
    251262      else CoolTranslator1.Language := CoolTranslator1.Languages.SearchByCode('');
    252     CompilerIndex := ReadIntegerWithDefault('SelectedCompiler', 0);
     263    TargetName := ReadStringWithDefault('TargetName', 'Interpretter');
     264    CurrentTarget := Targets.FindByName(TargetName);
     265    if not Assigned(CurrentTarget) then CurrentTarget := TTarget(Targets[0]);
    253266  finally
    254267    Free;
     
    267280    OpenKey(Key, True);
    268281    WriteBool('OpenProjectOnStart', OpenProjectOnStart);
    269     WriteInteger('CellSize', BrainFuckInterpreter.CellSize);
    270     WriteInteger('MemorySize', BrainFuckInterpreter.MemorySize);
    271282    if Assigned(CoolTranslator1.Language) and (CoolTranslator1.Language.Code <> '') then
    272283      WriteString('LanguageCode', CoolTranslator1.Language.Code)
    273284      else DeleteValue('LanguageCode');
    274     WriteInteger('SelectedCompiler', CompilerIndex);
     285    WriteString('TargetName', CurrentTarget.Name);
    275286  finally
    276287    Free;
     
    289300  MemoSource.Enabled := ProjectFileName <> '';
    290301  AProjectClose.Enabled := ProjectFileName <> '';
    291   AProgramRun.Enabled := (ProjectFileName <> '') and (BrainFuckInterpreter.State = rsStopped);
    292   AProgramPause.Enabled := (ProjectFileName <> '') and (BrainFuckInterpreter.State = rsRunning);
    293   AProgramStop.Enabled := (ProjectFileName <> '') and (BrainFuckInterpreter.State <> rsStopped);
    294   ACompile.Enabled := ProjectFileName <> '';
     302  AProgramRun.Enabled := (tcRun in CurrentTarget.Capabilities) and
     303    (ProjectFileName <> '') and (CurrentTarget.State = rsStopped);
     304  AProgramPause.Enabled := (tcPause in CurrentTarget.Capabilities) and
     305    (ProjectFileName <> '') and (CurrentTarget.State = rsRunning);
     306  AProgramStop.Enabled := (tcStop in CurrentTarget.Capabilities) and
     307    (ProjectFileName <> '') and (CurrentTarget.State <> rsStopped);
     308  AProgramCompile.Enabled := (tcCompile in CurrentTarget.Capabilities) and (ProjectFileName <> '');
     309  AProgramStepInto.Enabled := (tcStepInto in CurrentTarget.Capabilities) and (ProjectFileName <> '');
     310  AProgramStepOut.Enabled := (tcStepOut in CurrentTarget.Capabilities) and (ProjectFileName <> '');
     311  AProgramRunToCursor.Enabled := (tcRunToCursor in CurrentTarget.Capabilities) and (ProjectFileName <> '');
     312  AProgramStepOver.Enabled := (tcStepOver in CurrentTarget.Capabilities) and (ProjectFileName <> '');
    295313  UpdateStatusBar;
    296314  UpdateTargetList;
     
    312330    NewMenuItem.Caption := TTarget(Targets[I]).Name;
    313331    NewMenuItem.OnClick := MenuItemTargetClick;
    314     if I = CompilerIndex then NewMenuItem.Checked := True;
     332    if TTarget(Targets[I]) = CurrentTarget then NewMenuItem.Checked := True;
    315333    MenuItemTarget.Add(NewMenuItem);
    316334  end;
     
    320338begin
    321339  BreakPoints := TListInteger.Create;
    322   BrainFuckInterpreter := TTargetInterpretter.Create;
    323   BrainFuckInterpreter.OnChangeState := BrainFuckInterpreterChangeState;
    324   BrainFuckCompiler := TTarget.Create;
    325340  Targets := TTargetList.Create;
    326341  Targets.Add(TTargetInterpretter.Create);
     
    340355  LastOpenedList.Free;
    341356  Targets.Free;
    342   BrainFuckCompiler.Free;
    343   BrainFuckInterpreter.Free;
    344357  BreakPoints.Free;
    345358end;
     
    349362  InterpreterForm.LastStepCounter := 0;
    350363  InterpreterForm.Show;
    351   BrainFuckInterpreter.Input := InterpreterForm.MemoInput.Lines.Text;
    352   BrainFuckInterpreter.Source := MemoSource.Text;
    353   BrainFuckInterpreter.Run;
     364  if CurrentTarget is TTargetInterpretter then
     365    TTargetInterpretter(CurrentTarget).Input := InterpreterForm.MemoInput.Lines.Text;
     366  CurrentTarget.Source := MemoSource.Text;
     367  CurrentTarget.Run;
    354368end;
    355369
     
    442456procedure TMainForm.AOptionsExecute(Sender: TObject);
    443457begin
    444   OptionsForm.LoadFromInterpretter(BrainFuckInterpreter);
     458  //OptionsForm.LoadFromInterpretter(CurrentTarget);
    445459  if OptionsForm.ShowModal = mrOK then begin
    446     OptionsForm.SaveToInterpretter(BrainFuckInterpreter);
    447   end;
    448 end;
    449 
    450 procedure TMainForm.ACompileExecute(Sender: TObject);
    451 begin
    452   with TTarget(Targets[CompilerIndex]) do begin
     460    //OptionsForm.SaveToInterpretter(CurrentTarget);
     461  end;
     462end;
     463
     464procedure TMainForm.AProgramCompileExecute(Sender: TObject);
     465begin
     466  with CurrentTarget do begin
    453467    Optimization := coNormal;
    454468    Source := MemoSource.Text;
     
    467481procedure TMainForm.ACompileAndRunExecute(Sender: TObject);
    468482begin
    469   with TTarget(Targets[CompilerIndex]) do begin
     483  with CurrentTarget do begin
    470484    Optimization := coNormal;
    471485    Source := MemoSource.Text;
     
    480494procedure TMainForm.AProgramPauseExecute(Sender: TObject);
    481495begin
    482   MainForm.BrainFuckInterpreter.Pause
     496  CurrentTarget.Pause
    483497end;
    484498
    485499procedure TMainForm.AProgramStopExecute(Sender: TObject);
    486500begin
    487   MainForm.BrainFuckInterpreter.Stop;
     501  CurrentTarget.Stop;
    488502end;
    489503
  • trunk/Languages/LazFuckIDE.cs.po

    r30 r32  
    55"POT-Creation-Date: \n"
    66"PO-Revision-Date: \n"
    7 "Last-Translator: Jiří Hajda <robie@centrum.cz>\n"
     7"Last-Translator: Chronos <robie@centrum.cz>\n"
    88"Language-Team: \n"
    99"MIME-Version: 1.0\n"
     
    9797msgstr "Přepnout bod zastavení"
    9898
    99 #: tmainform.acompile.caption
    100 msgid "Compile"
    101 msgstr "PřeloÅŸit"
    102 
    10399#: tmainform.acompileandrun.caption
    104100msgid "Compile and run"
     
    127123msgstr "Volby"
    128124
     125#: tmainform.aprogramcompile.caption
     126msgctxt "tmainform.aprogramcompile.caption"
     127msgid "Compile"
     128msgstr "PřeloÅŸit"
     129
    129130#: tmainform.aprogrampause.caption
    130131msgid "Pause"
     
    150151msgstr "Vystoupit z"
    151152
     153#: tmainform.aprogramstepover.caption
     154msgctxt "tmainform.aprogramstepover.caption"
     155msgid "Step over"
     156msgstr "Přejít přes"
     157
    152158#: tmainform.aprogramstop.caption
    153159msgid "Stop"
    154160msgstr "Zastavit"
    155 
    156 #: tmainform.aprogramstopover.caption
    157 msgctxt "tmainform.aprogramstopover.caption"
    158 msgid "Step over"
    159 msgstr "Přejít přes"
    160161
    161162#: tmainform.aprojectclose.caption
     
    319320msgctxt "ucompiler.scompiledfilenotfound"
    320321msgid "Program compiled file \"%s\" not found"
    321 msgstr ""
     322msgstr "Nenalezen sestavenÃœ soubor programu \"%s\""
    322323
    323324#: ucompiler.scompilernotfound
    324325msgctxt "ucompiler.scompilernotfound"
    325326msgid "Compiler \"%s\" not found"
    326 msgstr ""
     327msgstr "Nenalezen překladač \"%s\""
    327328
    328329#: ucompilersform.scompileroptions
     
    359360msgctxt "utarget.scompiledfilenotfound"
    360361msgid "Program compiled file \"%s\" not found"
    361 msgstr ""
     362msgstr "Nenalezen sestavenÃœ soubor programu \"%s\""
    362363
    363364#: utarget.scompilernotfound
    364365msgctxt "utarget.scompilernotfound"
    365366msgid "Compiler \"%s\" not found"
    366 msgstr ""
     367msgstr "Nenalezen překladač \"%s\""
    367368
    368369#: utargetinterpretter.sjumptablecolision
  • trunk/Languages/LazFuckIDE.po

    r30 r32  
    8888msgstr ""
    8989
    90 #: tmainform.acompile.caption
    91 msgid "Compile"
    92 msgstr ""
    93 
    9490#: tmainform.acompileandrun.caption
    9591msgid "Compile and run"
     
    118114msgstr ""
    119115
     116#: tmainform.aprogramcompile.caption
     117msgctxt "TMAINFORM.APROGRAMCOMPILE.CAPTION"
     118msgid "Compile"
     119msgstr ""
     120
    120121#: tmainform.aprogrampause.caption
    121122msgid "Pause"
     
    141142msgstr ""
    142143
     144#: tmainform.aprogramstepover.caption
     145msgctxt "TMAINFORM.APROGRAMSTEPOVER.CAPTION"
     146msgid "Step over"
     147msgstr ""
     148
    143149#: tmainform.aprogramstop.caption
    144150msgid "Stop"
    145 msgstr ""
    146 
    147 #: tmainform.aprogramstopover.caption
    148 msgctxt "TMAINFORM.APROGRAMSTOPOVER.CAPTION"
    149 msgid "Step over"
    150151msgstr ""
    151152
  • trunk/LazFuckIDE.lpi

    r30 r32  
    8585      </Item5>
    8686    </RequiredPackages>
    87     <Units Count="14">
     87    <Units Count="12">
    8888      <Unit0>
    8989        <Filename Value="LazFuckIDE.lpr"/>
     
    9797      </Unit1>
    9898      <Unit2>
    99         <Filename Value="Common\ULastOpenedList.pas"/>
    100         <IsPartOfProject Value="True"/>
    101         <UnitName Value="ULastOpenedList"/>
     99        <Filename Value="Forms\UCompiledForm.pas"/>
     100        <IsPartOfProject Value="True"/>
     101        <ComponentName Value="CompiledForm"/>
     102        <HasResources Value="True"/>
     103        <ResourceBaseClass Value="Form"/>
     104        <UnitName Value="UCompiledForm"/>
    102105      </Unit2>
    103106      <Unit3>
    104         <Filename Value="Common\URegistry.pas"/>
    105         <IsPartOfProject Value="True"/>
    106         <UnitName Value="URegistry"/>
     107        <Filename Value="Forms\UMainForm.pas"/>
     108        <IsPartOfProject Value="True"/>
     109        <ComponentName Value="MainForm"/>
     110        <HasResources Value="True"/>
     111        <ResourceBaseClass Value="Form"/>
     112        <UnitName Value="UMainForm"/>
    107113      </Unit3>
    108114      <Unit4>
    109         <Filename Value="Forms\UCompiledForm.pas"/>
    110         <IsPartOfProject Value="True"/>
    111         <ComponentName Value="CompiledForm"/>
    112         <HasResources Value="True"/>
    113         <ResourceBaseClass Value="Form"/>
    114         <UnitName Value="UCompiledForm"/>
     115        <Filename Value="Forms\UOptionsForm.pas"/>
     116        <IsPartOfProject Value="True"/>
     117        <ComponentName Value="OptionsForm"/>
     118        <HasResources Value="True"/>
     119        <ResourceBaseClass Value="Form"/>
     120        <UnitName Value="UOptionsForm"/>
    115121      </Unit4>
    116122      <Unit5>
    117         <Filename Value="Forms\UMainForm.pas"/>
    118         <IsPartOfProject Value="True"/>
    119         <ComponentName Value="MainForm"/>
    120         <HasResources Value="True"/>
    121         <ResourceBaseClass Value="Form"/>
    122         <UnitName Value="UMainForm"/>
     123        <Filename Value="Forms\UInterpretterForm.pas"/>
     124        <IsPartOfProject Value="True"/>
     125        <ComponentName Value="InterpreterForm"/>
     126        <HasResources Value="True"/>
     127        <ResourceBaseClass Value="Form"/>
     128        <UnitName Value="UInterpretterForm"/>
    123129      </Unit5>
    124130      <Unit6>
    125         <Filename Value="Forms\UOptionsForm.pas"/>
    126         <IsPartOfProject Value="True"/>
    127         <ComponentName Value="OptionsForm"/>
    128         <HasResources Value="True"/>
    129         <ResourceBaseClass Value="Form"/>
    130         <UnitName Value="UOptionsForm"/>
     131        <Filename Value="Forms\UCompilersForm.pas"/>
     132        <IsPartOfProject Value="True"/>
     133        <ComponentName Value="FormCompilers"/>
     134        <ResourceBaseClass Value="Form"/>
     135        <UnitName Value="UCompilersForm"/>
    131136      </Unit6>
    132137      <Unit7>
    133         <Filename Value="Forms\UInterpretterForm.pas"/>
    134         <IsPartOfProject Value="True"/>
    135         <ComponentName Value="InterpreterForm"/>
    136         <HasResources Value="True"/>
    137         <ResourceBaseClass Value="Form"/>
    138         <UnitName Value="UInterpretterForm"/>
     138        <Filename Value="Target\UTarget.pas"/>
     139        <IsPartOfProject Value="True"/>
     140        <UnitName Value="UTarget"/>
    139141      </Unit7>
    140142      <Unit8>
    141         <Filename Value="Forms\UCompilersForm.pas"/>
    142         <IsPartOfProject Value="True"/>
    143         <ComponentName Value="FormCompilers"/>
    144         <ResourceBaseClass Value="Form"/>
    145         <UnitName Value="UCompilersForm"/>
     143        <Filename Value="Target\UTargetC.pas"/>
     144        <IsPartOfProject Value="True"/>
     145        <UnitName Value="UTargetC"/>
    146146      </Unit8>
    147147      <Unit9>
    148         <Filename Value="Target\UTarget.pas"/>
    149         <IsPartOfProject Value="True"/>
    150         <UnitName Value="UTarget"/>
     148        <Filename Value="Target\UTargetDelphi.pas"/>
     149        <IsPartOfProject Value="True"/>
     150        <UnitName Value="UTargetDelphi"/>
    151151      </Unit9>
    152152      <Unit10>
    153         <Filename Value="Target\UTargetC.pas"/>
    154         <IsPartOfProject Value="True"/>
    155         <UnitName Value="UTargetC"/>
     153        <Filename Value="Target\UTargetInterpretter.pas"/>
     154        <IsPartOfProject Value="True"/>
     155        <UnitName Value="UTargetInterpretter"/>
    156156      </Unit10>
    157157      <Unit11>
    158         <Filename Value="Target\UTargetDelphi.pas"/>
    159         <IsPartOfProject Value="True"/>
    160         <UnitName Value="UTargetDelphi"/>
     158        <Filename Value="Target\UTargetPHP.pas"/>
     159        <IsPartOfProject Value="True"/>
     160        <UnitName Value="UTargetPHP"/>
    161161      </Unit11>
    162       <Unit12>
    163         <Filename Value="Target\UTargetInterpretter.pas"/>
    164         <IsPartOfProject Value="True"/>
    165         <UnitName Value="UTargetInterpretter"/>
    166       </Unit12>
    167       <Unit13>
    168         <Filename Value="Target\UTargetPHP.pas"/>
    169         <IsPartOfProject Value="True"/>
    170         <UnitName Value="UTargetPHP"/>
    171       </Unit13>
    172162    </Units>
    173163  </ProjectOptions>
     
    180170    <SearchPaths>
    181171      <IncludeFiles Value="$(ProjOutDir)"/>
    182       <OtherUnitFiles Value="Common;Forms;Target"/>
     172      <OtherUnitFiles Value="Forms;Target"/>
    183173      <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
    184174    </SearchPaths>
  • trunk/LazFuckIDE.lpr

    r30 r32  
    1111  Forms, UApplicationInfo, UTarget, UTargetC, UTargetDelphi,
    1212  UTargetInterpretter, UTargetPHP, UCompiledForm, UInterpretterForm, UMainForm,
    13   UOptionsForm, ULastOpenedList, URegistry, CoolTranslator, Common,
     13  UOptionsForm, CoolTranslator, Common,
    1414  TemplateGenerics, UCompilersForm;
    1515
  • 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.