Ignore:
Timestamp:
Feb 28, 2012, 8:34:31 PM (13 years ago)
Author:
chronos
Message:
  • Modified: Instead of TProducer class will be used TTarget as real target definition.
  • Added: For execution of compiled code TExecutor class is introduced.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Compiler/UCompiler.pas

    r38 r41  
    66
    77uses
    8   SysUtils, Variants, Classes, Contnrs, UAnalyzers, UProducers, FileUtil,
    9   Dialogs, USourceCode, UProducer, UAnalyzer, SpecializedList;
     8  SysUtils, Variants, Classes, Contnrs, FileUtil,
     9  Dialogs, USourceCode, UProducer, UAnalyzer, SpecializedList, UTarget;
    1010
    1111type
    12   TProducerType = (ptGCCC, ptDynamicC, ptPascal, ptAssembler, ptXML);
    13   TAnalyzerType = (ptCustomPascal, ptDelphi);
    14 
    1512  TErrorMessage = class
    1613    Text: string;
     
    1916  end;
    2017
    21   TCompilerTarget = class
    22     Vendor: string;
    23     Model: string;
    24     Architecture: string;
    25   end;
    26 
    2718  { TCompilerList }
    28 
    29   TCompilerTargetList = class(TObjectList)
    30     procedure Add(Vendor, Model, Architecture: string);
    31   end;
    3219
    3320  TCompiler = class
     
    3522    FAnalyzer: TAnalyzer;
    3623    FOnErrorMessage: TErrorMessageEvent;
    37     FProducerType: TProducerType;
    38     FProducer: TProducer;
    3924    function GetSource(Name: string; var SourceCode: string): Boolean;
    4025    procedure ErrorMessage(Text: string; Position: TPoint; FileName: string);
    4126    procedure SetAnalyzer(const AValue: TAnalyzer);
    42     procedure SetProducer(AValue: TProducer);
    4327    procedure AnalyzeAll;
    4428    procedure ProduceAll;
     
    4731    ErrorMessages: TListObject;
    4832    CompiledFolder: string;
    49     SupportedTargets: TCompilerTargetList;
    50     Target: TCompilerTarget;
     33    Target: TTarget;
    5134    TargetFolder: string;
    52     Producers: TListProducer;
    53     Analyzers: TListAnalyzer;
     35    Targets: TListTarget;
    5436    SourceFiles: TListString;
    5537    constructor Create;
     
    6042      write FOnErrorMessage;
    6143    property Analyzer: TAnalyzer read FAnalyzer write SetAnalyzer;
    62     property Producer: TProducer read FProducer write SetProducer;
    6344  end;
    6445
     46
    6547implementation
     48
     49uses
     50  UTargets;
    6651
    6752resourcestring
     
    7863constructor TCompiler.Create;
    7964begin
    80   Analyzers := TListAnalyzer.Create;
    81   Producers := TListProducer.Create;
     65  Targets := TListTarget.Create;
    8266  SourceFiles := TListString.Create;
    8367
    84   RegisterAnalyzers(Self);
    85   RegisterProducers(Self);
    86 
    87   SupportedTargets := TCompilerTargetList.Create;
    88   SupportedTargets.Add('AMD', 'Athlon II', 'amd64');
    89   SupportedTargets.Add('Zilog', 'Z80', 'Z80');
    90   SupportedTargets.Add('Rabbit', 'RC3000', 'Z180');
    91   SupportedTargets.Add('Atmel', 'ATmega8', 'AVR');
    92   SupportedTargets.Add('Atmel', 'UC3B0256', 'AVR32');
    93   SupportedTargets.Add('Dallas', 'DS89C450', '8052');
     68  RegisterTargets(Self);
    9469
    9570  AbstractCode := TProgram.Create;
    96   Producer := nil;
    97   Analyzer := nil;
    9871  ErrorMessages := TListObject.Create;
    9972  CompiledFolder := 'Compiled';
     
    10982begin
    11083  AbstractCode.Free;
    111   Analyzers.Free;
    112   Producers.Free;
     84  Targets.Free;
    11385  ErrorMessages.Free;
    114   SupportedTargets.Free;
    11586  SourceFiles.Free;
    11687end;
     
    159130end;
    160131
    161 procedure TCompiler.SetProducer(AValue: TProducer);
    162 begin
    163   if FProducer = AValue then Exit;
    164   FProducer := AValue;
    165 end;
    166 
    167132procedure TCompiler.AnalyzeAll;
    168133begin
     
    187152    with AbstractCode do
    188153    for I := 0 to Modules.Count - 1 do begin
    189       Producer.Produce(TModule(Modules[I]));
    190       Producer.AssignToStringList(ProducedCode);
     154      Target.Producer.Produce(TModule(Modules[I]));
     155      Target.Producer.AssignToStringList(ProducedCode);
    191156      TargetFileName := TargetFolder + DirectorySeparator +
    192         CompiledFolder + DirectorySeparator + Producer.Name +
     157        CompiledFolder + DirectorySeparator + Target.Producer.Name +
    193158        DirectorySeparator + TModule(Modules[I]).TargetFile;
    194159      ForceDirectoriesUTF8(ExtractFileDir(TargetFileName));
     
    200165end;
    201166
    202 { TCompilerTargetList }
    203 
    204 procedure TCompilerTargetList.Add(Vendor, Model, Architecture: string);
    205 var
    206   NewItem: TCompilerTarget;
    207 begin
    208   NewItem := TCompilerTarget.Create;
    209   NewItem.Vendor := Vendor;
    210   NewItem.Model := Model;
    211   NewItem.Architecture := Architecture;
    212   inherited Add(NewItem);
    213 end;
    214 
    215167end.
Note: See TracChangeset for help on using the changeset viewer.