use of com.github.anba.es6draft.ast.scope.Name in project es6draft by anba.
the class Parser method checkFormalParameterDuplicationStrict.
private void checkFormalParameterDuplicationStrict(FunctionNode node, List<Name> boundNames, NameSet names) {
boolean hasDuplicates = (boundNames.size() != names.size());
if (hasDuplicates) {
Name duplicate = findDuplicate(names, boundNames);
BindingIdentifier parameter = FindParameter.find(node, duplicate);
reportStrictModeSyntaxError(parameter, Messages.Key.DuplicateFormalParameter, duplicate);
}
}
use of com.github.anba.es6draft.ast.scope.Name in project es6draft by anba.
the class Parser method hasEnclosingLexicalDeclaration.
private boolean hasEnclosingLexicalDeclaration(FunctionDeclaration function, ScopeContext topScope) {
Name name = function.getIdentifier().getName();
ScopeContext enclosingScope = (ScopeContext) function.getScope().getEnclosingScope();
// Top-level function declarations are not applicable for legacy semantics.
assert enclosingScope != topScope : "top-level function declaration";
assert enclosingScope.isDeclared(name) : "undeclared block scoped function: " + name;
for (ScopeContext scope = enclosingScope; (scope = scope.parent) != topScope; ) {
// See 13.12.1 Static Semantics: Early Errors
if (scope.isDeclared(name)) {
// Found a block scoped, lexical declaration - cannot declare function as var.
if (scope instanceof CatchContext) {
// Unless "B.3.5 VariableStatements in Catch blocks" applies.
continue;
}
return true;
}
}
return false;
}
use of com.github.anba.es6draft.ast.scope.Name in project es6draft by anba.
the class Parser method addVarDeclaredName.
private void addVarDeclaredName(BindingIdentifier bindingIdentifier) {
Name name = BoundName(bindingIdentifier);
addVarDeclaredName(bindingIdentifier, name, Parser::redeclarationNode);
}
use of com.github.anba.es6draft.ast.scope.Name in project es6draft by anba.
the class RuntimeInfoGenerator method hasMappedOrLegacyArguments.
private boolean hasMappedOrLegacyArguments(FunctionNode node) {
// Strict or arrow functions never have mapped arguments.
if (IsStrict(node) || node.getThisMode() == FunctionNode.ThisMode.Lexical) {
return false;
}
// Functions with non-simple parameters (or no parameters at all) also never have mapped arguments.
FormalParameterList formals = node.getParameters();
if (formals.getFormals().isEmpty() || !IsSimpleParameterList(formals)) {
return false;
}
// Legacy functions always need the argument name mapping.
if (hasLegacyArguments(node)) {
return true;
}
// No mapping needed when 'arguments' is never accessed.
boolean argumentsObjectNeeded = node.getScope().needsArguments();
Name arguments = node.getScope().arguments();
if (!argumentsObjectNeeded || arguments == null) {
return false;
}
// Or a parameter named 'arguments' is present.
if (BoundNames(formals).contains(arguments)) {
return false;
}
// Or a lexical variable named 'arguments' is present.
if (LexicallyDeclaredNames(node).contains(arguments)) {
return false;
}
// Or a function named 'arguments' is present.
for (StatementListItem item : VarScopedDeclarations(node)) {
if (item instanceof HoistableDeclaration) {
HoistableDeclaration d = (HoistableDeclaration) item;
if (arguments.equals(BoundName(d))) {
return false;
}
}
}
return true;
}
use of com.github.anba.es6draft.ast.scope.Name in project es6draft by anba.
the class StatementGenerator method BindingClassDeclarationEvaluation.
/**
* 14.5.15 Runtime Semantics: BindingClassDeclarationEvaluation
*
* @param node
* the class declaration node
* @param mv
* the code visitor
*/
private void BindingClassDeclarationEvaluation(ClassDeclaration node, CodeVisitor mv) {
if (node.getIdentifier() != null) {
/* step 1 */
Name className = node.getIdentifier().getName();
/* steps 2-3 */
ClassDefinitionEvaluation(node, className, mv);
/* steps 4-6 */
SetFunctionName(node, className, mv);
/* steps 7-9 */
// stack: [value] -> []
InitializeBoundNameWithValue(className, FunctionObject.class, mv);
/* step 10 (return) */
} else {
// stack: [] -> [value]
ClassDefinitionEvaluation(node, null, mv);
}
}
Aggregations