Changeset 13
- Timestamp:
- Feb 11, 2012, 5:53:25 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LazFuckIDE.lpi
r12 r13 40 40 </Item2> 41 41 </RequiredPackages> 42 <Units Count=" 6">42 <Units Count="7"> 43 43 <Unit0> 44 44 <Filename Value="LazFuckIDE.lpr"/> … … 77 77 <UnitName Value="UCompiledForm"/> 78 78 </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> 79 86 </Units> 80 87 </ProjectOptions> … … 96 103 <StackChecks Value="True"/> 97 104 </Checks> 98 <VerifyObjMethodCallValidity Value="True"/>99 105 </CodeGeneration> 100 106 <Linking> -
trunk/LazFuckIDE.lpr
r12 r13 10 10 Interfaces, // this includes the LCL widgetset 11 11 Forms, UMainForm, UBrainFuck, UInterpreterForm, UApplicationInfo, 12 UCompiledForm 12 UCompiledForm, UOptionsForm 13 13 { you can add units after this }; 14 14 … … 22 22 Application.CreateForm(TInterpreterForm, InterpreterForm); 23 23 Application.CreateForm(TCompiledForm, CompiledForm); 24 Application.CreateForm(TOptionsForm, OptionsForm); 24 25 Application.Run; 25 26 end. -
trunk/UBrainFuck.pas
r12 r13 48 48 FThread: TBrainFuckInterpretterThread; 49 49 FStepCount: Integer; 50 function GetSource: string; 51 procedure SetSource(AValue: string); 50 52 procedure SetState(AValue: TRunState); 51 53 procedure Write(Value: Byte); … … 55 57 procedure PrepareJumpTable; 56 58 public 57 Source: array of Char;59 FSource: array of Char; 58 60 SourceJump: array of Integer; 59 61 SourcePosition: Integer; 62 SourceBreakpoint: array of Boolean; 60 63 Memory: array of Byte; 61 64 MemoryPosition: Integer; … … 73 76 property OnChangeState: TNotifyEvent read FOnChangeState write FOnChangeState; 74 77 property StepCount: Integer read FStepCount; 78 property Source: string read GetSource write SetSource; 75 79 end; 76 80 … … 90 94 begin 91 95 repeat 92 while (Parent.SourcePosition < Length(Parent. Source)) and (Parent.State <> rsStopped) do begin96 while (Parent.SourcePosition < Length(Parent.FSource)) and (Parent.State <> rsStopped) do begin 93 97 Parent.SingleStep; 94 98 while Parent.State = rsPaused do begin … … 114 118 end; 115 119 120 function TBrainFuckInterpretter.GetSource: string; 121 var 122 I: Integer; 123 begin 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]; 128 end; 129 130 procedure TBrainFuckInterpretter.SetSource(AValue: string); 131 var 132 I: Integer; 133 begin 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]; 138 end; 139 116 140 function TBrainFuckInterpretter.Read: Byte; 117 141 begin … … 125 149 function TBrainFuckInterpretter.ReadCode: Char; 126 150 begin 127 Result := Source[SourcePosition];151 Result := FSource[SourcePosition]; 128 152 end; 129 153 … … 148 172 I: Integer; 149 173 begin 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; 152 178 SetLength(Loop, 0); 153 for I := 0 to Length( Source) - 1 do begin154 case Source[I] of179 for I := 0 to Length(FSource) - 1 do begin 180 case FSource[I] of 155 181 '[': begin 156 182 SetLength(Loop, Length(Loop) + 1); … … 170 196 171 197 procedure TBrainFuckInterpretter.Reset; 198 var 199 I: Integer; 172 200 begin 173 201 PrepareJumpTable; … … 176 204 Output := ''; 177 205 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; 179 209 FStepCount := 0; 180 210 end; -
trunk/UMainForm.lfm
r12 r13 94 94 Action = ACompile 95 95 end 96 object ToolButton8: TToolButton 97 Left = 149 98 Top = 2 99 Action = AOptions 100 end 96 101 end 97 102 object TabControl1: TTabControl … … 518 523 object MenuItem18: TMenuItem 519 524 Caption = 'View' 525 object MenuItem22: TMenuItem 526 Action = AOptions 527 end 520 528 object MenuItem19: TMenuItem 521 529 Action = AViewInterpretter … … 663 671 object ABreakpointUnset: TAction 664 672 Caption = 'Unset breakpoint' 673 end 674 object AOptions: TAction 675 Caption = 'Options' 676 ImageIndex = 2 677 OnExecute = AOptionsExecute 665 678 end 666 679 end -
trunk/UMainForm.pas
r12 r13 18 18 ABreakpointSet: TAction; 19 19 ABreakpointUnset: TAction; 20 AOptions: TAction; 20 21 AInterpretterStepOut: TAction; 21 22 AInterpretterRunToCursor: TAction; … … 51 52 MenuItem2: TMenuItem; 52 53 MenuItem20: TMenuItem; 54 MenuItem22: TMenuItem; 53 55 MenuItem40: TMenuItem; 54 56 MenuItem21: TMenuItem; … … 72 74 ToolButton6: TToolButton; 73 75 ToolButton7: TToolButton; 76 ToolButton8: TToolButton; 74 77 procedure ACompileExecute(Sender: TObject); 75 78 procedure AExitExecute(Sender: TObject); 79 procedure AOptionsExecute(Sender: TObject); 76 80 procedure AProgramPauseExecute(Sender: TObject); 77 81 procedure AProgramStopExecute(Sender: TObject); … … 115 119 116 120 uses 117 UInterpreterForm, UApplicationInfo, UCompiledForm ;121 UInterpreterForm, UApplicationInfo, UCompiledForm, UOptionsForm; 118 122 119 123 { TMainForm } … … 193 197 194 198 procedure TMainForm.AProgramRunExecute(Sender: TObject); 195 var196 SourceText: string;197 199 begin 198 200 InterpreterForm.Show; 199 201 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; 203 203 BrainFuckInterpreter.Run; 204 204 end; … … 222 222 begin 223 223 Close; 224 end; 225 226 procedure TMainForm.AOptionsExecute(Sender: TObject); 227 begin 228 if OptionsForm.ShowModal = mrOK then begin 229 230 end; 224 231 end; 225 232
Note:
See TracChangeset
for help on using the changeset viewer.