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.element_map; | 5 library dart2js.kernel.element_map; |
6 | 6 |
7 import 'package:kernel/ast.dart' as ir; | 7 import 'package:kernel/ast.dart' as ir; |
8 import 'package:kernel/clone.dart'; | 8 import 'package:kernel/clone.dart'; |
9 import 'package:kernel/type_algebra.dart'; | 9 import 'package:kernel/type_algebra.dart'; |
10 | 10 |
(...skipping 23 matching lines...) Expand all Loading... |
34 import '../native/resolver.dart'; | 34 import '../native/resolver.dart'; |
35 import '../ordered_typeset.dart'; | 35 import '../ordered_typeset.dart'; |
36 import '../ssa/kernel_impact.dart'; | 36 import '../ssa/kernel_impact.dart'; |
37 import '../universe/class_set.dart'; | 37 import '../universe/class_set.dart'; |
38 import '../universe/function_set.dart'; | 38 import '../universe/function_set.dart'; |
39 import '../universe/selector.dart'; | 39 import '../universe/selector.dart'; |
40 import '../universe/world_builder.dart'; | 40 import '../universe/world_builder.dart'; |
41 import '../world.dart'; | 41 import '../world.dart'; |
42 import '../util/util.dart' show Link, LinkBuilder; | 42 import '../util/util.dart' show Link, LinkBuilder; |
43 import 'element_map.dart'; | 43 import 'element_map.dart'; |
| 44 import 'element_map_mixins.dart'; |
44 import 'elements.dart'; | 45 import 'elements.dart'; |
45 | 46 |
46 part 'native_basic_data.dart'; | 47 part 'native_basic_data.dart'; |
47 part 'no_such_method_resolver.dart'; | 48 part 'no_such_method_resolver.dart'; |
48 part 'types.dart'; | 49 part 'types.dart'; |
49 | 50 |
50 /// Interface for kernel queries needed to implement the [CodegenWorldBuilder]. | 51 /// Interface for kernel queries needed to implement the [CodegenWorldBuilder]. |
51 abstract class KernelToWorldBuilder implements KernelToElementMapForBuilding { | 52 abstract class KernelToWorldBuilder implements KernelToElementMapForBuilding { |
52 /// Returns `true` if [field] has a constant initializer. | 53 /// Returns `true` if [field] has a constant initializer. |
53 bool hasConstantFieldInitializer(FieldEntity field); | 54 bool hasConstantFieldInitializer(FieldEntity field); |
54 | 55 |
55 /// Returns the constant initializer for [field]. | 56 /// Returns the constant initializer for [field]. |
56 ConstantValue getConstantFieldInitializer(FieldEntity field); | 57 ConstantValue getConstantFieldInitializer(FieldEntity field); |
57 | 58 |
58 /// Calls [f] for each parameter of [function] providing the type and name of | 59 /// Calls [f] for each parameter of [function] providing the type and name of |
59 /// the parameter and the [defaultValue] if the parameter is optional. | 60 /// the parameter and the [defaultValue] if the parameter is optional. |
60 void forEachParameter(FunctionEntity function, | 61 void forEachParameter(FunctionEntity function, |
61 void f(DartType type, String name, ConstantValue defaultValue)); | 62 void f(DartType type, String name, ConstantValue defaultValue)); |
62 } | 63 } |
63 | 64 |
| 65 abstract class KernelToElementMapBase extends KernelToElementMapBaseMixin {} |
| 66 |
64 /// Element builder used for creating elements and types corresponding to Kernel | 67 /// Element builder used for creating elements and types corresponding to Kernel |
65 /// IR nodes. | 68 /// IR nodes. |
66 class KernelToElementMapImpl extends KernelToElementMapMixin | 69 class KernelToElementMapImpl extends KernelToElementMapBase |
67 implements KernelToWorldBuilder, KernelToElementMapForImpact { | 70 with KernelToElementMapForBuildingMixin, KernelToElementMapForImpactMixin |
| 71 implements KernelToWorldBuilder { |
68 final Environment _environment; | 72 final Environment _environment; |
69 CommonElements _commonElements; | 73 CommonElements _commonElements; |
70 native.BehaviorBuilder _nativeBehaviorBuilder; | 74 native.BehaviorBuilder _nativeBehaviorBuilder; |
71 final DiagnosticReporter reporter; | 75 final DiagnosticReporter reporter; |
72 ElementEnvironment _elementEnvironment; | 76 ElementEnvironment _elementEnvironment; |
73 DartTypeConverter _typeConverter; | 77 DartTypeConverter _typeConverter; |
74 KernelConstantEnvironment _constantEnvironment; | 78 KernelConstantEnvironment _constantEnvironment; |
75 _KernelDartTypes _types; | 79 _KernelDartTypes _types; |
76 | 80 |
77 /// Library environment. Used for fast lookup. | 81 /// Library environment. Used for fast lookup. |
(...skipping 1696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1774 !elementMap.isForeignLibrary(node.enclosingLibrary); | 1778 !elementMap.isForeignLibrary(node.enclosingLibrary); |
1775 } | 1779 } |
1776 | 1780 |
1777 @override | 1781 @override |
1778 bool isJsInteropMember(MemberEntity element) { | 1782 bool isJsInteropMember(MemberEntity element) { |
1779 // TODO(redemption): Compute this. | 1783 // TODO(redemption): Compute this. |
1780 return false; | 1784 return false; |
1781 } | 1785 } |
1782 } | 1786 } |
1783 | 1787 |
1784 class JsKernelToElementMap extends KernelToElementMapMixin | 1788 class JsKernelToElementMap extends KernelToElementMapBase |
| 1789 with KernelToElementMapForBuildingMixin |
1785 implements KernelToWorldBuilder { | 1790 implements KernelToWorldBuilder { |
1786 final JsToFrontendMap _map; | 1791 final JsToFrontendMap _map; |
1787 final ElementEnvironment _elementEnvironment; | 1792 final ElementEnvironment _elementEnvironment; |
1788 final CommonElements _commonElements; | 1793 final CommonElements _commonElements; |
1789 final KernelToElementMapImpl _elementMap; | 1794 final KernelToElementMapImpl _elementMap; |
1790 | 1795 |
1791 JsKernelToElementMap(this._map, this._elementEnvironment, | 1796 JsKernelToElementMap(this._map, this._elementEnvironment, |
1792 this._commonElements, this._elementMap); | 1797 this._commonElements, this._elementMap); |
1793 | 1798 |
1794 @override | 1799 @override |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1880 return _commonElements; | 1885 return _commonElements; |
1881 } | 1886 } |
1882 | 1887 |
1883 @override | 1888 @override |
1884 ConstantValue computeConstantValue(ConstantExpression constant, | 1889 ConstantValue computeConstantValue(ConstantExpression constant, |
1885 {bool requireConstant: true}) { | 1890 {bool requireConstant: true}) { |
1886 throw new UnsupportedError("JsKernelToElementMap.computeConstantValue"); | 1891 throw new UnsupportedError("JsKernelToElementMap.computeConstantValue"); |
1887 } | 1892 } |
1888 | 1893 |
1889 @override | 1894 @override |
1890 native.BehaviorBuilder get nativeBehaviorBuilder { | |
1891 throw new UnsupportedError("JsKernelToElementMap.nativeBehaviorBuilder"); | |
1892 } | |
1893 | |
1894 @override | |
1895 DiagnosticReporter get reporter { | 1895 DiagnosticReporter get reporter { |
1896 return _elementMap.reporter; | 1896 return _elementMap.reporter; |
1897 } | 1897 } |
1898 | 1898 |
1899 @override | 1899 @override |
1900 ConstantValue getFieldConstantValue(ir.Field field) { | 1900 ConstantValue getFieldConstantValue(ir.Field field) { |
1901 throw new UnsupportedError("JsKernelToElementMap.getFieldConstantValue"); | 1901 throw new UnsupportedError("JsKernelToElementMap.getFieldConstantValue"); |
1902 } | 1902 } |
1903 | 1903 |
1904 @override | 1904 @override |
1905 void forEachParameter(FunctionEntity function, | 1905 void forEachParameter(FunctionEntity function, |
1906 void f(DartType type, String name, ConstantValue defaultValue)) { | 1906 void f(DartType type, String name, ConstantValue defaultValue)) { |
1907 throw new UnsupportedError("JsKernelToElementMap.forEachParameter"); | 1907 throw new UnsupportedError("JsKernelToElementMap.forEachParameter"); |
1908 } | 1908 } |
1909 | 1909 |
1910 @override | 1910 @override |
1911 ConstantValue getConstantFieldInitializer(FieldEntity field) { | 1911 ConstantValue getConstantFieldInitializer(FieldEntity field) { |
1912 throw new UnsupportedError( | 1912 throw new UnsupportedError( |
1913 "JsKernelToElementMap.getConstantFieldInitializer"); | 1913 "JsKernelToElementMap.getConstantFieldInitializer"); |
1914 } | 1914 } |
1915 | 1915 |
1916 @override | 1916 @override |
1917 bool hasConstantFieldInitializer(FieldEntity field) { | 1917 bool hasConstantFieldInitializer(FieldEntity field) { |
1918 throw new UnsupportedError( | 1918 throw new UnsupportedError( |
1919 "JsKernelToElementMap.hasConstantFieldInitializer"); | 1919 "JsKernelToElementMap.hasConstantFieldInitializer"); |
1920 } | 1920 } |
1921 } | 1921 } |
OLD | NEW |