Ignore:
Timestamp:
Apr 22, 2020, 9:00:02 AM (5 years ago)
Author:
chronos
Message:
  • Added: Executor support for Break and Continue statements.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/interpreter2/USource.pas

    r208 r211  
    3434    function GetFieldsCount: Integer; virtual;
    3535  public
     36    Parent: TSourceNode;
    3637    function GetField(Index: Integer): TField; virtual;
    3738    procedure GetValue(Index: Integer; out Value); virtual;
     
    5455  TSourceNodes = class(TSourceNode)
    5556  private
     57    Parent: TSourceNode;
    5658    function GetCount: Integer;
    5759    function GetItem(Index: Integer): TObject;
     
    316318  end;
    317319
     320  TLoop = class(TCommand)
     321    DoBreak: Boolean;
     322    DoContinue: Boolean;
     323  end;
     324
    318325  { TWhileDo }
    319326
    320   TWhileDo = class(TCommand)
     327  TWhileDo = class(TLoop)
    321328  private
    322329    function GetFieldsCount: Integer; override;
     
    333340  { TRepeatUntil }
    334341
    335   TRepeatUntil = class(TCommand)
     342  TRepeatUntil = class(TLoop)
    336343  private
    337344    function GetFieldsCount: Integer; override;
     
    354361  { TForToDo }
    355362
    356   TForToDo = class(TCommand)
     363  TForToDo = class(TLoop)
    357364  private
    358365    function GetFieldsCount: Integer; override;
     
    375382    function GetFieldsCount: Integer; override;
    376383  public
    377     Parent: TBlock;
     384    ParentBlock: TBlock;
    378385    Variables: TVariables;
    379386    Constants: TConstants;
     
    12341241begin
    12351242  Result := Types.SearchByName(Name);
    1236   if not Assigned(Result) and Assigned(Parent) then
    1237     Result := Parent.Types.SearchByName(Name);
     1243  if not Assigned(Result) and Assigned(ParentBlock) then
     1244    Result := ParentBlock.Types.SearchByName(Name);
    12381245end;
    12391246
     
    12411248begin
    12421249  Result := Constants.SearchByName(Name);
    1243   if not Assigned(Result) and Assigned(Parent) then
    1244     Result := Parent.Constants.SearchByName(Name);
     1250  if not Assigned(Result) and Assigned(ParentBlock) then
     1251    Result := ParentBlock.Constants.SearchByName(Name);
    12451252end;
    12461253
     
    12481255begin
    12491256  Result := Variables.SearchByName(Name);
    1250   if not Assigned(Result) and Assigned(Parent) then
    1251     Result := Parent.Variables.SearchByName(Name);
     1257  if not Assigned(Result) and Assigned(ParentBlock) then
     1258    Result := ParentBlock.Variables.SearchByName(Name);
    12521259end;
    12531260
     
    12551262begin
    12561263  Result := Functions.SearchByName(Name);
    1257   if not Assigned(Result) and Assigned(Parent) then
    1258     Result := Parent.Functions.SearchByName(Name);
     1264  if not Assigned(Result) and Assigned(ParentBlock) then
     1265    Result := ParentBlock.Functions.SearchByName(Name);
    12591266end;
    12601267
Note: See TracChangeset for help on using the changeset viewer.