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/UExecutor.pas

    r205 r207  
    104104    procedure ExecuteRepeatUntil(Block: TExecutorBlock; RepeatUntil: TRepeatUntil);
    105105    procedure ExecuteForToDo(Block: TExecutorBlock; ForToDo: TForToDo);
     106    procedure ExecuteContinue(Block: TExecutorBlock; ContinueCmd: TContinue);
     107    procedure ExecuteBreak(Block: TExecutorBlock; BreakCmd: TBreak);
    106108    procedure ExecuteBlock(ParentBlock: TExecutorBlock; Block: TBlock);
    107109    function ExecuteFunctionCall(Block: TExecutorBlock; FunctionCall: TFunctionCall): TValue;
     
    435437  else if Command is TRepeatUntil then ExecuteRepeatUntil(Block, TRepeatUntil(Command))
    436438  else if Command is TForToDo then ExecuteForToDo(Block, TForToDo(Command))
     439  else if Command is TBreak then ExecuteBreak(Block, TBreak(Command))
     440  else if Command is TContinue then ExecuteContinue(Block, TContinue(Command))
     441  else if Command is TEmptyCommand then
    437442  else raise Exception.Create('Unsupported command type');
    438443end;
     
    446451  if Value is TValueBoolean then begin
    447452    if TValueBoolean(Value).Value then ExecuteCommand(Block, IfThenElse.CommandThen)
    448       else ExecuteCommand(Block, IfThenElse.CommandElse);
     453      else begin
     454        if not (IfThenElse.CommandElse is TCommand) then
     455          ExecuteCommand(Block, IfThenElse.CommandElse);
     456      end;
    449457  end else raise Exception.Create('Expected boolean value.');
    450458  Value.Free;
     
    497505  end;
    498506  Limit.Free;
     507end;
     508
     509procedure TExecutor.ExecuteContinue(Block: TExecutorBlock;
     510  ContinueCmd: TContinue);
     511begin
     512
     513end;
     514
     515procedure TExecutor.ExecuteBreak(Block: TExecutorBlock; BreakCmd: TBreak);
     516begin
     517
    499518end;
    500519
Note: See TracChangeset for help on using the changeset viewer.