Changeset 54 for branches/DelphiToC/Produce/UProducerPascal.pas
- Timestamp:
- Aug 10, 2010, 11:54:18 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DelphiToC/Produce/UProducerPascal.pas
r53 r54 38 38 IndentationLength: Integer; 39 39 Indetation: Integer; 40 procedure Produce ; override;40 procedure Produce(Module: TModule; ProducedCode: TStringList); override; 41 41 constructor Create; 42 42 destructor Destroy; override; … … 49 49 constructor TProducerPascal.Create; 50 50 begin 51 TextSource := TStringList.Create;52 51 IndentationLength := 2; 53 52 end; … … 55 54 destructor TProducerPascal.Destroy; 56 55 begin 57 TextSource.Free;58 56 inherited; 59 57 end; … … 86 84 procedure TProducerPascal.GenerateModule(Module: TModule); 87 85 begin 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 + ';'); 89 93 Emit(''); 90 94 GenerateUses(Module.UsedModules); … … 144 148 end; 145 149 146 procedure TProducerPascal.Produce ;150 procedure TProducerPascal.Produce(Module: TModule; ProducedCode: TStringList); 147 151 begin 148 152 inherited; 153 TextSource := ProducedCode; 149 154 TextSource.Clear; 150 Generate Program(ProgramCode);155 GenerateModule(Module); 151 156 end; 152 157 … … 183 188 Line := Line + ')'; 184 189 end; 185 if HaveResult then Line := Line + ': ' + ResultType.Name; 190 if HaveResult and Assigned(ResultType) then 191 Line := Line + ': ' + ResultType.Name; 186 192 Emit(Line + ';'); 187 193 GenerateBeginEnd(Code); … … 256 262 begin 257 263 with ForToDo do begin 264 if Assigned(ControlVariable) and Assigned(Start) and Assigned(Stop) then 258 265 Emit('for ' + ControlVariable.Name + ' := ' + 259 266 GenerateExpression(Start) + ' to ' + GenerateExpression(Stop) + ' do ');
Note:
See TracChangeset
for help on using the changeset viewer.