Search in sources :

Example 1 with ConstructorKind

use of com.github.anba.es6draft.runtime.types.builtins.FunctionObject.ConstructorKind in project es6draft by anba.

the class ScriptRuntime method EvaluateConstructorMethod.

/**
     * 14.3 Method Definitions, 14.5 Class Definitions
     * <p>
     * 14.3.8 Runtime Semantics: DefineMethod<br>
     * 14.5.14 Runtime Semantics: ClassDefinitionEvaluation
     * 
     * @param constructorParent
     *            the constructor prototype
     * @param proto
     *            the class prototype
     * @param fd
     *            the function runtime info object
     * @param isDerived
     *            {@code true} if evaluating the constructor of a derived class
     * @param cx
     *            the execution context
     * @return the new function instance
     */
public static OrdinaryConstructorFunction EvaluateConstructorMethod(ScriptObject constructorParent, OrdinaryObject proto, RuntimeInfo.Function fd, boolean isDerived, ExecutionContext cx) {
    // ClassDefinitionEvaluation - steps 11-13 (call DefineMethod)
    LexicalEnvironment<?> scope = cx.getLexicalEnvironment();
    ConstructorKind constructorKind = isDerived ? ConstructorKind.Derived : ConstructorKind.Base;
    OrdinaryConstructorFunction constructor = ConstructorFunctionCreate(cx, FunctionKind.ClassConstructor, constructorKind, fd, scope, constructorParent);
    MakeMethod(constructor, proto);
    // ClassDefinitionEvaluation - step 14 (not applicable, cf. ConstructorFunctionCreate)
    // ClassDefinitionEvaluation - step 15
    MakeConstructor(constructor, false, proto);
    // ClassDefinitionEvaluation - step 16
    MakeClassConstructor(constructor);
    // ClassDefinitionEvaluation - step 17
    proto.defineOwnProperty(cx, "constructor", new PropertyDescriptor(constructor, true, false, true));
    return constructor;
}
Also used : AccessorPropertyDescriptor(com.github.anba.es6draft.runtime.types.PropertyDescriptor.AccessorPropertyDescriptor) ToPropertyDescriptor(com.github.anba.es6draft.runtime.types.PropertyDescriptor.ToPropertyDescriptor) FromPropertyDescriptor(com.github.anba.es6draft.runtime.types.PropertyDescriptor.FromPropertyDescriptor) ConstructorKind(com.github.anba.es6draft.runtime.types.builtins.FunctionObject.ConstructorKind)

Aggregations

AccessorPropertyDescriptor (com.github.anba.es6draft.runtime.types.PropertyDescriptor.AccessorPropertyDescriptor)1 FromPropertyDescriptor (com.github.anba.es6draft.runtime.types.PropertyDescriptor.FromPropertyDescriptor)1 ToPropertyDescriptor (com.github.anba.es6draft.runtime.types.PropertyDescriptor.ToPropertyDescriptor)1 ConstructorKind (com.github.anba.es6draft.runtime.types.builtins.FunctionObject.ConstructorKind)1