Changeset 75 for branches/Transpascal/Compiler/Produce/UProducerC.pas
- Timestamp:
- Oct 21, 2010, 7:56:25 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/Transpascal/Compiler/Produce/UProducerC.pas
r68 r75 29 29 procedure GenerateFunctions(Functions: TFunctionList); 30 30 procedure GenerateBeginEnd(BeginEnd: TBeginEnd); 31 procedure GenerateVariableList(VariableList: TVariableList); 32 procedure GenerateVariable(Variable: TVariable); 31 33 procedure GenerateCommand(Command: TCommand); 32 34 procedure GenerateWhileDo(WhileDo: TWhileDo); … … 123 125 GenerateUses(TModuleProgram(Module).UsedModules); 124 126 GenerateCommonBlock(TModuleProgram(Module).Body, ''); 127 end else 128 if Module is TModuleUnit then begin 129 GenerateUses(TModuleProgram(Module).UsedModules); 130 GenerateCommonBlock(TModuleUnit(Module).Body, ''); 125 131 end; 126 132 end; … … 176 182 Inc(Indetation); 177 183 178 179 184 // Variables 180 185 if BeginEnd.Parent is TCommonBlock then begin 181 for I := 0 to BeginEnd.CommonBlock.Variables.Count - 1 do 182 with TVariable(BeginEnd.CommonBlock.Variables[I]) do 183 Emit(TranslateType(ValueType.Name) + ' ' + Name + ';'); 184 Emit(''); 186 GenerateVariableList(BeginEnd.CommonBlock.Variables); 185 187 end; 186 188 … … 191 193 Dec(Indetation); 192 194 Emit('}'); 195 end; 196 197 procedure TProducerC.GenerateVariableList(VariableList: TVariableList); 198 var 199 I: Integer; 200 begin 201 for I := 0 to VariableList.Count - 1 do 202 GenerateVariable(TVariable(VariableList[I])); 203 // Emit(''); 204 end; 205 206 procedure TProducerC.GenerateVariable(Variable: TVariable); 207 begin 208 with Variable do 209 Emit(TranslateType(ValueType.Name) + ' ' + Name + ';'); 193 210 end; 194 211 … … 296 313 if Assigned(AType) then begin 297 314 if AType is TTypeRecord then begin 298 Emit(' typedefstruct');315 Emit('struct'); 299 316 Emit('{'); 300 317 Inc(Indetation); 301 for I := 0 to TTypeRecord(AType).CommonBlock.Types.Count - 1 do begin 302 GenerateType(TType(TTypeRecord(AType).CommonBlock.Types[I])); 303 Emit(';'); 304 end; 318 GenerateVariableList(TTypeRecord(AType).CommonBlock.Variables); 305 319 Dec(Indetation); 306 320 Emit('} ' + TranslateType(AType.Name), False); … … 321 335 end else begin 322 336 if Assigned(AType.UsedType) then begin 323 GenerateType(AType.UsedType); 337 //GenerateType(AType.UsedType); 338 Emit(AType.UsedType.Name, False); 324 339 Emit(' ', False); 325 340 end; … … 338 353 with TType(Types[I]) do 339 354 if (not System) then begin 355 Emit('typedef ', False); 340 356 GenerateType(TType(Types[I])); 341 357 Emit(';');
Note:
See TracChangeset
for help on using the changeset viewer.