Index: tool/input_sdk/private/ddc_runtime/operations.dart |
diff --git a/tool/input_sdk/private/ddc_runtime/operations.dart b/tool/input_sdk/private/ddc_runtime/operations.dart |
index c6d58bbdd172e7ad344880fd2ec34e55f5694403..b9a324d7792a0b58e0599dda5fb1730680ddb3cc 100644 |
--- a/tool/input_sdk/private/ddc_runtime/operations.dart |
+++ b/tool/input_sdk/private/ddc_runtime/operations.dart |
@@ -466,7 +466,7 @@ _toString(obj) { |
if (extension != null) { |
return JS('', '#[dartx.toString]()', obj); |
} |
- return JS('', '#.toString()', obj); |
+ return JS('', '"" + #', obj); |
} |
// TODO(jmesserly): is the argument type verified statically? |
@@ -499,6 +499,18 @@ runtimeType(obj) { |
return JS('', '#.runtimeType', obj); |
} |
+/// Implements Dart's interpolated strings as ES2015 tagged template literals. |
+/// |
+/// For example: dart.str`hello ${name}` |
+String str(strings, @rest values) => JS('', '''(() => { |
+ let s = $strings[0]; |
+ for (let i = 0, len = $values.length; i < len; ) { |
+ s += $notNull($_toString($values[i])) + $strings[++i]; |
+ } |
+ return s; |
+})()'''); |
+ |
+ |
final JsIterator = JS('', ''' |
class JsIterator { |
constructor(dartIterator) { |