visitBlock method
dynamic
visitBlock(
- BlockStatement node
)
Implementation
@override
visitBlock(BlockStatement node) {
dynamic rtn;
final lexicalContext = _LexicalContext();
for (Statement stmt in node.body) {
if (stmt is VariableDeclaration && stmt.kind != 'var') {
for (final declarator in stmt.declarations) {
for (final name in _bindingNames(declarator.name)) {
lexicalContext.declare(name.value, mutable: stmt.kind != 'const');
}
}
}
}
_lexicalContexts.add(lexicalContext);
// Hoist function declarations in this block before executing statements.
try {
for (Statement stmt in node.body) {
if (stmt is FunctionDeclaration && stmt.function.name != null) {
addToThisContext(
stmt.function.name!, visitFunctionNode(stmt.function));
}
}
for (Node stmt in node.body) {
rtn = stmt.visitBy(this);
}
return rtn;
} finally {
_lexicalContexts.removeLast();
}
}