Changeset 18
- Timestamp:
- Feb 11, 2012, 9:32:25 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Languages/LazFuckIDE.cs.po
r16 r18 11 11 12 12 #: tinterpreterform.caption 13 #, fuzzy14 13 #| msgid "Runtime" 15 14 msgctxt "tinterpreterform.caption" 16 15 msgid "Interpretter" 17 msgstr " BÄh"16 msgstr "Interpreter" 18 17 19 18 #: tinterpreterform.label1.caption … … 41 40 msgstr "PamÄÅ¥" 42 41 42 #: tinterpreterform.label7.caption 43 msgid "Speed:" 44 msgstr "Rychlost:" 45 43 46 #: tinterpreterform.labelmemorypointer.caption 44 47 msgctxt "tinterpreterform.labelmemorypointer.caption" 45 48 msgid " " 46 msgstr " "49 msgstr " " 47 50 48 51 #: tinterpreterform.labelprogrampointer.caption 49 52 msgctxt "tinterpreterform.labelprogrampointer.caption" 50 53 msgid " " 51 msgstr " "54 msgstr " " 52 55 53 56 #: tinterpreterform.labelstepcounter.caption 54 57 msgctxt "tinterpreterform.labelstepcounter.caption" 55 58 msgid " " 56 msgstr "" 59 msgstr " " 60 61 #: tinterpreterform.labelstepspeed.caption 62 msgctxt "tinterpreterform.labelstepspeed.caption" 63 msgid " " 64 msgstr " " 57 65 58 66 #: tinterpreterform.listviewmemory.columns[0].caption … … 64 72 msgstr "Data" 65 73 66 #: tinterpreterform.toolbar1.caption67 msgid "ToolBar1"68 msgstr ""69 70 74 #: tmainform.aabout.caption 71 75 msgid "About" … … 74 78 #: tmainform.abreakpointtoggle.caption 75 79 msgid "Toggle breakpoint" 76 msgstr " "80 msgstr "PÅepnout bod zastavenÃ" 77 81 78 82 #: tmainform.acompile.caption … … 86 90 #: tmainform.aformatsource.caption 87 91 msgid "Format source" 88 msgstr " "92 msgstr "Formátovat zdroj" 89 93 90 94 #: tmainform.ahelp.caption … … 183 187 #: tmainform.menuitem24.caption 184 188 msgid "Tools" 185 msgstr " "189 msgstr "Nástroje" 186 190 187 191 #: tmainform.menuitem40.caption … … 251 255 msgstr "Chyba Ätenà vstupu" 252 256 257 #: uinterpreterform.sstepspersecond 258 msgid " steps/s" 259 msgstr " kroků/s" 260 -
trunk/Languages/LazFuckIDE.po
r16 r18 31 31 msgstr "" 32 32 33 #: tinterpreterform.label7.caption 34 msgid "Speed:" 35 msgstr "" 36 33 37 #: tinterpreterform.labelmemorypointer.caption 34 38 msgctxt "TINTERPRETERFORM.LABELMEMORYPOINTER.CAPTION" … … 46 50 msgstr "" 47 51 52 #: tinterpreterform.labelstepspeed.caption 53 msgctxt "TINTERPRETERFORM.LABELSTEPSPEED.CAPTION" 54 msgid " " 55 msgstr "" 56 48 57 #: tinterpreterform.listviewmemory.columns[0].caption 49 58 msgid "Address" … … 52 61 #: tinterpreterform.listviewmemory.columns[1].caption 53 62 msgid "Data" 54 msgstr ""55 56 #: tinterpreterform.toolbar1.caption57 msgid "ToolBar1"58 63 msgstr "" 59 64 … … 241 246 msgstr "" 242 247 248 #: uinterpreterform.sstepspersecond 249 msgid " steps/s" 250 msgstr "" 251 -
trunk/LazFuckIDE.lpi
r15 r18 19 19 <StringTable ProductVersion=""/> 20 20 </VersionInfo> 21 <BuildModes Count="1"> 22 <Item1 Name="Default" Default="True"/> 21 <BuildModes Count="2"> 22 <Item1 Name="Debug" Default="True"/> 23 <Item2 Name="Release"> 24 <CompilerOptions> 25 <Version Value="11"/> 26 <PathDelim Value="\"/> 27 <Target> 28 <Filename Value="LazFuckIDE"/> 29 </Target> 30 <SearchPaths> 31 <IncludeFiles Value="$(ProjOutDir)"/> 32 <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/> 33 </SearchPaths> 34 <CodeGeneration> 35 <SmartLinkUnit Value="True"/> 36 <Optimizations> 37 <OptimizationLevel Value="3"/> 38 </Optimizations> 39 </CodeGeneration> 40 <Linking> 41 <Debugging> 42 <GenerateDebugInfo Value="False"/> 43 </Debugging> 44 <Options> 45 <Win32> 46 <GraphicApplication Value="True"/> 47 </Win32> 48 </Options> 49 </Linking> 50 <Other> 51 <CompilerMessages> 52 <MsgFileName Value=""/> 53 </CompilerMessages> 54 <CompilerPath Value="$(CompPath)"/> 55 </Other> 56 </CompilerOptions> 57 </Item2> 23 58 </BuildModes> 24 59 <PublishOptions> … … 113 148 <StackChecks Value="True"/> 114 149 </Checks> 150 <VerifyObjMethodCallValidity Value="True"/> 115 151 </CodeGeneration> 116 152 <Linking> -
trunk/UBrainFuck.pas
r17 r18 39 39 end; 40 40 41 TBrainFuckCommand = (cmNone, cmInc, cmDec, cmPointerInc, cmPointerDec, 42 cmOutput, cmInput, cmLoopStart, cmLoopEnd); 43 44 TCommandHandler = procedure of object; 45 41 46 { TBrainFuckInterpretter } 42 47 … … 49 54 FThread: TBrainFuckInterpretterThread; 50 55 FStepCount: Integer; 56 FCommandTable: array[TBrainFuckCommand] of TCommandHandler; 51 57 function GetMemorySize: Integer; 52 function GetSource: string;53 58 procedure SetMemorySize(AValue: Integer); 54 59 procedure SetSource(AValue: string); 55 60 procedure SetState(AValue: TRunState); 56 procedure Write(Value: Byte);57 function Read: Byte;58 61 procedure SetThread(State: Boolean); 59 62 procedure PrepareJumpTable; 60 procedure RemoveBlankCharacters; 63 procedure CommandInc; 64 procedure CommandDec; 65 procedure CommandPointerInc; 66 procedure CommandPointerDec; 67 procedure CommandInput; 68 procedure CommandOutput; 69 procedure CommandLoopStart; 70 procedure CommandLoopEnd; 61 71 public 62 FSource: array of Char;72 FSource: array of TBrainFuckCommand; 63 73 SourceJump: array of Integer; 64 74 SourcePosition: Integer; … … 80 90 property OnChangeState: TNotifyEvent read FOnChangeState write FOnChangeState; 81 91 property StepCount: Integer read FStepCount; 82 property Source: string read GetSourcewrite SetSource;92 property Source: string write SetSource; 83 93 property MemorySize: Integer read GetMemorySize write SetMemorySize; 84 94 property CellSize: Integer read FCellSize write FCellSize; … … 113 123 { TBrainFuckInterpretter } 114 124 115 procedure TBrainFuckInterpretter.Write(Value: Byte);116 begin117 if OutputPosition > Length(Output) then118 SetLength(Output, Length(Output) + 1 + Length(Output) div 4);119 Output[OutputPosition] := Char(Value);120 Inc(OutputPosition);121 end;122 123 125 procedure TBrainFuckInterpretter.SetState(AValue: TRunState); 124 126 begin … … 128 130 end; 129 131 130 function TBrainFuckInterpretter.GetSource: string;131 var132 I: Integer;133 begin134 SetLength(Result, Length(FSource));135 //Move(Pointer(Result)^, Pointer(FSource)^, Length(Result));136 for I := 0 to Length(FSource) - 1 do137 Result[I + 1] := FSource[I];138 end;139 140 132 function TBrainFuckInterpretter.GetMemorySize: Integer; 141 133 begin … … 151 143 var 152 144 I: Integer; 145 Pos: Integer; 153 146 begin 154 147 SetLength(FSource, Length(AValue)); 155 //Move(Pointer(AValue)^, Pointer(FSource)^, Length(AValue)); 156 for I := 0 to Length(FSource) - 1 do 157 FSource[I] := AValue[I + 1]; 158 end; 159 160 function TBrainFuckInterpretter.Read: Byte; 161 begin 162 while (InputPosition > Length(Input)) and (FState <> rsStopped) do begin 163 Sleep(1); 164 end; 165 if InputPosition <= Length(Input) then begin 166 Result := Ord(Input[InputPosition]); 167 Inc(InputPosition); 168 end else Result := 0; 148 Pos := 0; 149 for I := 1 to Length(AValue) do begin 150 case AValue[I] of 151 '+': FSource[Pos] := cmInc; 152 '-': FSource[Pos] := cmDec; 153 '>': FSource[Pos] := cmPointerInc; 154 '<': FSource[Pos] := cmPointerDec; 155 ',': FSource[Pos] := cmInput; 156 '.': FSource[Pos] := cmOutput; 157 '[': FSource[Pos] := cmLoopStart; 158 ']': FSource[Pos] := cmLoopEnd; 159 else Dec(Pos); 160 end; 161 Inc(Pos); 162 end; 163 SetLength(FSource, Pos); 169 164 end; 170 165 … … 186 181 var 187 182 Loop: array of Integer; 188 LoopCurrent: Integer;189 183 I: Integer; 190 184 begin … … 196 190 for I := 0 to Length(FSource) - 1 do begin 197 191 case FSource[I] of 198 '[': begin192 cmLoopStart: begin 199 193 SetLength(Loop, Length(Loop) + 1); 200 194 Loop[High(Loop)] := I; 201 195 end; 202 ']': begin196 cmLoopEnd: begin 203 197 if SourceJump[I] > 0 then raise Exception.Create(SJumpTableColision); 204 198 SourceJump[I] := Loop[High(Loop)]; … … 212 206 end; 213 207 214 procedure TBrainFuckInterpretter.RemoveBlankCharacters; 215 var 216 I: Integer; 217 LastChar: Integer; 218 begin 219 LastChar := 0; 220 for I := 0 to Length(FSource) - 1 do 221 if FSource[I] in ['+','-','>','<','.',',','[',']'] then begin 222 FSource[LastChar] := FSource[I]; 223 Inc(LastChar); 224 end; 225 SetLength(FSource, LastChar); 208 procedure TBrainFuckInterpretter.CommandInc; 209 begin 210 Memory[MemoryPosition] := ((Memory[MemoryPosition] + 1) mod CellSize); 211 end; 212 213 procedure TBrainFuckInterpretter.CommandDec; 214 begin 215 Memory[MemoryPosition] := ((Memory[MemoryPosition] - 1) mod CellSize); 216 end; 217 218 procedure TBrainFuckInterpretter.CommandPointerInc; 219 begin 220 if MemoryPosition < MemorySize then Inc(MemoryPosition) 221 else raise Exception.Create(SProgramUpperLimit); 222 end; 223 224 procedure TBrainFuckInterpretter.CommandPointerDec; 225 begin 226 if MemoryPosition > 0 then Dec(MemoryPosition) 227 else raise Exception.Create(SProgramLowerLimit); 228 end; 229 230 procedure TBrainFuckInterpretter.CommandInput; 231 begin 232 while (InputPosition > Length(Input)) and (FState <> rsStopped) do begin 233 Sleep(1); 234 end; 235 if InputPosition <= Length(Input) then begin 236 Memory[MemoryPosition] := Ord(Input[InputPosition]); 237 Inc(InputPosition); 238 end; 239 end; 240 241 procedure TBrainFuckInterpretter.CommandOutput; 242 begin 243 if OutputPosition > Length(Output) then 244 SetLength(Output, Length(Output) + 1 + Length(Output) div 4); 245 Output[OutputPosition] := Char(Memory[MemoryPosition]); 246 Inc(OutputPosition); 247 end; 248 249 procedure TBrainFuckInterpretter.CommandLoopStart; 250 begin 251 if Memory[MemoryPosition] = 0 then 252 SourcePosition := SourceJump[SourcePosition]; 253 end; 254 255 procedure TBrainFuckInterpretter.CommandLoopEnd; 256 begin 257 if Memory[MemoryPosition] > 0 then 258 SourcePosition := SourceJump[SourcePosition] - 1; 226 259 end; 227 260 … … 230 263 I: Integer; 231 264 begin 232 RemoveBlankCharacters;233 265 PrepareJumpTable; 234 266 SourcePosition := 0; … … 244 276 245 277 procedure TBrainFuckInterpretter.SingleStep; 246 var 247 CodeText: string; 248 C: Integer; 249 NewPos: Integer; 250 begin 251 case FSource[SourcePosition] of 252 '>': if MemoryPosition < MemorySize then Inc(MemoryPosition) 253 else raise Exception.Create(SProgramUpperLimit); 254 '<': if MemoryPosition > 0 then Dec(MemoryPosition) 255 else raise Exception.Create(SProgramLowerLimit); 256 '+': Memory[MemoryPosition] := ((Memory[MemoryPosition] + 1) mod CellSize); 257 '-': Memory[MemoryPosition] := ((Memory[MemoryPosition] - 1) mod CellSize); 258 '.': Write(Memory[MemoryPosition]); 259 ',': Memory[MemoryPosition] := Read; 260 '[': begin 261 if Memory[MemoryPosition] = 0 then begin 262 SourcePosition := SourceJump[SourcePosition]; 263 (*C := 1; 264 Inc(SourcePosition); 265 while C > 0 do begin 266 case ReadCode of 267 '[': Inc(C); 268 ']': Dec(C); 269 end; 270 Inc(SourcePosition); 271 end; 272 Dec(SourcePosition);*) 273 //if NewPos <> SourcePosition then raise Exception.Create('Wrong pos: ' + IntToStr(SourcePosition) + ' ' + IntToStr(NewPos)); 274 end; 275 end; 276 ']': begin 277 if Memory[MemoryPosition] > 0 then begin 278 SourcePosition := SourceJump[SourcePosition] - 1; 279 (*C := 1; 280 Dec(SourcePosition); 281 while C > 0 do begin 282 case ReadCode of 283 ']': Inc(C); 284 '[': Dec(C); 285 end; 286 Dec(SourcePosition); 287 end; 288 if NewPos <> SourcePosition then raise Exception.Create('Wrong pos: ' + IntToStr(SourcePosition) + ' ' + IntToStr(NewPos)); 289 *) 290 end; 291 end; 292 end; 278 begin 279 FCommandTable[FSource[SourcePosition]]; 293 280 Inc(SourcePosition); 294 281 Inc(FStepCount); … … 317 304 MemorySize := 30000; 318 305 CellSize := 256; 306 FCommandTable[cmInc] := CommandInc; 307 FCommandTable[cmDec] := CommandDec; 308 FCommandTable[cmPointerInc] := CommandPointerInc; 309 FCommandTable[cmPointerDec] := CommandPointerDec; 310 FCommandTable[cmOutput] := CommandOutput; 311 FCommandTable[cmInput] := CommandInput; 312 FCommandTable[cmLoopStart] := CommandLoopStart; 313 FCommandTable[cmLoopEnd] := CommandLoopEnd; 319 314 end; 320 315 -
trunk/UInterpreterForm.lfm
r15 r18 7 7 ClientHeight = 509 8 8 ClientWidth = 762 9 OnHide = FormHide 10 OnShow = FormShow 9 11 LCLVersion = '0.9.31' 10 12 object Panel3: TPanel … … 187 189 ParentColor = False 188 190 end 191 object Label7: TLabel 192 Left = 1 193 Height = 18 194 Top = 62 195 Width = 45 196 Caption = 'Speed:' 197 ParentColor = False 198 end 199 object LabelStepSpeed: TLabel 200 Left = 112 201 Height = 18 202 Top = 62 203 Width = 13 204 Caption = ' ' 205 ParentColor = False 206 end 189 207 end 190 208 object ToolBar1: TToolBar … … 193 211 Top = 0 194 212 Width = 762 195 Caption = 'ToolBar1'196 213 Images = MainForm.ImageList1 197 214 TabOrder = 3 … … 233 250 end 234 251 object Timer1: TTimer 235 Interval = 500252 Enabled = False 236 253 OnTimer = Timer1Timer 237 254 left = 495 -
trunk/UInterpreterForm.lrt
r15 r18 11 11 TINTERPRETERFORM.LISTVIEWMEMORY.COLUMNS[1].CAPTION=Data 12 12 TINTERPRETERFORM.LABEL6.CAPTION=Memory: 13 TINTERPRETERFORM.TOOLBAR1.CAPTION=ToolBar1 13 TINTERPRETERFORM.LABEL7.CAPTION=Speed: 14 TINTERPRETERFORM.LABELSTEPSPEED.CAPTION= -
trunk/UInterpreterForm.pas
r12 r18 22 22 Label4: TLabel; 23 23 Label6: TLabel; 24 Label7: TLabel; 24 25 LabelStepCounter: TLabel; 25 26 LabelProgramPointer: TLabel; 26 27 Label5: TLabel; 27 28 LabelMemoryPointer: TLabel; 29 LabelStepSpeed: TLabel; 28 30 ListViewMemory: TListView; 29 31 MemoInput: TMemo; … … 44 46 ToolButton6: TToolButton; 45 47 ToolButton7: TToolButton; 48 procedure FormHide(Sender: TObject); 49 procedure FormShow(Sender: TObject); 46 50 procedure ListViewMemoryData(Sender: TObject; Item: TListItem); 47 51 procedure MemoInputKeyPress(Sender: TObject; var Key: char); 48 52 procedure Timer1Timer(Sender: TObject); 49 53 private 50 { private declarations }54 LastStepCounter: Integer; 51 55 public 52 56 procedure RefreshListViewMemory; … … 64 68 {$R *.lfm} 65 69 70 resourcestring 71 SStepsPerSecond = ' steps/s'; 72 66 73 { TInterpreterForm } 67 74 … … 71 78 LabelMemoryPointer.Caption := IntToStr(MainForm.BrainFuckInterpreter.MemoryPosition); 72 79 LabelStepCounter.Caption := IntToStr(MainForm.BrainFuckInterpreter.StepCount); 80 LabelStepSpeed.Caption := IntToStr(MainForm.BrainFuckInterpreter.StepCount - LastStepCounter) + SStepsPerSecond; 81 LastStepCounter := MainForm.BrainFuckInterpreter.StepCount; 73 82 RefreshListViewMemory; 74 83 MemoOutput.Lines.Text := MainForm.BrainFuckInterpreter.Output; … … 101 110 end; 102 111 112 procedure TInterpreterForm.FormHide(Sender: TObject); 113 begin 114 Timer1.Enabled := False; 115 end; 116 117 procedure TInterpreterForm.FormShow(Sender: TObject); 118 begin 119 Timer1.Enabled := True; 120 end; 121 103 122 procedure TInterpreterForm.MemoInputKeyPress(Sender: TObject; var Key: char); 104 123 begin -
trunk/UMainForm.lfm
r16 r18 1171 1171 object PopupMenuSource: TPopupMenu 1172 1172 Images = ImageList1 1173 left = 1 281174 top = 1 261173 left = 192 1174 top = 104 1175 1175 object MenuItem23: TMenuItem 1176 1176 Action = ABreakpointToggle 1177 Bitmap.Data = { 1178 36040000424D3604000000000000360000002800000010000000100000000100 1179 2000000000000004000064000000640000000000000000000000FFFFFF00FFFF 1180 FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF 1181 FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF 1182 FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF 1183 FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF 1184 FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF 1185 FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF 1186 FF000000810000007500000064200000607E000060B2000060C8000060B20000 1187 607E000064200000750000008100FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF 1188 FF00000081000000784102027DC10A0AA8E70F0FCAF81111D5FE0F0FCAF80A0A 1189 A8E702027DC10000784100008100FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF 1190 FF0000008420030389C11515BFF31212CDFF1111CCFF1111CCFF1111CCFF1111 1191 CCFF0E0EBCF3020288C100008420FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF 1192 FF000000897E1818AFE61414C1FF1111BFFF1111BFFF1111BFFF1111BFFF1111 1193 BFFF1111BFFF0A0AA6E60000897EFFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF 1194 FF0000008FB23434C3F81414B2FF1111B1FF1111B1FF1111B1FF1111B1FF1111 1195 B1FF1111B1FF1414B0F800008FB2FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF 1196 FF00000095C84848D0FE2E2EB8FF1D1DADFF1212A5FF1111A4FF1111A4FF1111 1197 A4FF1111A4FF1B1BADFE000095C8FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF 1198 FF0000009AB24A4AD4F83737BFFF3737BFFF3131BAFF2727B0FF1C1CA6FF1616 1199 A0FF12129CFF2323AEF800009AB2FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF 1200 FF0000009E7E3939CCE64A4AD2FF4545CDFF4545CDFF4545CDFF4545CDFF4545 1201 CDFF4848D0FF3131C3E600009E7EFFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF 1202 FF000000A3200A0AABC15555E3F35A5AE2FF5656DEFF5656DEFF5656DEFF5959 1203 E1FF5050DEF30909AAC10000A320FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF 1204 FF000000A4000000A6410A0AAEC13F3FD5E76060EDF86A6AF3FE6060ECF83E3E 1205 D4E70A0AADC10000A6410000A400FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF 1206 FF000000A4000000A6000000A9200000AA7E0000AAB20000AAC80000AAB20000 1207 AA7E0000A9200000A6000000A400FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF 1208 FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF 1209 FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF 1210 FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF 1211 FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00 1212 } 1213 end 1214 object MenuItem26: TMenuItem 1215 Action = AFormatSource 1177 1216 end 1178 1217 end -
trunk/UMainForm.pas
r16 r18 58 58 MenuItem24: TMenuItem; 59 59 MenuItem25: TMenuItem; 60 MenuItem26: TMenuItem; 60 61 MenuItem40: TMenuItem; 61 62 MenuItem21: TMenuItem; … … 307 308 procedure TMainForm.AProjectNewExecute(Sender: TObject); 308 309 begin 309 ProjectFileName := ' Project.b';310 ProjectFileName := 'Examples' + DirectorySeparator + 'Project.b'; 310 311 MemoSource.Clear; 311 312 Modified := False;
Note:
See TracChangeset
for help on using the changeset viewer.