- Timestamp:
- Aug 20, 2024, 12:23:10 AM (3 months ago)
- Location:
- tags/1.3.0
- Files:
-
- 14 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
tags/1.3.0
-
tags/1.3.0/Core.lfm
r160 r162 21 21 AppName = 'LazFuck' 22 22 Description = 'A simple BrainFuck IDE written in Lazarus/FPC.' 23 ReleaseDate = 45 52323 ReleaseDate = 45082 24 24 RegistryKey = '\Software\Chronosoft\LazFuck' 25 25 RegistryRoot = rrKeyCurrentUser -
tags/1.3.0/Core.pas
r157 r162 101 101 // If installed in Linux system then use installation shared game directory for data files 102 102 if DirectoryExists(LinuxDataDir) then 103 DataDir := LinuxDataDir; 103 DataDir := LinuxDataDir 104 else DataDir := GetCurrentDir; 104 105 // If installed in Linux system then use installation directory for po files 105 106 if not DirectoryExists(Translator.POFilesFolder) and DirectoryExists(LinuxLanguagesDir) then -
tags/1.3.0/Packages/Common/Common.pas
r153 r162 55 55 function EndsWith(Text, What: string): Boolean; 56 56 function Explode(Separator: Char; Data: string): TStringArray; 57 procedure ExecuteProgram(Executable: string; Parameters: array of string); 57 procedure ExecuteProgram(Executable: string; Parameters: array of string; 58 Environment: array of string; CurrentDirectory: string = ''); 59 procedure ExecuteProgramOutput(Executable: string; Parameters: array of string; 60 Environment: array of string; out Output, Error: string; 61 out ExitCode: Integer; CurrentDirectory: string = ''); 58 62 procedure FileDialogUpdateFilterFileType(FileDialog: TOpenDialog); 59 63 procedure FreeThenNil(var Obj); … … 63 67 function GetBit(Variable: QWord; Index: Byte): Boolean; 64 68 function GetStringPart(var Text: string; Separator: string): string; 69 function GetEnvironmentVariables: TStringArray; 65 70 function GenerateNewName(OldName: string): string; 66 71 function GetFileFilterItemExt(Filter: string; Index: Integer): string; 67 72 function IntToBin(Data: Int64; Count: Byte): string; 68 function Implode(Separator: string; List: TList<string>): string; 69 function Implode(Separator: string; List: TStringList; Around: string = ''): string; 73 function Implode(Separator: string; List: TList<string>): string; overload; 74 function Implode(Separator: string; List: array of string): string; overload; 75 function Implode(Separator: string; List: TStringList; Around: string = ''): string; overload; 70 76 function LastPos(const SubStr: String; const S: String): Integer; 71 77 function LoadFileToStr(const FileName: TFileName): AnsiString; … … 98 104 implementation 99 105 106 resourcestring 107 SExecutionError = 'Excution error: %s (exit code: %d)'; 108 100 109 function StartsWith(Text, What: string): Boolean; 101 110 begin … … 108 117 end; 109 118 110 function BinToInt(BinStr : string): Int64;111 var 112 i : byte;113 RetVar 119 function BinToInt(BinStr: string): Int64; 120 var 121 I: Byte; 122 RetVar: Int64; 114 123 begin 115 124 BinStr := UpperCase(BinStr); 116 if BinStr[length(BinStr)] = 'B' then Delete(BinStr, length(BinStr),1);125 if BinStr[length(BinStr)] = 'B' then Delete(BinStr, Length(BinStr), 1); 117 126 RetVar := 0; 118 for i := 1 to length(BinStr) do begin119 if not (BinStr[ i] in ['0','1']) then begin127 for I := 1 to Length(BinStr) do begin 128 if not (BinStr[I] in ['0','1']) then begin 120 129 RetVar := 0; 121 130 Break; 122 131 end; 123 RetVar := (RetVar shl 1) + ( byte(BinStr[i]) and 1);132 RetVar := (RetVar shl 1) + (Byte(BinStr[I]) and 1); 124 133 end; 125 134 … … 136 145 end; 137 146 end; 138 139 147 140 148 procedure DeleteFiles(APath, AFileSpec: string); … … 154 162 FindClose(SearchRec); 155 163 end; 156 157 164 158 165 function GetFileFilterItemExt(Filter: string; Index: Integer): string; … … 177 184 if FileExt <> '.*' then 178 185 FileDialog.FileName := ChangeFileExt(FileDialog.FileName, FileExt) 186 end; 187 188 function GetEnvironmentVariables: TStringArray; 189 var 190 I: Integer; 191 begin 192 SetLength(Result, GetEnvironmentVariableCount); 193 for I := 0 to GetEnvironmentVariableCount - 1 do 194 Result[I] := GetEnvironmentString(I); 179 195 end; 180 196 … … 219 235 end;*) 220 236 237 function Implode(Separator: string; List: array of string): string; 238 var 239 I: Integer; 240 begin 241 Result := ''; 242 for I := 0 to Length(List) - 1 do begin 243 Result := Result + List[I]; 244 if I < Length(List) - 1 then Result := Result + Separator; 245 end; 246 end; 247 221 248 function Implode(Separator: string; List: TStringList; Around: string = ''): string; 222 249 var … … 494 521 end; 495 522 496 procedure ExecuteProgram(Executable: string; Parameters: array of string); 523 procedure ExecuteProgram(Executable: string; Parameters: array of string; 524 Environment: array of string; CurrentDirectory: string = ''); 497 525 var 498 526 Process: TProcess; 499 527 I: Integer; 500 528 begin 529 Process := TProcess.Create(nil); 501 530 try 502 Process := TProcess.Create(nil);503 531 Process.Executable := Executable; 504 532 for I := 0 to Length(Parameters) - 1 do 505 533 Process.Parameters.Add(Parameters[I]); 534 for I := 0 to Length(Environment) - 1 do 535 Process.Environment.Add(Environment[I]); 536 Process.CurrentDirectory := CurrentDirectory; 537 Process.ShowWindow := swoHIDE; 506 538 Process.Options := [poNoConsole]; 507 539 Process.Execute; … … 511 543 end; 512 544 545 procedure ExecuteProgramOutput(Executable: string; Parameters: array of string; 546 Environment: array of string; out Output, Error: string; out ExitCode: Integer; 547 CurrentDirectory: string); 548 var 549 Process: TProcess; 550 I: Integer; 551 ReadCount: Integer; 552 Buffer: string; 553 const 554 BufferSize = 1000; 555 begin 556 Process := TProcess.Create(nil); 557 try 558 Process.Executable := Executable; 559 for I := 0 to Length(Parameters) - 1 do 560 Process.Parameters.Add(Parameters[I]); 561 for I := 0 to Length(Environment) - 1 do 562 Process.Environment.Add(Environment[I]); 563 Process.CurrentDirectory := CurrentDirectory; 564 Process.ShowWindow := swoHIDE; 565 Process.Options := [poNoConsole, poUsePipes]; 566 Process.Execute; 567 568 Output := ''; 569 Error := ''; 570 Buffer := ''; 571 SetLength(Buffer, BufferSize); 572 while Process.Running do begin 573 if Process.Output.NumBytesAvailable > 0 then begin 574 ReadCount := Process.Output.Read(Buffer[1], Length(Buffer)); 575 Output := Output + Copy(Buffer, 1, ReadCount); 576 end; 577 578 if Process.Stderr.NumBytesAvailable > 0 then begin 579 ReadCount := Process.Stderr.Read(Buffer[1], Length(Buffer)); 580 Error := Error + Copy(Buffer, 1, ReadCount) 581 end; 582 583 Sleep(10); 584 end; 585 586 if Process.Output.NumBytesAvailable > 0 then begin 587 ReadCount := Process.Output.Read(Buffer[1], Length(Buffer)); 588 Output := Output + Copy(Buffer, 1, ReadCount); 589 end; 590 591 if Process.Stderr.NumBytesAvailable > 0 then begin 592 ReadCount := Process.Stderr.Read(Buffer[1], Length(Buffer)); 593 Error := Error + Copy(Buffer, 1, ReadCount); 594 end; 595 596 ExitCode := Process.ExitCode; 597 598 if (ExitCode <> 0) or (Error <> '') then 599 raise Exception.Create(Format(SExecutionError, [Error, ExitCode])); 600 finally 601 Process.Free; 602 end; 603 end; 604 513 605 procedure FreeThenNil(var Obj); 514 606 begin … … 529 621 procedure OpenFileInShell(FileName: string); 530 622 begin 531 ExecuteProgram('cmd.exe', ['/c', 'start', FileName] );623 ExecuteProgram('cmd.exe', ['/c', 'start', FileName], []); 532 624 end; 533 625 -
tags/1.3.0/Target.pas
r151 r162 80 80 protected 81 81 FCompiledExtension: string; 82 FRunExtension: string;83 82 FSourceExtension: string; 84 83 FName: string; … … 118 117 procedure Compile; virtual; 119 118 procedure CompileToFile; virtual; 119 function GetSourceFileName: string; virtual; 120 function GetCompileParams: TStringArray; virtual; 121 function GetCompileFileName: string; virtual; 120 122 procedure RunFromFile; virtual; 123 function GetRunParams: TStringArray; virtual; 121 124 procedure Run; virtual; 122 125 procedure Pause; virtual; … … 129 132 procedure SaveToRegistry(Context: TRegistryContext); virtual; 130 133 property SourceExtension: string read FSourceExtension; 131 property RunExtension: string read FRunExtension;132 134 property CompiledExtension: string read FCompiledExtension; 133 135 property Name: string read FName; … … 183 185 184 186 uses 185 FormConsole ;187 FormConsole, Common; 186 188 187 189 procedure UpdateTranslation; … … 491 493 procedure TTarget.CompileToFile; 492 494 var 493 Process: TProcess; 494 CompiledFile: string; 495 SourceFile: string; 495 496 Lines: TStringList; 496 I: Integer;497 begin 498 CompiledFile := ExtractFilePath(ProjectFileName) +499 CompiledDir + DirectorySeparator + Name + DirectorySeparator + 500 ExtractFileNameOnly(ProjectFileName) + SourceExtension;501 ForceDirectories(ExtractFilePath( CompiledFile));497 Output, Error: string; 498 Executable: string; 499 Parameters: array of string; 500 begin 501 SourceFile := GetSourceFileName; 502 ForceDirectories(ExtractFilePath(SourceFile)); 502 503 with TStringList.Create do 503 504 try 504 505 Text := FTargetCode; 505 SaveToFile( CompiledFile);506 SaveToFile(SourceFile); 506 507 finally 507 508 Free; 508 509 end; 509 510 if CompilerPath <> '' then begin; 510 if FileExists(CompilerPath) then 511 try 512 Process := TProcess.Create(nil); 513 Process.CurrentDirectory := ExtractFilePath(CompiledFile); 514 Process.Executable := LongFileName(CompilerPath); 515 Process.Parameters.Add(LongFileName(CompiledFile)); 516 for I := 0 to GetEnvironmentVariableCount - 1 do 517 Process.Environment.Add(GetEnvironmentString(I)); 518 Process.Options := [poWaitOnExit, poUsePipes]; 519 Process.Execute; 511 if FileExists(CompilerPath) then begin 512 Executable := LongFileName(CompilerPath); 513 Parameters := GetCompileParams; 514 515 ExecuteProgramOutput(Executable, GetCompileParams, GetEnvironmentVariables, 516 Output, Error, ExitCode, ExtractFilePath(SourceFile)); 517 520 518 if Assigned(FOnLog) then begin 521 519 Lines := TStringList.Create; 522 Lines. LoadFromStream(Process.Output);523 Lines.Insert(0, Process.Executable + ' ' + Process.Parameters.Text);520 Lines.Text := Output; 521 Lines.Insert(0, Executable + ' ' + Implode(',', Parameters)); 524 522 FOnLog(Lines); 525 523 Lines.Free; 526 524 end; 527 finally 528 Process.Free; 525 529 526 end else raise Exception.Create(Format(SCompilerNotFound, [CompilerPath])); 530 527 end; 531 528 end; 532 529 533 procedure TTarget.RunFromFile; 534 var 535 CompiledFile: string; 536 RunFile: string; 537 FormConsole: TFormConsole; 538 begin 539 CompiledFile := ExtractFilePath(ProjectFileName) + 530 function TTarget.GetSourceFileName: string; 531 begin 532 Result := ExtractFilePath(ProjectFileName) + 533 CompiledDir + DirectorySeparator + Name + DirectorySeparator + 534 ExtractFileNameOnly(ProjectFileName) + SourceExtension; 535 end; 536 537 function TTarget.GetCompileParams: TStringArray; 538 begin 539 Result := [LongFileName(GetSourceFileName)]; 540 end; 541 542 function TTarget.GetCompileFileName: string; 543 begin 544 Result := ExtractFilePath(ProjectFileName) + 540 545 CompiledDir + DirectorySeparator + Name + DirectorySeparator + 541 546 ExtractFileNameOnly(ProjectFileName) + CompiledExtension; 542 RunFile := ExtractFilePath(ProjectFileName) + 543 CompiledDir + DirectorySeparator + Name + DirectorySeparator + 544 ExtractFileNameOnly(ProjectFileName) + RunExtension; 547 end; 548 549 procedure TTarget.RunFromFile; 550 var 551 CompiledFile: string; 552 FormConsole: TFormConsole; 553 Parameters: TStringArray; 554 I: Integer; 555 begin 556 CompiledFile := GetCompileFileName; 545 557 if FileExists(CompiledFile) then 546 558 try … … 550 562 raise Exception.Create(Format(SExecutorNotFound, [ExecutorPath])); 551 563 FormConsole.Executable := LongFileName(ExecutorPath); 552 FormConsole.Parameters.Add(LongFileName(RunFile)); 564 Parameters := GetRunParams; 565 for I := 0 to Length(Parameters) - 1 do 566 FormConsole.Parameters.Add(Parameters[I]); 553 567 end else 554 FormConsole.Executable := LongFileName( RunFile);568 FormConsole.Executable := LongFileName(CompiledFile); 555 569 FormConsole.ShowModal; 556 570 finally … … 558 572 end 559 573 else raise Exception.Create(Format(SCompiledFileNotFound, [CompiledFile])); 574 end; 575 576 function TTarget.GetRunParams: TStringArray; 577 begin 578 Result := [LongFileName(GetCompileFileName)]; 560 579 end; 561 580 -
tags/1.3.0/Target/TargetC.pas
r146 r162 15 15 function GetMemoryCell: string; 16 16 public 17 function GetCompileParams: TStringArray; override; 17 18 constructor Create; override; 18 19 procedure Compile; override; 19 procedure CompileToFile; override;20 20 procedure Run; override; 21 21 end; … … 23 23 24 24 implementation 25 26 uses 27 Common; 25 28 26 29 { TTargetC } … … 36 39 CompilerPath := 'c:\Program Files\MinGW\bin\gcc.exe'; 37 40 FCompiledExtension := '.exe'; 38 FRunExtension := '';39 41 {$ENDIF} 40 42 {$IFDEF UNIX} 41 43 CompilerPath := '/usr/bin/gcc'; 42 44 FCompiledExtension := ''; 43 FRunExtension := '';44 45 {$ENDIF} 45 46 end; … … 53 54 Result := Result + ' - ' + IntToStr(Abs(FProgram[FProgramIndex].RelIndex)); 54 55 Result := Result + ']'; 56 end; 57 58 function TTargetC.GetCompileParams: TStringArray; 59 begin 60 Result := [GetSourceFileName, '-o', GetCompileFileName]; 55 61 end; 56 62 … … 101 107 end; 102 108 103 procedure TTargetC.CompileToFile;104 var105 Process: TProcess;106 CompiledFile: string;107 begin108 CompiledFile := ExtractFilePath(ProjectFileName) +109 CompiledDir + DirectorySeparator + Name + DirectorySeparator +110 ExtractFileNameOnly(ProjectFileName) + SourceExtension;111 ForceDirectoriesUTF8(ExtractFilePath(CompiledFile));112 with TStringList.Create do113 try114 Text := FTargetCode;115 SaveToFile(CompiledFile);116 finally117 Free;118 end;119 if FileExistsUTF8(CompilerPath) then120 try121 Process := TProcess.Create(nil);122 Process.CurrentDirectory := ExtractFilePath(CompilerPath);123 Process.Executable := LongFileName(CompilerPath);124 Process.Parameters.Add(LongFileName(CompiledFile));125 Process.Parameters.Add('-o');126 Process.Parameters.Add(LongFileName(ExtractFilePath(CompiledFile) + ExtractFileNameOnly(CompiledFile) + CompiledExtension));127 Process.Options := [poWaitOnExit];128 Process.Execute;129 finally130 Process.Free;131 end else raise Exception.Create(Format(SCompilerNotFound, [CompilerPath]));132 end;133 134 109 procedure TTargetC.Run; 135 110 begin -
tags/1.3.0/Target/TargetCSharp.pas
r153 r162 30 30 FSourceExtension := '.cs'; 31 31 FCompiledExtension := '.exe'; 32 FRunExtension := '.exe';33 32 FImageIndex := 27; 34 33 FCapabilities := [tcCompile, tcRun]; -
tags/1.3.0/Target/TargetDelphi.pas
r146 r162 29 29 FSourceExtension := '.pas'; 30 30 FImageIndex := 22; 31 FCapabilities := [tcCompile]; 32 {$IFDEF Windows} 31 33 FCapabilities := [tcCompile, tcRun]; 32 {$IFDEF Windows}33 34 CompilerPath := 'c:\Program Files\Embarcadero\RAD Studio\9.0\bin\DCC32.EXE'; 34 35 FCompiledExtension := '.exe'; 35 FRunExtension := '';36 36 {$ENDIF} 37 37 end; -
tags/1.3.0/Target/TargetFPC.pas
r146 r162 33 33 FCompiledExtension := '.exe'; 34 34 CompilerPath := 'fpc.exe'; 35 FRunExtension := '';36 35 {$ENDIF} 37 36 {$IFDEF UNIX} 38 37 FCompiledExtension := ''; 39 38 CompilerPath := '/usr/bin/fpc'; 40 FRunExtension := '';41 39 {$ENDIF} 42 40 end; -
tags/1.3.0/Target/TargetJava.pas
r153 r162 4 4 5 5 uses 6 Classes, SysUtils, FileUtil, Target, BFTarget, Dialogs ;6 Classes, SysUtils, FileUtil, Target, BFTarget, Dialogs, LazFileUtils; 7 7 8 8 type … … 14 14 function GetMemoryCell: string; 15 15 public 16 function GetRunParams: TStringArray; override; 16 17 constructor Create; override; 17 18 procedure Compile; override; … … 30 31 FSourceExtension := '.java'; 31 32 FCompiledExtension := '.class'; 32 FRunExtension := '.class';33 33 FImageIndex := 24; 34 34 FCapabilities := [tcCompile, tcRun]; … … 51 51 Result := Result + ' - ' + IntToStr(Abs(FProgram[FProgramIndex].RelIndex)); 52 52 Result := Result + ']'; 53 end; 54 55 function TTargetJava.GetRunParams: TStringArray; 56 begin 57 Result := ['-classpath', ExtractFileDir(GetCompileFileName), ExtractFileNameOnly(GetCompileFileName)]; 53 58 end; 54 59 -
tags/1.3.0/Target/TargetJavascript.pas
r145 r162 36 36 CompilerPath := ''; 37 37 FCompiledExtension := ''; 38 FRunExtension := '';39 38 end; 40 39 -
tags/1.3.0/Target/TargetPHP.pas
r145 r162 29 29 FName := 'PHP'; 30 30 FSourceExtension := '.php'; 31 FRunExtension := '.php';32 31 FCompiledExtension := '.php'; 33 32 FImageIndex := 21; -
tags/1.3.0/Target/TargetPython.pas
r148 r162 29 29 FName := 'Python'; 30 30 FSourceExtension := '.py'; 31 FRunExtension := '.py';32 31 FCompiledExtension := '.py'; 33 32 FImageIndex := 26; -
tags/1.3.0/Target/TargetRust.pas
r150 r162 15 15 function GetMemoryCell: string; 16 16 public 17 function GetCompileParams: TStringArray; override; 17 18 constructor Create; override; 18 19 procedure Compile; override; 19 procedure CompileToFile; override;20 20 procedure Run; override; 21 21 end; … … 23 23 24 24 implementation 25 26 uses 27 Common; 25 28 26 29 { TTargetRust } … … 36 39 CompilerPath := 'c:\Program Files\Rust\rustc.exe'; 37 40 FCompiledExtension := '.exe'; 38 FRunExtension := '';39 41 {$ENDIF} 40 42 {$IFDEF UNIX} 41 43 CompilerPath := '/usr/bin/rustc'; 42 44 FCompiledExtension := ''; 43 FRunExtension := '';44 45 {$ENDIF} 45 46 end; … … 53 54 Result := Result + ' - ' + IntToStr(Abs(FProgram[FProgramIndex].RelIndex)); 54 55 Result := Result + ']'; 56 end; 57 58 function TTargetRust.GetCompileParams: TStringArray; 59 begin 60 Result := [GetSourceFileName, '-o', GetCompileFileName]; 55 61 end; 56 62 … … 110 116 end; 111 117 112 procedure TTargetRust.CompileToFile;113 var114 Process: TProcess;115 CompiledFile: string;116 begin117 CompiledFile := ExtractFilePath(ProjectFileName) +118 CompiledDir + DirectorySeparator + Name + DirectorySeparator +119 ExtractFileNameOnly(ProjectFileName) + SourceExtension;120 ForceDirectoriesUTF8(ExtractFilePath(CompiledFile));121 with TStringList.Create do122 try123 Text := FTargetCode;124 SaveToFile(CompiledFile);125 finally126 Free;127 end;128 if FileExistsUTF8(CompilerPath) then129 try130 Process := TProcess.Create(nil);131 Process.CurrentDirectory := ExtractFilePath(CompilerPath);132 Process.Executable := LongFileName(CompilerPath);133 Process.Parameters.Add(LongFileName(CompiledFile));134 Process.Parameters.Add('-o');135 Process.Parameters.Add(LongFileName(ExtractFilePath(CompiledFile) + ExtractFileNameOnly(CompiledFile) + CompiledExtension));136 Process.Options := [poWaitOnExit];137 Process.Execute;138 finally139 Process.Free;140 end else raise Exception.Create(Format(SCompilerNotFound, [CompilerPath]));141 end;142 143 118 procedure TTargetRust.Run; 144 119 begin
Note:
See TracChangeset
for help on using the changeset viewer.