use of com.github.anba.es6draft.runtime.types.Property in project es6draft by anba.
the class OrdinaryFunction method SetFunctionName.
/**
* 9.2.11 SetFunctionName (F, name, prefix)
*
* @param <FUNCTION>
* the function type
* @param f
* the function object
* @param name
* the function name
* @param prefix
* the function name prefix
*/
public static <FUNCTION extends OrdinaryObject & Callable> void SetFunctionName(FUNCTION f, Symbol name, String prefix) {
/* step 1 */
assert f.isExtensible() && !f.ordinaryHasOwnProperty("name");
/* steps 2-3 (not applicable) */
/* step 4 */
String description = name.getDescription();
String sname = description == null ? "" : "[" + description + "]";
/* step 5 */
if (prefix != null) {
sname = prefix + " " + sname;
}
/* steps 6-7 */
f.infallibleDefineOwnProperty("name", new Property(sname, false, false, true));
}
use of com.github.anba.es6draft.runtime.types.Property in project es6draft by anba.
the class ProxyObject method defineOwnProperty.
/**
* 9.5.6 [[DefineOwnProperty]] (P, Desc)
*/
@Override
public boolean defineOwnProperty(ExecutionContext cx, long propertyKey, PropertyDescriptor desc) {
/* step 1 (implicit) */
/* steps 2-4 */
ScriptObject handler = getProxyHandler(cx);
/* step 5 */
ScriptObject target = getProxyTarget();
/* step 6 */
Callable trap = GetMethod(cx, handler, "defineProperty");
/* step 7 */
if (trap == null) {
return target.defineOwnProperty(cx, propertyKey, desc);
}
/* step 8 */
Object descObj = FromPropertyDescriptor(cx, desc);
/* step 9 */
boolean trapResult = ToBoolean(trap.call(cx, handler, target, ToString(propertyKey), descObj));
/* step 10 */
if (!trapResult) {
return false;
}
/* step 11 */
Property targetDesc = target.getOwnProperty(cx, propertyKey);
/* steps 12-17 */
return validateDefineOwnProperty(cx, desc, target, targetDesc);
}
use of com.github.anba.es6draft.runtime.types.Property in project es6draft by anba.
the class ProxyObject method get.
/**
* 9.5.8 [[Get]] (P, Receiver)
*/
@Override
public Object get(ExecutionContext cx, long propertyKey, Object receiver) {
/* step 1 (implicit) */
/* steps 2-4 */
ScriptObject handler = getProxyHandler(cx);
/* step 5 */
ScriptObject target = getProxyTarget();
/* step 6 */
Callable trap = GetMethod(cx, handler, "get");
/* step 7 */
if (trap == null) {
return target.get(cx, propertyKey, receiver);
}
/* step 8 */
Object trapResult = trap.call(cx, handler, target, ToString(propertyKey), receiver);
/* step 9 */
Property targetDesc = target.getOwnProperty(cx, propertyKey);
/* steps 10-11 */
return validateGet(cx, trapResult, targetDesc);
}
use of com.github.anba.es6draft.runtime.types.Property in project es6draft by anba.
the class ProxyObject method delete.
/**
* 9.5.10 [[Delete]] (P)
*/
@Override
public boolean delete(ExecutionContext cx, Symbol propertyKey) {
/* step 1 (implicit) */
/* steps 2-4 */
ScriptObject handler = getProxyHandler(cx);
/* step 5 */
ScriptObject target = getProxyTarget();
/* step 6 */
Callable trap = GetMethod(cx, handler, "deleteProperty");
/* step 7 */
if (trap == null) {
return target.delete(cx, propertyKey);
}
/* step 8 */
boolean trapResult = ToBoolean(trap.call(cx, handler, target, propertyKey));
/* step 9 */
if (!trapResult) {
return false;
}
/* step 10 */
Property targetDesc = target.getOwnProperty(cx, propertyKey);
/* steps 11-13 */
return validateDelete(cx, targetDesc);
}
use of com.github.anba.es6draft.runtime.types.Property in project es6draft by anba.
the class ProxyObject method getOwnProperty.
/**
* 9.5.5 [[GetOwnProperty]] (P)
*/
@Override
public Property getOwnProperty(ExecutionContext cx, Symbol propertyKey) {
/* step 1 (implicit) */
/* steps 2-4 */
ScriptObject handler = getProxyHandler(cx);
/* step 5 */
ScriptObject target = getProxyTarget();
/* step 6 */
Callable trap = GetMethod(cx, handler, "getOwnPropertyDescriptor");
/* step 7 */
if (trap == null) {
return target.getOwnProperty(cx, propertyKey);
}
/* step 8 */
Object trapResultObj = trap.call(cx, handler, target, propertyKey);
/* step 9 */
if (!(Type.isObject(trapResultObj) || Type.isUndefined(trapResultObj))) {
throw newTypeError(cx, Messages.Key.ProxyNotObjectOrUndefined);
}
/* step 10 */
Property targetDesc = target.getOwnProperty(cx, propertyKey);
/* steps 11-18 */
return validateGetOwnProperty(cx, target, trapResultObj, targetDesc);
}
Aggregations