Ignore:
Timestamp:
Apr 9, 2009, 2:08:56 PM (16 years ago)
Author:
george
Message:
  • Přidáno: Nástřel parsování funkcí.
  • Přidáno: Zobrazení stromu struktury programu.
  • Opraveno: Zobrazení chybových hlášení.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/DelphiToC/UMainForm.pas

    r14 r19  
    55uses
    66  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
    7   Dialogs, StdCtrls, UPascalSource, UPascalCompiler, UAssemblerSource;
     7  Dialogs, StdCtrls, UPascalSource, UPascalCompiler, UAssemblerSource,
     8  UCSource, ComCtrls;
    89
    910type
     
    1314    Memo2: TMemo;
    1415    Memo3: TMemo;
     16    TreeView1: TTreeView;
    1517    procedure FormShow(Sender: TObject);
    1618    procedure FormClose(Sender: TObject; var Action: TCloseAction);
     
    2022    procedure ErrorMessage(Text: string);
    2123  private
    22     { Private declarations }
     24    procedure FillTreeView;
    2325  public
    2426    Compiler: TCompiler;
     
    4143  Compiler.SourceCode.Assign(Memo1.Lines);
    4244  Compiler.Compile;
     45  FillTreeView;
    4346  Memo2.Clear;
    44   with TAssemblerProducer(Compiler.Producer) do
    45   for I := 0 to AssemblyCode.Count - 1 do
    46     Memo2.Lines.Add(TAssemblerLine(AssemblyCode[I]).AsString);
     47  if Compiler.Producer is TAssemblerProducer then begin
     48    with TAssemblerProducer(Compiler.Producer) do
     49    for I := 0 to AssemblyCode.Count - 1 do
     50      Memo2.Lines.Add(TAssemblerLine(AssemblyCode[I]).AsString);
     51  end else
     52  if Compiler.Producer is TCProducer then begin
     53    with TCProducer(Compiler.Producer) do
     54      Memo2.Lines.Assign(TextSource);
     55  end;
    4756end;
    4857
     
    5059begin
    5160  MainForm.Memo3.Lines.Add(Text);
     61end;
     62
     63procedure TMainForm.FillTreeView;
     64var
     65  NewNode: TTreeNode;
     66  NewNode2: TTreeNode;
     67  ModuleNode: TTreeNode;
     68  I: Integer;
     69  M: Integer;
     70begin
     71  with TreeView1, Items, Compiler do begin
     72    BeginUpdate;
     73    Clear;
     74    AddChild(nil, 'Projekt');
     75    for M := 0 to ProgramCode.Modules.Count - 1 do
     76      with TModule(ProgramCode.Modules[M]) do begin
     77        ModuleNode := AddChild(TopItem, Name);
     78        NewNode := AddChild(ModuleNode, 'Typy');
     79        for I := 0 to Types.Count - 1 do
     80        with TType(Types[I]) do
     81          NewNode2 := AddChild(NewNode, Name);
     82        NewNode := AddChild(ModuleNode, 'Funkce');
     83        for I := 0 to Methods.Count - 1 do
     84        with TFunction(Methods[I]) do
     85          NewNode2 := AddChild(NewNode, Name);
     86        NewNode := AddChild(ModuleNode, 'Promìnné');
     87        for I := 0 to Variables.Count - 1 do
     88        with TVariable(Variables[I]) do
     89          NewNode2 := AddChild(NewNode, Name);
     90        NewNode := AddChild(ModuleNode, 'Konstanty');
     91        for I := 0 to Constants.Count - 1 do
     92        with TConstant(Constants[I]) do
     93          NewNode2 := AddChild(NewNode, Name);
     94        NewNode := AddChild(ModuleNode, 'Program');
     95      end;
     96    TopItem.Expand(True);
     97    EndUpdate;
     98  end;
    5299end;
    53100
Note: See TracChangeset for help on using the changeset viewer.