OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 // TODO(sigmund): rename and move to common/elements.dart | 5 // TODO(sigmund): rename and move to common/elements.dart |
6 library dart2js.type_system; | 6 library dart2js.type_system; |
7 | 7 |
8 import 'common.dart'; | 8 import 'common.dart'; |
9 import 'common/names.dart' show Identifiers, Uris; | 9 import 'common/names.dart' show Identifiers, Uris; |
10 import 'constants/values.dart'; | 10 import 'constants/values.dart'; |
11 import 'elements/entities.dart'; | 11 import 'elements/entities.dart'; |
12 import 'elements/names.dart' show PublicName; | 12 import 'elements/names.dart' show PublicName; |
13 import 'elements/types.dart'; | 13 import 'elements/types.dart'; |
14 import 'js_backend/backend.dart' show JavaScriptBackend; | 14 import 'js_backend/backend.dart' show JavaScriptBackend; |
15 import 'js_backend/constant_system_javascript.dart'; | 15 import 'js_backend/constant_system_javascript.dart'; |
| 16 import 'js_backend/native_data.dart' show NativeBasicData; |
16 import 'universe/call_structure.dart' show CallStructure; | 17 import 'universe/call_structure.dart' show CallStructure; |
17 import 'universe/selector.dart' show Selector; | 18 import 'universe/selector.dart' show Selector; |
18 import 'universe/call_structure.dart'; | 19 import 'universe/call_structure.dart'; |
19 | 20 |
20 /// The common elements and types in Dart. | 21 /// The common elements and types in Dart. |
21 class CommonElements { | 22 class CommonElements { |
22 final ElementEnvironment _env; | 23 final ElementEnvironment _env; |
23 | 24 |
24 CommonElements(this._env); | 25 CommonElements(this._env); |
25 | 26 |
(...skipping 1143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1169 /// Returns `true` if the implementation of the 'operator ==' [function] is | 1170 /// Returns `true` if the implementation of the 'operator ==' [function] is |
1170 /// known to handle `null` as argument. | 1171 /// known to handle `null` as argument. |
1171 bool operatorEqHandlesNullArgument(FunctionEntity function) { | 1172 bool operatorEqHandlesNullArgument(FunctionEntity function) { |
1172 assert(function.name == '==', | 1173 assert(function.name == '==', |
1173 failedAt(function, "Unexpected function $function.")); | 1174 failedAt(function, "Unexpected function $function.")); |
1174 ClassEntity cls = function.enclosingClass; | 1175 ClassEntity cls = function.enclosingClass; |
1175 return cls == objectClass || | 1176 return cls == objectClass || |
1176 cls == jsInterceptorClass || | 1177 cls == jsInterceptorClass || |
1177 cls == jsNullClass; | 1178 cls == jsNullClass; |
1178 } | 1179 } |
| 1180 |
| 1181 ClassEntity getDefaultSuperclass( |
| 1182 ClassEntity cls, NativeBasicData nativeBasicData) { |
| 1183 if (nativeBasicData.isJsInteropClass(cls)) { |
| 1184 return jsJavaScriptObjectClass; |
| 1185 } |
| 1186 // Native classes inherit from Interceptor. |
| 1187 return nativeBasicData.isNativeClass(cls) |
| 1188 ? jsInterceptorClass |
| 1189 : objectClass; |
| 1190 } |
1179 } | 1191 } |
1180 | 1192 |
1181 /// Interface for accessing libraries, classes and members. | 1193 /// Interface for accessing libraries, classes and members. |
1182 /// | 1194 /// |
1183 /// The element environment makes private and injected members directly | 1195 /// The element environment makes private and injected members directly |
1184 /// available and should therefore not be used to determine scopes. | 1196 /// available and should therefore not be used to determine scopes. |
1185 /// | 1197 /// |
1186 /// The properties exposed are Dart-centric and should therefore, long-term, not | 1198 /// The properties exposed are Dart-centric and should therefore, long-term, not |
1187 /// be used during codegen, expect for mirrors. | 1199 /// be used during codegen, expect for mirrors. |
1188 // TODO(johnniwinther): Split this into an element environment and a type query | 1200 // TODO(johnniwinther): Split this into an element environment and a type query |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1343 /// Returns the metadata constants declared on [typedef]. | 1355 /// Returns the metadata constants declared on [typedef]. |
1344 Iterable<ConstantValue> getTypedefMetadata(TypedefEntity typedef); | 1356 Iterable<ConstantValue> getTypedefMetadata(TypedefEntity typedef); |
1345 | 1357 |
1346 /// Returns the metadata constants declared on [member]. | 1358 /// Returns the metadata constants declared on [member]. |
1347 Iterable<ConstantValue> getMemberMetadata(MemberEntity member, | 1359 Iterable<ConstantValue> getMemberMetadata(MemberEntity member, |
1348 {bool includeParameterMetadata: false}); | 1360 {bool includeParameterMetadata: false}); |
1349 | 1361 |
1350 /// Returns the function type that is an alias of a [typedef]. | 1362 /// Returns the function type that is an alias of a [typedef]. |
1351 FunctionType getFunctionTypeOfTypedef(TypedefEntity typedef); | 1363 FunctionType getFunctionTypeOfTypedef(TypedefEntity typedef); |
1352 } | 1364 } |
OLD | NEW |