Changeset 13 for trunk


Ignore:
Timestamp:
Feb 11, 2012, 5:53:25 PM (13 years ago)
Author:
chronos
Message:
  • Added: Options form.
  • Modified: Interpretter now accept source code as string again.
Location:
trunk
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LazFuckIDE.lpi

    r12 r13  
    4040      </Item2>
    4141    </RequiredPackages>
    42     <Units Count="6">
     42    <Units Count="7">
    4343      <Unit0>
    4444        <Filename Value="LazFuckIDE.lpr"/>
     
    7777        <UnitName Value="UCompiledForm"/>
    7878      </Unit5>
     79      <Unit6>
     80        <Filename Value="UOptionsForm.pas"/>
     81        <IsPartOfProject Value="True"/>
     82        <ComponentName Value="OptionsForm"/>
     83        <ResourceBaseClass Value="Form"/>
     84        <UnitName Value="UOptionsForm"/>
     85      </Unit6>
    7986    </Units>
    8087  </ProjectOptions>
     
    96103        <StackChecks Value="True"/>
    97104      </Checks>
    98       <VerifyObjMethodCallValidity Value="True"/>
    99105    </CodeGeneration>
    100106    <Linking>
  • trunk/LazFuckIDE.lpr

    r12 r13  
    1010  Interfaces, // this includes the LCL widgetset
    1111  Forms, UMainForm, UBrainFuck, UInterpreterForm, UApplicationInfo,
    12 UCompiledForm
     12UCompiledForm, UOptionsForm
    1313  { you can add units after this };
    1414
     
    2222  Application.CreateForm(TInterpreterForm, InterpreterForm);
    2323  Application.CreateForm(TCompiledForm, CompiledForm);
     24  Application.CreateForm(TOptionsForm, OptionsForm);
    2425  Application.Run;
    2526end.
  • trunk/UBrainFuck.pas

    r12 r13  
    4848    FThread: TBrainFuckInterpretterThread;
    4949    FStepCount: Integer;
     50    function GetSource: string;
     51    procedure SetSource(AValue: string);
    5052    procedure SetState(AValue: TRunState);
    5153    procedure Write(Value: Byte);
     
    5557    procedure PrepareJumpTable;
    5658  public
    57     Source: array of Char;
     59    FSource: array of Char;
    5860    SourceJump: array of Integer;
    5961    SourcePosition: Integer;
     62    SourceBreakpoint: array of Boolean;
    6063    Memory: array of Byte;
    6164    MemoryPosition: Integer;
     
    7376    property OnChangeState: TNotifyEvent read FOnChangeState write FOnChangeState;
    7477    property StepCount: Integer read FStepCount;
     78    property Source: string read GetSource write SetSource;
    7579  end;
    7680
     
    9094begin
    9195  repeat
    92     while (Parent.SourcePosition < Length(Parent.Source)) and (Parent.State <> rsStopped) do begin
     96    while (Parent.SourcePosition < Length(Parent.FSource)) and (Parent.State <> rsStopped) do begin
    9397      Parent.SingleStep;
    9498      while Parent.State = rsPaused do begin
     
    114118end;
    115119
     120function TBrainFuckInterpretter.GetSource: string;
     121var
     122  I: Integer;
     123begin
     124  SetLength(Result, Length(FSource));
     125  //Move(Pointer(Result)^, Pointer(FSource)^, Length(Result));
     126  for I := 0 to Length(FSource) - 1 do
     127    Result[I + 1] := FSource[I];
     128end;
     129
     130procedure TBrainFuckInterpretter.SetSource(AValue: string);
     131var
     132  I: Integer;
     133begin
     134  SetLength(FSource, Length(AValue));
     135  //Move(Pointer(AValue)^, Pointer(FSource)^, Length(AValue));
     136  for I := 0 to Length(FSource) - 1 do
     137    FSource[I] := AValue[I + 1];
     138end;
     139
    116140function TBrainFuckInterpretter.Read: Byte;
    117141begin
     
    125149function TBrainFuckInterpretter.ReadCode: Char;
    126150begin
    127   Result := Source[SourcePosition];
     151  Result := FSource[SourcePosition];
    128152end;
    129153
     
    148172  I: Integer;
    149173begin
    150   SetLength(SourceJump, Length(Source));
    151   FillChar(Pointer(SourceJump)^, Length(SourceJump), 0);
     174  SetLength(SourceJump, Length(FSource));
     175  //FillChar(Pointer(SourceJump)^, Length(SourceJump), 0);
     176  for I := 0 to Length(FSource) - 1 do
     177    SourceJump[I] := 0;
    152178  SetLength(Loop, 0);
    153   for I := 0 to Length(Source) - 1 do begin
    154     case Source[I] of
     179  for I := 0 to Length(FSource) - 1 do begin
     180    case FSource[I] of
    155181      '[': begin
    156182        SetLength(Loop, Length(Loop) + 1);
     
    170196
    171197procedure TBrainFuckInterpretter.Reset;
     198var
     199  I: Integer;
    172200begin
    173201  PrepareJumpTable;
     
    176204  Output := '';
    177205  MemoryPosition := 0;
    178   FillChar(Pointer(Memory)^, Length(Memory), 0);
     206  //FillChar(Pointer(Memory)^, Length(Memory), 0);
     207  for I := 0 to Length(Memory) - 1 do
     208    Memory[I] := 0;
    179209  FStepCount := 0;
    180210end;
  • trunk/UMainForm.lfm

    r12 r13  
    9494      Action = ACompile
    9595    end
     96    object ToolButton8: TToolButton
     97      Left = 149
     98      Top = 2
     99      Action = AOptions
     100    end
    96101  end
    97102  object TabControl1: TTabControl
     
    518523    object MenuItem18: TMenuItem
    519524      Caption = 'View'
     525      object MenuItem22: TMenuItem
     526        Action = AOptions
     527      end
    520528      object MenuItem19: TMenuItem
    521529        Action = AViewInterpretter
     
    663671    object ABreakpointUnset: TAction
    664672      Caption = 'Unset breakpoint'
     673    end
     674    object AOptions: TAction
     675      Caption = 'Options'
     676      ImageIndex = 2
     677      OnExecute = AOptionsExecute
    665678    end
    666679  end
  • trunk/UMainForm.pas

    r12 r13  
    1818    ABreakpointSet: TAction;
    1919    ABreakpointUnset: TAction;
     20    AOptions: TAction;
    2021    AInterpretterStepOut: TAction;
    2122    AInterpretterRunToCursor: TAction;
     
    5152    MenuItem2: TMenuItem;
    5253    MenuItem20: TMenuItem;
     54    MenuItem22: TMenuItem;
    5355    MenuItem40: TMenuItem;
    5456    MenuItem21: TMenuItem;
     
    7274    ToolButton6: TToolButton;
    7375    ToolButton7: TToolButton;
     76    ToolButton8: TToolButton;
    7477    procedure ACompileExecute(Sender: TObject);
    7578    procedure AExitExecute(Sender: TObject);
     79    procedure AOptionsExecute(Sender: TObject);
    7680    procedure AProgramPauseExecute(Sender: TObject);
    7781    procedure AProgramStopExecute(Sender: TObject);
     
    115119
    116120uses
    117   UInterpreterForm, UApplicationInfo, UCompiledForm;
     121  UInterpreterForm, UApplicationInfo, UCompiledForm, UOptionsForm;
    118122
    119123{ TMainForm }
     
    193197
    194198procedure TMainForm.AProgramRunExecute(Sender: TObject);
    195 var
    196   SourceText: string;
    197199begin
    198200  InterpreterForm.Show;
    199201  BrainFuckInterpreter.Input := InterpreterForm.MemoInput.Lines.Text;
    200   SourceText := MemoSource.Lines.Text;
    201   SetLength(BrainFuckInterpreter.Source, Length(SourceText));
    202   Move(Pointer(SourceText)^, Pointer(BrainFuckInterpreter.Source)^, Length(SourceText));
     202  BrainFuckInterpreter.Source := MemoSource.Text;
    203203  BrainFuckInterpreter.Run;
    204204end;
     
    222222begin
    223223  Close;
     224end;
     225
     226procedure TMainForm.AOptionsExecute(Sender: TObject);
     227begin
     228  if OptionsForm.ShowModal = mrOK then begin
     229
     230  end;
    224231end;
    225232
Note: See TracChangeset for help on using the changeset viewer.