Search in sources :

Example 1 with Name

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);
}
Also used : Name(com.github.anba.es6draft.ast.scope.Name) RegExpParser(com.github.anba.es6draft.regexp.RegExpParser)

Example 2 with Name

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);
}
Also used : Name(com.github.anba.es6draft.ast.scope.Name)

Example 3 with 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);
        }
    }
}
Also used : Name(com.github.anba.es6draft.ast.scope.Name)

Example 4 with Name

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;
}
Also used : Name(com.github.anba.es6draft.ast.scope.Name)

Example 5 with Name

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);
}
Also used : InlineArrayList(com.github.anba.es6draft.runtime.internal.InlineArrayList) Name(com.github.anba.es6draft.ast.scope.Name)

Aggregations

Name (com.github.anba.es6draft.ast.scope.Name)49 MethodName (com.github.anba.es6draft.compiler.assembler.MethodName)31 DeclarativeEnvironmentRecord (com.github.anba.es6draft.runtime.DeclarativeEnvironmentRecord)24 LexicalEnvironment (com.github.anba.es6draft.runtime.LexicalEnvironment)16 HoistableDeclaration (com.github.anba.es6draft.ast.HoistableDeclaration)13 FunctionObject (com.github.anba.es6draft.runtime.types.builtins.FunctionObject)13 StatementListItem (com.github.anba.es6draft.ast.StatementListItem)12 Declaration (com.github.anba.es6draft.ast.Declaration)11 Jump (com.github.anba.es6draft.compiler.assembler.Jump)11 HashSet (java.util.HashSet)11 ExecutionContext (com.github.anba.es6draft.runtime.ExecutionContext)10 GlobalEnvironmentRecord (com.github.anba.es6draft.runtime.GlobalEnvironmentRecord)10 BlockScope (com.github.anba.es6draft.ast.scope.BlockScope)9 InitializeBoundName (com.github.anba.es6draft.compiler.BindingInitializationGenerator.InitializeBoundName)9 FunctionDeclaration (com.github.anba.es6draft.ast.FunctionDeclaration)8 VariableStatement (com.github.anba.es6draft.ast.VariableStatement)8 ArrayDeque (java.util.ArrayDeque)8 IdentifierName (com.github.anba.es6draft.ast.IdentifierName)7 VariableDeclaration (com.github.anba.es6draft.ast.VariableDeclaration)6 EnvironmentRecord (com.github.anba.es6draft.runtime.EnvironmentRecord)6