Ignore:
Timestamp:
Oct 21, 2010, 7:56:25 AM (14 years ago)
Author:
george
Message:
  • Modified: Parsing sections in record type.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/Transpascal/Compiler/Produce/UProducerC.pas

    r68 r75  
    2929    procedure GenerateFunctions(Functions: TFunctionList);
    3030    procedure GenerateBeginEnd(BeginEnd: TBeginEnd);
     31    procedure GenerateVariableList(VariableList: TVariableList);
     32    procedure GenerateVariable(Variable: TVariable);
    3133    procedure GenerateCommand(Command: TCommand);
    3234    procedure GenerateWhileDo(WhileDo: TWhileDo);
     
    123125    GenerateUses(TModuleProgram(Module).UsedModules);
    124126    GenerateCommonBlock(TModuleProgram(Module).Body, '');
     127  end else
     128  if Module is TModuleUnit then begin
     129    GenerateUses(TModuleProgram(Module).UsedModules);
     130    GenerateCommonBlock(TModuleUnit(Module).Body, '');
    125131  end;
    126132end;
     
    176182  Inc(Indetation);
    177183
    178 
    179184  // Variables
    180185  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);
    185187  end;
    186188
     
    191193  Dec(Indetation);
    192194  Emit('}');
     195end;
     196
     197procedure TProducerC.GenerateVariableList(VariableList: TVariableList);
     198var
     199  I: Integer;
     200begin
     201  for I := 0 to VariableList.Count - 1 do
     202    GenerateVariable(TVariable(VariableList[I]));
     203//  Emit('');
     204end;
     205
     206procedure TProducerC.GenerateVariable(Variable: TVariable);
     207begin
     208  with Variable do
     209    Emit(TranslateType(ValueType.Name) + ' ' + Name + ';');
    193210end;
    194211
     
    296313  if Assigned(AType) then begin
    297314  if AType is TTypeRecord then begin
    298     Emit('typedef struct');
     315    Emit('struct');
    299316    Emit('{');
    300317    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);
    305319    Dec(Indetation);
    306320    Emit('} ' + TranslateType(AType.Name), False);
     
    321335  end else begin
    322336    if Assigned(AType.UsedType) then begin
    323       GenerateType(AType.UsedType);
     337      //GenerateType(AType.UsedType);
     338      Emit(AType.UsedType.Name, False);
    324339      Emit(' ', False);
    325340    end;
     
    338353    with TType(Types[I]) do
    339354    if (not System) then begin
     355      Emit('typedef ', False);
    340356      GenerateType(TType(Types[I]));
    341357      Emit(';');
Note: See TracChangeset for help on using the changeset viewer.