use of com.github.anba.es6draft.runtime.internal.InlineArrayList 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);
}
use of com.github.anba.es6draft.runtime.internal.InlineArrayList in project es6draft by anba.
the class Parser method computeBlockFunctionsForScript.
private void computeBlockFunctionsForScript() {
assert context.kind.isScript();
if (!isEnabled(CompatibilityOption.BlockFunctionDeclaration)) {
return;
}
ScriptContext scriptScope = context.scriptContext;
InlineArrayList<FunctionDeclaration> functions = scriptScope.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, scriptScope)) {
continue;
}
// See 15.1.1 Static Semantics: Early Errors
Name name = function.getIdentifier().getName();
if (scriptScope.allowVarDeclaredName(name)) {
// Function declaration is applicable for legacy semantics, iff
// (1) Adding a VariableStatement with the same name would not produce an error.
function.setLegacyBlockScoped(true);
blockFunctions.add(function);
}
}
scriptScope.setBlockFunctions(blockFunctions);
}
Aggregations