use of com.github.anba.es6draft.runtime.types.ScriptObject in project es6draft by anba.
the class OrdinaryAsyncGenerator method AsyncGeneratorFunctionCreate.
/**
* 9.2.6 GeneratorFunctionCreate (kind, ParameterList, Body, Scope, Strict)
*
* @param cx
* the execution context
* @param kind
* the function kind
* @param function
* the function code
* @param scope
* the lexical environment
* @return the new async generator function object
*/
public static OrdinaryAsyncGenerator AsyncGeneratorFunctionCreate(ExecutionContext cx, FunctionKind kind, RuntimeInfo.Function function, LexicalEnvironment<?> scope) {
assert function.isAsync() && function.isGenerator() && kind != FunctionKind.ClassConstructor;
/* step 1 */
ScriptObject functionPrototype = cx.getIntrinsic(Intrinsics.AsyncGenerator);
/* step 2 */
OrdinaryAsyncGenerator f = FunctionAllocate(cx, functionPrototype, function.isStrict(), kind);
/* step 3 */
FunctionInitialize(f, kind, function, scope, cx.getCurrentExecutable());
return f;
}
use of com.github.anba.es6draft.runtime.types.ScriptObject in project es6draft by anba.
the class OrdinaryConstructorGenerator method ConstructorGeneratorFunctionCreate.
/**
* 9.2.6 GeneratorFunctionCreate (kind, ParameterList, Body, Scope, Strict)
*
* @param cx
* the execution context
* @param kind
* the function kind
* @param function
* the function code
* @param scope
* the lexical environment
* @return the new generator function object
*/
public static OrdinaryConstructorGenerator ConstructorGeneratorFunctionCreate(ExecutionContext cx, FunctionKind kind, RuntimeInfo.Function function, LexicalEnvironment<?> scope) {
assert function.isGenerator() && kind != FunctionKind.ClassConstructor;
/* step 1 */
ScriptObject functionPrototype = cx.getIntrinsic(Intrinsics.Generator);
/* step 2 */
OrdinaryConstructorGenerator f = FunctionAllocate(cx, functionPrototype, function.isStrict(), kind);
/* step 3 */
FunctionInitialize(f, kind, function, scope, cx.getCurrentExecutable());
return f;
}
use of com.github.anba.es6draft.runtime.types.ScriptObject in project es6draft by anba.
the class LegacyConstructorFunction method LegacyFunctionCreate.
/**
* 9.2.5 FunctionCreate (kind, ParameterList, Body, Scope, Strict)
*
* @param cx
* the execution context
* @param function
* the function code
* @param scope
* the lexical environment
* @return the new function object
*/
public static LegacyConstructorFunction LegacyFunctionCreate(ExecutionContext cx, RuntimeInfo.Function function, LexicalEnvironment<?> scope) {
/* step 1 */
ScriptObject prototype = cx.getIntrinsic(Intrinsics.FunctionPrototype);
/* steps 2-3 */
assert !function.isGenerator() && !function.isAsync();
/* step 4 */
LegacyConstructorFunction f = FunctionAllocate(cx, prototype);
/* step 5 */
FunctionInitialize(f, FunctionKind.Normal, function, scope, cx.getCurrentExecutable());
return f;
}
use of com.github.anba.es6draft.runtime.types.ScriptObject in project es6draft by anba.
the class SIMD method ArrayJoin.
/**
* Internal algorithms on SIMD types
* <p>
* ArrayJoin( array, separator )
*
* @param cx
* the execution context
* @param array
* the array object
* @param separator
* the separator string
* @return the result string
*/
public static String ArrayJoin(ExecutionContext cx, Object array, Object separator) {
/* steps 1-2 */
ScriptObject o = ToObject(cx, array);
/* steps 3-4 */
long len = ToLength(cx, Get(cx, o, "length"));
/* step 5 */
if (Type.isUndefined(separator)) {
separator = "";
}
/* steps 6-7 */
String sep = ToFlatString(cx, separator);
/* step 8 */
if (len == 0) {
return "";
}
StringBuilder r = new StringBuilder();
/* step 9 */
Object element0 = Get(cx, o, 0);
/* steps 10-11 */
if (!Type.isUndefinedOrNull(element0)) {
r.append(AbstractOperations.ToString(cx, element0));
}
/* steps 12-13 */
for (int k = 1; k < len; ++k) {
/* step 13.a */
r.append(sep);
/* step 13.b */
Object element = Get(cx, o, k);
/* steps 13.c-e */
if (!Type.isUndefinedOrNull(element)) {
r.append(AbstractOperations.ToString(cx, element));
}
}
/* step 14 */
return r.toString();
}
use of com.github.anba.es6draft.runtime.types.ScriptObject in project es6draft by anba.
the class OrdinaryObject method getValue.
/**
* 9.1.8 [[Get]] (P, Receiver)
*
* @param cx
* the execution context
* @param propertyKey
* the property key
* @param receiver
* the receiver object
* @return the property value
*/
protected Object getValue(ExecutionContext cx, String propertyKey, Object receiver) {
/* step 1 (implicit) */
/* steps 2-3 */
Property desc = getProperty(cx, propertyKey);
/* step 4 */
if (desc == null) {
ScriptObject parent = getPrototypeOf(cx);
if (parent == null) {
return UNDEFINED;
}
return parent.get(cx, propertyKey, receiver);
}
/* step 5 */
if (desc.isDataDescriptor()) {
return desc.getValue();
}
assert desc.isAccessorDescriptor();
/* step 6 */
Callable getter = desc.getGetter();
/* step 7 */
if (getter == null) {
return UNDEFINED;
}
/* step 8 */
return getter.call(cx, receiver, EMPTY_GETTER_ARGS);
}
Aggregations