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

Unified Diff: src/string.js

Issue 1027593005: [es6] remove --harmony-templates flag (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Remove extra references to harmony-templates stuff Created 5 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 | « src/scanner.cc ('k') | src/templates.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/string.js
diff --git a/src/string.js b/src/string.js
index 71b4e7e398e77d2b99175c82360b58d18b7fd234..6286be3e49d42e8e4fcad7c8b9286e3419d35b40 100644
--- a/src/string.js
+++ b/src/string.js
@@ -1091,6 +1091,29 @@ function StringFromCodePoint(_) { // length = 1
}
+// -------------------------------------------------------------------
+// String methods related to templates
+
+// ES6 Draft 03-17-2015, section 21.1.2.4
+function StringRaw(callSite) {
+ // TODO(caitp): Use rest parameters when implemented
+ var numberOfSubstitutions = %_ArgumentsLength();
+ var cooked = ToObject(callSite);
+ var raw = ToObject(cooked.raw);
+ var literalSegments = ToLength(raw.length);
+ if (literalSegments <= 0) return "";
+
+ var result = ToString(raw[0]);
+
+ for (var i = 1; i < literalSegments; ++i) {
+ if (i < numberOfSubstitutions) {
+ result += ToString(%_Arguments(i));
+ }
+ result += ToString(raw[i]);
+ }
+
+ return result;
+}
// -------------------------------------------------------------------
@@ -1105,7 +1128,8 @@ function StringFromCodePoint(_) { // length = 1
// Set up the non-enumerable functions on the String object.
InstallFunctions(GlobalString, DONT_ENUM, GlobalArray(
"fromCharCode", StringFromCharCode,
- "fromCodePoint", StringFromCodePoint
+ "fromCodePoint", StringFromCodePoint,
+ "raw", StringRaw
));
// Set up the non-enumerable functions on the String prototype object.
« no previous file with comments | « src/scanner.cc ('k') | src/templates.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698