Ignore:
Timestamp:
Nov 8, 2010, 2:14:13 PM (14 years ago)
Author:
george
Message:
  • Modified: Enhanced Delphi producer.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Compiler/Produce/UProducer.pas

    r12 r17  
    77
    88uses
    9   USourceCode, Classes, SysUtils;
     9  USourceCode, Classes, SysUtils, StrUtils;
    1010
    1111type
     12
     13  { TProducer }
     14
    1215  TProducer = class
    1316    Name: string;
     17    TextSource: TStringList;
     18    IndentationLength: Integer;
     19    Indetation: Integer;
     20    procedure Emit(AText: string);
     21    procedure EmitLn(AText: string = '');
    1422    procedure AssignToStringList(Target: TStringList); virtual; abstract;
    1523    procedure Produce(Module: TModule); virtual; abstract;
     24    constructor Create;
     25    destructor Destroy; override;
    1626  end;
    1727
     
    4151{$I 'GenericObjectList.inc'}
    4252
     53{ TProducer }
     54
     55procedure TProducer.EmitLn(AText: string = '');
     56begin
     57  Emit(AText);
     58  TextSource.Add('');
     59end;
     60
     61constructor TProducer.Create;
     62begin
     63  TextSource := TStringList.Create;
     64  IndentationLength := 2;
     65end;
     66
     67destructor TProducer.Destroy;
     68begin
     69  TextSource.Free;
     70  inherited Destroy;
     71end;
     72
     73procedure TProducer.Emit(AText: string);
     74begin
     75  with TextSource do begin
     76    if Count = 0 then Add('');
     77    if Strings[Count - 1] = '' then
     78      Strings[Count - 1] := Strings[Count - 1] + DupeString(' ', IndentationLength * Indetation);
     79    Strings[Count - 1] := Strings[Count - 1] + AText;
     80  end;
     81end;
     82
    4383end.
Note: See TracChangeset for help on using the changeset viewer.