Ignore:
Timestamp:
Aug 9, 2010, 11:22:45 AM (14 years ago)
Author:
george
Message:

Added pascal producer code.
Added selection combobox for producer type.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/DelphiToC/UMainForm.pas

    r42 r46  
    88  SysUtils, Variants, Classes, Graphics, Controls, Forms,
    99  Dialogs, StdCtrls, UPascalSource, UPascalCompiler, UAssemblerSource,
    10   UCSource, ComCtrls, USourceTree;
     10  UProducerC, ComCtrls, SynEdit, SynHighlighterPas, USourceTree,
     11  UProducerPascal;
    1112
    1213const
     
    1415
    1516type
     17
     18  { TMainForm }
     19
    1620  TMainForm = class(TForm)
    17     Memo1: TMemo;
    1821    Button1: TButton;
     22    ComboBox1: TComboBox;
    1923    Memo2: TMemo;
    2024    Memo3: TMemo;
     25    SynEdit1: TSynEdit;
     26    SynPasSyn1: TSynPasSyn;
    2127    TreeView1: TTreeView;
     28    procedure ComboBox1Change(Sender: TObject);
    2229    procedure FormShow(Sender: TObject);
    2330    procedure FormClose(Sender: TObject; var Action: TCloseAction);
     
    4653begin
    4754  MainForm.Memo3.Clear;
    48   Compiler.SourceCode.Assign(Memo1.Lines);
    49   Compiler.Compile;
     55  Compiler.SourceCode.Assign(SynEdit1.Lines);
     56
     57  Memo2.Clear;
     58  if ComboBox1.ItemIndex = 0 then begin
     59    Compiler.Producer.Free;
     60    Compiler.Producer := TProducerPascal.Create;
     61    Compiler.Producer.ProgramCode := Compiler.ProgramCode;
     62    Compiler.Compile;
     63    with TProducerPascal(Compiler.Producer) do
     64      Memo2.Lines.Assign(TextSource);
     65  end else
     66  if ComboBox1.ItemIndex = 1 then begin
     67    Compiler.Producer.Free;
     68    Compiler.Producer := TCProducer.Create;
     69    Compiler.Producer.ProgramCode := Compiler.ProgramCode;
     70    Compiler.Compile;
     71    with TCProducer(Compiler.Producer) do
     72      Memo2.Lines.Assign(TextSource);
     73  end else
     74  if ComboBox1.ItemIndex = 2 then begin
     75    Compiler.Producer.Free;
     76    Compiler.Producer := TAssemblerProducer.Create;
     77    Compiler.Producer.ProgramCode := Compiler.ProgramCode;
     78    Compiler.Compile;
     79    with TAssemblerProducer(Compiler.Producer) do
     80    for I := 0 to AssemblyCode.Count - 1 do
     81      Memo2.Lines.Add(TAssemblerLine(AssemblyCode[I]).AsString);
     82  end;
     83
    5084  SourceTree.TreeView := TreeView1;
    5185  SourceTree.Code := Compiler.ProgramCode;
    5286  SourceTree.Fill;
    53   Memo2.Clear;
    54   if Compiler.Producer is TAssemblerProducer then begin
    55     with TAssemblerProducer(Compiler.Producer) do
    56     for I := 0 to AssemblyCode.Count - 1 do
    57       Memo2.Lines.Add(TAssemblerLine(AssemblyCode[I]).AsString);
    58   end else
    59   if Compiler.Producer is TCProducer then begin
    60     with TCProducer(Compiler.Producer) do
    61       Memo2.Lines.Assign(TextSource);
    62   end;
    6387end;
    6488
     
    7094procedure TMainForm.FormClose(Sender: TObject; var Action: TCloseAction);
    7195begin
    72   Memo1.Lines.SaveToFile(ExampleFileName);
     96  SynEdit1.Lines.SaveToFile(ExampleFileName);
    7397end;
    7498
     
    89113begin
    90114  WindowState := wsMaximized;
    91   Memo1.Lines.LoadFromFile(ExampleFileName);
     115  SynEdit1.Lines.LoadFromFile(ExampleFileName);
     116  Button1Click(Self);
     117end;
     118
     119procedure TMainForm.ComboBox1Change(Sender: TObject);
     120begin
    92121  Button1Click(Self);
    93122end;
Note: See TracChangeset for help on using the changeset viewer.