| 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 import 'package:js_runtime/shared/embedded_names.dart'; |
| 5 import 'package:kernel/ast.dart' as ir; | 6 import 'package:kernel/ast.dart' as ir; |
| 6 | 7 |
| 7 import '../common.dart'; | 8 import '../common.dart'; |
| 8 import '../common/names.dart'; | 9 import '../common/names.dart'; |
| 9 import '../compiler.dart'; | 10 import '../compiler.dart'; |
| 10 import '../constants/values.dart'; | 11 import '../constants/values.dart'; |
| 11 import '../dart_types.dart'; | 12 import '../dart_types.dart'; |
| 12 import '../elements/elements.dart'; | 13 import '../elements/elements.dart'; |
| 14 import '../js/js.dart' as js; |
| 13 import '../js_backend/js_backend.dart'; | 15 import '../js_backend/js_backend.dart'; |
| 14 import '../kernel/kernel.dart'; | 16 import '../kernel/kernel.dart'; |
| 17 import '../native/native.dart' as native; |
| 15 import '../resolution/tree_elements.dart'; | 18 import '../resolution/tree_elements.dart'; |
| 16 import '../tree/tree.dart' as ast; | 19 import '../tree/tree.dart' as ast; |
| 17 import '../types/masks.dart'; | 20 import '../types/masks.dart'; |
| 18 import '../types/types.dart'; | 21 import '../types/types.dart'; |
| 19 import '../universe/call_structure.dart'; | 22 import '../universe/call_structure.dart'; |
| 20 import '../universe/selector.dart'; | 23 import '../universe/selector.dart'; |
| 21 import '../universe/side_effects.dart'; | 24 import '../universe/side_effects.dart'; |
| 22 import '../world.dart'; | 25 import '../world.dart'; |
| 23 import 'locals_handler.dart'; | 26 import 'locals_handler.dart'; |
| 24 import 'types.dart'; | 27 import 'types.dart'; |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 } | 216 } |
| 214 | 217 |
| 215 TypeMask inferredTypeOf(ir.Member node) { | 218 TypeMask inferredTypeOf(ir.Member node) { |
| 216 return TypeMaskFactory.inferredTypeForElement(getElement(node), _compiler); | 219 return TypeMaskFactory.inferredTypeForElement(getElement(node), _compiler); |
| 217 } | 220 } |
| 218 | 221 |
| 219 TypeMask selectorTypeOf(Selector selector, TypeMask mask) { | 222 TypeMask selectorTypeOf(Selector selector, TypeMask mask) { |
| 220 return TypeMaskFactory.inferredTypeForSelector(selector, mask, _compiler); | 223 return TypeMaskFactory.inferredTypeForSelector(selector, mask, _compiler); |
| 221 } | 224 } |
| 222 | 225 |
| 226 TypeMask typeFromNativeBehavior(native.NativeBehavior nativeBehavior) { |
| 227 return TypeMaskFactory.fromNativeBehavior(nativeBehavior, _compiler); |
| 228 } |
| 229 |
| 223 ConstantValue getConstantFor(ir.Node node) { | 230 ConstantValue getConstantFor(ir.Node node) { |
| 224 ConstantValue constantValue = | 231 ConstantValue constantValue = |
| 225 _backend.constants.getConstantValueForNode(getNode(node), elements); | 232 _backend.constants.getConstantValueForNode(getNode(node), elements); |
| 226 assert(invariant(getNode(node), constantValue != null, | 233 assert(invariant(getNode(node), constantValue != null, |
| 227 message: 'No constant computed for $node')); | 234 message: 'No constant computed for $node')); |
| 228 return constantValue; | 235 return constantValue; |
| 229 } | 236 } |
| 230 | 237 |
| 231 bool isIntercepted(ir.Node node) { | 238 bool isIntercepted(ir.Node node) { |
| 232 Selector selector = getSelector(node); | 239 Selector selector = getSelector(node); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 | 272 |
| 266 TypeMask get assertTestReturnType => TypeMaskFactory | 273 TypeMask get assertTestReturnType => TypeMaskFactory |
| 267 .inferredReturnTypeForElement(_backend.helpers.assertTest, _compiler); | 274 .inferredReturnTypeForElement(_backend.helpers.assertTest, _compiler); |
| 268 | 275 |
| 269 ir.Procedure get assertThrow => | 276 ir.Procedure get assertThrow => |
| 270 kernel.functions[_backend.helpers.assertThrow]; | 277 kernel.functions[_backend.helpers.assertThrow]; |
| 271 | 278 |
| 272 TypeMask get assertThrowReturnType => TypeMaskFactory | 279 TypeMask get assertThrowReturnType => TypeMaskFactory |
| 273 .inferredReturnTypeForElement(_backend.helpers.assertThrow, _compiler); | 280 .inferredReturnTypeForElement(_backend.helpers.assertThrow, _compiler); |
| 274 | 281 |
| 282 ir.Procedure get currentIsolate => |
| 283 kernel.functions[_backend.helpers.currentIsolate]; |
| 284 |
| 285 bool isInForeignLibrary(ir.Member member) => |
| 286 _backend.isForeign(getElement(member)); |
| 287 |
| 288 native.NativeBehavior getNativeBehavior(ir.Node node) { |
| 289 return elements.getNativeData(getNode(node)); |
| 290 } |
| 291 |
| 292 js.Name getNameForJsGetName(ir.Node argument, ConstantValue constant) { |
| 293 int index = _extractEnumIndexFromConstantValue( |
| 294 constant, _backend.helpers.jsGetNameEnum); |
| 295 if (index == null) return null; |
| 296 return _backend.namer |
| 297 .getNameForJsGetName(getNode(argument), JsGetName.values[index]); |
| 298 } |
| 299 |
| 300 js.Template getJsBuiltinTemplate(ConstantValue constant) { |
| 301 int index = _extractEnumIndexFromConstantValue( |
| 302 constant, _backend.helpers.jsBuiltinEnum); |
| 303 if (index == null) return null; |
| 304 return _backend.emitter.builtinTemplateFor(JsBuiltin.values[index]); |
| 305 } |
| 306 |
| 307 int _extractEnumIndexFromConstantValue( |
| 308 ConstantValue constant, Element classElement) { |
| 309 if (constant is ConstructedConstantValue) { |
| 310 if (constant.type.element == classElement) { |
| 311 assert(constant.fields.length == 1); |
| 312 ConstantValue indexConstant = constant.fields.values.single; |
| 313 if (indexConstant is IntConstantValue) { |
| 314 return indexConstant.primitiveValue; |
| 315 } |
| 316 } |
| 317 } |
| 318 return null; |
| 319 } |
| 320 |
| 275 DartType getDartType(ir.DartType type) { | 321 DartType getDartType(ir.DartType type) { |
| 276 return type.accept(_typeConverter); | 322 return type.accept(_typeConverter); |
| 277 } | 323 } |
| 278 | 324 |
| 279 List<DartType> getDartTypes(List<ir.DartType> types) { | 325 List<DartType> getDartTypes(List<ir.DartType> types) { |
| 280 return types.map(getDartType).toList(); | 326 return types.map(getDartType).toList(); |
| 281 } | 327 } |
| 282 } | 328 } |
| 283 | 329 |
| 284 class DartTypeConverter extends ir.DartTypeVisitor<DartType> { | 330 class DartTypeConverter extends ir.DartTypeVisitor<DartType> { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 @override | 372 @override |
| 327 DartType visitDynamicType(ir.DynamicType node) { | 373 DartType visitDynamicType(ir.DynamicType node) { |
| 328 return const DynamicType(); | 374 return const DynamicType(); |
| 329 } | 375 } |
| 330 | 376 |
| 331 @override | 377 @override |
| 332 DartType visitInvalidType(ir.InvalidType node) { | 378 DartType visitInvalidType(ir.InvalidType node) { |
| 333 throw new UnimplementedError("Invalid types not currently supported"); | 379 throw new UnimplementedError("Invalid types not currently supported"); |
| 334 } | 380 } |
| 335 } | 381 } |
| OLD | NEW |