Search in sources :

Example 11 with Realm

use of com.github.anba.es6draft.runtime.Realm in project es6draft by anba.

the class OrdinaryAsyncFunction method FunctionAllocate.

/* ***************************************************************************************** */
/**
     * 9.2.3 FunctionAllocate (functionPrototype, strict [,functionKind] )
     * 
     * @param cx
     *            the execution context
     * @param functionPrototype
     *            the function prototype
     * @param strict
     *            the strict mode flag
     * @param kind
     *            the function kind
     * @return the new async function object
     */
public static OrdinaryAsyncFunction FunctionAllocate(ExecutionContext cx, ScriptObject functionPrototype, boolean strict, FunctionKind kind) {
    assert kind != FunctionKind.ClassConstructor;
    Realm realm = cx.getRealm();
    /* steps 1-5 (implicit) */
    /* steps 6-9 */
    OrdinaryAsyncFunction f = new OrdinaryAsyncFunction(realm);
    /* steps 10-14 */
    f.allocate(realm, functionPrototype, strict, kind, ConstructorKind.Base);
    /* step 15 */
    return f;
}
Also used : Realm(com.github.anba.es6draft.runtime.Realm)

Example 12 with Realm

use of com.github.anba.es6draft.runtime.Realm in project es6draft by anba.

the class OrdinaryConstructorGenerator method FunctionAllocate.

/* ***************************************************************************************** */
/**
     * 9.2.3 FunctionAllocate (functionPrototype, strict [,functionKind] )
     * 
     * @param cx
     *            the execution context
     * @param functionPrototype
     *            the function prototype
     * @param strict
     *            the strict mode flag
     * @param kind
     *            the function kind
     * @return the new generator function object
     */
public static OrdinaryConstructorGenerator FunctionAllocate(ExecutionContext cx, ScriptObject functionPrototype, boolean strict, FunctionKind kind) {
    assert kind != FunctionKind.ClassConstructor;
    Realm realm = cx.getRealm();
    /* steps 1-5 (implicit) */
    /* steps 6-9 */
    OrdinaryConstructorGenerator f = new OrdinaryConstructorGenerator(realm);
    /* steps 10-14 */
    f.allocate(realm, functionPrototype, strict, kind, ConstructorKind.Derived);
    /* step 15 */
    return f;
}
Also used : Realm(com.github.anba.es6draft.runtime.Realm)

Example 13 with Realm

use of com.github.anba.es6draft.runtime.Realm in project es6draft by anba.

the class OrdinaryFunction method FunctionAllocate.

/* ***************************************************************************************** */
/**
     * 9.2.3 FunctionAllocate (functionPrototype, strict)
     * 
     * @param cx
     *            the execution context
     * @param functionPrototype
     *            the function prototype
     * @param strict
     *            the strict mode flag
     * @param functionKind
     *            the function kind
     * @return the new function object
     */
public static OrdinaryFunction FunctionAllocate(ExecutionContext cx, ScriptObject functionPrototype, boolean strict, FunctionKind functionKind) {
    assert !(functionKind == FunctionKind.Normal || functionKind == FunctionKind.ClassConstructor);
    Realm realm = cx.getRealm();
    /* steps 1-5 (implicit) */
    /* steps 6-9 */
    OrdinaryFunction f = new OrdinaryFunction(realm);
    /* steps 10-14 */
    f.allocate(realm, functionPrototype, strict, functionKind, ConstructorKind.Base);
    /* step 15 */
    return f;
}
Also used : Realm(com.github.anba.es6draft.runtime.Realm)

Example 14 with Realm

use of com.github.anba.es6draft.runtime.Realm in project es6draft by anba.

the class OrdinaryGenerator method FunctionAllocate.

/* ***************************************************************************************** */
/**
     * 9.2.3 FunctionAllocate (functionPrototype, strict [,functionKind] )
     * 
     * @param cx
     *            the execution context
     * @param functionPrototype
     *            the function prototype
     * @param strict
     *            the strict mode flag
     * @param kind
     *            the function kind
     * @return the new generator function object
     */
public static OrdinaryGenerator FunctionAllocate(ExecutionContext cx, ScriptObject functionPrototype, boolean strict, FunctionKind kind) {
    assert kind != FunctionKind.ClassConstructor;
    Realm realm = cx.getRealm();
    /* steps 1-5 (implicit) */
    /* steps 6-9 */
    OrdinaryGenerator f = new OrdinaryGenerator(realm);
    /* steps 10-14 */
    f.allocate(realm, functionPrototype, strict, kind, ConstructorKind.Base);
    /* step 15 */
    return f;
}
Also used : Realm(com.github.anba.es6draft.runtime.Realm)

Example 15 with Realm

use of com.github.anba.es6draft.runtime.Realm in project es6draft by anba.

the class InterpretedScriptBody method scriptEvaluation.

/**
 * 15.1.7 Runtime Semantics: ScriptEvaluation
 *
 * @param cx
 *            the execution context
 * @param script
 *            the script object
 * @param interpreter
 *            the interpreter
 * @return the script evaluation result
 */
private Object scriptEvaluation(ExecutionContext cx, Script script, Interpreter interpreter) {
    Realm realm = cx.getRealm();
    /* step 1 (not applicable) */
    /* step 2 */
    LexicalEnvironment<GlobalEnvironmentRecord> globalEnv = realm.getGlobalEnv();
    /* steps 3-7 */
    ExecutionContext scriptCxt = newScriptExecutionContext(realm, script);
    /* steps 8-9 */
    ExecutionContext oldScriptContext = realm.getWorld().getScriptContext();
    try {
        realm.getWorld().setScriptContext(scriptCxt);
        /* step 10 */
        GlobalDeclarationInstantiation(scriptCxt, parsedScript, globalEnv);
        /* steps 11-12 */
        Object result = parsedScript.accept(interpreter, scriptCxt);
        /* step 16 */
        return result;
    } finally {
        /* steps 13-15  */
        realm.getWorld().setScriptContext(oldScriptContext);
    }
}
Also used : ExecutionContext(com.github.anba.es6draft.runtime.ExecutionContext) ExecutionContext.newScriptExecutionContext(com.github.anba.es6draft.runtime.ExecutionContext.newScriptExecutionContext) ExecutionContext.newEvalExecutionContext(com.github.anba.es6draft.runtime.ExecutionContext.newEvalExecutionContext) GlobalEnvironmentRecord(com.github.anba.es6draft.runtime.GlobalEnvironmentRecord) Realm(com.github.anba.es6draft.runtime.Realm)

Aggregations

Realm (com.github.anba.es6draft.runtime.Realm)96 Test (org.junit.Test)39 ScriptObject (com.github.anba.es6draft.runtime.types.ScriptObject)17 Script (com.github.anba.es6draft.Script)16 ExecutionContext (com.github.anba.es6draft.runtime.ExecutionContext)16 Source (com.github.anba.es6draft.runtime.internal.Source)15 ParserException (com.github.anba.es6draft.parser.ParserException)9 Function (com.github.anba.es6draft.runtime.internal.Properties.Function)9 ModuleRecord (com.github.anba.es6draft.runtime.modules.ModuleRecord)8 ModuleLoader (com.github.anba.es6draft.runtime.modules.ModuleLoader)7 IOException (java.io.IOException)7 CompilationException (com.github.anba.es6draft.compiler.CompilationException)6 ScriptException (com.github.anba.es6draft.runtime.internal.ScriptException)6 ToSource (com.github.anba.es6draft.repl.SourceBuilder.ToSource)5 World (com.github.anba.es6draft.runtime.World)5 RuntimeContext (com.github.anba.es6draft.runtime.internal.RuntimeContext)5 ModuleSource (com.github.anba.es6draft.runtime.modules.ModuleSource)5 SourceIdentifier (com.github.anba.es6draft.runtime.modules.SourceIdentifier)5 GlobalObject (com.github.anba.es6draft.runtime.objects.GlobalObject)5 ExecutionContext.newEvalExecutionContext (com.github.anba.es6draft.runtime.ExecutionContext.newEvalExecutionContext)4