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

Unified Diff: src/js/string.js

Issue 2117273002: Revert of [intrinsic] Drop the %_ValueOf intrinsic. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 5 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/js/prologue.js ('k') | src/js/symbol.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/js/string.js
diff --git a/src/js/string.js b/src/js/string.js
index 5180e3056fa55c374531eaf0545a99b109f0f321..b3bc3933cda29b04a3253f74d6949c85419f7231 100644
--- a/src/js/string.js
+++ b/src/js/string.js
@@ -36,6 +36,24 @@
});
//-------------------------------------------------------------------
+
+// ECMA-262 section 15.5.4.2
+function StringToString() {
+ if (!IS_STRING(this) && !IS_STRING_WRAPPER(this)) {
+ throw MakeTypeError(kNotGeneric, 'String.prototype.toString');
+ }
+ return %_ValueOf(this);
+}
+
+
+// ECMA-262 section 15.5.4.3
+function StringValueOf() {
+ if (!IS_STRING(this) && !IS_STRING_WRAPPER(this)) {
+ throw MakeTypeError(kNotGeneric, 'String.prototype.valueOf');
+ }
+ return %_ValueOf(this);
+}
+
// ECMA-262, section 15.5.4.6
function StringConcat(other /* and more */) { // length == 1
@@ -738,6 +756,8 @@
// Set up the non-enumerable functions on the String prototype object.
utils.InstallFunctions(GlobalString.prototype, DONT_ENUM, [
+ "valueOf", StringValueOf,
+ "toString", StringToString,
"codePointAt", StringCodePointAt,
"concat", StringConcat,
"endsWith", StringEndsWith,
« no previous file with comments | « src/js/prologue.js ('k') | src/js/symbol.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698