Export js_CheckForStringIndex from jsobj.c for use by assert in jsinterp.c (416460, r=shaver).

This commit is contained in:
brendan@mozilla.org 2008-02-10 17:12:29 -08:00
parent fd3df216c5
commit b744a843ed
3 changed files with 32 additions and 23 deletions

View File

@ -329,8 +329,13 @@ js_FullTestPropertyCache(JSContext *cx, jsbytecode *pc,
}
if (PCVCAP_PCTYPE(vcap) == OBJ_SCOPE(pobj)->shape) {
#ifdef DEBUG
jsid id = ATOM_TO_JSID(atom);
CHECK_FOR_STRING_INDEX(id);
JS_ASSERT(SCOPE_GET_PROPERTY(OBJ_SCOPE(pobj), id));
JS_ASSERT(OBJ_SCOPE(pobj)->object == pobj);
JS_ASSERT(SCOPE_GET_PROPERTY(OBJ_SCOPE(pobj), ATOM_TO_JSID(atom)));
#endif
*pobjp = pobj;
return NULL;
}

View File

@ -2824,28 +2824,9 @@ js_FreeSlot(JSContext *cx, JSObject *obj, uint32 slot)
}
}
/* JSVAL_INT_MAX as a string */
#define JSVAL_INT_MAX_STRING "1073741823"
#define CHECK_FOR_STRING_INDEX(id) \
JS_BEGIN_MACRO \
if (JSID_IS_ATOM(id)) { \
JSAtom *atom_ = JSID_TO_ATOM(id); \
JSString *str_ = ATOM_TO_STRING(atom_); \
const jschar *cp_ = JSFLATSTR_CHARS(str_); \
JSBool negative_ = (*cp_ == '-'); \
if (negative_) cp_++; \
if (JS7_ISDEC(*cp_)) { \
size_t n_ = JSFLATSTR_LENGTH(str_) - negative_; \
if (n_ <= sizeof(JSVAL_INT_MAX_STRING) - 1) \
id = CheckForStringIndex(id, cp_, cp_ + n_, negative_); \
} \
} \
JS_END_MACRO
static jsid
CheckForStringIndex(jsid id, const jschar *cp, const jschar *end,
JSBool negative)
jsid
js_CheckForStringIndex(jsid id, const jschar *cp, const jschar *end,
JSBool negative)
{
jsuint index = JS7_UNDEC(*cp++);
jsuint oldIndex = 0;

View File

@ -450,6 +450,29 @@ js_AllocSlot(JSContext *cx, JSObject *obj, uint32 *slotp);
extern void
js_FreeSlot(JSContext *cx, JSObject *obj, uint32 slot);
/* JSVAL_INT_MAX as a string */
#define JSVAL_INT_MAX_STRING "1073741823"
#define CHECK_FOR_STRING_INDEX(id) \
JS_BEGIN_MACRO \
if (JSID_IS_ATOM(id)) { \
JSAtom *atom_ = JSID_TO_ATOM(id); \
JSString *str_ = ATOM_TO_STRING(atom_); \
const jschar *s_ = JSFLATSTR_CHARS(str_); \
JSBool negative_ = (*s_ == '-'); \
if (negative_) s_++; \
if (JS7_ISDEC(*s_)) { \
size_t n_ = JSFLATSTR_LENGTH(str_) - negative_; \
if (n_ <= sizeof(JSVAL_INT_MAX_STRING) - 1) \
id = js_CheckForStringIndex(id, s_, s_ + n_, negative_); \
} \
} \
JS_END_MACRO
extern jsid
js_CheckForStringIndex(jsid id, const jschar *cp, const jschar *end,
JSBool negative);
/*
* Find or create a property named by id in obj's scope, with the given getter
* and setter, slot, attributes, and other members.