use of com.github.anba.es6draft.runtime.types.Undefined in project es6draft by anba.
the class EvalDeclarationInstantiationGenerator method generateStrict.
private void generateStrict(Script evalScript, InstructionVisitor mv) {
assert evalScript.isStrict() && !evalScript.isScripting();
Variable<ExecutionContext> context = mv.getParameter(EXECUTION_CONTEXT, ExecutionContext.class);
Variable<LexicalEnvironment<DeclarativeEnvironmentRecord>> varEnv = mv.newVariable("varEnv", LexicalEnvironment.class).uncheckedCast();
Variable<LexicalEnvironment<DeclarativeEnvironmentRecord>> lexEnv = mv.newVariable("lexEnv", LexicalEnvironment.class).uncheckedCast();
Variable<FunctionObject> fo = null;
Variable<Undefined> undef = mv.newVariable("undef", Undefined.class);
mv.loadUndefined();
mv.store(undef);
getVariableEnvironment(context, varEnv, mv);
getLexicalEnvironment(context, lexEnv, mv);
/* step 1 */
Set<Name> varNames = VarDeclaredNames(evalScript);
/* step 2 */
List<StatementListItem> varDeclarations = VarScopedDeclarations(evalScript);
/* step 3 */
Variable<DeclarativeEnvironmentRecord> lexEnvRec = mv.newVariable("lexEnvRec", DeclarativeEnvironmentRecord.class);
getEnvironmentRecord(lexEnv, lexEnvRec, mv);
/* step 4 */
Variable<DeclarativeEnvironmentRecord> varEnvRec = mv.newVariable("varEnvRec", DeclarativeEnvironmentRecord.class);
getEnvironmentRecord(varEnv, varEnvRec, mv);
/* step 5 (not applicable) */
/* step 6 */
ArrayDeque<HoistableDeclaration> functionsToInitialize = new ArrayDeque<>();
/* step 7 */
HashSet<Name> declaredFunctionNames = new HashSet<>();
/* step 8 */
if (findFunctionDeclarations(varDeclarations, functionsToInitialize, declaredFunctionNames)) {
fo = mv.newVariable("fo", FunctionObject.class);
}
/* step 9 */
LinkedHashSet<Name> declaredVarNames = new LinkedHashSet<>(varNames);
/* step 10 */
declaredVarNames.removeAll(declaredFunctionNames);
// ES2016: Block-scoped global function declarations
assert !hasBlockFunctions(evalScript);
/* step 12 */
List<Declaration> lexDeclarations = LexicallyScopedDeclarations(evalScript);
/* step 13 */
createLexicalDeclarations(lexDeclarations, lexEnvRec, mv);
/* step 14 */
for (HoistableDeclaration f : functionsToInitialize) {
Name fn = BoundName(f);
// stack: [] -> []
InstantiateFunctionObject(context, lexEnv, f, mv);
mv.store(fo);
// Early error semantics ensure that fn does not already exist in varEnvRec.
BindingOp<DeclarativeEnvironmentRecord> op = BindingOp.of(varEnvRec, fn);
op.createMutableBinding(varEnvRec, fn, true, mv);
op.initializeBinding(varEnvRec, fn, fo, mv);
}
/* step 15 */
for (Name vn : declaredVarNames) {
// Early error semantics ensure that vn does not already exist in varEnvRec.
BindingOp<DeclarativeEnvironmentRecord> op = BindingOp.of(varEnvRec, vn);
op.createMutableBinding(varEnvRec, vn, true, mv);
op.initializeBinding(varEnvRec, vn, undef, mv);
}
/* step 16 */
mv._return();
}
Aggregations