opensLexicalFrame function

bool opensLexicalFrame(
  1. AstNode node
)

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 S1 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(AstNode node) {
  return node is Block ||
      node is ForStatement ||
      node is ForElement ||
      node is WhileStatement ||
      node is DoStatement ||
      node is SwitchStatement ||
      node is SwitchExpression ||
      node is CatchClause ||
      node is FunctionExpression ||
      node is MethodDeclaration ||
      node is ConstructorDeclaration;
}