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

Unified Diff: tool/input_sdk/private/ddc_runtime/operations.dart

Issue 1989663002: fix #470, string interpolation now respects Dart toString (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 4 years, 7 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
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..e5de57819ebfbf26a955a6cf72c86788c9811169 100644
--- a/tool/input_sdk/private/ddc_runtime/operations.dart
+++ b/tool/input_sdk/private/ddc_runtime/operations.dart
@@ -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 += $_toString($values[i]) + $strings[++i];
+ }
+ return s;
+})()''');
+
+
final JsIterator = JS('', '''
class JsIterator {
constructor(dartIterator) {
« lib/src/compiler/code_generator.dart ('K') | « test/codegen/expect/sunflower/sunflower.js.map ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698