Ignore:
Timestamp:
Apr 20, 2020, 11:31:59 PM (5 years ago)
Author:
chronos
Message:
  • Added: Optimizer class for implementation of various optimizations on AST.
  • Added: Transformation of repeat-until loop to while-do loop.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/interpreter2/UFormMain.pas

    r206 r207  
    1515  TFormMain = class(TForm)
    1616    ACompile: TAction;
     17    AOptimize: TAction;
    1718    AExit: TAction;
    1819    ARun: TAction;
     
    4041    procedure AGeneratePascalExecute(Sender: TObject);
    4142    procedure AGeneratePhpExecute(Sender: TObject);
     43    procedure AOptimizeExecute(Sender: TObject);
    4244    procedure ARunExecute(Sender: TObject);
    4345    procedure FormActivate(Sender: TObject);
     
    6668uses
    6769  UParser, UExecutor, UGeneratorPascal, UGeneratorPhp, UFormMessages, UFormSource,
    68   UGeneratorCSharp;
     70  UGeneratorCSharp, UOptimizer;
    6971
    7072{ TFormMain }
     
    121123begin
    122124  ACompile.Execute;
     125  AOptimize.Execute;
    123126  MemoOutput.Lines.Clear;
    124127  if Assigned(Prog) then begin
     
    137140begin
    138141  ACompile.Execute;
     142  AOptimize.Execute;
    139143  MemoOutput.Lines.Clear;
    140144  if Assigned(Prog) then begin
     
    164168end;
    165169
     170procedure TFormMain.AOptimizeExecute(Sender: TObject);
     171var
     172  Optimizer: TOptimizer;
     173begin
     174  if Assigned(Prog) then begin
     175    Optimizer := TOptimizer.Create;
     176    Optimizer.Prog := Prog;
     177    Optimizer.Optimize;
     178    Optimizer.Free;
     179  end;
     180end;
     181
    166182procedure TFormMain.ARunExecute(Sender: TObject);
    167183var
     
    169185begin
    170186  ACompile.Execute;
     187  //AOptimize.Execute;
    171188  MemoOutput.Lines.Clear;
    172189  if Assigned(Prog) then begin
Note: See TracChangeset for help on using the changeset viewer.