| Index: src/harmony-templates.js
|
| diff --git a/src/harmony-templates.js b/src/harmony-templates.js
|
| index dd122cce85f28ae5e478af25fb9a1a8c8bbb2c9c..712d8d3a12bbb996d1bd838c09d81fd9d180e3e6 100644
|
| --- a/src/harmony-templates.js
|
| +++ b/src/harmony-templates.js
|
| @@ -12,3 +12,37 @@ function GetTemplateCallSite(siteObj, rawStrings) {
|
|
|
| return %ObjectFreeze(siteObj);
|
| }
|
| +
|
| +
|
| +// ES6 Draft 10-14-2014, 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;
|
| +}
|
| +
|
| +
|
| +function ExtendStringForTemplates() {
|
| + %CheckIsBootstrapping();
|
| +
|
| + // Set up the non-enumerable functions on the String object.
|
| + InstallFunctions($String, DONT_ENUM, $Array(
|
| + "raw", StringRaw
|
| + ));
|
| +}
|
| +
|
| +ExtendStringForTemplates();
|
|
|