use of com.github.anba.es6draft.ast.scope.Name in project es6draft by anba.
the class Parser method checkVarDeclaredName.
private void checkVarDeclaredName(BindingIdentifier bindingIdentifier) {
Name name = BoundName(bindingIdentifier);
checkVarDeclaredName(bindingIdentifier, name, Parser::redeclarationNode);
}
use of com.github.anba.es6draft.ast.scope.Name in project es6draft by anba.
the class Parser method addLexDeclaredName.
private void addLexDeclaredName(BindingIdentifier bindingIdentifier) {
Name name = BoundName(bindingIdentifier);
addLexDeclaredName(bindingIdentifier, context, name);
}
use of com.github.anba.es6draft.ast.scope.Name in project es6draft by anba.
the class Parser method checkFormalParameterRedeclaration.
private void checkFormalParameterRedeclaration(FunctionNode node, List<Name> boundNames, NameSet declaredNames) {
if (!(declaredNames == null || declaredNames.isEmpty())) {
Name redeclared = containsAny(boundNames, declaredNames);
if (redeclared != null) {
BindingIdentifier parameter = FindParameter.find(node, redeclared);
reportSyntaxError(parameter, Messages.Key.FormalParameterRedeclaration, redeclared);
}
}
}
use of com.github.anba.es6draft.ast.scope.Name in project es6draft by anba.
the class Parser method module_EarlyErrors.
/**
* 15.2.1.1 Static Semantics: Early Errors
*/
private void module_EarlyErrors() {
assert context.scopeContext == context.modContext;
ModuleContext scope = context.modContext;
if (!scope.undeclaredExportBindings.isEmpty()) {
for (Map.Entry<Name, Long> export : scope.undeclaredExportBindings.entrySet()) {
Name exportBinding = export.getKey();
if (!scope.isDeclared(exportBinding)) {
reportSyntaxError(export.getValue(), Messages.Key.MissingExportBinding, exportBinding.getIdentifier());
}
}
}
scope.exportNames = null;
scope.undeclaredExportBindings = null;
scope.importBindings = null;
}
use of com.github.anba.es6draft.ast.scope.Name in project es6draft by anba.
the class Parser method computeBlockFunctions.
private void computeBlockFunctions() {
// TODO: Consider moving computeBlockFunctions() after node is assigned to funscope.
assert context.kind.isFunction();
if (!isEnabled(CompatibilityOption.BlockFunctionDeclaration)) {
return;
}
FunctionContext funScope = context.funContext;
ScopeContext topScope = funScope.lexicalScope;
InlineArrayList<FunctionDeclaration> functions = funScope.blockFunctions;
if (functions == null) {
return;
}
assert context.strictMode != StrictMode.Strict : "block functions in strict mode";
InlineArrayList<FunctionDeclaration> blockFunctions = new InlineArrayList<>();
for (FunctionDeclaration function : functions) {
if (hasEnclosingLexicalDeclaration(function, topScope)) {
continue;
}
// See 14.1.2 Static Semantics: Early Errors
Name name = function.getIdentifier().getName();
if (topScope.allowVarDeclaredName(name) && !funScope.parameterNames.contains(name)) {
// Function declaration is applicable for legacy semantics, iff
// (1) Adding a VariableStatement with the same name would not produce an error.
// (2) The name is not an element of BoundNames of FormalParameters.
function.setLegacyBlockScoped(true);
blockFunctions.add(function);
}
}
funScope.setBlockFunctions(blockFunctions);
}
Aggregations