Changeset 8


Ignore:
Timestamp:
Feb 9, 2012, 3:48:16 PM (12 years ago)
Author:
chronos
Message:
  • Modified: Some optimalization of interpretter.
Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LazFuckIDE.lpi

    r4 r8  
    77      <SessionStorage Value="InProjectDir"/>
    88      <MainUnit Value="0"/>
    9       <Title Value="project1"/>
     9      <Title Value="LazFuck"/>
    1010      <ResourceType Value="res"/>
    1111      <UseXPManifest Value="True"/>
  • trunk/LazFuckIDE.lpr

    r4 r8  
    1414
    1515begin
     16  Application.Title:='LazFuck';
    1617  RequireDerivedFormResource := True;
    1718  Application.Initialize;
  • trunk/UBrainFuck.pas

    r7 r8  
    7676begin
    7777  repeat
    78     while Parent.SourcePosition < Length(Parent.Source) do begin
     78    while (Parent.SourcePosition < Length(Parent.Source)) and (Parent.State <> rsStopped) do begin
    7979      Parent.SingleStep;
    8080      while Parent.State = rsPaused do begin
     
    8383    end;
    8484    Parent.SetState(rsStopped);
    85   until Terminated;
     85  until Terminated or (Parent.State = rsStopped);
    8686end;
    8787
     
    101101
    102102function TBrainFuckInterpretter.Read: Byte;
    103 var
    104   Character: string;
    105103begin
    106104  while InputPosition >= Length(Input) do begin
    107105    Sleep(1);
    108     Application.ProcessMessages;
    109   end;
    110   Character := Copy(Input, InputPosition, 1);
    111   Result := Ord(Character[1]);
     106  end;
     107  Result := Ord(Input[InputPosition + 1]);
    112108  Inc(InputPosition);
    113109end;
    114110
    115111function TBrainFuckInterpretter.ReadCode: Char;
    116 var
    117   Code: string;
    118 begin
    119   Code := Copy(Source, SourcePosition + 1, 1);
    120   Result := Code[1];
     112begin
     113  Result := Source[SourcePosition + 1]
    121114end;
    122115
     
    156149begin
    157150  case ReadCode of
    158     '>': Inc(MemoryPosition);
     151    '>': if MemoryPosition < Length(Memory) then Inc(MemoryPosition)
     152      else raise Exception.Create(SProgramUpperLimit);
    159153    '<': if MemoryPosition > 0 then Dec(MemoryPosition)
    160154      else raise Exception.Create(SProgramLowerLimit);
     
    199193  SetState(rsRunning);
    200194  Reset;
     195  SetThread(False);
    201196  SetThread(True);
    202197end;
  • trunk/UInterpreterForm.lfm

    r6 r8  
    3434        Width = 309
    3535        Anchors = [akTop, akLeft, akRight, akBottom]
     36        Font.Name = 'Courier New'
    3637        OnKeyPress = MemoInputKeyPress
     38        ParentFont = False
    3739        ScrollBars = ssAutoBoth
    3840        TabOrder = 0
     
    8082        Width = 309
    8183        Anchors = [akTop, akLeft, akRight, akBottom]
     84        Font.Name = 'Courier New'
     85        ParentFont = False
    8286        ScrollBars = ssAutoBoth
    8387        TabOrder = 0
Note: See TracChangeset for help on using the changeset viewer.