Changeset 30 for trunk/Target
- Timestamp:
- Feb 18, 2012, 7:49:17 PM (13 years ago)
- Location:
- trunk/Target
- Files:
-
- 4 deleted
- 4 copied
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/Target/UTarget.pas
r29 r30 1 unit U Compiler;1 unit UTarget; 2 2 3 3 {$mode Delphi}{$H+} … … 12 12 TCompilerOptimization = (coNone, coNormal); 13 13 14 { T BrainFuckCompiler}14 { TTarget } 15 15 16 T BrainFuckCompiler= class16 TTarget = class 17 17 protected 18 18 Indent: Integer; … … 36 36 end; 37 37 38 { T CompilerList }38 { TTargetList } 39 39 40 T CompilerList = class(TListObject)40 TTargetList = class(TListObject) 41 41 procedure LoadFromRegistry(Root: HKEY; Key: string); 42 42 procedure SaveToRegistry(Root: HKEY; Key: string); … … 52 52 53 53 54 { T CompilerList }54 { TTargetList } 55 55 56 procedure T CompilerList.LoadFromRegistry(Root: HKEY; Key: string);56 procedure TTargetList.LoadFromRegistry(Root: HKEY; Key: string); 57 57 var 58 58 I: Integer; … … 63 63 OpenKey(Key + '\Compiler', True); 64 64 for I := 0 to Count - 1 do 65 with T BrainFuckCompiler(Items[I]) do65 with TTarget(Items[I]) do 66 66 if ValueExists(Name) then CompilerPath := ReadString(Name); 67 67 finally … … 70 70 end; 71 71 72 procedure T CompilerList.SaveToRegistry(Root: HKEY; Key: string);72 procedure TTargetList.SaveToRegistry(Root: HKEY; Key: string); 73 73 var 74 74 I: Integer; … … 79 79 OpenKey(Key + '\Compiler', True); 80 80 for I := 0 to Count - 1 do 81 with T BrainFuckCompiler(Items[I]) do81 with TTarget(Items[I]) do 82 82 if CompilerPath <> '' then WriteString(Name, CompilerPath) 83 83 else DeleteValue(Name); … … 87 87 end; 88 88 89 { T BrainFuckCompiler}89 { TTarget } 90 90 91 procedure T BrainFuckCompiler.AddLine(Text: string);91 procedure TTarget.AddLine(Text: string); 92 92 begin 93 93 Output := Output + DupeString(' ', Indent) + Text + LineEnding; 94 94 end; 95 95 96 function T BrainFuckCompiler.LongFileName(FileName: string): string;96 function TTarget.LongFileName(FileName: string): string; 97 97 begin 98 98 Result := FileName; … … 105 105 end; 106 106 107 constructor T BrainFuckCompiler.Create;107 constructor TTarget.Create; 108 108 begin 109 109 Optimization := coNormal; 110 110 end; 111 111 112 procedure T BrainFuckCompiler.OptimizeSource;112 procedure TTarget.OptimizeSource; 113 113 begin 114 114 // Remove redundand code … … 116 116 end; 117 117 118 procedure T BrainFuckCompiler.Compile;118 procedure TTarget.Compile; 119 119 begin 120 120 121 121 end; 122 122 123 procedure T BrainFuckCompiler.CompileToFile;123 procedure TTarget.CompileToFile; 124 124 var 125 125 Process: TProcess; … … 149 149 end; 150 150 151 procedure T BrainFuckCompiler.Run;151 procedure TTarget.Run; 152 152 var 153 153 CompiledFile: string; -
trunk/Target/UTargetC.pas
r29 r30 1 unit U CompilerC;1 unit UTargetC; 2 2 3 3 {$mode Delphi}{$H+} … … 6 6 7 7 uses 8 Classes, SysUtils, FileUtil, U Compiler, Process, Dialogs;8 Classes, SysUtils, FileUtil, UTarget, Process, Dialogs; 9 9 10 10 type 11 11 12 { T BrainFuckCompilerC }12 { TTargetC } 13 13 14 T BrainFuckCompilerC = class(TBrainFuckCompiler)14 TTargetC = class(TTarget) 15 15 constructor Create; override; 16 16 procedure Compile; override; … … 21 21 implementation 22 22 23 { T BrainFuckCompilerC }23 { TTargetC } 24 24 25 constructor T BrainFuckCompilerC.Create;25 constructor TTargetC.Create; 26 26 begin 27 27 inherited Create; … … 37 37 end; 38 38 39 procedure T BrainFuckCompilerC.Compile;39 procedure TTargetC.Compile; 40 40 var 41 41 I: Integer; … … 104 104 end; 105 105 106 procedure T BrainFuckCompilerC.CompileToFile;106 procedure TTargetC.CompileToFile; 107 107 var 108 108 Process: TProcess; … … 133 133 end; 134 134 135 procedure T BrainFuckCompilerC.Run;135 procedure TTargetC.Run; 136 136 begin 137 137 inherited Run; -
trunk/Target/UTargetDelphi.pas
r29 r30 1 unit U CompilerDelphi;1 unit UTargetDelphi; 2 2 3 3 {$mode Delphi}{$H+} … … 6 6 7 7 uses 8 Classes, SysUtils, U Compiler;8 Classes, SysUtils, UTarget; 9 9 10 10 type 11 11 12 { T BrainFuckCompilerDelphi }12 { TTargetDelphi } 13 13 14 T BrainFuckCompilerDelphi = class(TBrainFuckCompiler)14 TTargetDelphi = class(TTarget) 15 15 constructor Create; override; 16 16 procedure Compile; override; … … 19 19 implementation 20 20 21 { T BrainFuckCompilerDelphi }21 { TTargetDelphi } 22 22 23 constructor T BrainFuckCompilerDelphi.Create;23 constructor TTargetDelphi.Create; 24 24 begin 25 25 inherited Create; … … 32 32 end; 33 33 34 procedure T BrainFuckCompilerDelphi.Compile;34 procedure TTargetDelphi.Compile; 35 35 var 36 36 I: Integer; -
trunk/Target/UTargetInterpretter.pas
r29 r30 1 unit U BrainFuck;1 unit UTargetInterpretter; 2 2 3 3 {$mode Delphi}{$H+} … … 9 9 10 10 type 11 T BrainFuckInterpretter = class;11 TTargetInterpretter = class; 12 12 13 13 14 14 TRunState = (rsStopped, rsPaused, rsRunning); 15 15 16 { T BrainFuckInterpretterThread }17 18 T BrainFuckInterpretterThread = class(TThread)19 Parent: T BrainFuckInterpretter;16 { TTargetInterpretterThread } 17 18 TTargetInterpretterThread = class(TThread) 19 Parent: TTargetInterpretter; 20 20 procedure Execute; override; 21 21 end; … … 26 26 TCommandHandler = procedure of object; 27 27 28 { T BrainFuckInterpretter }29 30 T BrainFuckInterpretter = class28 { TTargetInterpretter } 29 30 TTargetInterpretter = class 31 31 private 32 32 FCellSize: Integer; … … 34 34 FState: TRunState; 35 35 FThreadState: Boolean; 36 FThread: T BrainFuckInterpretterThread;36 FThread: TTargetInterpretterThread; 37 37 FStepCount: Integer; 38 38 FCommandTable: array[TBrainFuckCommand] of TCommandHandler; … … 88 88 SMemoryCellOutOfRange = 'Memory cell %s value out of range'; 89 89 90 { T BrainFuckInterpretterThread }91 92 procedure T BrainFuckInterpretterThread.Execute;90 { TTargetInterpretterThread } 91 92 procedure TTargetInterpretterThread.Execute; 93 93 begin 94 94 repeat … … 103 103 end; 104 104 105 { T BrainFuckInterpretter }106 107 procedure T BrainFuckInterpretter.SetState(AValue: TRunState);105 { TTargetInterpretter } 106 107 procedure TTargetInterpretter.SetState(AValue: TRunState); 108 108 begin 109 109 if FState = AValue then Exit; … … 112 112 end; 113 113 114 function T BrainFuckInterpretter.GetMemorySize: Integer;114 function TTargetInterpretter.GetMemorySize: Integer; 115 115 begin 116 116 Result := Length(Memory); 117 117 end; 118 118 119 procedure T BrainFuckInterpretter.SetMemorySize(AValue: Integer);119 procedure TTargetInterpretter.SetMemorySize(AValue: Integer); 120 120 begin 121 121 SetLength(Memory, AValue); 122 122 end; 123 123 124 procedure T BrainFuckInterpretter.SetSource(AValue: string);124 procedure TTargetInterpretter.SetSource(AValue: string); 125 125 var 126 126 I: Integer; … … 146 146 end; 147 147 148 procedure T BrainFuckInterpretter.SetThread(State: Boolean);148 procedure TTargetInterpretter.SetThread(State: Boolean); 149 149 begin 150 150 if FThreadState = State then Exit; 151 151 FThreadState := State; 152 152 if State then begin 153 FThread := T BrainFuckInterpretterThread.Create(True);153 FThread := TTargetInterpretterThread.Create(True); 154 154 FThread.Parent := Self; 155 155 FThread.FreeOnTerminate := False; … … 160 160 end; 161 161 162 procedure T BrainFuckInterpretter.PrepareJumpTable;162 procedure TTargetInterpretter.PrepareJumpTable; 163 163 var 164 164 Loop: array of Integer; … … 188 188 end; 189 189 190 procedure T BrainFuckInterpretter.CommandInc;190 procedure TTargetInterpretter.CommandInc; 191 191 begin 192 192 Memory[MemoryPosition] := ((Memory[MemoryPosition] + 1) mod CellSize); 193 193 end; 194 194 195 procedure T BrainFuckInterpretter.CommandDec;195 procedure TTargetInterpretter.CommandDec; 196 196 begin 197 197 Memory[MemoryPosition] := ((Memory[MemoryPosition] - 1) mod CellSize); 198 198 end; 199 199 200 procedure T BrainFuckInterpretter.CommandPointerInc;200 procedure TTargetInterpretter.CommandPointerInc; 201 201 begin 202 202 if MemoryPosition < MemorySize then Inc(MemoryPosition) … … 204 204 end; 205 205 206 procedure T BrainFuckInterpretter.CommandPointerDec;206 procedure TTargetInterpretter.CommandPointerDec; 207 207 begin 208 208 if MemoryPosition > 0 then Dec(MemoryPosition) … … 210 210 end; 211 211 212 procedure T BrainFuckInterpretter.CommandInput;212 procedure TTargetInterpretter.CommandInput; 213 213 begin 214 214 while (InputPosition > Length(Input)) and (FState <> rsStopped) do begin … … 221 221 end; 222 222 223 procedure T BrainFuckInterpretter.CommandOutput;223 procedure TTargetInterpretter.CommandOutput; 224 224 begin 225 225 if OutputPosition > Length(Output) then … … 229 229 end; 230 230 231 procedure T BrainFuckInterpretter.CommandLoopStart;231 procedure TTargetInterpretter.CommandLoopStart; 232 232 begin 233 233 if Memory[MemoryPosition] = 0 then … … 235 235 end; 236 236 237 procedure T BrainFuckInterpretter.CommandLoopEnd;237 procedure TTargetInterpretter.CommandLoopEnd; 238 238 begin 239 239 if Memory[MemoryPosition] > 0 then … … 241 241 end; 242 242 243 procedure T BrainFuckInterpretter.Reset;243 procedure TTargetInterpretter.Reset; 244 244 var 245 245 I: Integer; … … 257 257 end; 258 258 259 procedure T BrainFuckInterpretter.SingleStep;259 procedure TTargetInterpretter.SingleStep; 260 260 begin 261 261 FCommandTable[FSource[SourcePosition]]; … … 264 264 end; 265 265 266 procedure T BrainFuckInterpretter.Run;266 procedure TTargetInterpretter.Run; 267 267 begin 268 268 SetState(rsRunning); … … 272 272 end; 273 273 274 procedure T BrainFuckInterpretter.Pause;274 procedure TTargetInterpretter.Pause; 275 275 begin 276 276 if State = rsRunning then SetState(rsPaused); 277 277 end; 278 278 279 procedure T BrainFuckInterpretter.Stop;279 procedure TTargetInterpretter.Stop; 280 280 begin 281 281 SetState(rsStopped); 282 282 end; 283 283 284 constructor T BrainFuckInterpretter.Create;284 constructor TTargetInterpretter.Create; 285 285 begin 286 286 MemorySize := 30000; … … 296 296 end; 297 297 298 destructor T BrainFuckInterpretter.Destroy;298 destructor TTargetInterpretter.Destroy; 299 299 begin 300 300 FState := rsStopped; -
trunk/Target/UTargetPHP.pas
r29 r30 1 unit U CompilerPHP;1 unit UTargetPHP; 2 2 3 3 {$mode Delphi}{$H+} … … 6 6 7 7 uses 8 Classes, SysUtils, U Compiler;8 Classes, SysUtils, UTarget; 9 9 10 10 type 11 11 12 { T BrainFuckCompilerPHP }12 { TTargetPHP } 13 13 14 T BrainFuckCompilerPHP = class(TBrainFuckCompiler)14 TTargetPHP = class(TTarget) 15 15 constructor Create; override; 16 16 procedure Compile; override; … … 21 21 implementation 22 22 23 { T BrainFuckCompilerPHP }23 { TTargetPHP } 24 24 25 constructor T BrainFuckCompilerPHP.Create;25 constructor TTargetPHP.Create; 26 26 begin 27 27 inherited Create; … … 36 36 end; 37 37 38 procedure T BrainFuckCompilerPHP.Compile;38 procedure TTargetPHP.Compile; 39 39 var 40 40 I: Integer; … … 93 93 end; 94 94 95 procedure T BrainFuckCompilerPHP.Run;95 procedure TTargetPHP.Run; 96 96 begin 97 97 inherited Run;
Note:
See TracChangeset
for help on using the changeset viewer.