Changeset 8 for trunk/UBrainFuck.pas
- Timestamp:
- Feb 9, 2012, 3:48:16 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UBrainFuck.pas
r7 r8 76 76 begin 77 77 repeat 78 while Parent.SourcePosition < Length(Parent.Source) do begin78 while (Parent.SourcePosition < Length(Parent.Source)) and (Parent.State <> rsStopped) do begin 79 79 Parent.SingleStep; 80 80 while Parent.State = rsPaused do begin … … 83 83 end; 84 84 Parent.SetState(rsStopped); 85 until Terminated ;85 until Terminated or (Parent.State = rsStopped); 86 86 end; 87 87 … … 101 101 102 102 function TBrainFuckInterpretter.Read: Byte; 103 var104 Character: string;105 103 begin 106 104 while InputPosition >= Length(Input) do begin 107 105 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]); 112 108 Inc(InputPosition); 113 109 end; 114 110 115 111 function TBrainFuckInterpretter.ReadCode: Char; 116 var 117 Code: string; 118 begin 119 Code := Copy(Source, SourcePosition + 1, 1); 120 Result := Code[1]; 112 begin 113 Result := Source[SourcePosition + 1] 121 114 end; 122 115 … … 156 149 begin 157 150 case ReadCode of 158 '>': Inc(MemoryPosition); 151 '>': if MemoryPosition < Length(Memory) then Inc(MemoryPosition) 152 else raise Exception.Create(SProgramUpperLimit); 159 153 '<': if MemoryPosition > 0 then Dec(MemoryPosition) 160 154 else raise Exception.Create(SProgramLowerLimit); … … 199 193 SetState(rsRunning); 200 194 Reset; 195 SetThread(False); 201 196 SetThread(True); 202 197 end;
Note:
See TracChangeset
for help on using the changeset viewer.