Changeset 68 for trunk/Compiler


Ignore:
Timestamp:
Jul 30, 2012, 3:52:56 PM (12 years ago)
Author:
chronos
Message:
  • Added: Addon modules support.
  • Modified: Restored usage of URegistry unit.
Location:
trunk/Compiler
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/Compiler/Analyze/UAnalyzerPascal.pas

    r67 r68  
    2929    function ParseUses(SourceCode: TUsedModuleList; AExported: Boolean): Boolean;
    3030    function ParseUsesItem(SourceCode: TUsedModuleList; AExported: Boolean): Boolean;
    31     function ParseModule(ProgramCode: TProgram): TModule; override;
     31    function ParseModule(ProgramCode: TProgram): TSourceModule; override;
    3232    function ParseUnit(var SourceCode: TModuleUnit; ProgramCode: TProgram): Boolean;
    3333    function ParseUnitInterface(SourceCode: TModuleUnit): Boolean;
     
    106106var
    107107  Parser: TAnalyzerPascal;
    108   NewModule: TModule;
     108  NewModule: TSourceModule;
    109109begin
    110110  try
     
    420420{ TParserModule }
    421421
    422 function TAnalyzerPascal.ParseModule(ProgramCode: TProgram): TModule;
     422function TAnalyzerPascal.ParseModule(ProgramCode: TProgram): TSourceModule;
    423423begin
    424424  Self.ProgramCode := ProgramCode;
     
    454454function TAnalyzerPascal.ParseUnit(var SourceCode: TModuleUnit; ProgramCode: TProgram): Boolean;
    455455var
    456   NewModule: TModule;
     456  NewModule: TSourceModule;
    457457  NewCommand: TCommand;
    458458begin
  • trunk/Compiler/Target/ASM8051/UProducerASM8051.pas

    r44 r68  
    3535    procedure GenerateExpression(Expression: TExpression; LabelPrefix: string);
    3636    procedure GenerateProgram(ProgramBlock: TProgram);
    37     procedure GenerateModule(Module: TModule);
     37    procedure GenerateModule(Module: TSourceModule);
    3838  public
    3939    AssemblyCode: TObjectList; // TList<TAssemblerLine>
    4040    procedure AssignToStringList(Target: TStringList); override;
    41     procedure Produce(Module: TModule); override;
     41    procedure Produce(Module: TSourceModule); override;
    4242    constructor Create;
    4343    destructor Destroy; override;
     
    189189//  with ProgramBlock do
    190190//  for I := 0 to Modules.Count - 1 do
    191 //    GenerateCommonBlock(TModule(Modules[I]), '');
    192 end;
    193 
    194 procedure TProducerAsm8051.GenerateModule(Module: TModule);
     191//    GenerateCommonBlock(TSourceModuleTSourceModule(Modules[I]), '');
     192end;
     193
     194procedure TProducerAsm8051.GenerateModule(Module: TSourceModule);
    195195begin
    196196  Module.TargetFile := Module.Name + '.asm';
     
    207207end;
    208208
    209 procedure TProducerAsm8051.Produce(Module: TModule);
     209procedure TProducerAsm8051.Produce(Module: TSourceModule);
    210210begin
    211211  GenerateModule(Module);
  • trunk/Compiler/Target/Delphi/UProducerPascal.pas

    r65 r68  
    1616  private
    1717    procedure GenerateUses(UsedModules: TUsedModuleList);
    18     procedure GenerateModule(Module: TModule);
    19     procedure GenerateUnit(Module: TModule);
    20     procedure GenerateLibrary(Module: TModule);
    21     procedure GeneratePackage(Module: TModule);
     18    procedure GenerateModule(Module: TSourceModule);
     19    procedure GenerateUnit(Module: TSourceModule);
     20    procedure GenerateLibrary(Module: TSourceModule);
     21    procedure GeneratePackage(Module: TSourceModule);
    2222    procedure GenerateType(AType: TType; AssignSymbol: Char = ':');
    2323    procedure GenerateTypes(Types: TTypeList);
     
    4343  public
    4444    procedure AssignToStringList(Target: TStringList); override;
    45     procedure Produce(Module: TModule); override;
     45    procedure Produce(Module: TSourceModule); override;
    4646    constructor Create;
    4747    destructor Destroy; override;
     
    9494end;
    9595
    96 procedure TProducerPascal.GenerateModule(Module: TModule);
     96procedure TProducerPascal.GenerateModule(Module: TSourceModule);
    9797begin
    9898  Module.TargetFile := Module.Name + '.pas';
     
    113113end;
    114114
    115 procedure TProducerPascal.GenerateUnit(Module: TModule);
     115procedure TProducerPascal.GenerateUnit(Module: TSourceModule);
    116116begin
    117117  EmitLn('unit ' + TModuleUnit(Module).Name + ';');
     
    127127end;
    128128
    129 procedure TProducerPascal.GenerateLibrary(Module: TModule);
    130 begin
    131 
    132 end;
    133 
    134 procedure TProducerPascal.GeneratePackage(Module: TModule);
     129procedure TProducerPascal.GenerateLibrary(Module: TSourceModule);
     130begin
     131
     132end;
     133
     134procedure TProducerPascal.GeneratePackage(Module: TSourceModule);
    135135begin
    136136
     
    196196end;
    197197
    198 procedure TProducerPascal.Produce(Module: TModule);
     198procedure TProducerPascal.Produce(Module: TSourceModule);
    199199var
    200200  I: Integer;
     
    206206  with Module.ParentProgram do
    207207  for I := 0 to Modules.Count - 1 do
    208     if TModule(Modules[I]).Name = 'System' then
    209       TModule(Modules[I]).Name := 'System2';
     208    if TSourceModule(Modules[I]).Name = 'System' then
     209      TSourceModule(Modules[I]).Name := 'System2';
    210210
    211211  GenerateModule(Module);
  • trunk/Compiler/Target/Dynamic C/UProducerDynamicc.pas

    r44 r68  
    1818    function TranslateOperator(Name: string): string;
    1919    procedure GenerateUses(UsedModules: TUsedModuleList);
    20     procedure GenerateModule(Module: TModule);
     20    procedure GenerateModule(Module: TSourceModule);
    2121    procedure GenerateCommonBlock(CommonBlock: TCommonBlock;
    2222      LabelPrefix: string);
     
    3838  public
    3939    procedure AssignToStringList(Target: TStringList); override;
    40     procedure Produce(Module: TModule); override;
     40    procedure Produce(Module: TSourceModule); override;
    4141    constructor Create;
    4242    destructor Destroy; override;
     
    9696end;
    9797
    98 procedure TProducerDynamicC.GenerateModule(Module: TModule);
     98procedure TProducerDynamicC.GenerateModule(Module: TSourceModule);
    9999begin
    100100  if Module is TModuleProgram then begin
     
    133133end;
    134134
    135 procedure TProducerDynamicC.Produce(Module: TModule);
     135procedure TProducerDynamicC.Produce(Module: TSourceModule);
    136136begin
    137137  inherited;
     
    147147  with ProgramBlock do
    148148  for I := 0 to Modules.Count - 1 do
    149     GenerateModule(TModule(Modules[I]));
     149    GenerateModule(TSourceModule(Modules[I]));
    150150end;
    151151
  • trunk/Compiler/Target/GCC/UProducerGCC.pas

    r44 r68  
    2020    procedure EmitLn(AText: string = '');
    2121    procedure GenerateUses(UsedModules: TUsedModuleList);
    22     procedure GenerateModule(Module: TModule);
     22    procedure GenerateModule(Module: TSourceModule);
    2323    procedure GenerateCommonBlock(CommonBlock: TCommonBlock;
    2424      LabelPrefix: string);
     
    4343    Indetation: Integer;
    4444    procedure AssignToStringList(Target: TStringList); override;
    45     procedure Produce(Module: TModule); override;
     45    procedure Produce(Module: TSourceModule); override;
    4646    constructor Create;
    4747    destructor Destroy; override;
     
    122122end;
    123123
    124 procedure TProducerGCCC.GenerateModule(Module: TModule);
     124procedure TProducerGCCC.GenerateModule(Module: TSourceModule);
    125125begin
    126126  Module.TargetFile := Module.Name + '.c';
     
    138138end;
    139139
    140 procedure TProducerGCCC.Produce(Module: TModule);
     140procedure TProducerGCCC.Produce(Module: TSourceModule);
    141141begin
    142142  inherited;
     
    152152  with ProgramBlock do
    153153  for I := 0 to Modules.Count - 1 do
    154     GenerateModule(TModule(Modules[I]));
     154    GenerateModule(TSourceModule(Modules[I]));
    155155end;
    156156
  • trunk/Compiler/Target/XML/UTargetXML.pas

    r63 r68  
    2020  TProducerXML = class(TProducer)
    2121  private
    22     procedure GenerateModule(Module: TModule);
    23     procedure GenerateUnit(Module: TModule);
    24     procedure GenerateLibrary(Module: TModule);
    25     procedure GeneratePackage(Module: TModule);
     22    procedure GenerateModule(Module: TSourceModule);
     23    procedure GenerateUnit(Module: TSourceModule);
     24    procedure GenerateLibrary(Module: TSourceModule);
     25    procedure GeneratePackage(Module: TSourceModule);
    2626  public
    2727    procedure AssignToStringList(Target: TStringList); override;
    28     procedure Produce(Module: TModule); override;
     28    procedure Produce(Module: TSourceModule); override;
    2929  end;
    3030
     
    3434{ TProducerXML }
    3535
    36 procedure TProducerXML.GenerateModule(Module: TModule);
     36procedure TProducerXML.GenerateModule(Module: TSourceModule);
    3737begin
    3838  Module.TargetFile := Module.Name + '.xml';
     
    5050end;
    5151
    52 procedure TProducerXML.GenerateUnit(Module: TModule);
     52procedure TProducerXML.GenerateUnit(Module: TSourceModule);
    5353begin
    5454  EmitLn('<?xml version="1.0"?>');
     
    5959end;
    6060
    61 procedure TProducerXML.GenerateLibrary(Module: TModule);
     61procedure TProducerXML.GenerateLibrary(Module: TSourceModule);
    6262begin
    6363  EmitLn('<?xml version="1.0"?>');
     
    6868end;
    6969
    70 procedure TProducerXML.GeneratePackage(Module: TModule);
     70procedure TProducerXML.GeneratePackage(Module: TSourceModule);
    7171begin
    7272  EmitLn('<?xml version="1.0"?>');
     
    7777end;
    7878
    79 procedure TProducerXML.Produce(Module: TModule);
     79procedure TProducerXML.Produce(Module: TSourceModule);
    8080begin
    8181  GenerateModule(Module);
  • trunk/Compiler/UAnalyzer.pas

    r65 r68  
    7777    procedure Process;
    7878    procedure Log(Text: string);
    79     function ParseModule(ProgramCode: TProgram): TModule; virtual; abstract;
     79    function ParseModule(ProgramCode: TProgram): TSourceModule; virtual; abstract;
    8080    property FileName: string read FFileName write FFileName;
    8181    property OnGetSource: TGetSourceEvent read FOnGetSource
  • trunk/Compiler/UCompiler.pas

    r66 r68  
    221221procedure TCompiler.ProduceAll;
    222222var
    223   NewModule: TModule;
     223  NewModule: TSourceModule;
    224224  ProducedCode: TStringList;
    225225  I: Integer;
     
    231231    with AbstractCode do
    232232    for I := 0 to Modules.Count - 1 do begin
    233       Target.Producer.Produce(TModule(Modules[I]));
     233      Target.Producer.Produce(TSourceModule(Modules[I]));
    234234      Target.Producer.AssignToStringList(ProducedCode);
    235       TargetFileName := TargetFolder + DirectorySeparator + TModule(Modules[I]).TargetFile;
     235      TargetFileName := TargetFolder + DirectorySeparator + TSourceModule(Modules[I]).TargetFile;
    236236      if Assigned(Target.Producer.OnWriteTarget) then
    237237        Target.Producer.OnWriteTarget(TargetFileName, ProducedCode.Text);
  • trunk/Compiler/UProducer.pas

    r61 r68  
    3030    procedure EmitLn(AText: string = '');
    3131    procedure AssignToStringList(Target: TStringList); virtual; abstract;
    32     procedure Produce(Module: TModule); virtual; abstract;
     32    procedure Produce(Module: TSourceModule); virtual; abstract;
    3333    procedure ExternalExecute(CommandLine: string);
    3434    constructor Create;
  • trunk/Compiler/USourceCode.pas

    r63 r68  
    3131  TVariable = class;
    3232  TConstant = class;
    33   TModule = class;
     33  TSourceModule = class;
    3434  TProgram = class;
    3535
     
    149149    Name: string;
    150150    Parent: TCommonBlock;
    151     ParentModule: TModule;
     151    ParentModule: TSourceModule;
    152152    Constants: TConstantList;
    153153    Types: TTypeList;
     
    322322    Name: string;
    323323    Location: string;
    324     Module: TModule;
     324    Module: TSourceModule;
    325325    Exported: Boolean;
    326326  end;
     
    330330
    331331  TUsedModuleList = class(TListUsedModule)
    332     ParentModule: TModule;
    333   end;
    334 
    335   { TModule }
    336 
    337   TModule = class
     332    ParentModule: TSourceModule;
     333  end;
     334
     335  { TSourceModule }
     336
     337  TSourceModule = class
    338338  public
    339339    ParentProgram: TProgram;
     
    342342    UsedModules: TUsedModuleList;
    343343    Body: TCommonBlock;
     344    Internal: Boolean;
    344345    function SearchVariable(Name: string; Outside: Boolean): TVariable; virtual;
    345346    function SearchConstant(Name: string; Outside: Boolean): TConstant; virtual;
     
    352353  { TModuleProgram }
    353354
    354   TModuleProgram = class(TModule)
     355  TModuleProgram = class(TSourceModule)
    355356    constructor Create;
    356357    destructor Destroy; override;
     
    359360  { TModuleUnit }
    360361
    361   TModuleUnit = class(TModule)
     362  TModuleUnit = class(TSourceModule)
    362363    InititializeSection: TCommonBlock;
    363364    FinalalizeSection: TCommonBlock;
     
    366367  end;
    367368
    368   TModulePackage = class(TModule)
    369 
    370   end;
    371 
    372   TModuleLibrary = class(TModule)
     369  TModulePackage = class(TSourceModule)
     370
     371  end;
     372
     373  TModuleLibrary = class(TSourceModule)
    373374  end;
    374375
     
    379380
    380381  TModuleList = class(TListModule)
    381     function Search(Name: string): TModule;
     382    function Search(Name: string): TSourceModule;
    382383  end;
    383384
     
    387388    Device: TDevice;
    388389    Modules: TModuleList;
    389     MainModule: TModule;
     390    MainModule: TSourceModule;
    390391    procedure Clear;
    391392    constructor Create;
     
    470471end;
    471472
    472 { TModule }
    473 
    474 constructor TModule.Create;
     473{ TSourceModule }
     474
     475constructor TSourceModule.Create;
    475476begin
    476477  inherited;
     
    481482end;
    482483
    483 destructor TModule.Destroy;
     484destructor TSourceModule.Destroy;
    484485begin
    485486  Body.Free;
     
    790791{ TModuleList }
    791792
    792 function TModuleList.Search(Name: string): TModule;
     793function TModuleList.Search(Name: string): TSourceModule;
    793794var
    794795  I: Integer;
    795796begin
    796797  I := 0;
    797   while (I < Count) and (LowerCase(TModule(Items[I]).Name) <> LowerCase(Name)) do Inc(I);
    798   if I < Count then Result := TModule(Items[I])
     798  while (I < Count) and (LowerCase(TSourceModule(Items[I]).Name) <> LowerCase(Name)) do Inc(I);
     799  if I < Count then Result := TSourceModule(Items[I])
    799800    else Result := nil;
    800801end;
     
    802803{ TModuleProgram }
    803804
    804 function TModule.SearchVariable(Name: string; Outside: Boolean): TVariable;
     805function TSourceModule.SearchVariable(Name: string; Outside: Boolean): TVariable;
    805806var
    806807  I: Integer;
     
    817818end;
    818819
    819 function TModule.SearchConstant(Name: string; Outside: Boolean): TConstant;
    820 begin
    821 
    822 end;
    823 
    824 function TModule.SearchType(AName: string; Outside: Boolean): TType;
     820function TSourceModule.SearchConstant(Name: string; Outside: Boolean): TConstant;
     821begin
     822
     823end;
     824
     825function TSourceModule.SearchType(AName: string; Outside: Boolean): TType;
    825826var
    826827  I: Integer;
     
    840841end;
    841842
    842 function TModule.SearchFunction(Name: string; Outside: Boolean): TFunction;
     843function TSourceModule.SearchFunction(Name: string; Outside: Boolean): TFunction;
    843844var
    844845  I: Integer;
Note: See TracChangeset for help on using the changeset viewer.