Changeset 32 for trunk/Target
- Timestamp:
- Feb 18, 2012, 8:44:10 PM (13 years ago)
- Location:
- trunk/Target
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Target/UTarget.pas
r31 r32 12 12 TCompilerOptimization = (coNone, coNormal); 13 13 14 TTargetCapability = (tcRun, tcPause, tcStop, tcStepOut, t sStepOver, tsStepInto,15 t sRunToCursor, tcCompile, tcBreakpoint);14 TTargetCapability = (tcRun, tcPause, tcStop, tcStepOut, tcStepOver, tcStepInto, 15 tcRunToCursor, tcCompile, tcBreakpoint); 16 16 TTargetCapabilities = set of TTargetCapability; 17 17 18 TRunState = (rsStopped, rsPaused, rsRunning); 19 18 20 { TTarget } 19 21 20 22 TTarget = class 23 private 21 24 protected 25 FSource: string; 22 26 Indent: Integer; 27 FState: TRunState; 28 FOnChangeState: TNotifyEvent; 29 procedure SetSource(AValue: string); virtual; 23 30 procedure AddLine(Text: string); 24 31 function LongFileName(FileName: string): string; … … 26 33 Name: string; 27 34 ProgramName: string; 28 Source: string;29 35 Output: string; 30 36 Optimization: TCompilerOptimization; … … 45 51 procedure StepOut; virtual; 46 52 procedure RunToCursor; virtual; 53 procedure LoadFromRegistry(Root: HKEY; Key: string); virtual; 54 procedure SaveToRegistry(Root: HKEY; Key: string); virtual; 55 property State: TRunState read FState; 56 property OnChangeState: TNotifyEvent read FOnChangeState write FOnChangeState; 57 property Source: string write SetSource; 47 58 end; 48 59 … … 52 63 procedure LoadFromRegistry(Root: HKEY; Key: string); 53 64 procedure SaveToRegistry(Root: HKEY; Key: string); 65 function FindByName(Name: string): TTarget; 54 66 end; 55 67 … … 98 110 end; 99 111 112 function TTargetList.FindByName(Name: string): TTarget; 113 var 114 I: Integer; 115 begin 116 I := 0; 117 while (I < Count) and (TTarget(Items[I]).Name <> Name) do Inc(I); 118 if I < Count then Result := TTarget(Items[I]) 119 else Result := nil; 120 end; 121 100 122 { TTarget } 123 124 procedure TTarget.SetSource(AValue: string); 125 begin 126 FSource := AValue; 127 end; 101 128 102 129 procedure TTarget.AddLine(Text: string); … … 209 236 end; 210 237 238 procedure TTarget.LoadFromRegistry(Root: HKEY; Key: string); 239 begin 240 241 end; 242 243 procedure TTarget.SaveToRegistry(Root: HKEY; Key: string); 244 begin 245 246 end; 247 211 248 end. 212 249 -
trunk/Target/UTargetC.pas
r31 r32 13 13 14 14 TTargetC = class(TTarget) 15 private 16 public 15 17 constructor Create; override; 16 18 procedure Compile; override; … … 48 50 Result := 1; 49 51 if Optimization = coNormal then 50 while ((I + 1) <= Length( Source)) and (Source[I + 1] = C) do begin52 while ((I + 1) <= Length(FSource)) and (FSource[I + 1] = C) do begin 51 53 Inc(Result); 52 54 Inc(I) … … 69 71 AddLine('Pos = 0;'); 70 72 I := 1; 71 while (I <= Length( Source)) do begin72 case Source[I] of73 while (I <= Length(FSource)) do begin 74 case FSource[I] of 73 75 '>': begin 74 76 Sum := CheckOccurence('>'); -
trunk/Target/UTargetDelphi.pas
r31 r32 13 13 14 14 TTargetDelphi = class(TTarget) 15 private 16 public 15 17 constructor Create; override; 16 18 procedure Compile; override; … … 42 44 Result := 1; 43 45 if Optimization = coNormal then 44 while ((I + 1) <= Length( Source)) and (Source[I + 1] = C) do begin46 while ((I + 1) <= Length(FSource)) and (FSource[I + 1] = C) do begin 45 47 Inc(Result); 46 48 Inc(I) … … 64 66 AddLine('Pos := 0;'); 65 67 I := 1; 66 while (I <= Length( Source)) do begin67 case Source[I] of68 while (I <= Length(FSource)) do begin 69 case FSource[I] of 68 70 '>': begin 69 71 Sum := CheckOccurence('>'); -
trunk/Target/UTargetInterpretter.pas
r31 r32 6 6 7 7 uses 8 Classes, SysUtils, Dialogs, Forms, StrUtils, UTarget ;8 Classes, SysUtils, Dialogs, Forms, StrUtils, UTarget, Registry, URegistry; 9 9 10 10 type 11 11 TTargetInterpretter = class; 12 13 14 TRunState = (rsStopped, rsPaused, rsRunning);15 12 16 13 { TTargetInterpretterThread } … … 31 28 private 32 29 FCellSize: Integer; 33 FOnChangeState: TNotifyEvent;34 FState: TRunState;35 30 FThreadState: Boolean; 36 31 FThread: TTargetInterpretterThread; … … 39 34 function GetMemorySize: Integer; 40 35 procedure SetMemorySize(AValue: Integer); 41 procedure SetSource(AValue: string);42 36 procedure SetState(AValue: TRunState); 43 37 procedure SetThread(State: Boolean); … … 51 45 procedure CommandLoopStart; 52 46 procedure CommandLoopEnd; 47 protected 48 procedure SetSource(AValue: string); override; 53 49 public 54 50 FSource: array of TBrainFuckCommand; … … 67 63 procedure Pause; override; 68 64 procedure Stop; override; 69 constructor Create; 65 constructor Create; override; 70 66 destructor Destroy; override; 71 pro perty State: TRunState read FState;72 pro perty OnChangeState: TNotifyEvent read FOnChangeState write FOnChangeState;67 procedure LoadFromRegistry(Root: HKEY; Key: string); override; 68 procedure SaveToRegistry(Root: HKEY; Key: string); override; 73 69 property StepCount: Integer read FStepCount; 74 property Source: string write SetSource;75 70 property MemorySize: Integer read GetMemorySize write SetMemorySize; 76 71 property CellSize: Integer read FCellSize write FCellSize; … … 284 279 constructor TTargetInterpretter.Create; 285 280 begin 281 inherited; 286 282 Name := 'Interpretter'; 287 283 Capabilities := [tcRun, tcPause, tcStop]; … … 305 301 end; 306 302 303 procedure TTargetInterpretter.LoadFromRegistry(Root: HKEY; Key: string); 304 begin 305 inherited LoadFromRegistry(Root, Key); 306 with TRegistryEx.Create do 307 try 308 RootKey := Root; 309 OpenKey(Key, True); 310 CellSize := ReadIntegerWithDefault('CellSize', 256); 311 MemorySize := ReadIntegerWithDefault('MemorySize', 30000); 312 finally 313 Free; 314 end; 315 end; 316 317 procedure TTargetInterpretter.SaveToRegistry(Root: HKEY; Key: string); 318 begin 319 inherited SaveToRegistry(Root, Key); 320 with TRegistryEx.Create do 321 try 322 RootKey := Root; 323 OpenKey(Key, True); 324 WriteInteger('CellSize', CellSize); 325 WriteInteger('MemorySize', MemorySize); 326 finally 327 Free; 328 end; 329 end; 330 307 331 end. 308 332 -
trunk/Target/UTargetPHP.pas
r31 r32 13 13 14 14 TTargetPHP = class(TTarget) 15 private 16 public 15 17 constructor Create; override; 16 18 procedure Compile; override; … … 46 48 Result := 1; 47 49 if Optimization = coNormal then 48 while ((I + 1) <= Length( Source)) and (Source[I + 1] = C) do begin50 while ((I + 1) <= Length(FSource)) and (FSource[I + 1] = C) do begin 49 51 Inc(Result); 50 52 Inc(I) … … 60 62 AddLine('$Memory = str_repeat("\0", 30000);'); 61 63 AddLine('$Position = 0;'); 62 for I := 1 to Length( Source) do begin63 case Source[I] of64 for I := 1 to Length(FSource) do begin 65 case FSource[I] of 64 66 '>': begin 65 67 Sum := CheckOccurence('>');
Note:
See TracChangeset
for help on using the changeset viewer.