Changeset 18 for trunk/Compiler


Ignore:
Timestamp:
Nov 9, 2010, 8:10:12 AM (14 years ago)
Author:
george
Message:
Location:
trunk/Compiler
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Compiler/Analyze/UAnalyzerPascal.pas

    r17 r18  
    11981198      UseName := NextToken;
    11991199      if NextTokenType = ttIdentifier then begin
    1200         UseType := TypeList.Parent.Types.Search(UseName);
     1200        TTypeArray(Result).IndexType := TypeList.Parent.Types.Search(UseName);
    12011201        if not Assigned(TTypeArray(Result).IndexType) then
    12021202          ErrorMessage(SUndefinedType, [UseName], -1) else
     
    12041204      end else
    12051205      if NextTokenType = ttConstantNumber then begin
    1206         UseType := ParseTypeSubRange(TypeList, Name);
    1207         if not Assigned(UseType) then begin
     1206        TTypeArray(Result).IndexType := ParseTypeSubRange(TypeList, Name);
     1207        if not Assigned(TTypeArray(Result).IndexType) then begin
    12081208          ErrorMessage(SInvalidConstruction, [], -1);
    12091209        end;
  • trunk/Compiler/Produce/UProducerPascal.pas

    r17 r18  
    123123begin
    124124  if AType is TTypeRecord then begin
    125     EmitLn(AType.Name + ' ' + AssignSymbol + ' record');
     125    EmitLn('record');
    126126    Inc(Indetation);
    127     for I := 0 to TTypeRecord(AType).CommonBlock.Types.Count - 1 do begin
    128       GenerateType(TType(TTypeRecord(AType).CommonBlock.Types[I]));
     127    with TTypeRecord(AType).CommonBlock do
     128    for I := 0 to Variables.Count - 1 do begin
     129      Emit(Variables[I].Name + ': ');
     130      GenerateType(Variables[I].ValueType);
    129131      EmitLn(';');
    130132    end;
     
    132134    Emit('end');
    133135  end else
     136  if AType is TTypeSubRange then begin
     137    Emit(TTypeSubRange(AType).Bottom + '..' + TTypeSubRange(AType).Top);
     138  end else
    134139  if AType is TTypeArray then begin
    135     Emit(AType.Name + ' ' + AssignSymbol + ' array ');
     140    Emit('array ');
    136141    if Assigned(TTypeArray(AType).IndexType) then begin
    137142      Emit('[');
     
    142147    if Assigned(TTypeArray(AType).ItemType) then
    143148      GenerateType(TTypeArray(AType).ItemType);
     149  end else
     150  if AType is TTypePointer then begin
     151    Emit('^' + TTypePointer(AType).UsedType.Name);
    144152  end else begin
    145153    Emit(AType.Name);
    146     if Assigned(AType.UsedType) then begin
    147       Emit(' ' + AssignSymbol + ' ');
     154    if AType.Name = '' then begin
    148155      GenerateType(AType.UsedType);
    149156    end;
     
    161168    with TType(Types[I]) do
    162169    if (not Internal) then begin
    163       GenerateType(TType(Types[I]), '=');
     170      Emit(TType(Types[I]).Name + ' = ');
     171      GenerateType(TType(Types[I]));
    164172      EmitLn(';');
    165173    end;
Note: See TracChangeset for help on using the changeset viewer.