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 662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
673 ClassEntity getClass(ir.Class node) => _getClass(node); | 673 ClassEntity getClass(ir.Class node) => _getClass(node); |
674 | 674 |
675 @override | 675 @override |
676 FieldEntity getField(ir.Field node) => _getField(node); | 676 FieldEntity getField(ir.Field node) => _getField(node); |
677 | 677 |
678 bool hasConstantFieldInitializer(KField field) { | 678 bool hasConstantFieldInitializer(KField field) { |
679 _FieldData data = _memberList[field.memberIndex]; | 679 _FieldData data = _memberList[field.memberIndex]; |
680 return getFieldConstantValue(data.node) != null; | 680 return getFieldConstantValue(data.node) != null; |
681 } | 681 } |
682 | 682 |
| 683 ConstantValue getConstantFieldInitializer(KField field) { |
| 684 _FieldData data = _memberList[field.memberIndex]; |
| 685 ConstantValue value = getFieldConstantValue(data.node); |
| 686 assert(value != null, |
| 687 failedAt(field, "Field $field doesn't have a constant initial value.")); |
| 688 return value; |
| 689 } |
| 690 |
683 TypeVariableEntity getTypeVariable(ir.TypeParameter node) => | 691 TypeVariableEntity getTypeVariable(ir.TypeParameter node) => |
684 _getTypeVariable(node); | 692 _getTypeVariable(node); |
685 | 693 |
686 @override | 694 @override |
687 FunctionEntity getMethod(ir.Procedure node) => _getMethod(node); | 695 FunctionEntity getMethod(ir.Procedure node) => _getMethod(node); |
688 | 696 |
689 void forEachParameter(KFunction function, | 697 void forEachParameter(KFunction function, |
690 void f(DartType type, String name, ConstantValue defaultValue)) { | 698 void f(DartType type, String name, ConstantValue defaultValue)) { |
691 _FunctionData data = _memberList[function.memberIndex]; | 699 _FunctionData data = _memberList[function.memberIndex]; |
692 data.forEachParameter(this, f); | 700 data.forEachParameter(this, f); |
(...skipping 1170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1863 @override | 1871 @override |
1864 DiagnosticReporter get reporter { | 1872 DiagnosticReporter get reporter { |
1865 return _elementMap.reporter; | 1873 return _elementMap.reporter; |
1866 } | 1874 } |
1867 | 1875 |
1868 @override | 1876 @override |
1869 ConstantValue getFieldConstantValue(ir.Field field) { | 1877 ConstantValue getFieldConstantValue(ir.Field field) { |
1870 throw new UnsupportedError("JsKernelToElementMap.getFieldConstantValue"); | 1878 throw new UnsupportedError("JsKernelToElementMap.getFieldConstantValue"); |
1871 } | 1879 } |
1872 } | 1880 } |
OLD | NEW |