opensLexicalFrame function
Does node open a new runtime Environment frame?
This is the shared scope-frame predicate (plan_3 §4.4, risk R1): the
single decision the resolver and the interpreter must agree on. It is
deliberately over-approximating — it may return true for a construct
the interpreter happens not to wrap in its own frame. Over-approximation is
safe for the depth-0 resolver: modelling an extra frame only ever raises a
computed depth (suppressing a coordinate), never lowers it, so it can never
manufacture a false depth-0. Under-approximation (missing a frame the
interpreter does push) is the unsafe direction and is what this list guards
against by erring generous.
Implementation
bool opensLexicalFrame(SAstNode node) {
return node is SBlock ||
node is SForStatement ||
node is SForElement ||
node is SWhileStatement ||
node is SDoStatement ||
node is SSwitchStatement ||
node is SSwitchExpression ||
node is SCatchClause ||
node is SFunctionExpression ||
node is SMethodDeclaration ||
node is SConstructorDeclaration;
}