| 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'; | |
| 6 import 'package:kernel/ast.dart' as ir; | 5 import 'package:kernel/ast.dart' as ir; |
| 7 | 6 |
| 8 import '../closure.dart'; | 7 import '../closure.dart'; |
| 9 import '../common.dart'; | 8 import '../common.dart'; |
| 10 import '../compiler.dart'; | 9 import '../compiler.dart'; |
| 11 import '../constants/expressions.dart'; | 10 import '../constants/expressions.dart'; |
| 12 import '../constants/values.dart'; | 11 import '../constants/values.dart'; |
| 13 import '../common_elements.dart'; | 12 import '../common_elements.dart'; |
| 14 import '../elements/elements.dart'; | 13 import '../elements/elements.dart'; |
| 15 import '../elements/entities.dart'; | 14 import '../elements/entities.dart'; |
| 16 import '../elements/jumps.dart'; | 15 import '../elements/jumps.dart'; |
| 17 import '../elements/modelx.dart'; | 16 import '../elements/modelx.dart'; |
| 18 import '../elements/resolution_types.dart'; | 17 import '../elements/resolution_types.dart'; |
| 19 import '../elements/types.dart'; | 18 import '../elements/types.dart'; |
| 20 import '../js/js.dart' as js; | |
| 21 import '../js_backend/js_backend.dart'; | 19 import '../js_backend/js_backend.dart'; |
| 22 import '../kernel/element_map.dart'; | 20 import '../kernel/element_map.dart'; |
| 23 import '../kernel/kernel.dart'; | 21 import '../kernel/kernel.dart'; |
| 24 import '../native/native.dart' as native; | 22 import '../native/native.dart' as native; |
| 25 import '../resolution/tree_elements.dart'; | 23 import '../resolution/tree_elements.dart'; |
| 26 import '../tree/tree.dart' as ast; | 24 import '../tree/tree.dart' as ast; |
| 27 import '../types/masks.dart'; | 25 import '../types/masks.dart'; |
| 28 import '../types/types.dart'; | 26 import '../types/types.dart'; |
| 29 import '../universe/selector.dart'; | 27 import '../universe/selector.dart'; |
| 30 import '../world.dart'; | 28 import '../world.dart'; |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 {bool isContinueTarget: false}) { | 232 {bool isContinueTarget: false}) { |
| 235 return _jumpTargets.putIfAbsent(node, () { | 233 return _jumpTargets.putIfAbsent(node, () { |
| 236 if (node is ir.LabeledStatement && _jumpTargets.containsKey(node.body)) { | 234 if (node is ir.LabeledStatement && _jumpTargets.containsKey(node.body)) { |
| 237 return _jumpTargets[node.body]; | 235 return _jumpTargets[node.body]; |
| 238 } | 236 } |
| 239 return new KernelJumpTarget(node, this, | 237 return new KernelJumpTarget(node, this, |
| 240 makeContinueLabel: isContinueTarget); | 238 makeContinueLabel: isContinueTarget); |
| 241 }); | 239 }); |
| 242 } | 240 } |
| 243 | 241 |
| 244 js.Name getNameForJsGetName(ir.Node argument, ConstantValue constant) { | |
| 245 int index = _extractEnumIndexFromConstantValue( | |
| 246 constant, _compiler.resolution.commonElements.jsGetNameEnum); | |
| 247 if (index == null) return null; | |
| 248 return _backend.namer | |
| 249 .getNameForJsGetName(getNode(argument), JsGetName.values[index]); | |
| 250 } | |
| 251 | |
| 252 js.Template getJsBuiltinTemplate(ConstantValue constant) { | |
| 253 int index = _extractEnumIndexFromConstantValue( | |
| 254 constant, _compiler.resolution.commonElements.jsBuiltinEnum); | |
| 255 if (index == null) return null; | |
| 256 return _backend.emitter.builtinTemplateFor(JsBuiltin.values[index]); | |
| 257 } | |
| 258 | |
| 259 int _extractEnumIndexFromConstantValue( | |
| 260 ConstantValue constant, ClassEntity classElement) { | |
| 261 if (constant is ConstructedConstantValue) { | |
| 262 if (constant.type.element == classElement) { | |
| 263 assert(constant.fields.length == 1 || constant.fields.length == 2); | |
| 264 ConstantValue indexConstant = constant.fields.values.first; | |
| 265 if (indexConstant is IntConstantValue) { | |
| 266 return indexConstant.primitiveValue; | |
| 267 } | |
| 268 } | |
| 269 } | |
| 270 return null; | |
| 271 } | |
| 272 | |
| 273 DartType getDartType(ir.DartType type) { | 242 DartType getDartType(ir.DartType type) { |
| 274 return _typeConverter.convert(type); | 243 return _typeConverter.convert(type); |
| 275 } | 244 } |
| 276 | 245 |
| 277 List<DartType> getDartTypes(List<ir.DartType> types) { | 246 List<DartType> getDartTypes(List<ir.DartType> types) { |
| 278 return types.map(getDartType).toList(); | 247 return types.map(getDartType).toList(); |
| 279 } | 248 } |
| 280 | 249 |
| 281 /// Computes the function type corresponding the signature of [node]. | 250 /// Computes the function type corresponding the signature of [node]. |
| 282 FunctionType getFunctionType(ir.FunctionNode node) { | 251 FunctionType getFunctionType(ir.FunctionNode node) { |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 643 TypeMask selectorTypeOf(Selector selector, TypeMask mask) { | 612 TypeMask selectorTypeOf(Selector selector, TypeMask mask) { |
| 644 return TypeMaskFactory.inferredTypeForSelector( | 613 return TypeMaskFactory.inferredTypeForSelector( |
| 645 selector, mask, _globalInferenceResults); | 614 selector, mask, _globalInferenceResults); |
| 646 } | 615 } |
| 647 | 616 |
| 648 TypeMask typeFromNativeBehavior( | 617 TypeMask typeFromNativeBehavior( |
| 649 native.NativeBehavior nativeBehavior, ClosedWorld closedWorld) { | 618 native.NativeBehavior nativeBehavior, ClosedWorld closedWorld) { |
| 650 return TypeMaskFactory.fromNativeBehavior(nativeBehavior, closedWorld); | 619 return TypeMaskFactory.fromNativeBehavior(nativeBehavior, closedWorld); |
| 651 } | 620 } |
| 652 } | 621 } |
| OLD | NEW |