use of com.github.anba.es6draft.runtime.ObjectEnvironmentRecord in project es6draft by anba.
the class ScriptRuntime method canDeclareVarBinding.
/**
* 18.2.1.2 Runtime Semantics: EvalDeclarationInstantiation( body, varEnv, lexEnv, strict)
*
* @param varEnv
* the variable environment
* @param lexEnv
* the lexical environment
* @param name
* the function name
* @param catchVar
* {@code true} if variable redeclarations are allowed in catch clauses
* @return {@code true} if the name can be declared
*/
public static boolean canDeclareVarBinding(LexicalEnvironment<?> varEnv, LexicalEnvironment<DeclarativeEnvironmentRecord> lexEnv, String name, boolean catchVar) {
for (LexicalEnvironment<?> thisEnv = lexEnv; thisEnv != varEnv; thisEnv = thisEnv.getOuter()) {
EnvironmentRecord thisEnvRec = thisEnv.getEnvRec();
if (thisEnvRec instanceof ObjectEnvironmentRecord) {
continue;
}
DeclarativeEnvironmentRecord declEnvRec = (DeclarativeEnvironmentRecord) thisEnvRec;
if (declEnvRec.hasBinding(name) && !(catchVar && declEnvRec.isCatchEnvironment())) {
return false;
}
}
return true;
}
use of com.github.anba.es6draft.runtime.ObjectEnvironmentRecord in project es6draft by anba.
the class DeclarationOperations method canDeclareVarBinding.
/**
* 18.2.1.2 Runtime Semantics: EvalDeclarationInstantiation( body, varEnv, lexEnv, strict)
*
* @param varEnv
* the variable environment
* @param lexEnv
* the lexical environment
* @param name
* the function name
* @param catchVar
* {@code true} if variable redeclarations are allowed in catch clauses
* @return {@code true} if the name can be declared
*/
public static boolean canDeclareVarBinding(LexicalEnvironment<?> varEnv, LexicalEnvironment<DeclarativeEnvironmentRecord> lexEnv, String name, boolean catchVar) {
for (LexicalEnvironment<?> thisEnv = lexEnv; thisEnv != varEnv; thisEnv = thisEnv.getOuter()) {
EnvironmentRecord thisEnvRec = thisEnv.getEnvRec();
if (thisEnvRec instanceof ObjectEnvironmentRecord) {
continue;
}
DeclarativeEnvironmentRecord declEnvRec = (DeclarativeEnvironmentRecord) thisEnvRec;
if (declEnvRec.hasBinding(name) && !(catchVar && declEnvRec.isCatchEnvironment())) {
return false;
}
}
return true;
}
Aggregations