REPEAT Statement

This procedure processes Repeat statement. It calls routine to process statements between tokens Repeat and until. Loop statements Break and Continue are also taken into account.
Procedure TStatement.Process_REPEAT_Statement;
Var UntilCondition: TExpression;
    Statement: TStatement;
    SavedLastJumpOutOfBlock, SavedLastJumpToNextBlockIteration: Word;
begin
  SavedLastJumpOutOfBlock := LastJumpOutOfBlock;
  SavedLastJumpToNextBlockIteration := LastJumpToNextBlockIteration;
  LastJumpOutOfBlock := 0;
  LastJumpToNextBlockIteration := 0;
  Statement.ProcessStatementsBetweenTokens (Token_REPEAT, Token_UNTIL);
  UntilCondition.ExpectBooleanExpression;
  If UntilCondition.Location = elConstant then
    begin
      UntilCondition.Value.LastJumpToFalse := 0;
      If UntilCondition.Value.Byte = 0 then
        begin                    { until False creates endless loop }
          GenerateCodeForNearJump (UntilCondition.Value.LastJumpToFalse, JMP_ShortDirect);
          UntilCondition.EndIntermediateCodeSubroutine;
        end;
    end;
  GenerateLabelAndSetJumpsToIt (UntilCondition.Value.LastJumpToFalse);
  StoreCode_icGoSub (Statement.StatementCode);
  GenerateLabelAndSetJumpsToIt (LastJumpToNextBlockIteration);
  StoreCode_icGoSub (UntilCondition.IntermediateCodeOffset);
  GenerateLabelAndSetJumpsToIt (LastJumpOutOfBlock);
  StatementCode := EndSubroutine;
  LastJumpOutOfBlock := SavedLastJumpOutOfBlock;
  LastJumpToNextBlockIteration := SavedLastJumpToNextBlockIteration;
end;
 
 
 
© 2017 Turbo Pascal | Privacy Policy