use of com.github.anba.es6draft.runtime.types.Property in project es6draft by anba.
the class ObjectConstructor method EnumerableOwnProperties.
/**
* EnumerableOwnProperties (O)
*
* @param cx
* the execution context
* @param object
* the script object
* @param kind
* the property kind
* @return <var>object</var>'s own enumerable properties
*/
static List<Object> EnumerableOwnProperties(ExecutionContext cx, ScriptObject object, PropertyKind kind) {
/* step 1 (not applicable) */
/* steps 2-3 */
List<?> ownKeys = object.ownPropertyKeys(cx);
/* step 4 */
int initialSize = Math.min(16, ownKeys.size());
ArrayList<Object> properties = new ArrayList<>(initialSize);
/* step 5 */
for (Object key : ownKeys) {
if (key instanceof String) {
String skey = (String) key;
Property desc = object.getOwnProperty(cx, skey);
if (desc != null && desc.isEnumerable()) {
if (kind == PropertyKind.Key) {
properties.add(skey);
} else {
Object value = Get(cx, object, skey);
if (kind == PropertyKind.Value) {
properties.add(value);
} else {
ArrayObject entry = CreateArrayFromList(cx, key, value);
properties.add(entry);
}
}
}
}
}
/* step 7 */
return properties;
}
use of com.github.anba.es6draft.runtime.types.Property in project es6draft by anba.
the class RegExpConstructor method RegExpAlloc.
/**
* 21.2.3.2 Abstract Operations for the RegExp Constructor<br>
* 21.2.3.2.1 Runtime Semantics: RegExpAlloc ( newTarget )
*
* @param cx
* the execution context
* @param newTarget
* the constructor function
* @return the new regular expression object
*/
public static RegExpObject RegExpAlloc(ExecutionContext cx, Constructor newTarget) {
/* steps 1-2 */
RegExpObject obj = OrdinaryCreateFromConstructor(cx, newTarget, Intrinsics.RegExpPrototype, RegExpObject::new);
/* steps 3-4 */
obj.infallibleDefineOwnProperty("lastIndex", new Property(0, true, false, false));
/* step 5 */
return obj;
}
use of com.github.anba.es6draft.runtime.types.Property in project es6draft by anba.
the class RegExpPrototype method isBuiltinRegExpPrototypeForExec.
private static boolean isBuiltinRegExpPrototypeForExec(ExecutionContext cx) {
OrdinaryObject prototype = cx.getIntrinsic(Intrinsics.RegExpPrototype);
Property execProp = prototype.getOwnProperty(cx, "exec");
if (execProp == null || !isBuiltinExec(cx.getRealm(), execProp.getValue())) {
return false;
}
Property globalProp = prototype.getOwnProperty(cx, "global");
if (globalProp == null || !isBuiltinGlobal(cx.getRealm(), globalProp.getGetter())) {
return false;
}
Property stickyProp = prototype.getOwnProperty(cx, "sticky");
if (stickyProp == null || !isBuiltinSticky(cx.getRealm(), stickyProp.getGetter())) {
return false;
}
return true;
}
use of com.github.anba.es6draft.runtime.types.Property in project es6draft by anba.
the class ModuleNamespaceObject method ModuleNamespaceCreate.
/**
* 9.4.6.13 ModuleNamespaceCreate (module, exports)
*
* @param cx
* the execution context
* @param module
* the module record
* @param exports
* the exported bindings
* @return the new module namespace object
*/
public static ModuleNamespaceObject ModuleNamespaceCreate(ExecutionContext cx, ModuleRecord module, Set<String> exports) {
/* step 2 */
assert module.getNamespace() == null;
/* step 3 (not applicable) */
/* steps 4-7 */
ModuleNamespaceObject m = new ModuleNamespaceObject(cx.getRealm(), module, exports);
/* step 8 */
// 26.3.1 @@toStringTag
m.infallibleDefineOwnProperty(BuiltinSymbol.toStringTag.get(), new Property("Module", false, false, true));
// 26.3.2 [ @@iterator ] ( )
BuiltinFunction iterator;
if (cx.getRealm().isEnabled(CompatibilityOption.Enumerate)) {
iterator = new ModuleIteratorFunction(cx.getRealm());
} else {
iterator = new ModuleExportsIteratorFunction(cx.getRealm());
}
m.infallibleDefineOwnProperty(BuiltinSymbol.iterator.get(), new Property(iterator, true, false, true));
/* step 9 */
module.setNamespace(m);
/* step 10 */
return m;
}
use of com.github.anba.es6draft.runtime.types.Property in project es6draft by anba.
the class ArgumentsObject method CreateUnmappedArgumentsObject.
/**
* 9.4.4.6 CreateUnmappedArgumentsObject(argumentsList)
* <p>
* [Called from generated code]
*
* @param cx
* the execution context
* @param argumentsList
* the function arguments
* @return the strict mode arguments object
*/
public static ArgumentsObject CreateUnmappedArgumentsObject(ExecutionContext cx, Object[] argumentsList) {
/* step 1 */
int len = argumentsList.length;
/* steps 2-3 */
ArgumentsObject obj = new ArgumentsObject(cx.getRealm());
obj.setPrototype(cx.getIntrinsic(Intrinsics.ObjectPrototype));
/* step 4 */
obj.infallibleDefineOwnProperty("length", new Property(len, true, false, true));
/* steps 5-6 */
for (int index = 0; index < len; ++index) {
obj.setIndexed(index, argumentsList[index]);
}
Callable thrower = cx.getRealm().getThrowTypeError();
/* step 7 */
obj.infallibleDefineOwnProperty(BuiltinSymbol.iterator.get(), new Property(cx.getIntrinsic(Intrinsics.ArrayProto_values), true, false, true));
/* step 8 */
obj.infallibleDefineOwnProperty("callee", new Property(thrower, thrower, false, false));
/* step 9 */
obj.infallibleDefineOwnProperty("caller", new Property(thrower, thrower, false, false));
/* step 11 */
return obj;
}
Aggregations