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

Side by Side Diff: pkg/dev_compiler/lib/src/compiler/code_generator.dart

Issue 2624283003: Revert "Add support for generic function type syntax, part 1" (TBR) (Closed)
Patch Set: Created 3 years, 11 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 unified diff | Download patch
« no previous file with comments | « pkg/dev_compiler/lib/src/compiler/ast_builder.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 2
3 // for details. All rights reserved. Use of this source code is governed by a 3 // for details. All rights reserved. Use of this source code is governed by a
4 // BSD-style license that can be found in the LICENSE file. 4 // BSD-style license that can be found in the LICENSE file.
5 5
6 import 'dart:collection' show HashMap, HashSet; 6 import 'dart:collection' show HashMap, HashSet;
7 import 'dart:math' show min, max; 7 import 'dart:math' show min, max;
8 8
9 import 'package:analyzer/analyzer.dart' hide ConstantEvaluator; 9 import 'package:analyzer/analyzer.dart' hide ConstantEvaluator;
10 import 'package:analyzer/dart/ast/ast.dart'; 10 import 'package:analyzer/dart/ast/ast.dart';
(...skipping 3606 matching lines...) Expand 10 before | Expand all | Expand 10 after
3617 List<JS.Expression> _emitFunctionTypeArguments(DartType g, DartType f, 3617 List<JS.Expression> _emitFunctionTypeArguments(DartType g, DartType f,
3618 [TypeArgumentList typeArgs]) { 3618 [TypeArgumentList typeArgs]) {
3619 if (g is FunctionType && 3619 if (g is FunctionType &&
3620 g.typeFormals.isNotEmpty && 3620 g.typeFormals.isNotEmpty &&
3621 f is FunctionType && 3621 f is FunctionType &&
3622 f.typeFormals.isEmpty) { 3622 f.typeFormals.isEmpty) {
3623 return _recoverTypeArguments(g, f).map(_emitType).toList(growable: false); 3623 return _recoverTypeArguments(g, f).map(_emitType).toList(growable: false);
3624 } else if (typeArgs != null) { 3624 } else if (typeArgs != null) {
3625 // Dynamic calls may have type arguments, even though the function types 3625 // Dynamic calls may have type arguments, even though the function types
3626 // are not known. 3626 // are not known.
3627 return typeArgs.arguments.map((argument) { 3627 return typeArgs.arguments.map(visitTypeName).toList(growable: false);
3628 if (argument is TypeName) {
3629 return visitTypeName(argument);
3630 } else {
3631 // TODO(brianwilkerson) Implement support for GenericFunctionType.
3632 throw new StateError(
3633 'Cannot compile type argument of kind ${argument.runtimeType}');
3634 }
3635 }).toList(growable: false);
3636 } 3628 }
3637 return null; 3629 return null;
3638 } 3630 }
3639 3631
3640 /// Given a generic function type [g] and an instantiated function type [f], 3632 /// Given a generic function type [g] and an instantiated function type [f],
3641 /// find a list of type arguments TArgs such that `g<TArgs> == f`, 3633 /// find a list of type arguments TArgs such that `g<TArgs> == f`,
3642 /// and return TArgs. 3634 /// and return TArgs.
3643 /// 3635 ///
3644 /// This function must be called with type [f] that was instantiated from [g]. 3636 /// This function must be called with type [f] that was instantiated from [g].
3645 Iterable<DartType> _recoverTypeArguments(FunctionType g, FunctionType f) { 3637 Iterable<DartType> _recoverTypeArguments(FunctionType g, FunctionType f) {
(...skipping 2185 matching lines...) Expand 10 before | Expand all | Expand 10 after
5831 if (targetIdentifier.staticElement is! PrefixElement) return false; 5823 if (targetIdentifier.staticElement is! PrefixElement) return false;
5832 var prefix = targetIdentifier.staticElement as PrefixElement; 5824 var prefix = targetIdentifier.staticElement as PrefixElement;
5833 5825
5834 // The library the prefix is referring to must come from a deferred import. 5826 // The library the prefix is referring to must come from a deferred import.
5835 var containingLibrary = resolutionMap 5827 var containingLibrary = resolutionMap
5836 .elementDeclaredByCompilationUnit(target.root as CompilationUnit) 5828 .elementDeclaredByCompilationUnit(target.root as CompilationUnit)
5837 .library; 5829 .library;
5838 var imports = containingLibrary.getImportsWithPrefix(prefix); 5830 var imports = containingLibrary.getImportsWithPrefix(prefix);
5839 return imports.length == 1 && imports[0].isDeferred; 5831 return imports.length == 1 && imports[0].isDeferred;
5840 } 5832 }
OLDNEW
« no previous file with comments | « pkg/dev_compiler/lib/src/compiler/ast_builder.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698