Ignore:
Timestamp:
Aug 10, 2010, 10:14:57 AM (14 years ago)
Author:
george
Message:

Project renamed to Transpascal.
Added support for generatin cycle For-to-do.
Added support for parsing and generating structured types as record and array.
Emit procedure in TProducerPascal and TProducerC reworked.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/DelphiToC/Produce/UProducerTreeView.pas

    r52 r53  
    2222    procedure AddNodeTypeRecord(Node: TTreeNode; TypeRecord: TTypeRecord);
    2323    procedure AddNodeTypeList(Node: TTreeNode; Types: TTypeList);
     24    procedure AddNodeType(Node: TTreeNode; AType: TType);
    2425    procedure AddNodeVariableList(Node: TTreeNode; Variables: TVariableList);
    2526    procedure AddNodeConstantList(Node: TTreeNode; Constants: TConstantList);
     
    5657  NewNode: TTreeNode;
    5758  NewNode2: TTreeNode;
    58   NewNode3: TTreeNode;
    59   I: Integer;
    6059begin
    6160  NewNode := TreeView.Items.AddChild(Node, 'while');
     
    194193var
    195194  NewNode: TTreeNode;
    196   NewNode2: TTreeNode;
    197   NewNode3: TTreeNode;
    198195  I: Integer;
    199196begin
     
    202199    for I := 0 to Types.Count - 1 do
    203200    with TType(Types[I]) do
    204     if not System then begin
    205       if TType(Types[I]) is TTypeRecord then begin
    206         NewNode2 := TreeView.Items.AddChild(NewNode, Name + ' = record');
    207         AddNodeTypeRecord(NewNode2, TTypeRecord(Types[I]));
    208       end else if Assigned(UsedType) then
    209         NewNode2 := TreeView.Items.AddChild(NewNode, Name + ' = ' + UsedType.Name)
    210       else NewNode2 := TreeView.Items.AddChild(NewNode, Name);
    211     end;
     201    if not System then AddNodeType(NewNode, TType(Types[I]));
     202  end;
     203end;
     204
     205procedure TProducerTreeView.AddNodeType(Node: TTreeNode; AType: TType);
     206var
     207  NewNode: TTreeNode;
     208  NewNode2: TTreeNode;
     209begin
     210  with AType do begin
     211    if AType is TTypeRecord then begin
     212      NewNode := TreeView.Items.AddChild(Node, Name + ' = record');
     213      AddNodeTypeRecord(NewNode, TTypeRecord(AType));
     214    end else
     215    if AType is TTypeArray then begin
     216      NewNode := TreeView.Items.AddChild(Node, Name + ' = array');
     217      if Assigned(TTypeArray(AType).IndexType) then begin
     218        NewNode2 := TreeView.Items.AddChild(NewNode, 'Index');
     219        AddNodeType(NewNode2, TTypeArray(AType).IndexType);
     220      end;
     221      if Assigned(TTypeArray(AType).ItemType) then begin
     222        NewNode2 := TreeView.Items.AddChild(NewNode, 'ItemType');
     223        AddNodeType(NewNode2, TTypeArray(AType).ItemType);
     224      end;
     225    end else if Assigned(UsedType) then
     226      NewNode := TreeView.Items.AddChild(Node, Name + ' = ' + UsedType.Name)
     227    else NewNode := TreeView.Items.AddChild(Node, Name);
    212228  end;
    213229end;
     
    217233var
    218234  NewNode: TTreeNode;
    219   NewNode2: TTreeNode;
    220235  I: Integer;
    221236begin
     
    253268  );
    254269var
    255   NewNode: TTreeNode;
    256   NewNode2: TTreeNode;
    257   NewNode3: TTreeNode;
    258270  I: Integer;
    259271begin
     
    261273    for I := 0 to TypeRecord.Items.Count - 1 do
    262274    with TType(TypeRecord.Items[I]) do
    263     if not System then begin
    264       if TType(TypeRecord.Items[I]) is TTypeRecord then begin
    265         NewNode2 := TreeView.Items.AddChild(NewNode, Name + ' = record');
    266         AddNodeTypeRecord(NewNode2, TTypeRecord(TypeRecord.Items[I]))
    267       end else if Assigned(UsedType) then
    268         NewNode2 := TreeView.Items.AddChild(NewNode, Name + ' = ' + UsedType.Name)
    269       else NewNode2 := TreeView.Items.AddChild(NewNode, Name);
    270     end;
     275    if not System then
     276      AddNodeType(Node, TType(TypeRecord.Items[I]));
    271277  end;
    272278end;
Note: See TracChangeset for help on using the changeset viewer.