| 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 dart2js.kernel.impact_test; | 5 library dart2js.kernel.impact_test; |
| 6 | 6 |
| 7 import 'package:async_helper/async_helper.dart'; | 7 import 'package:async_helper/async_helper.dart'; |
| 8 import 'package:compiler/src/commandline_options.dart'; | 8 import 'package:compiler/src/commandline_options.dart'; |
| 9 import 'package:compiler/src/common.dart'; | 9 import 'package:compiler/src/common.dart'; |
| 10 import 'package:compiler/src/common/names.dart'; | 10 import 'package:compiler/src/common/names.dart'; |
| 11 import 'package:compiler/src/common/resolution.dart'; | 11 import 'package:compiler/src/common/resolution.dart'; |
| 12 import 'package:compiler/src/compiler.dart'; | 12 import 'package:compiler/src/compiler.dart'; |
| 13 import 'package:compiler/src/constants/expressions.dart'; | 13 import 'package:compiler/src/constants/expressions.dart'; |
| 14 import 'package:compiler/src/elements/elements.dart'; | 14 import 'package:compiler/src/elements/elements.dart'; |
| 15 import 'package:compiler/src/elements/resolution_types.dart'; | 15 import 'package:compiler/src/elements/resolution_types.dart'; |
| 16 import 'package:compiler/src/js_backend/backend.dart'; | 16 import 'package:compiler/src/js_backend/backend.dart'; |
| 17 import 'package:compiler/src/kernel/element_map.dart'; | 17 import 'package:compiler/src/kernel/element_map.dart'; |
| 18 import 'package:compiler/src/kernel/element_map_impl.dart'; | 18 import 'package:compiler/src/kernel/element_map_impl.dart'; |
| 19 import 'package:compiler/src/resolution/registry.dart'; | 19 import 'package:compiler/src/resolution/registry.dart'; |
| 20 import 'package:compiler/src/resolution/tree_elements.dart'; | 20 import 'package:compiler/src/resolution/tree_elements.dart'; |
| 21 import 'package:compiler/src/ssa/kernel_impact.dart'; | 21 import 'package:compiler/src/ssa/kernel_impact.dart'; |
| 22 import 'package:compiler/src/serialization/equivalence.dart'; | 22 import 'package:compiler/src/serialization/equivalence.dart'; |
| 23 import 'package:compiler/src/universe/call_structure.dart'; | 23 import 'package:compiler/src/universe/call_structure.dart'; |
| 24 import 'package:compiler/src/universe/feature.dart'; | 24 import 'package:compiler/src/universe/feature.dart'; |
| 25 import 'package:compiler/src/universe/use.dart'; | 25 import 'package:compiler/src/universe/use.dart'; |
| 26 import 'package:expect/expect.dart'; | 26 import 'package:expect/expect.dart'; |
| 27 import 'package:kernel/ast.dart' as ir; | 27 import 'package:kernel/ast.dart' as ir; |
| 28 import '../memory_compiler.dart'; | 28 import '../memory_compiler.dart'; |
| 29 import '../serialization/test_helper.dart'; | 29 import '../equivalence/check_helpers.dart'; |
| 30 import 'test_helpers.dart'; |
| 30 | 31 |
| 31 const Map<String, String> SOURCE = const <String, String>{ | 32 const Map<String, String> SOURCE = const <String, String>{ |
| 32 // Pretend this is a dart2js_native test to allow use of 'native' keyword. | 33 // Pretend this is a dart2js_native test to allow use of 'native' keyword. |
| 33 'sdk/tests/compiler/dart2js_native/main.dart': r''' | 34 'sdk/tests/compiler/dart2js_native/main.dart': r''' |
| 34 import 'dart:_foreign_helper'; | 35 import 'dart:_foreign_helper'; |
| 35 import 'dart:_js_helper'; | 36 import 'dart:_js_helper'; |
| 36 import 'dart:_interceptors'; | 37 import 'dart:_interceptors'; |
| 37 import 'dart:_native_typed_data'; | 38 import 'dart:_native_typed_data'; |
| 38 import 'dart:indexed_db'; | 39 import 'dart:indexed_db'; |
| 39 import 'dart:html'; | 40 import 'dart:html'; |
| (...skipping 857 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 897 builder.registerFeature(Feature.THROW_EXPRESSION); | 898 builder.registerFeature(Feature.THROW_EXPRESSION); |
| 898 break; | 899 break; |
| 899 default: | 900 default: |
| 900 builder.registerFeature(feature); | 901 builder.registerFeature(feature); |
| 901 break; | 902 break; |
| 902 } | 903 } |
| 903 } | 904 } |
| 904 impact.nativeData.forEach(builder.registerNativeData); | 905 impact.nativeData.forEach(builder.registerNativeData); |
| 905 return builder; | 906 return builder; |
| 906 } | 907 } |
| 907 | |
| 908 /// Visitor the performers unaliasing of all typedefs nested within a | |
| 909 /// [ResolutionDartType]. | |
| 910 class Unaliaser | |
| 911 extends BaseResolutionDartTypeVisitor<dynamic, ResolutionDartType> { | |
| 912 const Unaliaser(); | |
| 913 | |
| 914 @override | |
| 915 ResolutionDartType visit(ResolutionDartType type, [_]) => | |
| 916 type.accept(this, null); | |
| 917 | |
| 918 @override | |
| 919 ResolutionDartType visitType(ResolutionDartType type, _) => type; | |
| 920 | |
| 921 List<ResolutionDartType> visitList(List<ResolutionDartType> types) => | |
| 922 types.map(visit).toList(); | |
| 923 | |
| 924 @override | |
| 925 ResolutionDartType visitInterfaceType(ResolutionInterfaceType type, _) { | |
| 926 return type.createInstantiation(visitList(type.typeArguments)); | |
| 927 } | |
| 928 | |
| 929 @override | |
| 930 ResolutionDartType visitTypedefType(ResolutionTypedefType type, _) { | |
| 931 return visit(type.unaliased); | |
| 932 } | |
| 933 | |
| 934 @override | |
| 935 ResolutionDartType visitFunctionType(ResolutionFunctionType type, _) { | |
| 936 return new ResolutionFunctionType.synthesized( | |
| 937 visit(type.returnType), | |
| 938 visitList(type.parameterTypes), | |
| 939 visitList(type.optionalParameterTypes), | |
| 940 type.namedParameters, | |
| 941 visitList(type.namedParameterTypes)); | |
| 942 } | |
| 943 } | |
| 944 | |
| 945 /// Perform unaliasing of all typedefs nested within a [ResolutionDartType]. | |
| 946 ResolutionDartType unalias(ResolutionDartType type) { | |
| 947 return const Unaliaser().visit(type); | |
| 948 } | |
| OLD | NEW |