use of com.github.anba.es6draft.ast.scope.Scope in project es6draft by anba.
the class ExpressionGenerator method isGlobalThis.
private static boolean isGlobalThis(Scope currentScope) {
for (Scope scope = currentScope; ; ) {
TopLevelScope top = scope.getTop();
TopLevelNode<?> node = top.getNode();
if (node instanceof Script) {
return ((Script) node).isGlobalThis();
}
if (node instanceof Module) {
return true;
}
assert node instanceof FunctionNode : "class=" + node.getClass();
if (((FunctionNode) node).getThisMode() != FunctionNode.ThisMode.Lexical) {
return false;
}
scope = top.getEnclosingScope();
}
}
use of com.github.anba.es6draft.ast.scope.Scope in project es6draft by anba.
the class ExpressionGenerator method isEnclosedByLexicalDeclaration.
private boolean isEnclosedByLexicalDeclaration(Scope currentScope) {
final boolean catchVar = codegen.isEnabled(CompatibilityOption.CatchVarStatement);
final boolean catchPattern = codegen.isEnabled(CompatibilityOption.CatchVarPattern);
TopLevelScope top = currentScope.getTop();
for (Scope scope : currentScope) {
if (scope instanceof BlockScope) {
if (catchVar) {
ScopedNode node = scope.getNode();
if (node instanceof CatchClause) {
if (!catchPattern || ((CatchClause) node).getCatchParameter() instanceof BindingIdentifier) {
continue;
}
}
}
if (!((BlockScope) scope).lexicallyDeclaredNames().isEmpty()) {
return true;
}
} else if (scope == top) {
break;
}
}
if (!top.lexicallyDeclaredNames().isEmpty()) {
TopLevelNode<?> topNode = top.getNode();
if (topNode instanceof Script) {
return ((Script) topNode).isEvalScript();
}
return true;
}
return codegen.isEnabled(Parser.Option.EnclosedByLexicalDeclaration);
}
Aggregations