Changeset 92 for branches/dcomp
- Timestamp:
- Nov 4, 2016, 4:25:29 PM (8 years ago)
- Location:
- branches/dcomp/CmdLine
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/dcomp/CmdLine/Compiler/UAnalyzer.pas
r91 r92 5 5 type 6 6 TAnalyzer = class 7 procedure Analyze; 7 procedure Analyze; virtual; 8 8 end; 9 10 TAnalyzerClass = class of TAnalyzer; 9 11 10 12 implementation -
branches/dcomp/CmdLine/Compiler/UCompiler.pas
r91 r92 7 7 8 8 type 9 10 { TCompiler } 11 9 12 TCompiler = class 13 Analyzers: array of TAnalyzer; 10 14 Targets: array of TTarget; 11 15 Analyzer: TAnalyzer; … … 13 17 procedure Compile; 14 18 procedure RegisterTarget(TargetClass: TTargetClass); 19 procedure RegisterAnalyzer(AnalyzerClass: TAnalyzerClass); 15 20 end; 16 21 … … 19 24 procedure TCompiler.Compile; 20 25 begin 26 if Assigned(Analyzer) then Analyzer.Analyze 27 else raise Exception.Create('Undefined analyzer'); 21 28 if Assigned(Target) then Target.Produce 22 29 else raise Exception.Create('Undefined target'); … … 32 39 end; 33 40 41 procedure TCompiler.RegisterAnalyzer(AnalyzerClass: TAnalyzerClass); 42 begin 43 SetLength(Analyzers, Length(Analyzers) + 1); 44 Analyzers[Length(Analyzers) - 1] := AnalyzerClass.Create; 45 if not Assigned(Analyzer) then 46 Analyzer := Analyzers[Length(Analyzers) - 1]; 47 end; 48 34 49 end. -
branches/dcomp/CmdLine/dcomp.dpr
r91 r92 2 2 3 3 uses 4 UCompiler, UTargetPHP ;4 UCompiler, UTargetPHP, UAnalyzerPascal; 5 5 6 6 var … … 9 9 Compiler := TCompiler.Create; 10 10 Compiler.RegisterTarget(TTargetPHP); 11 Compiler.RegisterAnalyzer(TAnalyzerPascal); 11 12 Compiler.Compile; 12 13 Compiler.Free;
Note:
See TracChangeset
for help on using the changeset viewer.