| 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; | 5 library dart2js.serialization; |
| 6 | 6 |
| 7 import 'package:front_end/src/scanner/token.dart' show TokenType; | 7 import 'package:front_end/src/scanner/token.dart' show TokenType; |
| 8 | 8 |
| 9 import '../common.dart'; | 9 import '../common.dart'; |
| 10 import '../common/resolution.dart'; | 10 import '../common/resolution.dart'; |
| (...skipping 714 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 725 } | 725 } |
| 726 | 726 |
| 727 if (element.isLibrary) { | 727 if (element.isLibrary) { |
| 728 LibraryElement library = element; | 728 LibraryElement library = element; |
| 729 _elementMap[element] = dataObject = new DataObject( | 729 _elementMap[element] = dataObject = new DataObject( |
| 730 new IntValue(_elementMap.length), | 730 new IntValue(_elementMap.length), |
| 731 new EnumValue(SerializedElementKind.EXTERNAL_LIBRARY)); | 731 new EnumValue(SerializedElementKind.EXTERNAL_LIBRARY)); |
| 732 ObjectEncoder encoder = new ObjectEncoder(this, dataObject.map); | 732 ObjectEncoder encoder = new ObjectEncoder(this, dataObject.map); |
| 733 encoder.setUri(Key.URI, library.canonicalUri, library.canonicalUri); | 733 encoder.setUri(Key.URI, library.canonicalUri, library.canonicalUri); |
| 734 } else if (element.isConstructor) { | 734 } else if (element.isConstructor) { |
| 735 assert(invariant( | 735 assert( |
| 736 element, | |
| 737 verifyElement( | 736 verifyElement( |
| 738 element.enclosingClass.implementation | 737 element.enclosingClass.implementation |
| 739 .lookupConstructor(element.name), | 738 .lookupConstructor(element.name), |
| 740 element), | 739 element), |
| 741 message: "Element $element is not found as a " | 740 failedAt( |
| 741 element, |
| 742 "Element $element is not found as a " |
| 742 "constructor of ${element.enclosingClass.implementation}.")); | 743 "constructor of ${element.enclosingClass.implementation}.")); |
| 743 Value classId = _getElementId(element.enclosingClass); | 744 Value classId = _getElementId(element.enclosingClass); |
| 744 _elementMap[element] = dataObject = new DataObject( | 745 _elementMap[element] = dataObject = new DataObject( |
| 745 new IntValue(_elementMap.length), | 746 new IntValue(_elementMap.length), |
| 746 new EnumValue(SerializedElementKind.EXTERNAL_CONSTRUCTOR)); | 747 new EnumValue(SerializedElementKind.EXTERNAL_CONSTRUCTOR)); |
| 747 ObjectEncoder encoder = new ObjectEncoder(this, dataObject.map); | 748 ObjectEncoder encoder = new ObjectEncoder(this, dataObject.map); |
| 748 encoder.setValue(Key.CLASS, classId); | 749 encoder.setValue(Key.CLASS, classId); |
| 749 encoder.setString(Key.NAME, element.name); | 750 encoder.setString(Key.NAME, element.name); |
| 750 } else if (element.isClassMember) { | 751 } else if (element.isClassMember) { |
| 751 assert(invariant( | 752 assert( |
| 752 element, | |
| 753 verifyElement( | 753 verifyElement( |
| 754 element.enclosingClass.lookupLocalMember(element.name), | 754 element.enclosingClass.lookupLocalMember(element.name), |
| 755 element), | 755 element), |
| 756 message: "Element $element is not found as a " | 756 failedAt( |
| 757 element, |
| 758 "Element $element is not found as a " |
| 757 "class member of ${element.enclosingClass}.")); | 759 "class member of ${element.enclosingClass}.")); |
| 758 Value classId = _getElementId(element.enclosingClass); | 760 Value classId = _getElementId(element.enclosingClass); |
| 759 _elementMap[element] = dataObject = new DataObject( | 761 _elementMap[element] = dataObject = new DataObject( |
| 760 new IntValue(_elementMap.length), | 762 new IntValue(_elementMap.length), |
| 761 new EnumValue(SerializedElementKind.EXTERNAL_CLASS_MEMBER)); | 763 new EnumValue(SerializedElementKind.EXTERNAL_CLASS_MEMBER)); |
| 762 ObjectEncoder encoder = new ObjectEncoder(this, dataObject.map); | 764 ObjectEncoder encoder = new ObjectEncoder(this, dataObject.map); |
| 763 encoder.setValue(Key.CLASS, classId); | 765 encoder.setValue(Key.CLASS, classId); |
| 764 encoder.setString(Key.NAME, element.name); | 766 encoder.setString(Key.NAME, element.name); |
| 765 if (element.isAccessor) { | 767 if (element.isAccessor) { |
| 766 encoder.setBool(Key.GETTER, element.isGetter); | 768 encoder.setBool(Key.GETTER, element.isGetter); |
| 767 } | 769 } |
| 768 } else { | 770 } else { |
| 769 assert(invariant( | 771 assert( |
| 770 element, | |
| 771 verifyElement( | 772 verifyElement( |
| 772 element.library.implementation.find(element.name), element), | 773 element.library.implementation.find(element.name), element), |
| 773 message: "Element $element is not found as a " | 774 failedAt( |
| 775 element, |
| 776 "Element $element is not found as a " |
| 774 "library member of ${element.library.implementation}.")); | 777 "library member of ${element.library.implementation}.")); |
| 775 Value libraryId = _getElementId(element.library); | 778 Value libraryId = _getElementId(element.library); |
| 776 _elementMap[element] = dataObject = new DataObject( | 779 _elementMap[element] = dataObject = new DataObject( |
| 777 new IntValue(_elementMap.length), | 780 new IntValue(_elementMap.length), |
| 778 new EnumValue(SerializedElementKind.EXTERNAL_LIBRARY_MEMBER)); | 781 new EnumValue(SerializedElementKind.EXTERNAL_LIBRARY_MEMBER)); |
| 779 ObjectEncoder encoder = new ObjectEncoder(this, dataObject.map); | 782 ObjectEncoder encoder = new ObjectEncoder(this, dataObject.map); |
| 780 encoder.setValue(Key.LIBRARY, libraryId); | 783 encoder.setValue(Key.LIBRARY, libraryId); |
| 781 encoder.setString(Key.NAME, element.name); | 784 encoder.setString(Key.NAME, element.name); |
| 782 if (element.isAccessor) { | 785 if (element.isAccessor) { |
| 783 encoder.setBool(Key.GETTER, element.isGetter); | 786 encoder.setBool(Key.GETTER, element.isGetter); |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1151 | 1154 |
| 1152 /// Returns the value used to store [key] as a property in the encoding an | 1155 /// Returns the value used to store [key] as a property in the encoding an |
| 1153 /// [ObjectValue]. | 1156 /// [ObjectValue]. |
| 1154 /// | 1157 /// |
| 1155 /// Different encodings have different restrictions and capabilities as how | 1158 /// Different encodings have different restrictions and capabilities as how |
| 1156 /// to store a [Key] value. For instance: A JSON encoding needs to convert | 1159 /// to store a [Key] value. For instance: A JSON encoding needs to convert |
| 1157 /// [Key] to a [String] to store it in a JSON object; a Dart encoding can | 1160 /// [Key] to a [String] to store it in a JSON object; a Dart encoding can |
| 1158 /// choose to store a [Key] as an [int] or as the [Key] itself. | 1161 /// choose to store a [Key] as an [int] or as the [Key] itself. |
| 1159 getObjectPropertyValue(Key key); | 1162 getObjectPropertyValue(Key key); |
| 1160 } | 1163 } |
| OLD | NEW |