OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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.serialization.elements; | 5 library dart2js.serialization.elements; |
6 | 6 |
7 import '../common.dart'; | 7 import '../common.dart'; |
8 import '../constants/constructors.dart'; | 8 import '../constants/constructors.dart'; |
9 import '../constants/expressions.dart'; | 9 import '../constants/expressions.dart'; |
10 import '../dart_types.dart'; | 10 import '../dart_types.dart'; |
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 return null; | 391 return null; |
392 } | 392 } |
393 | 393 |
394 void serialize( | 394 void serialize( |
395 FieldElement element, ObjectEncoder encoder, SerializedElementKind kind) { | 395 FieldElement element, ObjectEncoder encoder, SerializedElementKind kind) { |
396 encoder.setString(Key.NAME, element.name); | 396 encoder.setString(Key.NAME, element.name); |
397 SerializerUtil.serializePosition(element, encoder); | 397 SerializerUtil.serializePosition(element, encoder); |
398 encoder.setType(Key.TYPE, element.type); | 398 encoder.setType(Key.TYPE, element.type); |
399 encoder.setBool(Key.IS_FINAL, element.isFinal); | 399 encoder.setBool(Key.IS_FINAL, element.isFinal); |
400 encoder.setBool(Key.IS_CONST, element.isConst); | 400 encoder.setBool(Key.IS_CONST, element.isConst); |
401 if (element.isConst) { | 401 ConstantExpression constant = element.constant; |
402 ConstantExpression constant = element.constant; | 402 if (constant != null) { |
403 encoder.setConstant(Key.CONSTANT, constant); | 403 encoder.setConstant(Key.CONSTANT, constant); |
404 } | 404 } |
405 SerializerUtil.serializeParentRelation(element, encoder); | 405 SerializerUtil.serializeParentRelation(element, encoder); |
406 if (element is EnumConstantElement) { | 406 if (element is EnumConstantElement) { |
407 EnumConstantElement enumConstant = element; | 407 EnumConstantElement enumConstant = element; |
408 encoder.setInt(Key.INDEX, enumConstant.index); | 408 encoder.setInt(Key.INDEX, enumConstant.index); |
409 } | 409 } |
410 } | 410 } |
411 } | 411 } |
412 | 412 |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
701 return new LocalVariableElementZ(decoder); | 701 return new LocalVariableElementZ(decoder); |
702 case SerializedElementKind.EXTERNAL_LIBRARY: | 702 case SerializedElementKind.EXTERNAL_LIBRARY: |
703 case SerializedElementKind.EXTERNAL_LIBRARY_MEMBER: | 703 case SerializedElementKind.EXTERNAL_LIBRARY_MEMBER: |
704 case SerializedElementKind.EXTERNAL_STATIC_MEMBER: | 704 case SerializedElementKind.EXTERNAL_STATIC_MEMBER: |
705 case SerializedElementKind.EXTERNAL_CONSTRUCTOR: | 705 case SerializedElementKind.EXTERNAL_CONSTRUCTOR: |
706 break; | 706 break; |
707 } | 707 } |
708 throw new UnsupportedError("Unexpected element kind '${elementKind}."); | 708 throw new UnsupportedError("Unexpected element kind '${elementKind}."); |
709 } | 709 } |
710 } | 710 } |
OLD | NEW |