| OLD | NEW |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 /// This file declares a "shadow hierarchy" of concrete classes which extend | 5 /// This file declares a "shadow hierarchy" of concrete classes which extend |
| 6 /// the kernel class hierarchy, adding methods and fields needed by the | 6 /// the kernel class hierarchy, adding methods and fields needed by the |
| 7 /// BodyBuilder. | 7 /// BodyBuilder. |
| 8 /// | 8 /// |
| 9 /// Instances of these classes may be created using the factory methods in | 9 /// Instances of these classes may be created using the factory methods in |
| 10 /// `ast_factory.dart`. | 10 /// `ast_factory.dart`. |
| 11 /// | 11 /// |
| 12 /// Note that these classes represent the Dart language prior to desugaring. | 12 /// Note that these classes represent the Dart language prior to desugaring. |
| 13 /// When a single Dart construct desugars to a tree containing multiple kernel | 13 /// When a single Dart construct desugars to a tree containing multiple kernel |
| 14 /// AST nodes, the shadow class extends the kernel object at the top of the | 14 /// AST nodes, the shadow class extends the kernel object at the top of the |
| 15 /// desugared tree. | 15 /// desugared tree. |
| 16 /// | 16 /// |
| 17 /// This means that in some cases multiple shadow classes may extend the same | 17 /// This means that in some cases multiple shadow classes may extend the same |
| 18 /// kernel class, because multiple constructs in Dart may desugar to a tree | 18 /// kernel class, because multiple constructs in Dart may desugar to a tree |
| 19 /// with the same kind of root node. | 19 /// with the same kind of root node. |
| 20 import 'package:front_end/src/base/instrumentation.dart'; | 20 import 'package:front_end/src/base/instrumentation.dart'; |
| 21 import 'package:front_end/src/fasta/type_inference/dependency_collector.dart'; | 21 import 'package:front_end/src/fasta/type_inference/dependency_collector.dart'; |
| 22 import 'package:front_end/src/fasta/type_inference/type_inference_engine.dart'; | 22 import 'package:front_end/src/fasta/type_inference/type_inference_engine.dart'; |
| 23 import 'package:front_end/src/fasta/type_inference/type_inference_listener.dart'
; | 23 import 'package:front_end/src/fasta/type_inference/type_inference_listener.dart'
; |
| 24 import 'package:front_end/src/fasta/type_inference/type_inferrer.dart'; | 24 import 'package:front_end/src/fasta/type_inference/type_inferrer.dart'; |
| 25 import 'package:front_end/src/fasta/type_inference/type_promotion.dart'; | 25 import 'package:front_end/src/fasta/type_inference/type_promotion.dart'; |
| 26 import 'package:front_end/src/fasta/type_inference/type_schema.dart'; | 26 import 'package:front_end/src/fasta/type_inference/type_schema.dart'; |
| 27 import 'package:front_end/src/fasta/type_inference/type_schema_elimination.dart'
; | 27 import 'package:front_end/src/fasta/type_inference/type_schema_elimination.dart'
; |
| 28 import 'package:front_end/src/fasta/type_inference/type_schema_environment.dart'
; |
| 28 import 'package:kernel/ast.dart' | 29 import 'package:kernel/ast.dart' |
| 29 hide InvalidExpression, InvalidInitializer, InvalidStatement; | 30 hide InvalidExpression, InvalidInitializer, InvalidStatement; |
| 30 import 'package:kernel/frontend/accessors.dart'; | 31 import 'package:kernel/frontend/accessors.dart'; |
| 31 import 'package:kernel/type_algebra.dart'; | 32 import 'package:kernel/type_algebra.dart'; |
| 32 import 'package:kernel/type_environment.dart'; | 33 import 'package:kernel/type_environment.dart'; |
| 33 | 34 |
| 34 import '../errors.dart' show internalError; | 35 import '../errors.dart' show internalError; |
| 35 | 36 |
| 36 /// Computes the return type of a (possibly factory) constructor. | 37 /// Computes the return type of a (possibly factory) constructor. |
| 37 InterfaceType computeConstructorReturnType(Member constructor) { | 38 InterfaceType computeConstructorReturnType(Member constructor) { |
| (...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 809 // set of matched type parameters and `(Q0, ..., Qm)` be the set of matched | 810 // set of matched type parameters and `(Q0, ..., Qm)` be the set of matched |
| 810 // formal parameter types, and let `N` be the return type. | 811 // formal parameter types, and let `N` be the return type. |
| 811 Substitution substitution; | 812 Substitution substitution; |
| 812 List<DartType> formalTypesFromContext = | 813 List<DartType> formalTypesFromContext = |
| 813 new List<DartType>.filled(formals.length, null); | 814 new List<DartType>.filled(formals.length, null); |
| 814 DartType returnContext; | 815 DartType returnContext; |
| 815 if (inferrer.strongMode && typeContext is FunctionType) { | 816 if (inferrer.strongMode && typeContext is FunctionType) { |
| 816 for (int i = 0; i < formals.length; i++) { | 817 for (int i = 0; i < formals.length; i++) { |
| 817 if (i < function.positionalParameters.length) { | 818 if (i < function.positionalParameters.length) { |
| 818 formalTypesFromContext[i] = | 819 formalTypesFromContext[i] = |
| 819 inferrer.getPositionalParameterType(typeContext, i); | 820 getPositionalParameterType(typeContext, i); |
| 820 } else { | 821 } else { |
| 821 formalTypesFromContext[i] = | 822 formalTypesFromContext[i] = |
| 822 inferrer.getNamedParameterType(typeContext, formals[i].name); | 823 getNamedParameterType(typeContext, formals[i].name); |
| 823 } | 824 } |
| 824 } | 825 } |
| 825 returnContext = typeContext.returnType; | 826 returnContext = typeContext.returnType; |
| 826 | 827 |
| 827 // Let `[T/S]` denote the type substitution where each `Si` is replaced wi
th | 828 // Let `[T/S]` denote the type substitution where each `Si` is replaced wi
th |
| 828 // the corresponding `Ti`. | 829 // the corresponding `Ti`. |
| 829 var substitutionMap = <TypeParameter, DartType>{}; | 830 var substitutionMap = <TypeParameter, DartType>{}; |
| 830 for (int i = 0; i < typeContext.typeParameters.length; i++) { | 831 for (int i = 0; i < typeContext.typeParameters.length; i++) { |
| 831 substitutionMap[typeContext.typeParameters[i]] = | 832 substitutionMap[typeContext.typeParameters[i]] = |
| 832 i < typeParameters.length | 833 i < typeParameters.length |
| (...skipping 1471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2304 } | 2305 } |
| 2305 | 2306 |
| 2306 transformChildren(v) { | 2307 transformChildren(v) { |
| 2307 return internalError("Internal error: Unsupported operation."); | 2308 return internalError("Internal error: Unsupported operation."); |
| 2308 } | 2309 } |
| 2309 | 2310 |
| 2310 visitChildren(v) { | 2311 visitChildren(v) { |
| 2311 return internalError("Internal error: Unsupported operation."); | 2312 return internalError("Internal error: Unsupported operation."); |
| 2312 } | 2313 } |
| 2313 } | 2314 } |
| OLD | NEW |