Ignore:
Timestamp:
Nov 4, 2016, 9:17:57 PM (8 years ago)
Author:
chronos
Message:
  • Modified: Use generic lists in supported analyzers and parsers.
  • Fixed: Build under Delphi.
Location:
branches/dcomp/CmdLine/Compiler
Files:
2 edited

Legend:

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

    r92 r93  
    11unit UAnalyzerPascal;
    2 
    3 {$mode delphi}
    42
    53interface
  • branches/dcomp/CmdLine/Compiler/UCompiler.pas

    r92 r93  
    44
    55uses
    6   SysUtils, UAnalyzer, UTarget;
     6  SysUtils, Generics.Collections, UAnalyzer, UTarget;
    77
    88type
     
    1111
    1212  TCompiler = class
    13     Analyzers: array of TAnalyzer;
    14     Targets: array of TTarget;
     13    SupportedAnalyzers: TObjectList<TAnalyzer>;
     14    SupportedTargets: TObjectList<TTarget>;
    1515    Analyzer: TAnalyzer;
    1616    Target: TTarget;
     17    MainSourceFile: string;
    1718    procedure Compile;
    1819    procedure RegisterTarget(TargetClass: TTargetClass);
    1920    procedure RegisterAnalyzer(AnalyzerClass: TAnalyzerClass);
     21    constructor Create;
     22    destructor Destroy; override;
    2023  end;
    2124
     
    3336procedure TCompiler.RegisterTarget(TargetClass: TTargetClass);
    3437begin
    35   SetLength(Targets, Length(Targets) + 1);
    36   Targets[Length(Targets) - 1] := TargetClass.Create;
     38  SupportedTargets.Add(TargetClass.Create);
    3739  if not Assigned(Target) then
    38     Target := Targets[Length(Targets) - 1];
     40    Target := SupportedTargets.Last;
     41end;
     42
     43constructor TCompiler.Create;
     44begin
     45  SupportedTargets := TObjectList<TTarget>.Create;
     46  SupportedAnalyzers := TObjectList<TAnalyzer>.Create;
     47end;
     48
     49destructor TCompiler.Destroy;
     50begin
     51  SupportedTargets.Free;
     52  SupportedAnalyzers.Free;
     53  inherited;
    3954end;
    4055
    4156procedure TCompiler.RegisterAnalyzer(AnalyzerClass: TAnalyzerClass);
    4257begin
    43   SetLength(Analyzers, Length(Analyzers) + 1);
    44   Analyzers[Length(Analyzers) - 1] := AnalyzerClass.Create;
     58  SupportedAnalyzers.Add(AnalyzerClass.Create);
    4559  if not Assigned(Analyzer) then
    46     Analyzer := Analyzers[Length(Analyzers) - 1];
     60    Analyzer := SupportedAnalyzers.Last;
    4761end;
    4862
Note: See TracChangeset for help on using the changeset viewer.