Changeset 90
- Timestamp:
- Aug 29, 2017, 11:13:14 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/UFormMain.pas
r88 r90 480 480 ProgramName := ExtractFileNameOnly(Core.Project.FileName); 481 481 Core.CurrentTarget.Messages.AddMessage(SCompileStart); 482 Application.ProcessMessages; 482 483 Compile; 483 484 Core.CurrentTarget.Messages.AppendMessage(SDone); -
trunk/Target/UTargetCSharp.pas
r87 r90 63 63 AddLine('using System;'); 64 64 AddLine; 65 AddLine('public class ' + ProgramName + ' {'); 65 AddLine('public class ' + ProgramName); 66 AddLine('{'); 66 67 Inc(Indent); 67 AddLine('public static void Main() {'); 68 AddLine('public static void Main()'); 69 AddLine('{'); 68 70 Inc(Indent); 69 AddLine(' char[] Memory;');71 AddLine('int[] Memory;'); 70 72 AddLine('int Pos;'); 71 73 AddLine; 72 AddLine('Memory = new char[' + IntToStr(MemorySize) + '];');74 AddLine('Memory = new int[' + IntToStr(MemorySize) + '];'); 73 75 AddLine('Pos = 0;'); 74 76 FProgramIndex := 0; 75 77 while (FProgramIndex < Length(FProgram)) do begin 76 78 case FProgram[FProgramIndex].Command of 77 cmPointerInc: AddLine('Pos = Pos + ' + IntToStr(FProgram[FProgramIndex].Parameter) + ';'); 78 cmPointerDec: AddLine('Pos = Pos - ' + IntToStr(FProgram[FProgramIndex].Parameter) + ';'); 79 cmInc: AddLine(GetMemoryCell + ' = (char)((int)' + GetMemoryCell + ' + ' + IntToStr(FProgram[FProgramIndex].Parameter) + ');'); 80 cmDec: AddLine(GetMemoryCell + ' = (char)((int)' + GetMemoryCell + ' - ' + IntToStr(FProgram[FProgramIndex].Parameter) + ');'); 81 cmOutput: AddLine('Console.Write(' + GetMemoryCell + ');'); 82 cmInput: AddLine(GetMemoryCell + ' = Console.ReadKey().KeyChar;'); 83 cmSet: AddLine(GetMemoryCell + ' = (char)' + IntToStr(FProgram[FProgramIndex].Parameter) + ';'); 84 cmMultipy: AddLine(GetMemoryCell + ' = (char)((int)' + GetMemoryCell + ' + (int)Memory[Pos] * ' + IntToStr(FProgram[FProgramIndex].Parameter) + ');'); 79 cmPointerInc: AddLine('Pos += ' + IntToStr(FProgram[FProgramIndex].Parameter) + ';'); 80 cmPointerDec: AddLine('Pos -= ' + IntToStr(FProgram[FProgramIndex].Parameter) + ';'); 81 cmInc: AddLine(GetMemoryCell + ' += ' + IntToStr(FProgram[FProgramIndex].Parameter) + ';'); 82 cmDec: AddLine(GetMemoryCell + ' -= ' + IntToStr(FProgram[FProgramIndex].Parameter) + ';'); 83 cmOutput: AddLine('Console.Write((char)' + GetMemoryCell + ');'); 84 cmInput: AddLine(GetMemoryCell + ' = (int)Console.ReadKey().KeyChar;'); 85 cmSet: AddLine(GetMemoryCell + ' = ' + IntToStr(FProgram[FProgramIndex].Parameter) + ';'); 86 cmMultipy: begin 87 if FProgram[FProgramIndex].Parameter = 1 then 88 AddLine(GetMemoryCell + ' += Memory[Pos];') 89 else 90 if FProgram[FProgramIndex].Parameter > 0 then 91 AddLine(GetMemoryCell + ' += Memory[Pos] * ' + IntToStr(FProgram[FProgramIndex].Parameter) + ';') 92 else 93 if FProgram[FProgramIndex].Parameter < 0 then 94 AddLine(GetMemoryCell + ' -= Memory[Pos] * ' + IntToStr(Abs(FProgram[FProgramIndex].Parameter)) + ';'); 95 end; 85 96 cmLoopStart: begin 86 AddLine('while (' + GetMemoryCell + ' != 0)');97 AddLine('while (' + GetMemoryCell + ' != 0)'); 87 98 AddLine('{'); 88 99 Inc(Indent); -
trunk/UBFTarget.pas
r86 r90 423 423 NewProgram[NewProgramIndex].RelIndex := 0; 424 424 ProcessLoop := False; 425 NumberOfBaseDecrement := 0; 425 426 end; 426 427 end;
Note:
See TracChangeset
for help on using the changeset viewer.