use of com.github.anba.es6draft.runtime.types.ScriptObject in project es6draft by anba.
the class RegExpConstructor method RegExpCreate.
private static RegExpObject RegExpCreate(ExecutionContext cx, Constructor newTarget, Object pattern, Object flags, boolean patternIsRegExp) {
/* steps 5-7 */
Object p, f;
if (pattern instanceof RegExpObject) {
/* step 5 */
RegExpObject regexp = (RegExpObject) pattern;
/* step 5.a */
p = regexp.getOriginalSource();
/* steps 5.b-5.c */
f = Type.isUndefined(flags) ? regexp.getOriginalFlags() : flags;
} else if (patternIsRegExp) {
/* step 6 */
ScriptObject patternObject = Type.objectValue(pattern);
/* steps 6.a-b */
p = Get(cx, patternObject, "source");
/* steps 6.c-d */
f = Type.isUndefined(flags) ? Get(cx, patternObject, "flags") : flags;
} else {
/* step 7 */
p = pattern;
f = flags;
}
/* steps 8-9 */
RegExpObject obj = RegExpAlloc(cx, newTarget);
/* step 10 */
return RegExpInitialize(cx, obj, p, f);
}
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();
}
Aggregations