Index: src/v8natives.js |
=================================================================== |
--- src/v8natives.js (revision 7676) |
+++ src/v8natives.js (working copy) |
@@ -208,12 +208,20 @@ |
// ECMA-262 - 15.2.4.2 |
function ObjectToString() { |
+ if (IS_UNDEFINED(this) && !IS_UNDETECTABLE(this)) { |
+ return '[object Undefined]'; |
+ } |
+ if (IS_NULL(this)) return '[object Null]'; |
return "[object " + %_ClassOf(ToObject(this)) + "]"; |
} |
// ECMA-262 - 15.2.4.3 |
function ObjectToLocaleString() { |
+ if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) { |
+ throw MakeTypeError("called_on_null_or_undefined", |
+ ["Object.prototype.toLocaleString"]); |
+ } |
return this.toString(); |
} |
@@ -232,6 +240,10 @@ |
// ECMA-262 - 15.2.4.6 |
function ObjectIsPrototypeOf(V) { |
+ if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) { |
+ throw MakeTypeError("called_on_null_or_undefined", |
+ ["Object.prototype.isPrototypeOf"]); |
+ } |
if (!IS_SPEC_OBJECT(V)) return false; |
return %IsInPrototypeChain(this, V); |
} |
@@ -1062,6 +1074,10 @@ |
// ECMA-262 section 15.7.4.3 |
function NumberToLocaleString() { |
+ if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) { |
+ throw MakeTypeError("called_on_null_or_undefined", |
+ ["Number.prototype.toLocaleString"]); |
+ } |
return this.toString(); |
} |
@@ -1082,6 +1098,10 @@ |
if (f < 0 || f > 20) { |
throw new $RangeError("toFixed() digits argument must be between 0 and 20"); |
} |
+ if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) { |
+ throw MakeTypeError("called_on_null_or_undefined", |
+ ["Number.prototype.toFixed"]); |
+ } |
var x = ToNumber(this); |
return %NumberToFixed(x, f); |
} |
@@ -1096,6 +1116,10 @@ |
throw new $RangeError("toExponential() argument must be between 0 and 20"); |
} |
} |
+ if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) { |
+ throw MakeTypeError("called_on_null_or_undefined", |
+ ["Number.prototype.toExponential"]); |
+ } |
var x = ToNumber(this); |
return %NumberToExponential(x, f); |
} |
@@ -1103,6 +1127,10 @@ |
// ECMA-262 section 15.7.4.7 |
function NumberToPrecision(precision) { |
+ if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) { |
+ throw MakeTypeError("called_on_null_or_undefined", |
+ ["Number.prototype.toPrecision"]); |
+ } |
if (IS_UNDEFINED(precision)) return ToString(%_ValueOf(this)); |
var p = TO_INTEGER(precision); |
if (p < 1 || p > 21) { |