OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library kernel.transformations.reify.transformation.builder; | 5 library kernel.transformations.reify.transformation.builder; |
6 | 6 |
7 import '../asts.dart'; | 7 import '../asts.dart'; |
8 import 'package:kernel/ast.dart'; | 8 import 'package:kernel/ast.dart'; |
9 import 'dart:collection' show LinkedHashMap; | 9 import 'dart:collection' show LinkedHashMap; |
10 import 'binding.dart' show RuntimeLibrary; | 10 import 'binding.dart' show RuntimeLibrary; |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 | 231 |
232 /// Helper to make recursive invocation more readable. | 232 /// Helper to make recursive invocation more readable. |
233 Expression createPart(DartType type) { | 233 Expression createPart(DartType type) { |
234 return createRuntimeType(type, | 234 return createRuntimeType(type, |
235 reifyTypeVariable: reifyTypeVariable, | 235 reifyTypeVariable: reifyTypeVariable, |
236 createReference: createReference, | 236 createReference: createReference, |
237 typeContext: typeContext); | 237 typeContext: typeContext); |
238 } | 238 } |
239 | 239 |
240 if (type is InterfaceType || type is Supertype) { | 240 if (type is InterfaceType || type is Supertype) { |
241 InterfaceType interfaceType = null; | 241 InterfaceType interfaceType = |
242 if (type is InterfaceType) { | 242 (type is InterfaceType) ? type : (type as Supertype).asInterfaceType; |
243 interfaceType = type; | |
244 } else { | |
245 interfaceType = (type as Supertype).asInterfaceType; | |
246 } | |
247 Class cls = interfaceType.classNode; | 243 Class cls = interfaceType.classNode; |
248 Expression declaration = createReference(cls); | 244 Expression declaration = createReference(cls); |
249 List<DartType> typeArguments = interfaceType.typeArguments; | 245 List<DartType> typeArguments = interfaceType.typeArguments; |
250 Expression typeArgumentList; | 246 Expression typeArgumentList; |
251 if (typeArguments.isNotEmpty) { | 247 if (typeArguments.isNotEmpty) { |
252 if (!reifyTypeVariable && matchesTypeParameters(typeArguments)) { | 248 if (!reifyTypeVariable && matchesTypeParameters(typeArguments)) { |
253 // The type argument list corresponds to the list of type parameters | 249 // The type argument list corresponds to the list of type parameters |
254 // and we are not in "declaration emitter" mode, we can reuse the | 250 // and we are not in "declaration emitter" mode, we can reuse the |
255 // type argument vector. | 251 // type argument vector. |
256 TypeParameterType parameterType = typeArguments[0]; | 252 TypeParameterType parameterType = typeArguments[0]; |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 declarations.type = declarationType; | 500 declarations.type = declarationType; |
505 } | 501 } |
506 | 502 |
507 Procedure createGetter( | 503 Procedure createGetter( |
508 Name name, Expression expression, Class cls, DartType type) { | 504 Name name, Expression expression, Class cls, DartType type) { |
509 return new Procedure(name, ProcedureKind.Getter, | 505 return new Procedure(name, ProcedureKind.Getter, |
510 new FunctionNode(new ReturnStatement(expression), returnType: type), | 506 new FunctionNode(new ReturnStatement(expression), returnType: type), |
511 fileUri: cls.fileUri); | 507 fileUri: cls.fileUri); |
512 } | 508 } |
513 } | 509 } |
OLD | NEW |