55 |
#include "jsarray.h" |
#include "jsarray.h" |
56 |
#include "jsatom.h" |
#include "jsatom.h" |
57 |
#include "jsbool.h" |
#include "jsbool.h" |
58 |
|
#include "jsbuiltins.h" |
59 |
#include "jscntxt.h" |
#include "jscntxt.h" |
60 |
#include "jsversion.h" |
#include "jsversion.h" |
61 |
#include "jsemit.h" |
#include "jsemit.h" |
325 |
} |
} |
326 |
return JS_FALSE; |
return JS_FALSE; |
327 |
} |
} |
328 |
|
|
329 |
|
// Maintain the "any Array prototype has indexed properties hazard" flag. |
330 |
|
if (slot == JSSLOT_PROTO && |
331 |
|
OBJ_IS_ARRAY(cx, pobj) && |
332 |
|
pobj->fslots[JSSLOT_ARRAY_LENGTH] != 0) { |
333 |
|
rt->anyArrayProtoHasElement = JS_TRUE; |
334 |
|
} |
335 |
return JS_TRUE; |
return JS_TRUE; |
336 |
} |
} |
337 |
|
|
1168 |
} |
} |
1169 |
|
|
1170 |
if (caller->regs && *caller->regs->pc == JSOP_EVAL) { |
if (caller->regs && *caller->regs->pc == JSOP_EVAL) { |
1171 |
JS_ASSERT(caller->regs->pc[JSOP_EVAL_LENGTH] == JSOP_RESUME); |
JS_ASSERT(caller->regs->pc[JSOP_EVAL_LENGTH] == JSOP_LINENO); |
1172 |
JS_ASSERT(caller->regs->pc[JSOP_EVAL_LENGTH + JSOP_RESUME_LENGTH] == JSOP_LINENO); |
*linenop = GET_UINT16(caller->regs->pc + JSOP_EVAL_LENGTH); |
|
*linenop = GET_UINT16(caller->regs->pc + JSOP_EVAL_LENGTH + JSOP_RESUME_LENGTH); |
|
1173 |
} else { |
} else { |
1174 |
*linenop = js_PCToLineNumber(cx, caller->script, |
*linenop = js_FramePCToLineNumber(cx, caller); |
|
caller->regs ? caller->regs->pc : NULL); |
|
1175 |
} |
} |
1176 |
return caller->script->filename; |
return caller->script->filename; |
1177 |
} |
} |
1178 |
|
|
1179 |
JSBool |
static JSBool |
1180 |
js_obj_eval(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) |
obj_eval(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) |
1181 |
{ |
{ |
1182 |
JSStackFrame *fp, *caller; |
JSStackFrame *fp, *caller; |
1183 |
JSBool indirectCall; |
JSBool indirectCall; |
1474 |
*/ |
*/ |
1475 |
|
|
1476 |
/* Proposed ECMA 15.2.4.5. */ |
/* Proposed ECMA 15.2.4.5. */ |
1477 |
JSBool |
static JSBool |
1478 |
js_obj_hasOwnProperty(JSContext *cx, uintN argc, jsval *vp) |
obj_hasOwnProperty(JSContext *cx, uintN argc, jsval *vp) |
1479 |
{ |
{ |
1480 |
JSObject *obj; |
JSObject *obj; |
1481 |
|
|
1554 |
return JS_TRUE; |
return JS_TRUE; |
1555 |
} |
} |
1556 |
|
|
1557 |
|
#ifdef JS_TRACER |
1558 |
|
static int32 FASTCALL |
1559 |
|
Object_p_hasOwnProperty(JSContext* cx, JSObject* obj, JSString *str) |
1560 |
|
{ |
1561 |
|
jsid id; |
1562 |
|
jsval v; |
1563 |
|
|
1564 |
|
if (!js_ValueToStringId(cx, STRING_TO_JSVAL(str), &id)) |
1565 |
|
return JSVAL_TO_BOOLEAN(JSVAL_VOID); |
1566 |
|
if (!js_HasOwnProperty(cx, obj->map->ops->lookupProperty, obj, id, &v)) |
1567 |
|
return JSVAL_TO_BOOLEAN(JSVAL_VOID); |
1568 |
|
JS_ASSERT(JSVAL_IS_BOOLEAN(v)); |
1569 |
|
return JSVAL_TO_BOOLEAN(v); |
1570 |
|
} |
1571 |
|
#endif |
1572 |
|
|
1573 |
/* Proposed ECMA 15.2.4.6. */ |
/* Proposed ECMA 15.2.4.6. */ |
1574 |
static JSBool |
static JSBool |
1575 |
obj_isPrototypeOf(JSContext *cx, uintN argc, jsval *vp) |
obj_isPrototypeOf(JSContext *cx, uintN argc, jsval *vp) |
1585 |
} |
} |
1586 |
|
|
1587 |
/* Proposed ECMA 15.2.4.7. */ |
/* Proposed ECMA 15.2.4.7. */ |
1588 |
JSBool |
static JSBool |
1589 |
js_obj_propertyIsEnumerable(JSContext *cx, uintN argc, jsval *vp) |
obj_propertyIsEnumerable(JSContext *cx, uintN argc, jsval *vp) |
1590 |
{ |
{ |
1591 |
jsid id; |
jsid id; |
1592 |
JSObject *obj; |
JSObject *obj; |
1598 |
return obj && js_PropertyIsEnumerable(cx, obj, id, vp); |
return obj && js_PropertyIsEnumerable(cx, obj, id, vp); |
1599 |
} |
} |
1600 |
|
|
1601 |
|
#ifdef JS_TRACER |
1602 |
|
static int32 FASTCALL |
1603 |
|
Object_p_propertyIsEnumerable(JSContext* cx, JSObject* obj, JSString *str) |
1604 |
|
{ |
1605 |
|
jsid id = ATOM_TO_JSID(STRING_TO_JSVAL(str)); |
1606 |
|
jsval v; |
1607 |
|
if (!js_PropertyIsEnumerable(cx, obj, id, &v)) |
1608 |
|
return JSVAL_TO_BOOLEAN(JSVAL_VOID); |
1609 |
|
JS_ASSERT(JSVAL_IS_BOOLEAN(v)); |
1610 |
|
return JSVAL_TO_BOOLEAN(v); |
1611 |
|
} |
1612 |
|
#endif |
1613 |
|
|
1614 |
JSBool |
JSBool |
1615 |
js_PropertyIsEnumerable(JSContext *cx, JSObject *obj, jsid id, jsval *vp) |
js_PropertyIsEnumerable(JSContext *cx, JSObject *obj, jsid id, jsval *vp) |
1616 |
{ |
{ |
1810 |
const char js_lookupSetter_str[] = "__lookupSetter__"; |
const char js_lookupSetter_str[] = "__lookupSetter__"; |
1811 |
#endif |
#endif |
1812 |
|
|
1813 |
|
JS_DEFINE_TRCINFO_1(obj_hasOwnProperty, |
1814 |
|
(3, (static, BOOL_FAIL, Object_p_hasOwnProperty, CONTEXT, THIS, STRING, 0, 0))) |
1815 |
|
JS_DEFINE_TRCINFO_1(obj_propertyIsEnumerable, |
1816 |
|
(3, (static, BOOL_FAIL, Object_p_propertyIsEnumerable, CONTEXT, THIS, STRING, 0, 0))) |
1817 |
|
|
1818 |
static JSFunctionSpec object_methods[] = { |
static JSFunctionSpec object_methods[] = { |
1819 |
#if JS_HAS_TOSOURCE |
#if JS_HAS_TOSOURCE |
1820 |
JS_FN(js_toSource_str, obj_toSource, 0,0), |
JS_FN(js_toSource_str, obj_toSource, 0,0), |
1826 |
JS_FN(js_watch_str, obj_watch, 2,0), |
JS_FN(js_watch_str, obj_watch, 2,0), |
1827 |
JS_FN(js_unwatch_str, obj_unwatch, 1,0), |
JS_FN(js_unwatch_str, obj_unwatch, 1,0), |
1828 |
#endif |
#endif |
1829 |
JS_FN(js_hasOwnProperty_str, js_obj_hasOwnProperty, 1,0), |
JS_TN(js_hasOwnProperty_str, obj_hasOwnProperty, 1,0, |
1830 |
|
obj_hasOwnProperty_trcinfo), |
1831 |
JS_FN(js_isPrototypeOf_str, obj_isPrototypeOf, 1,0), |
JS_FN(js_isPrototypeOf_str, obj_isPrototypeOf, 1,0), |
1832 |
JS_FN(js_propertyIsEnumerable_str, js_obj_propertyIsEnumerable, 1,0), |
JS_TN(js_propertyIsEnumerable_str, obj_propertyIsEnumerable, 1,0, |
1833 |
|
obj_propertyIsEnumerable_trcinfo), |
1834 |
#if JS_HAS_GETTER_SETTER |
#if JS_HAS_GETTER_SETTER |
1835 |
JS_FN(js_defineGetter_str, obj_defineGetter, 2,0), |
JS_FN(js_defineGetter_str, obj_defineGetter, 2,0), |
1836 |
JS_FN(js_defineSetter_str, obj_defineSetter, 2,0), |
JS_FN(js_defineSetter_str, obj_defineSetter, 2,0), |
1841 |
}; |
}; |
1842 |
|
|
1843 |
static JSFunctionSpec object_static_methods[] = { |
static JSFunctionSpec object_static_methods[] = { |
1844 |
JS_FN("getPrototypeOf", obj_getPrototypeOf, 1,0), |
JS_FN("getPrototypeOf", obj_getPrototypeOf, 1,0), |
1845 |
JS_FS_END |
JS_FS_END |
1846 |
}; |
}; |
1847 |
|
|
2326 |
{ |
{ |
2327 |
/* ECMA (15.1.2.1) says 'eval' is a property of the global object. */ |
/* ECMA (15.1.2.1) says 'eval' is a property of the global object. */ |
2328 |
if (!js_DefineFunction(cx, obj, cx->runtime->atomState.evalAtom, |
if (!js_DefineFunction(cx, obj, cx->runtime->atomState.evalAtom, |
2329 |
js_obj_eval, 1, 0)) { |
obj_eval, 1, 0)) { |
2330 |
return NULL; |
return NULL; |
2331 |
} |
} |
2332 |
|
|
3316 |
} |
} |
3317 |
return JS_FALSE; |
return JS_FALSE; |
3318 |
|
|
|
case JSOP_GROUP: |
|
|
break; |
|
|
|
|
3319 |
default: |
default: |
3320 |
/* |
/* |
3321 |
* At this point, anything but an extended atom index prefix means |
* At this point, anything but an extended atom index prefix means |
3413 |
format = cs->format; |
format = cs->format; |
3414 |
if (JOF_MODE(format) != JOF_NAME) |
if (JOF_MODE(format) != JOF_NAME) |
3415 |
flags |= JSRESOLVE_QUALIFIED; |
flags |= JSRESOLVE_QUALIFIED; |
3416 |
if ((format & JOF_ASSIGNING) || |
if ((format & (JOF_SET | JOF_FOR)) || |
3417 |
(cx->fp->flags & JSFRAME_ASSIGNING)) { |
(cx->fp->flags & JSFRAME_ASSIGNING)) { |
3418 |
flags |= JSRESOLVE_ASSIGNING; |
flags |= JSRESOLVE_ASSIGNING; |
3419 |
} else { |
} else { |
4620 |
|
|
4621 |
callee = JSVAL_TO_OBJECT(argv[-2]); |
callee = JSVAL_TO_OBJECT(argv[-2]); |
4622 |
if (!OBJ_GET_PROPERTY(cx, callee, |
if (!OBJ_GET_PROPERTY(cx, callee, |
4623 |
ATOM_TO_JSID(cx->runtime->atomState.callAtom), |
ATOM_TO_JSID(cx->runtime->atomState.__call__Atom), |
4624 |
&fval)) { |
&fval)) { |
4625 |
return JS_FALSE; |
return JS_FALSE; |
4626 |
} |
} |
4663 |
callee = JSVAL_TO_OBJECT(argv[-2]); |
callee = JSVAL_TO_OBJECT(argv[-2]); |
4664 |
if (!OBJ_GET_PROPERTY(cx, callee, |
if (!OBJ_GET_PROPERTY(cx, callee, |
4665 |
ATOM_TO_JSID(cx->runtime->atomState |
ATOM_TO_JSID(cx->runtime->atomState |
4666 |
.constructAtom), |
.__construct__Atom), |
4667 |
&cval)) { |
&cval)) { |
4668 |
return JS_FALSE; |
return JS_FALSE; |
4669 |
} |
} |
4703 |
|
|
4704 |
if (!OBJ_GET_PROPERTY(cx, obj, |
if (!OBJ_GET_PROPERTY(cx, obj, |
4705 |
ATOM_TO_JSID(cx->runtime->atomState |
ATOM_TO_JSID(cx->runtime->atomState |
4706 |
.hasInstanceAtom), |
.__hasInstance__Atom), |
4707 |
&fval)) { |
&fval)) { |
4708 |
return JS_FALSE; |
return JS_FALSE; |
4709 |
} |
} |
5458 |
fputc('\n', stderr); |
fputc('\n', stderr); |
5459 |
} |
} |
5460 |
|
|
5461 |
void |
static void |
5462 |
dumpScopeProp(JSScopeProperty *sprop) |
dumpScopeProp(JSScopeProperty *sprop) |
5463 |
{ |
{ |
5464 |
jsid id = sprop->id; |
jsid id = sprop->id; |
5488 |
uint32 i, slots; |
uint32 i, slots; |
5489 |
JSClass *clasp; |
JSClass *clasp; |
5490 |
jsuint reservedEnd; |
jsuint reservedEnd; |
5491 |
|
JSBool sharesScope = JS_FALSE; |
5492 |
|
|
5493 |
fprintf(stderr, "object %p\n", (void *) obj); |
fprintf(stderr, "object %p\n", (void *) obj); |
5494 |
clasp = STOBJ_GET_CLASS(obj); |
clasp = STOBJ_GET_CLASS(obj); |
5515 |
if (SCOPE_IS_SEALED(scope)) |
if (SCOPE_IS_SEALED(scope)) |
5516 |
fprintf(stderr, "sealed\n"); |
fprintf(stderr, "sealed\n"); |
5517 |
|
|
5518 |
if (proto && scope == OBJ_SCOPE(proto)) { |
sharesScope = (scope->object != obj); |
5519 |
fprintf(stderr, "shares scope with proto (%s at %p)\n", |
if (sharesScope) { |
5520 |
|
fprintf(stderr, "no own properties - see proto (%s at %p)\n", |
5521 |
STOBJ_GET_CLASS(proto)->name, proto); |
STOBJ_GET_CLASS(proto)->name, proto); |
5522 |
} |
} else { |
5523 |
|
fprintf(stderr, "properties:\n"); |
5524 |
fprintf(stderr, "properties:\n"); |
for (JSScopeProperty *sprop = SCOPE_LAST_PROP(scope); sprop; |
5525 |
for (JSScopeProperty *sprop = SCOPE_LAST_PROP(scope); sprop; |
sprop = sprop->parent) { |
5526 |
sprop = sprop->parent) { |
if (!SCOPE_HAD_MIDDLE_DELETE(scope) || |
5527 |
if (!SCOPE_HAD_MIDDLE_DELETE(scope) || |
SCOPE_HAS_PROPERTY(scope, sprop)) { |
5528 |
SCOPE_HAS_PROPERTY(scope, sprop)) { |
dumpScopeProp(sprop); |
5529 |
dumpScopeProp(sprop); |
} |
5530 |
} |
} |
5531 |
} |
} |
5532 |
} else { |
} else { |
5535 |
} |
} |
5536 |
|
|
5537 |
fprintf(stderr, "slots:\n"); |
fprintf(stderr, "slots:\n"); |
|
slots = obj->map->freeslot; |
|
5538 |
reservedEnd = JSSLOT_PRIVATE; |
reservedEnd = JSSLOT_PRIVATE; |
5539 |
if (clasp->flags & JSCLASS_HAS_PRIVATE) |
if (clasp->flags & JSCLASS_HAS_PRIVATE) |
5540 |
reservedEnd++; |
reservedEnd++; |
5541 |
reservedEnd += JSCLASS_RESERVED_SLOTS(clasp); |
reservedEnd += JSCLASS_RESERVED_SLOTS(clasp); |
5542 |
|
slots = sharesScope ? reservedEnd : obj->map->freeslot; |
5543 |
for (i = 0; i < slots; i++) { |
for (i = 0; i < slots; i++) { |
5544 |
fprintf(stderr, " %3d ", i); |
fprintf(stderr, " %3d ", i); |
5545 |
if (i == JSSLOT_PRIVATE && (clasp->flags & JSCLASS_HAS_PRIVATE)) { |
if (i == JSSLOT_PRIVATE && (clasp->flags & JSCLASS_HAS_PRIVATE)) { |
5546 |
fprintf(stderr, "(private) = %p", |
fprintf(stderr, "(private) = %p\n", |
5547 |
JSVAL_TO_PRIVATE(STOBJ_GET_SLOT(obj, i))); |
JSVAL_TO_PRIVATE(STOBJ_GET_SLOT(obj, i))); |
5548 |
continue; |
continue; |
5549 |
} |
} |