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

Unified Diff: src/v8natives.js

Issue 9630009: Implement Object.is and Number.is[Finite,NaN] functions. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments by Andreas Rossberg. Created 8 years, 9 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 | « no previous file | test/mjsunit/mjsunit.js » ('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 26724a24199d3384e224573a6bc50138071d4d75..f1e8084a53038dff8d8c33a888d2e1bf41311af4 100644
--- a/src/v8natives.js
+++ b/src/v8natives.js
@@ -1258,6 +1258,16 @@ function ObjectIsExtensible(obj) {
}
+// Harmony egal.
+function ObjectIs(obj1, obj2) {
+ if (obj1 === obj2) {
arv (Not doing code reviews) 2012/03/13 05:15:49 Why don't we use the SameValue function? http://c
Michael Starzinger 2012/03/13 09:02:08 Yes we could use that function, but I didn't care
+ return (obj1 !== 0) || (1 / obj1 === 1 / obj2);
+ } else {
+ return (obj1 !== obj1) && (obj2 !== obj2);
+ }
+}
+
+
%SetCode($Object, function(x) {
if (%_IsConstructCall()) {
if (x == null) return this;
@@ -1297,6 +1307,7 @@ function SetUpObject() {
"getPrototypeOf", ObjectGetPrototypeOf,
"getOwnPropertyDescriptor", ObjectGetOwnPropertyDescriptor,
"getOwnPropertyNames", ObjectGetOwnPropertyNames,
+ "is", ObjectIs,
"isExtensible", ObjectIsExtensible,
"isFrozen", ObjectIsFrozen,
"isSealed", ObjectIsSealed,
@@ -1461,6 +1472,18 @@ function NumberToPrecision(precision) {
}
+// Harmony isFinite.
+function NumberIsFinite(number) {
+ return IS_NUMBER(number) && NUMBER_IS_FINITE(number);
+}
+
+
+// Harmony isNaN.
+function NumberIsNaN(number) {
+ return IS_NUMBER(number) && NUMBER_IS_NAN(number);
+}
+
+
// ----------------------------------------------------------------------------
function SetUpNumber() {
@@ -1505,6 +1528,10 @@ function SetUpNumber() {
"toExponential", NumberToExponential,
"toPrecision", NumberToPrecision
));
+ InstallFunctions($Number, DONT_ENUM, $Array(
+ "isFinite", NumberIsFinite,
+ "isNaN", NumberIsNaN
+ ));
}
SetUpNumber();
« no previous file with comments | « no previous file | test/mjsunit/mjsunit.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698