classFlowFacts
final class FlowFacts
Derives the flow control statements of stored programs.
Rule: MYSQL-PROGRAM-FLOW-001. The expression of every IF, ELSEIF, WHEN, WHILE, UNTIL and RETURN is derived in the scope of the statement, where parameters and local variables resolve as values; the nested statements are derived in the same scope, inside a loop with the label of the loop added (MYSQL-PROGRAM-LABELS-001). LEAVE needs an enclosing block or loop with its label, ITERATE an enclosing loop (ER_SP_LILABEL_MISMATCH). RETURN outside a stored function is reported (ER_SP_BADRETURN). Terminates: nested statements are strict parts. Source: https://dev.mysql.com/doc/refman/8.4/en/flow-control-statements.html. Status: Implemented.
Methods§
public function branches(
list<ConditionalBranch> $branches,
list<Node> $otherwise,
Derivation $derivation,
ProgramScope $scope,
): voidDerives the branches of IF or CASE and the statements of ELSE.
Parameters
$branches | list<ConditionalBranch> | |
$otherwise | list<Node> | |
$derivation | Derivation | |
$scope | ProgramScope |
Called from 3
- method-call SqlSemantics\Platform\MySql\Statement\Routine\Program\Flow\IfStatement::deriveProgram() packages/sql-semantics-mysql/src/Statement/Routine/Program/Flow/IfStatement.php:60
- method-call SqlSemantics\Platform\MySql\Statement\Routine\Program\Flow\SearchedCase::deriveProgram() packages/sql-semantics-mysql/src/Statement/Routine/Program/Flow/SearchedCase.php:59
- method-call SqlSemantics\Platform\MySql\Statement\Routine\Program\Flow\SimpleCase::deriveProgram() packages/sql-semantics-mysql/src/Statement/Routine/Program/Flow/SimpleCase.php:64
Calls 3
- method-call Derivation::scalar() line 43
- method-call BodyFacts::statements() line 44
- new BodyFacts line 44
public function loop(
?Name $label,
?Name $end,
?Scalar $condition,
list<Node> $statements,
Derivation $derivation,
ProgramScope $scope,
): voidDerives a loop: its labels, its condition when it has one, and its statements.
Parameters
$label | ?Name | |
$end | ?Name | |
$condition | ?Scalar | |
$statements | list<Node> | |
$derivation | Derivation | |
$scope | ProgramScope |
Called from 3
- method-call SqlSemantics\Platform\MySql\Statement\Routine\Program\Flow\Loop::deriveProgram() packages/sql-semantics-mysql/src/Statement/Routine/Program/Flow/Loop.php:57
- method-call SqlSemantics\Platform\MySql\Statement\Routine\Program\Flow\RepeatLoop::deriveProgram() packages/sql-semantics-mysql/src/Statement/Routine/Program/Flow/RepeatLoop.php:59
- method-call SqlSemantics\Platform\MySql\Statement\Routine\Program\Flow\WhileLoop::deriveProgram() packages/sql-semantics-mysql/src/Statement/Routine/Program/Flow/WhileLoop.php:59
Calls 5
- method-call LabelFacts::enter() line 56
- new LabelFacts line 56
- method-call Derivation::scalar() line 58
- method-call BodyFacts::statements() line 60
- new BodyFacts line 60
public function jump(
Name $label,
bool $iterate,
Derivation $derivation,
ProgramScope $scope,
): voidChecks the label of LEAVE, or of ITERATE when a loop is required.
Parameters
$label | Name | |
$iterate | bool | |
$derivation | Derivation | |
$scope | ProgramScope |
Called from 2
- method-call SqlSemantics\Platform\MySql\Statement\Routine\Program\Flow\Iterate::deriveProgram() packages/sql-semantics-mysql/src/Statement/Routine/Program/Flow/Iterate.php:43
- method-call SqlSemantics\Platform\MySql\Statement\Routine\Program\Flow\Leave::deriveProgram() packages/sql-semantics-mysql/src/Statement/Routine/Program/Flow/Leave.php:43
Calls 5
- method-call ProgramScope::holds() line 68
- method-call Derivation::report() line 71
- new ProgramProblem line 71
- class-const ProgramRule::IterateWithoutLabel() line 71
- class-const ProgramRule::LeaveWithoutLabel() line 71
public function returned(Scalar $value, Derivation $derivation, ProgramScope $scope): voidDerives the expression of RETURN and checks that the program is a function.
Parameters
$value | Scalar | |
$derivation | Derivation | |
$scope | ProgramScope |
Called from 1
Calls 5
- method-call Derivation::scalar() line 79
- class-const ProgramKind::Function() line 80
- method-call Derivation::report() line 81
- new ProgramProblem line 81
- class-const ProgramRule::ReturnOutsideFunction() line 81
Test cases 1§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 1
FlowFactsTestcalls
Relations§
Instantiated in 9
- new SqlSemantics\Platform\MySql\Statement\Routine\Program\Flow\IfStatement::deriveProgram() packages/sql-semantics-mysql/src/Statement/Routine/Program/Flow/IfStatement.php:60
- new SqlSemantics\Platform\MySql\Statement\Routine\Program\Flow\Iterate::deriveProgram() packages/sql-semantics-mysql/src/Statement/Routine/Program/Flow/Iterate.php:43
- new SqlSemantics\Platform\MySql\Statement\Routine\Program\Flow\Leave::deriveProgram() packages/sql-semantics-mysql/src/Statement/Routine/Program/Flow/Leave.php:43
- new SqlSemantics\Platform\MySql\Statement\Routine\Program\Flow\Loop::deriveProgram() packages/sql-semantics-mysql/src/Statement/Routine/Program/Flow/Loop.php:57
- new SqlSemantics\Platform\MySql\Statement\Routine\Program\Flow\RepeatLoop::deriveProgram() packages/sql-semantics-mysql/src/Statement/Routine/Program/Flow/RepeatLoop.php:59
- new SqlSemantics\Platform\MySql\Statement\Routine\Program\Flow\ReturnStatement::deriveProgram() packages/sql-semantics-mysql/src/Statement/Routine/Program/Flow/ReturnStatement.php:42
- new SqlSemantics\Platform\MySql\Statement\Routine\Program\Flow\SearchedCase::deriveProgram() packages/sql-semantics-mysql/src/Statement/Routine/Program/Flow/SearchedCase.php:59
- new SqlSemantics\Platform\MySql\Statement\Routine\Program\Flow\SimpleCase::deriveProgram() packages/sql-semantics-mysql/src/Statement/Routine/Program/Flow/SimpleCase.php:64
- new SqlSemantics\Platform\MySql\Statement\Routine\Program\Flow\WhileLoop::deriveProgram() packages/sql-semantics-mysql/src/Statement/Routine/Program/Flow/WhileLoop.php:59
Method calls 9
- method-call SqlSemantics\Platform\MySql\Statement\Routine\Program\Flow\IfStatement::deriveProgram() packages/sql-semantics-mysql/src/Statement/Routine/Program/Flow/IfStatement.php:60
- method-call SqlSemantics\Platform\MySql\Statement\Routine\Program\Flow\Iterate::deriveProgram() packages/sql-semantics-mysql/src/Statement/Routine/Program/Flow/Iterate.php:43
- method-call SqlSemantics\Platform\MySql\Statement\Routine\Program\Flow\Leave::deriveProgram() packages/sql-semantics-mysql/src/Statement/Routine/Program/Flow/Leave.php:43
- method-call SqlSemantics\Platform\MySql\Statement\Routine\Program\Flow\Loop::deriveProgram() packages/sql-semantics-mysql/src/Statement/Routine/Program/Flow/Loop.php:57
- method-call SqlSemantics\Platform\MySql\Statement\Routine\Program\Flow\RepeatLoop::deriveProgram() packages/sql-semantics-mysql/src/Statement/Routine/Program/Flow/RepeatLoop.php:59
- method-call SqlSemantics\Platform\MySql\Statement\Routine\Program\Flow\ReturnStatement::deriveProgram() packages/sql-semantics-mysql/src/Statement/Routine/Program/Flow/ReturnStatement.php:42
- method-call SqlSemantics\Platform\MySql\Statement\Routine\Program\Flow\SearchedCase::deriveProgram() packages/sql-semantics-mysql/src/Statement/Routine/Program/Flow/SearchedCase.php:59
- method-call SqlSemantics\Platform\MySql\Statement\Routine\Program\Flow\SimpleCase::deriveProgram() packages/sql-semantics-mysql/src/Statement/Routine/Program/Flow/SimpleCase.php:64
- method-call SqlSemantics\Platform\MySql\Statement\Routine\Program\Flow\WhileLoop::deriveProgram() packages/sql-semantics-mysql/src/Statement/Routine/Program/Flow/WhileLoop.php:59