Changeset 41 for trunk/Compiler


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.
Location:
trunk/Compiler
Files:
19 added
2 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Compiler/TranspascalCompiler.lpk

    r38 r41  
    99      <PathDelim Value="\"/>
    1010      <SearchPaths>
    11         <OtherUnitFiles Value="Produce;Analyze"/>
     11        <OtherUnitFiles Value="Target;Target\Interpretter;Target\ASM8051;Target\Java;Target\GCC;Target\PHP;Target\Delphi;Target\Dynamic C"/>
    1212        <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
    1313      </SearchPaths>
     14      <Parsing>
     15        <SyntaxOptions>
     16          <SyntaxMode Value="Delphi"/>
     17        </SyntaxOptions>
     18      </Parsing>
    1419      <Other>
    1520        <CompilerMessages>
     
    2126    </CompilerOptions>
    2227    <Version Minor="1"/>
    23     <Files Count="12">
     28    <Files Count="13">
    2429      <Item1>
    2530        <Filename Value="UCompiler.pas"/>
     
    3136      </Item2>
    3237      <Item3>
    33         <Filename Value="Produce\UProducerTreeView.pas"/>
    34         <UnitName Value="UProducerTreeView"/>
     38        <Filename Value="UProducer.pas"/>
     39        <UnitName Value="UProducer"/>
    3540      </Item3>
    3641      <Item4>
    37         <Filename Value="Produce\UProducer.pas"/>
    38         <UnitName Value="UProducer"/>
     42        <Filename Value="Target\ASM8051\UProducerASM8051.pas"/>
     43        <UnitName Value="UProducerAsm8051"/>
    3944      </Item4>
    4045      <Item5>
    41         <Filename Value="Produce\UProducers.pas"/>
    42         <UnitName Value="UProducers"/>
     46        <Filename Value="Target\Dynamic C\UProducerDynamicc.pas"/>
     47        <UnitName Value="UProducerDynamicC"/>
    4348      </Item5>
    4449      <Item6>
    45         <Filename Value="Produce\UProducerAsm8051.pas"/>
    46         <UnitName Value="UProducerAsm8051"/>
     50        <Filename Value="Target\Delphi\UProducerPascal.pas"/>
     51        <UnitName Value="UProducerPascal"/>
    4752      </Item6>
    4853      <Item7>
    49         <Filename Value="Produce\UProducerDynamicC.pas"/>
    50         <UnitName Value="UProducerDynamicC"/>
     54        <Filename Value="Target\GCC\UProducerGCC.pas"/>
     55        <UnitName Value="UProducerGCC"/>
    5156      </Item7>
    5257      <Item8>
    53         <Filename Value="Produce\UProducerPascal.pas"/>
    54         <UnitName Value="UProducerPascal"/>
     58        <Filename Value="UAnalyzer.pas"/>
     59        <UnitName Value="UAnalyzer"/>
    5560      </Item8>
    5661      <Item9>
    57         <Filename Value="Produce\UProducerGCCC.pas"/>
    58         <UnitName Value="UProducerGCCC"/>
     62        <Filename Value="Analyze\UAnalyzerPascal.pas"/>
     63        <UnitName Value="UAnalyzerPascal"/>
    5964      </Item9>
    6065      <Item10>
    61         <Filename Value="Analyze\UAnalyzer.pas"/>
    62         <UnitName Value="UAnalyzer"/>
     66        <Filename Value="UTarget.pas"/>
     67        <UnitName Value="UTarget"/>
    6368      </Item10>
    6469      <Item11>
    65         <Filename Value="Analyze\UAnalyzers.pas"/>
    66         <UnitName Value="UAnalyzers"/>
     70        <Filename Value="UExecutor.pas"/>
     71        <UnitName Value="UExecutor"/>
    6772      </Item11>
    6873      <Item12>
    69         <Filename Value="Analyze\UAnalyzerPascal.pas"/>
    70         <UnitName Value="UAnalyzerPascal"/>
     74        <Filename Value="Target\UTargets.pas"/>
     75        <UnitName Value="UTargets"/>
    7176      </Item12>
     77      <Item13>
     78        <Filename Value="Target\Interpretter\UTargetInterpretter.pas"/>
     79        <UnitName Value="UTargetInterpretter"/>
     80      </Item13>
    7281    </Files>
    7382    <Type Value="RunAndDesignTime"/>
  • trunk/Compiler/TranspascalCompiler.pas

    r38 r41  
    88
    99uses
    10   UCompiler, USourceCode, UProducerTreeView, UProducer, UProducers,
    11   UProducerAsm8051, UProducerDynamicC, UProducerPascal, UProducerGCCC,
    12   UAnalyzer, UAnalyzers, UAnalyzerPascal, LazarusPackageIntf;
     10  UCompiler, USourceCode, UProducer, UProducerASM8051, UProducerDynamicc,
     11  UProducerPascal, UProducerGCC, UAnalyzer, UAnalyzerPascal, UTarget,
     12  UExecutor, UTargets, UTargetInterpretter, LazarusPackageIntf;
    1313
    1414implementation
  • 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.