Fixed bugs; can compile imacros

This commit is contained in:
Luke Wagner
2010-05-19 17:11:57 -07:00
parent 2e25472d9d
commit f89fd83a65
4 changed files with 37 additions and 33 deletions

View File

@@ -177,12 +177,8 @@ Enumerate(JSContext *cx, JSObject *obj, jsid id, bool enumerable, uintN flags,
if (!NewKeyValuePair(cx, IdToValue(id), *tmpRoot, wp))
return false;
} else {
/*
* TODO: This is expensive and unnecessary if there are a bunch
* of doubles. To fix, we need to change the stored type of
* iterators to something fatter than jsboxedword when
* iterating in a for-each.
*/
/* XXX: this begs for a for-each-specialized iterator: we are
* boxing going both directions! */
if (!ValueToBoxedWord(cx, *tmpRoot, wp))
return false;
}
@@ -657,10 +653,19 @@ js_IteratorNext(JSContext *cx, JSObject *iterobj, Value *rval)
*/
NativeIterator *ni = iterobj->getNativeIterator();
JS_ASSERT(ni->props_cursor < ni->props_end);
*rval = BoxedWordToValue(*ni->props_cursor++);
if (rval->isString() || (ni->flags & JSITER_FOREACH))
/* Stringifying of array indices is a common case. */
jsboxedword w = *ni->props_cursor++;
if (JSBOXEDWORD_IS_INT(w)) {
rval->setInt32(JSBOXEDWORD_TO_INT(w));
} else if (JSBOXEDWORD_IS_STRING(w)) {
rval->setString(JSBOXEDWORD_TO_STRING(w));
return true;
} else {
*rval = BoxedWordToValue(w);
if (ni->flags & JSITER_FOREACH)
return true;
}
JSString *str;
jsint i;