JavaScript: Model data flow of destructuring assignments more precisely.

This commit is contained in:
Max Schaefer
2018-10-10 08:36:21 +01:00
parent c577f6d9f8
commit d2993b9e04
5 changed files with 31 additions and 1 deletions

View File

@@ -67,7 +67,27 @@ private cached module Internal {
}
cached predicate defAt(BasicBlock bb, int i, Variable v, VarDef d) {
v = d.getAVariable() and bbIndex(bb, d, i)
exists (VarRef def |
def = d.getTarget().(BindingPattern).getABindingVarRef() and
v = def.getVariable() |
def = d.getTarget() and
bbIndex(bb, d, i)
or
exists (PropertyPattern pp |
def = pp.getValuePattern() and
bbIndex(bb, pp, i)
)
or
exists (ObjectPattern op |
def = op.getRest() and
bbIndex(bb, def, i)
)
or
exists (ArrayPattern ap |
def = ap.getAnElement() and
bbIndex(bb, def, i)
)
)
}
cached predicate reachableBB(BasicBlock bb) {