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 29 matching lines...) Expand all Loading... |
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 'elements.dart'; | 44 import 'elements.dart'; |
45 | 45 |
46 part 'native_basic_data.dart'; | 46 part 'native_basic_data.dart'; |
47 part 'no_such_method_resolver.dart'; | 47 part 'no_such_method_resolver.dart'; |
48 part 'types.dart'; | 48 part 'types.dart'; |
49 | 49 |
| 50 /// Interface for kernel queries needed to implement the [CodegenWorldBuilder]. |
| 51 abstract class KernelToWorldBuilder implements KernelToElementMap { |
| 52 /// Returns `true` if [field] has a constant initializer. |
| 53 bool hasConstantFieldInitializer(FieldEntity field); |
| 54 |
| 55 /// Returns the constant initializer for [field]. |
| 56 ConstantValue getConstantFieldInitializer(FieldEntity field); |
| 57 |
| 58 /// 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 void forEachParameter(FunctionEntity function, |
| 61 void f(DartType type, String name, ConstantValue defaultValue)); |
| 62 } |
| 63 |
50 /// Element builder used for creating elements and types corresponding to Kernel | 64 /// Element builder used for creating elements and types corresponding to Kernel |
51 /// IR nodes. | 65 /// IR nodes. |
52 class KernelToElementMapImpl extends KernelToElementMapMixin { | 66 class KernelToElementMapImpl extends KernelToElementMapMixin |
| 67 implements KernelToWorldBuilder { |
53 final Environment _environment; | 68 final Environment _environment; |
54 CommonElements _commonElements; | 69 CommonElements _commonElements; |
55 native.BehaviorBuilder _nativeBehaviorBuilder; | 70 native.BehaviorBuilder _nativeBehaviorBuilder; |
56 final DiagnosticReporter reporter; | 71 final DiagnosticReporter reporter; |
57 ElementEnvironment _elementEnvironment; | 72 ElementEnvironment _elementEnvironment; |
58 DartTypeConverter _typeConverter; | 73 DartTypeConverter _typeConverter; |
59 KernelConstantEnvironment _constantEnvironment; | 74 KernelConstantEnvironment _constantEnvironment; |
60 _KernelDartTypes _types; | 75 _KernelDartTypes _types; |
61 | 76 |
62 /// Library environment. Used for fast lookup. | 77 /// Library environment. Used for fast lookup. |
(...skipping 1682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1745 !elementMap.isForeignLibrary(node.enclosingLibrary); | 1760 !elementMap.isForeignLibrary(node.enclosingLibrary); |
1746 } | 1761 } |
1747 | 1762 |
1748 @override | 1763 @override |
1749 bool isJsInteropMember(MemberEntity element) { | 1764 bool isJsInteropMember(MemberEntity element) { |
1750 // TODO(johnniwinther): Compute this. | 1765 // TODO(johnniwinther): Compute this. |
1751 return false; | 1766 return false; |
1752 } | 1767 } |
1753 } | 1768 } |
1754 | 1769 |
1755 class JsKernelToElementMap extends KernelToElementMapMixin { | 1770 class JsKernelToElementMap extends KernelToElementMapMixin |
| 1771 implements KernelToWorldBuilder { |
1756 final JsToFrontendMap _map; | 1772 final JsToFrontendMap _map; |
1757 final ElementEnvironment _elementEnvironment; | 1773 final ElementEnvironment _elementEnvironment; |
1758 final CommonElements _commonElements; | 1774 final CommonElements _commonElements; |
1759 final KernelToElementMapImpl _elementMap; | 1775 final KernelToElementMapImpl _elementMap; |
1760 | 1776 |
1761 JsKernelToElementMap(this._map, this._elementEnvironment, | 1777 JsKernelToElementMap(this._map, this._elementEnvironment, |
1762 this._commonElements, this._elementMap); | 1778 this._commonElements, this._elementMap); |
1763 | 1779 |
1764 @override | 1780 @override |
1765 Spannable getSpannable(MemberEntity member, ir.Node node) { | 1781 Spannable getSpannable(MemberEntity member, ir.Node node) { |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1870 | 1886 |
1871 @override | 1887 @override |
1872 DiagnosticReporter get reporter { | 1888 DiagnosticReporter get reporter { |
1873 return _elementMap.reporter; | 1889 return _elementMap.reporter; |
1874 } | 1890 } |
1875 | 1891 |
1876 @override | 1892 @override |
1877 ConstantValue getFieldConstantValue(ir.Field field) { | 1893 ConstantValue getFieldConstantValue(ir.Field field) { |
1878 throw new UnsupportedError("JsKernelToElementMap.getFieldConstantValue"); | 1894 throw new UnsupportedError("JsKernelToElementMap.getFieldConstantValue"); |
1879 } | 1895 } |
| 1896 |
| 1897 @override |
| 1898 void forEachParameter(FunctionEntity function, |
| 1899 void f(DartType type, String name, ConstantValue defaultValue)) { |
| 1900 throw new UnsupportedError("JsKernelToElementMap.forEachParameter"); |
| 1901 } |
| 1902 |
| 1903 @override |
| 1904 ConstantValue getConstantFieldInitializer(FieldEntity field) { |
| 1905 throw new UnsupportedError( |
| 1906 "JsKernelToElementMap.getConstantFieldInitializer"); |
| 1907 } |
| 1908 |
| 1909 @override |
| 1910 bool hasConstantFieldInitializer(FieldEntity field) { |
| 1911 throw new UnsupportedError( |
| 1912 "JsKernelToElementMap.hasConstantFieldInitializer"); |
| 1913 } |
1880 } | 1914 } |
OLD | NEW |