Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(200)

Unified Diff: src/v8natives.js

Issue 6960009: Version 3.3.5 (Closed) Base URL: https://v8.googlecode.com/svn/trunk
Patch Set: Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/unbound-queue.h ('k') | src/v8threads.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/v8natives.js
diff --git a/src/v8natives.js b/src/v8natives.js
index 4fcf0ac481c3158e4318bbb4696bde4ac340817c..7a4be276d72f1af93e4c2cfa95e8956acfb429db 100644
--- a/src/v8natives.js
+++ b/src/v8natives.js
@@ -208,12 +208,20 @@ $Object.prototype.constructor = $Object;
// 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 @@ function ObjectHasOwnProperty(V) {
// 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 @@ function NumberToString(radix) {
// 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 @@ function NumberToFixed(fractionDigits) {
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 @@ function NumberToExponential(fractionDigits) {
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 @@ function NumberToExponential(fractionDigits) {
// 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) {
« no previous file with comments | « src/unbound-queue.h ('k') | src/v8threads.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698