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

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

Issue 1997473002: Future flattening at runtime. (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 | « lib/src/compiler/code_generator.dart ('k') | tool/patch_sdk.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tool/input_sdk/private/ddc_runtime/classes.dart
diff --git a/tool/input_sdk/private/ddc_runtime/classes.dart b/tool/input_sdk/private/ddc_runtime/classes.dart
index f6cb1af603420b0268f107db6021f6bda12df2ce..637a2302ff1b01a491f038a6b79fb87e2f59dafe 100644
--- a/tool/input_sdk/private/ddc_runtime/classes.dart
+++ b/tool/input_sdk/private/ddc_runtime/classes.dart
@@ -75,6 +75,24 @@ final _typeArguments = JS('', 'Symbol("typeArguments")');
final _originalDeclaration = JS('', 'Symbol("originalDeclaration")');
+/// Wrap a generic class builder function with future flattening.
+flattenFutures(builder) => JS('', '''(() => {
+ function flatten(T) {
+ if (!T) return $builder($dynamic);
+ let futureClass = $getGenericClass($Future);
+ //TODO(leafp): This only handles the direct flattening case.
+ // It would probably be good to at least search up the class
+ // hierarchy. If we keep doing flattening long term, we may
+ // want to implement the full future flattening per spec.
+ if ($getGenericClass(T) == futureClass) {
+ let args = $getGenericArgs(T);
+ if (args) return $builder(args[0]);
+ }
+ return $builder(T);
+ }
+ return flatten;
+})()''');
+
/// Memoize a generic type constructor function.
generic(typeConstructor) => JS('', '''(() => {
let length = $typeConstructor.length;
« no previous file with comments | « lib/src/compiler/code_generator.dart ('k') | tool/patch_sdk.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698