Implement dataflow for record patterns

Strategy: there is now a regular flow step from an instance-of LHS / switch expr to the pattern, 0 or more read steps corresponding to record pattern destructors, and then finally a normal SSA def/use step connecting the binding patterns to their first uses.
This commit is contained in:
Chris Smowton
2023-11-01 20:33:09 +00:00
parent 05addde957
commit 20b97af02f
6 changed files with 55 additions and 3 deletions

View File

@@ -1639,7 +1639,11 @@ class LocalVariableDeclExpr extends Expr, @localvariabledeclexpr {
/** Gets the name of the variable declared by this local variable declaration expression. */
string getName() { result = this.getVariable().getName() }
/** Gets the switch statement or expression whose pattern declares this identifier, if any. */
/**
* Gets the switch statement or expression whose pattern declares this identifier, if any.
*
* Note this only applies to a direct binding pattern, such as `case T t`, not a record pattern.
*/
StmtParent getAssociatedSwitch() { result = this.getParent().(PatternCase).getParent() }
/** Holds if this is a declaration stemming from a pattern switch case. */