use of com.github.anba.es6draft.runtime.DeclarativeEnvironmentRecord in project es6draft by anba.
the class InterpretedScriptBody method evalScriptEvaluation.
/**
* 18.2.1.1 Runtime Semantics: PerformEval( x, evalRealm, strictCaller, direct)
*
* @param cx
* the execution context
* @param script
* the script object
* @return the script evaluation result
*/
private Object evalScriptEvaluation(ExecutionContext cx, Script script) {
// TODO: Skip allocating lex-env if not needed
/* steps 1-5 (not applicable) */
/* steps 6-7 */
boolean strictEval = parsedScript.isStrict();
/* step 8 (omitted) */
/* steps 9-10 */
LexicalEnvironment<DeclarativeEnvironmentRecord> lexEnv;
LexicalEnvironment<?> varEnv;
if (parsedScript.isDirectEval()) {
/* step 9 */
lexEnv = newDeclarativeEnvironment(cx.getLexicalEnvironment());
varEnv = cx.getVariableEnvironment();
} else {
Realm evalRealm = cx.getRealm();
/* step 10 */
lexEnv = newDeclarativeEnvironment(evalRealm.getGlobalEnv());
varEnv = evalRealm.getGlobalEnv();
}
/* step 11 */
if (strictEval) {
varEnv = lexEnv;
}
/* steps 12-17 */
ExecutionContext evalCxt = newEvalExecutionContext(cx, script, varEnv, lexEnv);
/* step 18 */
EvalDeclarationInstantiation(evalCxt, parsedScript, varEnv, lexEnv);
/* steps 19-23 */
return parsedScript.accept(new Interpreter(parsedScript), evalCxt);
}
use of com.github.anba.es6draft.runtime.DeclarativeEnvironmentRecord in project es6draft by anba.
the class ScriptRuntime method EvaluateConstructorGeneratorExpression.
/**
* 14.4 Generator Function Definitions
* <p>
* 14.4.14 Runtime Semantics: Evaluation
* <ul>
* <li>GeneratorExpression: function* ( FormalParameters ) { FunctionBody }
* <li>GeneratorExpression: function* BindingIdentifier ( FormalParameters ) { FunctionBody }
* </ul>
*
* @param fd
* the function runtime info object
* @param cx
* the execution context
* @return the new generator function instance
*/
public static OrdinaryConstructorGenerator EvaluateConstructorGeneratorExpression(RuntimeInfo.Function fd, ExecutionContext cx) {
OrdinaryConstructorGenerator closure;
if (!fd.is(RuntimeInfo.FunctionFlags.ScopedName)) {
/* step 1 (not applicable) */
/* step 2 */
LexicalEnvironment<?> scope = cx.getLexicalEnvironment();
/* step 3 */
closure = ConstructorGeneratorFunctionCreate(cx, FunctionKind.Normal, fd, scope);
/* step 4 */
OrdinaryObject prototype = ObjectCreate(cx, Intrinsics.GeneratorPrototype);
/* step 5 */
MakeConstructor(closure, true, prototype);
} else {
/* step 1 (not applicable) */
/* step 2 */
LexicalEnvironment<?> scope = cx.getLexicalEnvironment();
/* step 3 */
LexicalEnvironment<DeclarativeEnvironmentRecord> funcEnv = newDeclarativeEnvironment(scope);
/* step 4 */
DeclarativeEnvironmentRecord envRec = funcEnv.getEnvRec();
/* step 5 */
String name = fd.functionName();
/* step 6 */
envRec.createImmutableBinding(name, false);
/* step 7 */
closure = ConstructorGeneratorFunctionCreate(cx, FunctionKind.Normal, fd, funcEnv);
/* step 8 */
OrdinaryObject prototype = ObjectCreate(cx, Intrinsics.GeneratorPrototype);
/* step 9 */
MakeConstructor(closure, true, prototype);
/* step 10 */
SetFunctionName(closure, name);
/* step 11 */
envRec.initializeBinding(name, closure);
}
/* step 6/12 */
return closure;
}
use of com.github.anba.es6draft.runtime.DeclarativeEnvironmentRecord in project es6draft by anba.
the class ScriptRuntime method EvaluateLegacyGeneratorExpression.
/**
* 14.4 Generator Function Definitions
* <p>
* 14.4.14 Runtime Semantics: Evaluation
* <ul>
* <li>GeneratorExpression: function* ( FormalParameters ) { FunctionBody }
* <li>GeneratorExpression: function* BindingIdentifier ( FormalParameters ) { FunctionBody }
* </ul>
*
* @param fd
* the function runtime info object
* @param cx
* the execution context
* @return the new generator function instance
*/
public static OrdinaryConstructorGenerator EvaluateLegacyGeneratorExpression(RuntimeInfo.Function fd, ExecutionContext cx) {
OrdinaryConstructorGenerator closure;
if (!fd.is(RuntimeInfo.FunctionFlags.ScopedName)) {
/* step 1 (not applicable) */
/* step 2 */
LexicalEnvironment<?> scope = cx.getLexicalEnvironment();
/* step 3 */
closure = ConstructorGeneratorFunctionCreate(cx, FunctionKind.Normal, fd, scope);
/* step 4 */
OrdinaryObject prototype = ObjectCreate(cx, Intrinsics.LegacyGeneratorPrototype);
/* step 5 */
MakeConstructor(closure, true, prototype);
} else {
/* step 1 (not applicable) */
/* step 2 */
LexicalEnvironment<?> scope = cx.getLexicalEnvironment();
/* step 2 */
LexicalEnvironment<DeclarativeEnvironmentRecord> funcEnv = newDeclarativeEnvironment(scope);
/* step 4 */
DeclarativeEnvironmentRecord envRec = funcEnv.getEnvRec();
/* step 5 */
String name = fd.functionName();
/* step 6 */
envRec.createImmutableBinding(name, false);
/* step 7 */
closure = ConstructorGeneratorFunctionCreate(cx, FunctionKind.Normal, fd, funcEnv);
/* step 8 */
OrdinaryObject prototype = ObjectCreate(cx, Intrinsics.LegacyGeneratorPrototype);
/* step 9 */
MakeConstructor(closure, true, prototype);
/* step 10 */
SetFunctionName(closure, name);
/* step 11 */
envRec.initializeBinding(name, closure);
}
/* step 6/12 */
return closure;
}
use of com.github.anba.es6draft.runtime.DeclarativeEnvironmentRecord in project es6draft by anba.
the class ScriptRuntime method EvaluateGeneratorExpression.
/**
* 14.4 Generator Function Definitions
* <p>
* 14.4.14 Runtime Semantics: Evaluation
* <ul>
* <li>GeneratorExpression: function* ( FormalParameters ) { FunctionBody }
* <li>GeneratorExpression: function* BindingIdentifier ( FormalParameters ) { FunctionBody }
* </ul>
*
* @param fd
* the function runtime info object
* @param cx
* the execution context
* @return the new generator function instance
*/
public static OrdinaryGenerator EvaluateGeneratorExpression(RuntimeInfo.Function fd, ExecutionContext cx) {
OrdinaryGenerator closure;
if (!fd.is(RuntimeInfo.FunctionFlags.ScopedName)) {
/* step 1 (not applicable) */
/* step 2 */
LexicalEnvironment<?> scope = cx.getLexicalEnvironment();
/* step 3 */
closure = GeneratorFunctionCreate(cx, FunctionKind.Normal, fd, scope);
/* step 4 */
OrdinaryObject prototype = ObjectCreate(cx, Intrinsics.GeneratorPrototype);
/* step 5 */
closure.infallibleDefineOwnProperty("prototype", new Property(prototype, true, false, false));
} else {
/* step 1 (not applicable) */
/* step 2 */
LexicalEnvironment<?> scope = cx.getLexicalEnvironment();
/* step 3 */
LexicalEnvironment<DeclarativeEnvironmentRecord> funcEnv = newDeclarativeEnvironment(scope);
/* step 4 */
DeclarativeEnvironmentRecord envRec = funcEnv.getEnvRec();
/* step 5 */
String name = fd.functionName();
/* step 6 */
envRec.createImmutableBinding(name, false);
/* step 7 */
closure = GeneratorFunctionCreate(cx, FunctionKind.Normal, fd, funcEnv);
/* step 8 */
OrdinaryObject prototype = ObjectCreate(cx, Intrinsics.GeneratorPrototype);
/* step 9 */
closure.infallibleDefineOwnProperty("prototype", new Property(prototype, true, false, false));
/* step 10 */
SetFunctionName(closure, name);
/* step 11 */
envRec.initializeBinding(name, closure);
}
/* step 6/12 */
return closure;
}
use of com.github.anba.es6draft.runtime.DeclarativeEnvironmentRecord in project es6draft by anba.
the class ScriptRuntime method EvaluateAsyncGeneratorExpression.
/**
* Extension: Async Generator Function Definitions
*
* @param fd
* the function runtime info object
* @param cx
* the execution context
* @return the new async generator instance
*/
public static OrdinaryAsyncGenerator EvaluateAsyncGeneratorExpression(RuntimeInfo.Function fd, ExecutionContext cx) {
OrdinaryAsyncGenerator closure;
if (!fd.is(RuntimeInfo.FunctionFlags.ScopedName)) {
/* step 1 (not applicable) */
/* step 2 */
LexicalEnvironment<?> scope = cx.getLexicalEnvironment();
/* step 3 */
closure = AsyncGeneratorFunctionCreate(cx, FunctionKind.Normal, fd, scope);
/* step 4 */
OrdinaryObject prototype = ObjectCreate(cx, Intrinsics.AsyncGeneratorPrototype);
/* step 5 */
closure.infallibleDefineOwnProperty("prototype", new Property(prototype, true, false, false));
} else {
/* step 1 (not applicable) */
/* step 2 */
LexicalEnvironment<?> scope = cx.getLexicalEnvironment();
/* step 3 */
LexicalEnvironment<DeclarativeEnvironmentRecord> funcEnv = newDeclarativeEnvironment(scope);
/* step 4 */
DeclarativeEnvironmentRecord envRec = funcEnv.getEnvRec();
/* step 5 */
String name = fd.functionName();
/* step 6 */
envRec.createImmutableBinding(name, false);
/* step 7 */
closure = AsyncGeneratorFunctionCreate(cx, FunctionKind.Normal, fd, funcEnv);
/* step 8 */
OrdinaryObject prototype = ObjectCreate(cx, Intrinsics.AsyncGeneratorPrototype);
/* step 9 */
closure.infallibleDefineOwnProperty("prototype", new Property(prototype, true, false, false));
/* step 10 */
SetFunctionName(closure, name);
/* step 11 */
envRec.initializeBinding(name, closure);
}
/* step 6/12 */
return closure;
}
Aggregations