| 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:js_runtime/shared/embedded_names.dart'; |
| 6 import 'package:kernel/ast.dart' as ir; | 6 import 'package:kernel/ast.dart' as ir; |
| 7 | 7 |
| 8 import '../common.dart'; | 8 import '../common.dart'; |
| 9 import '../compiler.dart'; | 9 import '../compiler.dart'; |
| 10 import '../constants/expressions.dart'; | 10 import '../constants/expressions.dart'; |
| (...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 497 int index = _extractEnumIndexFromConstantValue( | 497 int index = _extractEnumIndexFromConstantValue( |
| 498 constant, _backend.helpers.jsBuiltinEnum); | 498 constant, _backend.helpers.jsBuiltinEnum); |
| 499 if (index == null) return null; | 499 if (index == null) return null; |
| 500 return _backend.emitter.builtinTemplateFor(JsBuiltin.values[index]); | 500 return _backend.emitter.builtinTemplateFor(JsBuiltin.values[index]); |
| 501 } | 501 } |
| 502 | 502 |
| 503 int _extractEnumIndexFromConstantValue( | 503 int _extractEnumIndexFromConstantValue( |
| 504 ConstantValue constant, ClassEntity classElement) { | 504 ConstantValue constant, ClassEntity classElement) { |
| 505 if (constant is ConstructedConstantValue) { | 505 if (constant is ConstructedConstantValue) { |
| 506 if (constant.type.element == classElement) { | 506 if (constant.type.element == classElement) { |
| 507 assert(constant.fields.length == 1); | 507 assert(constant.fields.length == 1 || constant.fields.length == 2); |
| 508 ConstantValue indexConstant = constant.fields.values.single; | 508 ConstantValue indexConstant = constant.fields.values.first; |
| 509 if (indexConstant is IntConstantValue) { | 509 if (indexConstant is IntConstantValue) { |
| 510 return indexConstant.primitiveValue; | 510 return indexConstant.primitiveValue; |
| 511 } | 511 } |
| 512 } | 512 } |
| 513 } | 513 } |
| 514 return null; | 514 return null; |
| 515 } | 515 } |
| 516 | 516 |
| 517 ResolutionDartType getDartType(ir.DartType type) { | 517 ResolutionDartType getDartType(ir.DartType type) { |
| 518 return _typeConverter.convert(type); | 518 return _typeConverter.convert(type); |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 791 JumpTarget continueTarget = | 791 JumpTarget continueTarget = |
| 792 astAdapter.getJumpTarget(switchCase, isContinueTarget: true); | 792 astAdapter.getJumpTarget(switchCase, isContinueTarget: true); |
| 793 assert(continueTarget is KernelJumpTarget); | 793 assert(continueTarget is KernelJumpTarget); |
| 794 targetIndexMap[continueTarget] = switchIndex; | 794 targetIndexMap[continueTarget] = switchIndex; |
| 795 assert(builder.jumpTargets[continueTarget] == null); | 795 assert(builder.jumpTargets[continueTarget] == null); |
| 796 builder.jumpTargets[continueTarget] = this; | 796 builder.jumpTargets[continueTarget] = this; |
| 797 switchIndex++; | 797 switchIndex++; |
| 798 } | 798 } |
| 799 } | 799 } |
| 800 } | 800 } |
| OLD | NEW |