| 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 library dart2js.kernel.world_builder; | 5 library dart2js.kernel.world_builder; |
| 6 | 6 |
| 7 import 'package:kernel/ast.dart' as ir; | 7 import 'package:kernel/ast.dart' as ir; |
| 8 | 8 |
| 9 import '../common.dart'; | 9 import '../common.dart'; |
| 10 import '../common/backend_api.dart'; | |
| 11 import '../common/resolution.dart'; | 10 import '../common/resolution.dart'; |
| 12 import '../compile_time_constants.dart'; | 11 import '../compile_time_constants.dart'; |
| 13 import '../constants/constant_system.dart'; | 12 import '../constants/constant_system.dart'; |
| 14 import '../constants/constructors.dart'; | 13 import '../constants/constructors.dart'; |
| 15 import '../constants/evaluation.dart'; | 14 import '../constants/evaluation.dart'; |
| 16 import '../constants/expressions.dart'; | 15 import '../constants/expressions.dart'; |
| 17 import '../constants/values.dart'; | 16 import '../constants/values.dart'; |
| 18 import '../common_elements.dart'; | 17 import '../common_elements.dart'; |
| 19 import '../elements/elements.dart'; | 18 import '../elements/elements.dart'; |
| 20 import '../elements/entities.dart'; | 19 import '../elements/entities.dart'; |
| 21 import '../elements/types.dart'; | 20 import '../elements/types.dart'; |
| 22 import '../js_backend/constant_system_javascript.dart'; | 21 import '../js_backend/constant_system_javascript.dart'; |
| 22 import '../js_backend/native_data.dart' show NativeData; |
| 23 import '../js_backend/no_such_method_registry.dart'; | 23 import '../js_backend/no_such_method_registry.dart'; |
| 24 import '../native/native.dart' as native; | 24 import '../native/native.dart' as native; |
| 25 import '../native/resolver.dart'; | 25 import '../native/resolver.dart'; |
| 26 import '../ssa/kernel_impact.dart'; | 26 import '../ssa/kernel_impact.dart'; |
| 27 import '../universe/call_structure.dart'; | 27 import '../universe/call_structure.dart'; |
| 28 import 'element_adapter.dart'; | 28 import 'element_adapter.dart'; |
| 29 import 'elements.dart'; | 29 import 'elements.dart'; |
| 30 | 30 |
| 31 part 'native_class_resolver.dart'; | 31 part 'native_class_resolver.dart'; |
| 32 part 'no_such_method_resolver.dart'; | 32 part 'no_such_method_resolver.dart'; |
| (...skipping 824 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 857 // Nested invalid types are treated as `dynamic`. | 857 // Nested invalid types are treated as `dynamic`. |
| 858 return const DynamicType(); | 858 return const DynamicType(); |
| 859 } | 859 } |
| 860 } | 860 } |
| 861 | 861 |
| 862 /// [native.BehaviorBuilder] for kernel based elements. | 862 /// [native.BehaviorBuilder] for kernel based elements. |
| 863 class KernelBehaviorBuilder extends native.BehaviorBuilder { | 863 class KernelBehaviorBuilder extends native.BehaviorBuilder { |
| 864 final CommonElements commonElements; | 864 final CommonElements commonElements; |
| 865 final ConstantEnvironment constants; | 865 final ConstantEnvironment constants; |
| 866 | 866 |
| 867 KernelBehaviorBuilder(this.commonElements, this.constants); | 867 KernelBehaviorBuilder( |
| 868 this.commonElements, |
| 869 this.constants, |
| 870 ); |
| 868 | 871 |
| 869 @override | 872 @override |
| 870 bool get trustJSInteropTypeAnnotations { | 873 bool get trustJSInteropTypeAnnotations { |
| 871 throw new UnimplementedError( | 874 throw new UnimplementedError( |
| 872 "KernelNativeBehaviorComputer.trustJSInteropTypeAnnotations"); | 875 "KernelNativeBehaviorComputer.trustJSInteropTypeAnnotations"); |
| 873 } | 876 } |
| 874 | 877 |
| 875 @override | 878 @override |
| 876 DiagnosticReporter get reporter { | 879 DiagnosticReporter get reporter { |
| 877 throw new UnimplementedError("KernelNativeBehaviorComputer.reporter"); | 880 throw new UnimplementedError("KernelNativeBehaviorComputer.reporter"); |
| 878 } | 881 } |
| 879 | 882 |
| 880 @override | 883 @override |
| 881 BackendClasses get backendClasses { | 884 NativeData get nativeData { |
| 882 throw new UnimplementedError("KernelNativeBehaviorComputer.backendClasses"); | 885 throw new UnimplementedError("KernelNativeBehaviorComputer.nativeData"); |
| 883 } | 886 } |
| 884 } | 887 } |
| 885 | 888 |
| 886 /// Constant environment mapping [ConstantExpression]s to [ConstantValue]s using | 889 /// Constant environment mapping [ConstantExpression]s to [ConstantValue]s using |
| 887 /// [_EvaluationEnvironment] for the evaluation. | 890 /// [_EvaluationEnvironment] for the evaluation. |
| 888 class KernelConstantEnvironment implements ConstantEnvironment { | 891 class KernelConstantEnvironment implements ConstantEnvironment { |
| 889 KernelWorldBuilder _worldBuilder; | 892 KernelWorldBuilder _worldBuilder; |
| 890 Map<ConstantExpression, ConstantValue> _valueMap = | 893 Map<ConstantExpression, ConstantValue> _valueMap = |
| 891 <ConstantExpression, ConstantValue>{}; | 894 <ConstantExpression, ConstantValue>{}; |
| 892 | 895 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 921 final KernelWorldBuilder _worldBuilder; | 924 final KernelWorldBuilder _worldBuilder; |
| 922 | 925 |
| 923 _EvaluationEnvironment(this._worldBuilder); | 926 _EvaluationEnvironment(this._worldBuilder); |
| 924 | 927 |
| 925 @override | 928 @override |
| 926 CommonElements get commonElements { | 929 CommonElements get commonElements { |
| 927 throw new UnimplementedError("_EvaluationEnvironment.commonElements"); | 930 throw new UnimplementedError("_EvaluationEnvironment.commonElements"); |
| 928 } | 931 } |
| 929 | 932 |
| 930 @override | 933 @override |
| 931 BackendClasses get backendClasses { | |
| 932 throw new UnimplementedError("_EvaluationEnvironment.backendClasses"); | |
| 933 } | |
| 934 | |
| 935 @override | |
| 936 InterfaceType substByContext(InterfaceType base, InterfaceType target) { | 934 InterfaceType substByContext(InterfaceType base, InterfaceType target) { |
| 937 if (base.typeArguments.isNotEmpty) { | 935 if (base.typeArguments.isNotEmpty) { |
| 938 throw new UnimplementedError("_EvaluationEnvironment.substByContext"); | 936 throw new UnimplementedError("_EvaluationEnvironment.substByContext"); |
| 939 } | 937 } |
| 940 return base; | 938 return base; |
| 941 } | 939 } |
| 942 | 940 |
| 943 @override | 941 @override |
| 944 ConstantConstructor getConstructorConstant(ConstructorEntity constructor) { | 942 ConstantConstructor getConstructorConstant(ConstructorEntity constructor) { |
| 945 return _worldBuilder._getConstructorConstant(constructor); | 943 return _worldBuilder._getConstructorConstant(constructor); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1003 } | 1001 } |
| 1004 | 1002 |
| 1005 InterfaceType getMixinTypeForClass(KClass cls) { | 1003 InterfaceType getMixinTypeForClass(KClass cls) { |
| 1006 KClassEnv env = builder._classEnvs[cls.classIndex]; | 1004 KClassEnv env = builder._classEnvs[cls.classIndex]; |
| 1007 ir.Supertype mixedInType = env.cls.mixedInType; | 1005 ir.Supertype mixedInType = env.cls.mixedInType; |
| 1008 if (mixedInType == null) return null; | 1006 if (mixedInType == null) return null; |
| 1009 return builder.createInterfaceType( | 1007 return builder.createInterfaceType( |
| 1010 mixedInType.classNode, mixedInType.typeArguments); | 1008 mixedInType.classNode, mixedInType.typeArguments); |
| 1011 } | 1009 } |
| 1012 } | 1010 } |
| OLD | NEW |