Ignore:
Timestamp:
Jan 16, 2018, 3:19:23 PM (7 years ago)
Author:
chronos
Message:
  • Added: Support for begin end block.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/easy compiler/USourceExecutor.pas

    r141 r142  
    2828    FOnOutput: TOutputEvent;
    2929    Variables: TExecutorVariables;
     30    procedure ExecuteBeginEnd(BeginEnd: TSourceBeginEnd);
    3031  public
    3132    constructor Create;
     
    6869
    6970procedure TSourceExecutor.Execute(SourceCode: TSourceCode);
     71begin
     72  ExecuteBeginEnd(SourceCode.Main);
     73end;
     74
     75procedure TSourceExecutor.ExecuteBeginEnd(BeginEnd: TSourceBeginEnd);
    7076var
    7177  IP: Integer;
     
    96102begin
    97103  IP := 0;
    98   while IP < SourceCode.Instructions.Count do begin
    99     Instruction := TSourceInstruction(SourceCode.Instructions[IP]);
    100     if Instruction is TSourceInstructionFunction then
    101     with TSourceInstructionFunction(Instruction) do begin
     104  while IP < BeginEnd.Instructions.Count do begin
     105    Instruction := TSourceInstruction(BeginEnd.Instructions[IP]);
     106    if Instruction is TSourceFunctionCall then
     107    with TSourceFunctionCall(Instruction) do begin
    102108      if Name = 'print' then begin
    103109        if Assigned(FOnOutput) then begin
     
    156162        else raise Exception.Create('Wrong type for increment');
    157163      end else
    158       raise Exception.Create('Unsupported function: ' + TSourceInstructionFunction(Instruction).Name);
    159     end else raise Exception.Create('Unsupported instruction');
     164      raise Exception.Create('Unsupported function: ' + TSourceFunctionCall(Instruction).Name);
     165    end else
     166    if Instruction is TSourceBeginEnd then begin
     167      ExecuteBeginEnd(TSourceBeginEnd(Instruction));
     168    end else
     169    raise Exception.Create('Unsupported instruction');
    160170    Inc(IP);
    161171  end;
Note: See TracChangeset for help on using the changeset viewer.