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

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
« no previous file with comments | « test/codegen/expect/sunflower/sunflower.js.map ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) {
« no previous file with comments | « 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