Example #1
0
// ECMA262: 26.1.6 Reflect.get ( target, propertyKey [ , receiver ]) 
static ejsval
_ejs_Reflect_get (ejsval env, ejsval _this, uint32_t argc, ejsval *args)
{
    ejsval target = _ejs_undefined;
    ejsval propertyKey = _ejs_undefined;
    ejsval receiver = _ejs_undefined;

    if (argc > 0) target       = args[0];
    if (argc > 1) propertyKey  = args[1];
    if (argc > 2) receiver     = args[2];

    // 1. Let obj be ToObject(target). 
    // 2. ReturnIfAbrupt(obj). 
    ejsval obj = ToObject(target);

    // 3. Let key be ToPropertyKey(propertyKey). 
    // 4. ReturnIfAbrupt(key). 
    ejsval key = ToPropertyKey(propertyKey);

    // 5. If receiver is not present, then 
    //    a. Let receiver be target. 
    if (argc <= 2)
        receiver = target;

    // 6. Return the result of calling the [[Get]] internal method of obj with arguments key, and receiver
    return OP(EJSVAL_TO_OBJECT(obj),Get)(obj, key, receiver);
}
Example #2
0
// ECMA262: 26.1.13 Reflect.set ( target, propertyKey, V [ , receiver ] ) 
static ejsval
_ejs_Reflect_set (ejsval env, ejsval _this, uint32_t argc, ejsval *args)
{
    ejsval target      = _ejs_undefined;
    ejsval propertyKey = _ejs_undefined;
    ejsval V           = _ejs_undefined;
    ejsval receiver    = _ejs_undefined;

    if (argc > 0) target       = args[0];
    if (argc > 1) propertyKey  = args[1];
    if (argc > 2) V            = args[2];
    if (argc > 3) receiver     = args[3];

    // 1. Let obj be ToObject(target). 
    // 2. ReturnIfAbrupt(obj). 
    ejsval obj = ToObject(target);

    // 3. Let key be ToPropertyKey(propertyKey). 
    // 4. ReturnIfAbrupt(key). 
    ejsval key = ToPropertyKey(propertyKey);

    // 5. If receiver is not present, then 
    //    a. Let receiver be target. 
    if (argc <= 3)
        receiver = target;

    // 6. Return the result of calling the [[Set]] internal method of obj with arguments key, V, and receiver. 
    return BOOLEAN_TO_EJSVAL(_ejs_specop_set(obj, key, V, receiver));
}
Example #3
0
// ECMA262: 26.1.9 Reflect.has ( target, propertyKey ) 
static ejsval
_ejs_Reflect_has (ejsval env, ejsval _this, uint32_t argc, ejsval *args)
{
    ejsval target = _ejs_undefined;
    ejsval propertyKey = _ejs_undefined;

    if (argc > 0) target       = args[0];
    if (argc > 1) propertyKey  = args[1];

    // 1. Let obj be ToObject(target). 
    // 2. ReturnIfAbrupt(obj). 
    ejsval obj = ToObject(target);

    // 3. Let key be ToPropertyKey(propertyKey). 
    // 4. ReturnIfAbrupt(key). 
    ejsval key = ToPropertyKey(propertyKey);
    
    // 5. Return the result of calling the [[HasProperty]] internal method of obj with argument key.
    return BOOLEAN_TO_EJSVAL(OP(EJSVAL_TO_OBJECT(obj),HasProperty)(obj, key));
}
Example #4
0
// ECMA262: 26.1.7 Reflect.getOwnPropertyDescriptor ( target, propertyKey )
static ejsval
_ejs_Reflect_getOwnPropertyDescriptor (ejsval env, ejsval _this, uint32_t argc, ejsval *args)
{
    ejsval target = _ejs_undefined;
    ejsval propertyKey = _ejs_undefined;
    if (argc > 0) target = args[0];
    if (argc > 1) propertyKey = args[1];

    // 1. Let obj be ToObject(target). 
    // 2. ReturnIfAbrupt(obj). 
    ejsval obj = ToObject(target);

    // 3. Let key be ToPropertyKey(propertyKey). 
    // 4. ReturnIfAbrupt(key). 
    ejsval key = ToPropertyKey(propertyKey);

    // 5. Let desc be the result of calling the [[GetOwnProperty]] internal method of obj with argument key. 
    // 6. ReturnIfAbrupt(desc). 
    EJSPropertyDesc* desc = OP(EJSVAL_TO_OBJECT(obj),GetOwnProperty)(obj, key, NULL);

    // 7. Return the result of calling FromPropertyDescriptor(desc). 
    return FromPropertyDescriptor(desc);
}