Ignore:
Timestamp:
Aug 10, 2010, 11:54:18 AM (14 years ago)
Author:
george
Message:

Added support for multiple source files and compilations for multiple modules in Project.pas

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/DelphiToC/Produce/UProducerPascal.pas

    r53 r54  
    3838    IndentationLength: Integer;
    3939    Indetation: Integer;
    40     procedure Produce; override;
     40    procedure Produce(Module: TModule; ProducedCode: TStringList); override;
    4141    constructor Create;
    4242    destructor Destroy; override;
     
    4949constructor TProducerPascal.Create;
    5050begin
    51   TextSource := TStringList.Create;
    5251  IndentationLength := 2;
    5352end;
     
    5554destructor TProducerPascal.Destroy;
    5655begin
    57   TextSource.Free;
    5856  inherited;
    5957end;
     
    8684procedure TProducerPascal.GenerateModule(Module: TModule);
    8785begin
    88   Emit('program ' + Module.Name + ';');
     86  case Module.ModuleType of
     87    mdProgram: Emit('program', False);
     88    mdUnit: Emit('unit', False);
     89    mdLibrary: Emit('library', False);
     90    mdPackage: Emit('package', False);
     91  end;
     92  Emit(' ' + Module.Name + ';');
    8993  Emit('');
    9094  GenerateUses(Module.UsedModules);
     
    144148end;
    145149
    146 procedure TProducerPascal.Produce;
     150procedure TProducerPascal.Produce(Module: TModule; ProducedCode: TStringList);
    147151begin
    148152  inherited;
     153  TextSource := ProducedCode;
    149154  TextSource.Clear;
    150   GenerateProgram(ProgramCode);
     155  GenerateModule(Module);
    151156end;
    152157
     
    183188      Line := Line + ')';
    184189    end;
    185     if HaveResult then Line := Line + ': ' + ResultType.Name;
     190    if HaveResult and Assigned(ResultType) then
     191      Line := Line + ': ' + ResultType.Name;
    186192    Emit(Line + ';');
    187193    GenerateBeginEnd(Code);
     
    256262begin
    257263  with ForToDo do begin
     264    if Assigned(ControlVariable) and Assigned(Start) and Assigned(Stop) then
    258265    Emit('for ' + ControlVariable.Name + ' := ' +
    259266      GenerateExpression(Start) + ' to ' + GenerateExpression(Stop) + ' do ');
Note: See TracChangeset for help on using the changeset viewer.