Changeset 126 for trunk/Target
- Timestamp:
- Jan 14, 2022, 7:13:36 PM (3 years ago)
- Location:
- trunk/Target
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Target/UTargetC.pas
r125 r126 74 74 AddLine('Pos = 0;'); 75 75 FProgramIndex := 0; 76 while (FProgramIndex < Length(FProgram))do begin76 while FProgramIndex < FProgram.Count do begin 77 77 case FProgram[FProgramIndex].Command of 78 78 cmPointerInc: AddLine('Pos = Pos + ' + IntToStr(FProgram[FProgramIndex].Parameter) + ';'); … … 83 83 cmInput: AddLine(GetMemoryCell + ' = getchar();'); 84 84 cmSet: AddLine(GetMemoryCell + ' = ' + IntToStr(FProgram[FProgramIndex].Parameter) + ';'); 85 cmMultip y: AddLine(GetMemoryCell + ' = ' + GetMemoryCell + ' + Memory[Pos] * ' + IntToStr(FProgram[FProgramIndex].Parameter) + ';');85 cmMultiply: AddLine(GetMemoryCell + ' = ' + GetMemoryCell + ' + Memory[Pos] * ' + IntToStr(FProgram[FProgramIndex].Parameter) + ';'); 86 86 cmLoopStart: begin 87 87 AddLine('while(' + GetMemoryCell + ' != 0)'); -
trunk/Target/UTargetCSharp.pas
r125 r126 75 75 AddLine('Pos = 0;'); 76 76 FProgramIndex := 0; 77 while (FProgramIndex < Length(FProgram))do begin77 while FProgramIndex < FProgram.Count do begin 78 78 case FProgram[FProgramIndex].Command of 79 79 cmPointerInc: AddLine('Pos += ' + IntToStr(FProgram[FProgramIndex].Parameter) + ';'); … … 84 84 cmInput: AddLine(GetMemoryCell + ' = (int)Console.ReadKey().KeyChar;'); 85 85 cmSet: AddLine(GetMemoryCell + ' = ' + IntToStr(FProgram[FProgramIndex].Parameter) + ';'); 86 cmMultip y: begin86 cmMultiply: begin 87 87 if FProgram[FProgramIndex].Parameter = 1 then 88 88 AddLine(GetMemoryCell + ' += Memory[Pos];') -
trunk/Target/UTargetDelphi.pas
r125 r126 67 67 AddLine('Pos := 0;'); 68 68 FProgramIndex := 0; 69 while (FProgramIndex < Length(FProgram))do begin69 while FProgramIndex < FProgram.Count do begin 70 70 case FProgram[FProgramIndex].Command of 71 71 cmPointerInc: AddLine('Inc(Pos, ' + IntToStr(FProgram[FProgramIndex].Parameter) + ');'); … … 74 74 cmDec: AddLine(GetMemoryCell + ' := ' + GetMemoryCell + ' - ' + IntToStr(FProgram[FProgramIndex].Parameter) + ';'); 75 75 cmSet: AddLine(GetMemoryCell + ' := ' + IntToStr(FProgram[FProgramIndex].Parameter) + ';'); 76 cmMultip y: AddLine(GetMemoryCell + ' := ' + GetMemoryCell + ' + Memory[Pos] * ' + IntToStr(FProgram[FProgramIndex].Parameter) + ';');76 cmMultiply: AddLine(GetMemoryCell + ' := ' + GetMemoryCell + ' + Memory[Pos] * ' + IntToStr(FProgram[FProgramIndex].Parameter) + ';'); 77 77 cmOutput: AddLine('Write(Chr(' + GetMemoryCell + '));'); 78 78 cmInput: AddLine('Read(ReadChar); ' + GetMemoryCell + ' := Ord(ReadChar);'); -
trunk/Target/UTargetFPC.pas
r125 r126 69 69 AddLine('Pos := 0;'); 70 70 FProgramIndex := 0; 71 while (FProgramIndex < Length(FProgram))do begin71 while FProgramIndex < FProgram.Count do begin 72 72 case FProgram[FProgramIndex].Command of 73 73 cmPointerInc: AddLine('Inc(Pos, ' + IntToStr(FProgram[FProgramIndex].Parameter) + ');'); … … 76 76 cmDec: AddLine(GetMemoryCell + ' := ' + GetMemoryCell + ' - ' + IntToStr(FProgram[FProgramIndex].Parameter) + ';'); 77 77 cmSet: AddLine(GetMemoryCell + ' := ' + IntToStr(FProgram[FProgramIndex].Parameter) + ';'); 78 cmMultip y: AddLine(GetMemoryCell + ' := ' + GetMemoryCell + ' + Memory[Pos] * ' + IntToStr(FProgram[FProgramIndex].Parameter) + ';');78 cmMultiply: AddLine(GetMemoryCell + ' := ' + GetMemoryCell + ' + Memory[Pos] * ' + IntToStr(FProgram[FProgramIndex].Parameter) + ';'); 79 79 cmOutput: AddLine('Write(Chr(' + GetMemoryCell + '));'); 80 80 cmInput: AddLine('Read(ReadChar); ' + GetMemoryCell + ' := Ord(ReadChar);'); -
trunk/Target/UTargetInterpretter.pas
r125 r126 83 83 SProgramUpperLimit = 'Program run over upper limit'; 84 84 SJumpTableInsistent = 'Jump table is inconsistent'; 85 SJumpTableCol ision = 'Jump table colision';85 SJumpTableCollision = 'Jump table collision'; 86 86 SProgramNotRunning = 'Program not running'; 87 87 SUnsupportedCommand = 'Unsupported command'; … … 95 95 with Parent do 96 96 repeat 97 while (FProgramIndex < Length(FProgram)) and (State <> rsStopped) do begin97 while (FProgramIndex < FProgram.Count) and (State <> rsStopped) do begin 98 98 if State = rsRunning then begin 99 99 if FProgramBreakpoints[FProgramIndex] then begin … … 154 154 I: Integer; 155 155 begin 156 for I := 0 to Length(FProgram)- 1 do begin156 for I := 0 to FProgram.Count - 1 do begin 157 157 case FProgram[I].Command of 158 cmLoopStart: FProgram [I].Parameter := 0;159 cmLoopEnd: FProgram [I].Parameter := 0;158 cmLoopStart: FProgram.Operations[I].Parameter := 0; 159 cmLoopEnd: FProgram.Operations[I].Parameter := 0; 160 160 end; 161 161 end; 162 162 163 163 SetLength(Loop, 0); 164 for I := 0 to Length(FProgram)- 1 do begin164 for I := 0 to FProgram.Count - 1 do begin 165 165 case FProgram[I].Command of 166 166 cmLoopStart: begin … … 170 170 cmLoopEnd: begin 171 171 if FProgram[I].Parameter > 0 then 172 raise Exception.Create(SJumpTableCol ision);173 FProgram [I].Parameter := Loop[High(Loop)];172 raise Exception.Create(SJumpTableCollision); 173 FProgram.Operations[I].Parameter := Loop[High(Loop)]; 174 174 if FProgram[Loop[High(Loop)]].Parameter > 0 then 175 raise Exception.Create(SJumpTableCol ision);176 FProgram [Loop[High(Loop)]].Parameter := I;175 raise Exception.Create(SJumpTableCollision); 176 FProgram.Operations[Loop[High(Loop)]].Parameter := I; 177 177 SetLength(Loop, Length(Loop) - 1); 178 178 end; … … 303 303 I: Integer; 304 304 begin 305 SetLength(FProgramBreakpoints, Length(FProgram));305 SetLength(FProgramBreakpoints, FProgram.Count); 306 306 for I := 0 to High(FProgramBreakpoints) do 307 307 FProgramBreakpoints[I] := False; 308 308 for I := 0 to BreakPoints.Count - 1 do 309 if TBreakPoint(BreakPoints[I]).TargetAddress < Length(FProgramBreakpoints) then310 FProgramBreakpoints[ TBreakPoint(BreakPoints[I]).TargetAddress] := True;309 if BreakPoints[I].TargetAddress < Length(FProgramBreakpoints) then 310 FProgramBreakpoints[BreakPoints[I].TargetAddress] := True; 311 311 end; 312 312 … … 316 316 begin 317 317 Result := ''; 318 for I := 0 to Length(FProgram)- 1 do begin318 for I := 0 to FProgram.Count - 1 do begin 319 319 Result := Result + GetOperationText(FProgram[I]); 320 320 end; … … 438 438 // Extended commands 439 439 FCommandTable[cmSet] := CommandSet; 440 FCommandTable[cmMultip y] := CommandMultiply;440 FCommandTable[cmMultiply] := CommandMultiply; 441 441 end; 442 442 -
trunk/Target/UTargetJava.pas
r125 r126 74 74 AddLine('Pos = 0;'); 75 75 FProgramIndex := 0; 76 while (FProgramIndex < Length(FProgram))do begin76 while FProgramIndex < FProgram.Count do begin 77 77 case FProgram[FProgramIndex].Command of 78 78 cmPointerInc: AddLine('Pos = Pos + ' + IntToStr(FProgram[FProgramIndex].Parameter) + ';'); … … 83 83 cmInput: AddLine(GetMemoryCell + ' = (char)System.in.read();'); 84 84 cmSet: AddLine(GetMemoryCell + ' = (char)' + IntToStr(FProgram[FProgramIndex].Parameter) + ';'); 85 cmMultip y: AddLine(GetMemoryCell + ' = (char)((int)' + GetMemoryCell + ' + (int)Memory[Pos] * ' + IntToStr(FProgram[FProgramIndex].Parameter) + ');');85 cmMultiply: AddLine(GetMemoryCell + ' = (char)((int)' + GetMemoryCell + ' + (int)Memory[Pos] * ' + IntToStr(FProgram[FProgramIndex].Parameter) + ');'); 86 86 cmLoopStart: begin 87 87 AddLine('while(' + GetMemoryCell + ' != 0)'); -
trunk/Target/UTargetJavascript.pas
r125 r126 61 61 AddLine(''); 62 62 FProgramIndex := 0; 63 while (FProgramIndex < Length(FProgram))do begin63 while FProgramIndex < FProgram.Count do begin 64 64 case FProgram[FProgramIndex].Command of 65 65 cmPointerInc: AddLine('Pos = Pos + ' + IntToStr(FProgram[FProgramIndex].Parameter) + ';'); … … 70 70 cmInput: ; //AddLine(GetMemoryCell + ' = getchar();'); 71 71 cmSet: AddLine(GetMemoryCell + ' = ' + IntToStr(FProgram[FProgramIndex].Parameter) + ';'); 72 cmMultip y: AddLine(GetMemoryCell + ' = ' + GetMemoryCell + ' + Memory[Pos] * ' + IntToStr(FProgram[FProgramIndex].Parameter) + ';');72 cmMultiply: AddLine(GetMemoryCell + ' = ' + GetMemoryCell + ' + Memory[Pos] * ' + IntToStr(FProgram[FProgramIndex].Parameter) + ';'); 73 73 cmLoopStart: begin 74 74 AddLine('while(' + GetMemoryCell + ' != 0)'); -
trunk/Target/UTargetPHP.pas
r125 r126 66 66 AddLine('$Position = 0;'); 67 67 FProgramIndex := 0; 68 while (FProgramIndex < Length(FProgram))do begin68 while FProgramIndex < FProgram.Count do begin 69 69 case FProgram[FProgramIndex].Command of 70 70 cmPointerInc: AddLine('$Position = $Position + ' + IntToStr(FProgram[FProgramIndex].Parameter) + ';'); … … 77 77 cmInput: AddLine(GetMemoryCell + ' = fgetc(STDIN);'); 78 78 cmSet: AddLine(GetMemoryCell + ' = chr(' + IntToStr(FProgram[FProgramIndex].Parameter) + ');'); 79 cmMultip y: AddLine(GetMemoryCell + ' = chr(ord(' + GetMemoryCell + ') + ord($Memory[$Position]) * ' + IntToStr(FProgram[FProgramIndex].Parameter) + ');');79 cmMultiply: AddLine(GetMemoryCell + ' = chr(ord(' + GetMemoryCell + ') + ord($Memory[$Position]) * ' + IntToStr(FProgram[FProgramIndex].Parameter) + ');'); 80 80 cmLoopStart: begin 81 81 AddLine('while(' + GetMemoryCell + ' != "\0") {'); -
trunk/Target/UTargetPython.pas
r125 r126 104 104 AddLine('position = 0'); 105 105 FProgramIndex := 0; 106 while (FProgramIndex < Length(FProgram))do begin106 while FProgramIndex < FProgram.Count do begin 107 107 case FProgram[FProgramIndex].Command of 108 108 cmPointerInc: AddLine('position += ' + IntToStr(FProgram[FProgramIndex].Parameter)); … … 116 116 cmInput: AddLine(GetMemoryCell + ' = ord(getchar())'); 117 117 cmSet: AddLine(GetMemoryCell + ' = ' + IntToStr(FProgram[FProgramIndex].Parameter)); 118 cmMultip y: AddLine(GetMemoryCell + ' = ' + GetMemoryCell + ' + memory[position] * ' + IntToStr(FProgram[FProgramIndex].Parameter) + ';');118 cmMultiply: AddLine(GetMemoryCell + ' = ' + GetMemoryCell + ' + memory[position] * ' + IntToStr(FProgram[FProgramIndex].Parameter) + ';'); 119 119 cmLoopStart: begin 120 120 AddLine('while(' + GetMemoryCell + ' != 0):');
Note:
See TracChangeset
for help on using the changeset viewer.