Bug 921548 - Remove js_ValueToNonNullObject, which was entirely equivalent to ToObject. r=jorendorff

--HG--
extra : rebase_source : 75b6afc174a72cd24f95edeee1291482b162bef8
This commit is contained in:
Jeff Walden 2013-09-27 11:19:47 -07:00
parent 26d2825aaf
commit 8c90bd1052
7 changed files with 8 additions and 24 deletions

View File

@ -53,7 +53,7 @@ function test()
webconsole: hud,
messages: [
{
text: "TypeError: this._toolPanels is null",
text: "TypeError: can't convert null to object",
category: CATEGORY_JS,
severity: SEVERITY_ERROR,
},

View File

@ -1175,7 +1175,7 @@ MapObject::construct(JSContext *cx, unsigned argc, Value *vp)
if (args.hasDefined(0)) {
ForOfIterator iter(cx, args[0]);
while (iter.next()) {
RootedObject pairobj(cx, js_ValueToNonNullObject(cx, iter.value()));
RootedObject pairobj(cx, ToObject(cx, iter.value()));
if (!pairobj)
return false;

View File

@ -1,3 +1,5 @@
load(libdir + "asserts.js");
function check_one(expected, f, err) {
var failed = true;
try {
@ -6,7 +8,7 @@ function check_one(expected, f, err) {
} catch (ex) {
var s = ex.toString();
assertEq(s.slice(0, 11), "TypeError: ");
assertEq(s.slice(-err.length), err);
assertEq(s.slice(-err.length), err, "" + f);
assertEq(s.slice(11, -err.length), expected);
}
if (!failed)
@ -97,4 +99,4 @@ check_one("null", function () { var [{ x }] = [null, {}]; }, " has no properties
check_one("x", function () { ieval("let (x) { var [a, b, [c0, c1]] = [x, x, x]; }") }, " is undefined");
// Check fallback behavior
check_one("undefined", (function () { for (let x of undefined) {} }), " has no properties");
assertThrowsInstanceOf(function () { for (let x of undefined) {} }, TypeError);

View File

@ -985,7 +985,7 @@ js::ValueToIterator(JSContext *cx, unsigned flags, MutableHandleValue vp)
return false;
/* fall through */
} else {
obj = js_ValueToNonNullObject(cx, vp);
obj = ToObject(cx, vp);
if (!obj)
return false;
}

View File

@ -5185,20 +5185,6 @@ js::ToObjectSlow(JSContext *cx, HandleValue val, bool reportScanStack)
return PrimitiveToObject(cx, val);
}
JSObject *
js_ValueToNonNullObject(JSContext *cx, const Value &v)
{
RootedObject obj(cx);
if (!js_ValueToObjectOrNull(cx, v, &obj))
return NULL;
if (!obj) {
RootedValue val(cx, v);
js_ReportIsNullOrUndefined(cx, JSDVG_SEARCH_STACK, val, NullPtr());
}
return obj;
}
void
js_GetObjectSlotName(JSTracer *trc, char *buf, size_t bufsize)
{

View File

@ -1468,10 +1468,6 @@ PrimitiveToObject(JSContext *cx, const Value &v);
extern bool
js_ValueToObjectOrNull(JSContext *cx, const js::Value &v, JS::MutableHandleObject objp);
/* Throws if v could not be converted to an object. */
extern JSObject *
js_ValueToNonNullObject(JSContext *cx, const js::Value &v);
namespace js {
/*

View File

@ -825,7 +825,7 @@ EnterWith(JSContext *cx, AbstractFramePtr frame, HandleValue val, uint32_t stack
if (val.isObject()) {
obj = &val.toObject();
} else {
obj = js_ValueToNonNullObject(cx, val);
obj = ToObject(cx, val);
if (!obj)
return false;
}