Changeset 17 for trunk/Compiler/Produce/UProducer.pas
- Timestamp:
- Nov 8, 2010, 2:14:13 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Compiler/Produce/UProducer.pas
r12 r17 7 7 8 8 uses 9 USourceCode, Classes, SysUtils ;9 USourceCode, Classes, SysUtils, StrUtils; 10 10 11 11 type 12 13 { TProducer } 14 12 15 TProducer = class 13 16 Name: string; 17 TextSource: TStringList; 18 IndentationLength: Integer; 19 Indetation: Integer; 20 procedure Emit(AText: string); 21 procedure EmitLn(AText: string = ''); 14 22 procedure AssignToStringList(Target: TStringList); virtual; abstract; 15 23 procedure Produce(Module: TModule); virtual; abstract; 24 constructor Create; 25 destructor Destroy; override; 16 26 end; 17 27 … … 41 51 {$I 'GenericObjectList.inc'} 42 52 53 { TProducer } 54 55 procedure TProducer.EmitLn(AText: string = ''); 56 begin 57 Emit(AText); 58 TextSource.Add(''); 59 end; 60 61 constructor TProducer.Create; 62 begin 63 TextSource := TStringList.Create; 64 IndentationLength := 2; 65 end; 66 67 destructor TProducer.Destroy; 68 begin 69 TextSource.Free; 70 inherited Destroy; 71 end; 72 73 procedure TProducer.Emit(AText: string); 74 begin 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; 81 end; 82 43 83 end.
Note:
See TracChangeset
for help on using the changeset viewer.