use of com.github.anba.es6draft.runtime.types.Callable in project es6draft by anba.
the class ProxyObject method setPrototypeOf.
/**
* 9.5.2 [[SetPrototypeOf]] (V)
*/
@Override
public boolean setPrototypeOf(ExecutionContext cx, ScriptObject prototype) {
/* step 1 (implicit) */
/* steps 2-4 */
ScriptObject handler = getProxyHandler(cx);
/* step 5 */
ScriptObject target = getProxyTarget();
/* step 6 */
Callable trap = GetMethod(cx, handler, "setPrototypeOf");
/* step 7 */
if (trap == null) {
return target.setPrototypeOf(cx, prototype);
}
/* step 8 */
Object prototypeValue = prototype != null ? prototype : NULL;
boolean trapResult = ToBoolean(trap.call(cx, handler, target, prototypeValue));
/* step 9 */
if (!trapResult) {
return false;
}
/* step 10 */
boolean extensibleTarget = IsExtensible(cx, target);
/* step 11 */
if (extensibleTarget) {
return true;
}
/* step 12 */
ScriptObject targetProto = target.getPrototypeOf(cx);
/* step 13 */
if (prototype != targetProto) {
throw newTypeError(cx, Messages.Key.ProxySamePrototype);
}
/* step 14 */
return true;
}
use of com.github.anba.es6draft.runtime.types.Callable in project es6draft by anba.
the class ProxyObject method ownPropertyKeys.
/**
* 9.5.12 [[OwnPropertyKeys]] ()
*/
@Override
public List<?> ownPropertyKeys(ExecutionContext cx) {
/* steps 1-3 */
ScriptObject handler = getProxyHandler(cx);
/* step 4 */
ScriptObject target = getProxyTarget();
/* steps 5-6 */
Callable trap = GetMethod(cx, handler, "ownKeys");
/* step 7 */
if (trap == null) {
return target.ownPropertyKeys(cx);
}
/* step 8 */
Object trapResultArray = trap.call(cx, handler, target);
/* steps 9-25 */
return validateOwnPropertyKeys(cx, target, trapResultArray);
}
use of com.github.anba.es6draft.runtime.types.Callable in project es6draft by anba.
the class ProxyObject method enumerateKeys.
/**
* 9.5.11 [[Enumerate]] ()
*/
@Override
public ScriptIterator<?> enumerateKeys(ExecutionContext cx) {
/* steps 1-3 */
ScriptObject handler = getProxyHandler(cx);
/* step 4 */
ScriptObject target = getProxyTarget();
/* steps 5-6 */
Callable trap = GetMethod(cx, handler, "enumerate");
/* step 7 */
if (trap == null) {
return target.enumerateKeys(cx);
}
/* steps 8-9 */
Object trapResult = trap.call(cx, handler, target);
/* step 10 */
if (!Type.isObject(trapResult)) {
throw newTypeError(cx, Messages.Key.ProxyNotObject);
}
/* step 11 */
return ToScriptIterator(cx, Type.objectValue(trapResult));
}
use of com.github.anba.es6draft.runtime.types.Callable in project es6draft by anba.
the class ProxyObject method getOwnProperty.
/**
* 9.5.5 [[GetOwnProperty]] (P)
*/
@Override
public Property getOwnProperty(ExecutionContext cx, String propertyKey) {
/* step 1 (implicit) */
/* steps 2-4 */
ScriptObject handler = getProxyHandler(cx);
/* step 5 */
ScriptObject target = getProxyTarget();
/* steps 6-7 */
Callable trap = GetMethod(cx, handler, "getOwnPropertyDescriptor");
/* step 8 */
if (trap == null) {
return target.getOwnProperty(cx, propertyKey);
}
/* steps 9-10 */
Object trapResultObj = trap.call(cx, handler, target, propertyKey);
/* step 11 */
if (!(Type.isObject(trapResultObj) || Type.isUndefined(trapResultObj))) {
throw newTypeError(cx, Messages.Key.ProxyNotObjectOrUndefined);
}
/* steps 12-13 */
Property targetDesc = target.getOwnProperty(cx, propertyKey);
/* steps 14-23 */
return validateGetOwnProperty(cx, target, trapResultObj, targetDesc);
}
use of com.github.anba.es6draft.runtime.types.Callable in project es6draft by anba.
the class ProxyObject method hasProperty.
/**
* 9.5.7 [[HasProperty]] (P)
*/
@Override
public boolean hasProperty(ExecutionContext cx, String propertyKey) {
/* step 1 (implicit) */
/* steps 2-4 */
ScriptObject handler = getProxyHandler(cx);
/* step 5 */
ScriptObject target = getProxyTarget();
/* steps 6-7 */
Callable trap = GetMethod(cx, handler, "has");
/* step 8 */
if (trap == null) {
return target.hasProperty(cx, propertyKey);
}
/* steps 9-10 */
boolean trapResult = ToBoolean(trap.call(cx, handler, target, propertyKey));
/* step 11 */
if (!trapResult) {
/* steps 11.a-11.b */
Property targetDesc = target.getOwnProperty(cx, propertyKey);
/* step 11.c */
validateHasProperty(cx, target, targetDesc);
}
/* step 12 */
return trapResult;
}
Aggregations