Changeset 64 for trunk/Target/UTargetPHP.pas
- Timestamp:
- Dec 4, 2014, 2:59:28 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Target/UTargetPHP.pas
r60 r64 58 58 FProgramIndex := 0; 59 59 while (FProgramIndex < Length(FProgram)) do begin 60 case FProgram[FProgramIndex] of 61 cmPointerInc: begin 62 Sum := CheckOccurence(cmPointerInc); 63 AddLine('$Position = $Position + ' + IntToStr(Sum) + ';'); 64 end; 65 cmPointerDec: begin 66 Sum := CheckOccurence(cmPointerDec); 67 AddLine('$Position = $Position - ' + IntToStr(Sum) + ';'); 68 end; 69 cmInc: begin 70 Sum := CheckOccurence(cmInc); 71 AddLine('$Memory[$Position] = chr(ord($Memory[$Position]) + ' + IntToStr(Sum) + ');'); 72 end; 73 cmDec: begin 74 Sum := CheckOccurence(cmDec); 75 AddLine('$Memory[$Position] = chr(ord($Memory[$Position]) - ' + IntToStr(Sum) + ');'); 76 end; 60 case FProgram[FProgramIndex].Command of 61 cmPointerInc: AddLine('$Position = $Position + ' + IntToStr(FProgram[FProgramIndex].Parameter) + ';'); 62 cmPointerDec: AddLine('$Position = $Position - ' + IntToStr(FProgram[FProgramIndex].Parameter) + ';'); 63 cmInc: AddLine('$Memory[$Position] = chr(ord($Memory[$Position]) + ' + IntToStr(FProgram[FProgramIndex].Parameter) + ');'); 64 cmDec: AddLine('$Memory[$Position] = chr(ord($Memory[$Position]) - ' + IntToStr(FProgram[FProgramIndex].Parameter) + ');'); 77 65 cmOutput: AddLine('echo($Memory[$Position]);'); 78 66 cmInput: AddLine('$Memory[$Position] = fgetc(STDIN);'); 67 cmSet: AddLine('$Memory[$Position] = chr(' + IntToStr(FProgram[FProgramIndex].Parameter) + ');'); 79 68 cmLoopStart: begin 80 if CheckClear then begin 81 AddLine('$Memory[$Position] = "\0";'); 82 Inc(FProgramIndex, 2); 83 end else begin 84 AddLine('while($Memory[$Position] != "\0") {'); 85 Inc(Indent); 86 end; 69 AddLine('while($Memory[$Position] != "\0") {'); 70 Inc(Indent); 87 71 end; 88 72 cmLoopEnd: begin
Note:
See TracChangeset
for help on using the changeset viewer.