Ignore:
Timestamp:
Nov 4, 2016, 4:25:29 PM (8 years ago)
Author:
chronos
Message:
  • Added: Allow to register analyzer.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/dcomp/CmdLine/Compiler/UCompiler.pas

    r91 r92  
    77
    88type
     9
     10  { TCompiler }
     11
    912  TCompiler = class
     13    Analyzers: array of TAnalyzer;
    1014    Targets: array of TTarget;
    1115    Analyzer: TAnalyzer;
     
    1317    procedure Compile;
    1418    procedure RegisterTarget(TargetClass: TTargetClass);
     19    procedure RegisterAnalyzer(AnalyzerClass: TAnalyzerClass);
    1520  end;
    1621
     
    1924procedure TCompiler.Compile;
    2025begin
     26  if Assigned(Analyzer) then Analyzer.Analyze
     27    else raise Exception.Create('Undefined analyzer');
    2128  if Assigned(Target) then Target.Produce
    2229    else raise Exception.Create('Undefined target');
     
    3239end;
    3340
     41procedure TCompiler.RegisterAnalyzer(AnalyzerClass: TAnalyzerClass);
     42begin
     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];
     47end;
     48
    3449end.
Note: See TracChangeset for help on using the changeset viewer.