Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using a local clone.

dmd.dfa.fast.statement

Statement walker for the fast Data Flow Analysis engine.
This module implements the AST visitor that handles Control Flow. It is responsible for:
  1. Managing Scopes: Pushing and popping DFAScope as it enters/leaves blocks.
  2. Handling Branching: Splitting execution for if and switch statements.
  3. Handling Loops: Managing state for for, while, and do loops.
  4. Handling Jumps: Resolving break, continue, goto, and return.
class StatementWalker: dmd.visitor.SemanticTimeTransitiveVisitor;
Visits Statement nodes to drive the Data Flow Analysis.
This class navigates the structure of the function. When it encounters control flow (like an if statement), it acts as a traffic director:
  1. It creates a new Scope for the "True" branch.
  2. It analyzes that branch.
  3. It creates a new Scope for the "False" branch.
  4. It analyzes that branch.
  5. It calls analyzer.converge... to merge the results back together.
final void isBranchTakenIf(ref DFALatticeRef trueLR, ref DFALatticeRef falseLR, IfStatement ifs, out bool forTrue, out bool forFalse);
Check if a if statement will be branched into by a goto or by the condition
final bool isBranchTaken(ref DFALatticeRef condition, Statement stmt);
Check if a statement will be branched into either by a goto or by the condition.
final bool isBranchTaken(Statement stmt);
Check if a statement will be branched into either by a goto.