- Timestamp:
- Nov 4, 2016, 9:17:57 PM (8 years ago)
- Location:
- branches/dcomp/CmdLine
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/dcomp/CmdLine/Compiler/UAnalyzerPascal.pas
r92 r93 1 1 unit UAnalyzerPascal; 2 3 {$mode delphi}4 2 5 3 interface -
branches/dcomp/CmdLine/Compiler/UCompiler.pas
r92 r93 4 4 5 5 uses 6 SysUtils, UAnalyzer, UTarget;6 SysUtils, Generics.Collections, UAnalyzer, UTarget; 7 7 8 8 type … … 11 11 12 12 TCompiler = class 13 Analyzers: array of TAnalyzer;14 Targets: array of TTarget;13 SupportedAnalyzers: TObjectList<TAnalyzer>; 14 SupportedTargets: TObjectList<TTarget>; 15 15 Analyzer: TAnalyzer; 16 16 Target: TTarget; 17 MainSourceFile: string; 17 18 procedure Compile; 18 19 procedure RegisterTarget(TargetClass: TTargetClass); 19 20 procedure RegisterAnalyzer(AnalyzerClass: TAnalyzerClass); 21 constructor Create; 22 destructor Destroy; override; 20 23 end; 21 24 … … 33 36 procedure TCompiler.RegisterTarget(TargetClass: TTargetClass); 34 37 begin 35 SetLength(Targets, Length(Targets) + 1); 36 Targets[Length(Targets) - 1] := TargetClass.Create; 38 SupportedTargets.Add(TargetClass.Create); 37 39 if not Assigned(Target) then 38 Target := Targets[Length(Targets) - 1]; 40 Target := SupportedTargets.Last; 41 end; 42 43 constructor TCompiler.Create; 44 begin 45 SupportedTargets := TObjectList<TTarget>.Create; 46 SupportedAnalyzers := TObjectList<TAnalyzer>.Create; 47 end; 48 49 destructor TCompiler.Destroy; 50 begin 51 SupportedTargets.Free; 52 SupportedAnalyzers.Free; 53 inherited; 39 54 end; 40 55 41 56 procedure TCompiler.RegisterAnalyzer(AnalyzerClass: TAnalyzerClass); 42 57 begin 43 SetLength(Analyzers, Length(Analyzers) + 1); 44 Analyzers[Length(Analyzers) - 1] := AnalyzerClass.Create; 58 SupportedAnalyzers.Add(AnalyzerClass.Create); 45 59 if not Assigned(Analyzer) then 46 Analyzer := Analyzers[Length(Analyzers) - 1];60 Analyzer := SupportedAnalyzers.Last; 47 61 end; 48 62 -
branches/dcomp/CmdLine/dcomp.dpr
r92 r93 1 1 program dcomp; 2 2 3 {$APPTYPE CONSOLE} 4 3 5 uses 4 UCompiler, UTargetPHP, UAnalyzerPascal; 6 System.SysUtils, 7 UCompiler in 'Compiler\UCompiler.pas', 8 UTargetPHP in 'TargetPHP\UTargetPHP.pas', 9 UAnalyzerPascal in 'Compiler\UAnalyzerPascal.pas', 10 UAnalyzer in 'Compiler\UAnalyzer.pas', 11 UTarget in 'Compiler\UTarget.pas'; 5 12 13 type 14 TApplication = class 15 procedure Run; 16 end; 17 18 { TApplication } 19 20 procedure TApplication.Run; 6 21 var 7 22 Compiler: TCompiler; 8 23 begin 9 24 Compiler := TCompiler.Create; 25 if ParamCount > 0 then 26 Compiler.MainSourceFile := ParamStr(1); 10 27 Compiler.RegisterTarget(TTargetPHP); 11 28 Compiler.RegisterAnalyzer(TAnalyzerPascal); 12 29 Compiler.Compile; 13 Compiler.Free; 30 end; 31 32 var 33 Application: TApplication; 34 begin 35 try 36 Application := TApplication.Create; 37 Application.Run; 38 Application.Free; 39 ReadLn; 40 { TODO -oUser -cConsole Main : Insert code here } 41 except 42 on E: Exception do 43 Writeln(E.ClassName, ': ', E.Message); 44 end; 14 45 end. 46
Note:
See TracChangeset
for help on using the changeset viewer.