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'; |
| 11 import '../diagnostics/messages.dart'; |
11 import '../elements/elements.dart'; | 12 import '../elements/elements.dart'; |
12 import '../elements/modelx.dart' show ErroneousElementX; | 13 import '../elements/modelx.dart' show ErroneousElementX; |
13 import 'constant_serialization.dart'; | 14 import 'constant_serialization.dart'; |
14 import 'keys.dart'; | 15 import 'keys.dart'; |
15 import 'modelz.dart'; | 16 import 'modelz.dart'; |
16 import 'serialization.dart'; | 17 import 'serialization.dart'; |
17 import 'serialization_util.dart'; | 18 import 'serialization_util.dart'; |
18 | 19 |
19 /// Enum kinds used for encoding [Element]s. | 20 /// Enum kinds used for encoding [Element]s. |
20 enum SerializedElementKind { | 21 enum SerializedElementKind { |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 return null; | 207 return null; |
207 } | 208 } |
208 | 209 |
209 void serialize(ErroneousElement element, ObjectEncoder encoder, | 210 void serialize(ErroneousElement element, ObjectEncoder encoder, |
210 SerializedElementKind kind) { | 211 SerializedElementKind kind) { |
211 encoder.setElement(Key.ENCLOSING, element.enclosingElement); | 212 encoder.setElement(Key.ENCLOSING, element.enclosingElement); |
212 encoder.setString(Key.NAME, element.name); | 213 encoder.setString(Key.NAME, element.name); |
213 encoder.setEnum(Key.MESSAGE_KIND, element.messageKind); | 214 encoder.setEnum(Key.MESSAGE_KIND, element.messageKind); |
214 if (element.messageArguments.isNotEmpty) { | 215 if (element.messageArguments.isNotEmpty) { |
215 MapEncoder mapEncoder = encoder.createMap(Key.ARGUMENTS); | 216 MapEncoder mapEncoder = encoder.createMap(Key.ARGUMENTS); |
216 element.messageArguments.forEach((String key, String value) { | 217 element.messageArguments.forEach((String key, var value) { |
217 mapEncoder.setString(key, value); | 218 mapEncoder.setString(key, Message.convertToString(value)); |
218 }); | 219 }); |
219 } | 220 } |
220 } | 221 } |
221 } | 222 } |
222 | 223 |
223 class LibrarySerializer implements ElementSerializer { | 224 class LibrarySerializer implements ElementSerializer { |
224 const LibrarySerializer(); | 225 const LibrarySerializer(); |
225 | 226 |
226 SerializedElementKind getSerializedKind(Element element) { | 227 SerializedElementKind getSerializedKind(Element element) { |
227 if (element.isLibrary) { | 228 if (element.isLibrary) { |
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
812 return new LocalVariableElementZ(decoder); | 813 return new LocalVariableElementZ(decoder); |
813 case SerializedElementKind.EXTERNAL_LIBRARY: | 814 case SerializedElementKind.EXTERNAL_LIBRARY: |
814 case SerializedElementKind.EXTERNAL_LIBRARY_MEMBER: | 815 case SerializedElementKind.EXTERNAL_LIBRARY_MEMBER: |
815 case SerializedElementKind.EXTERNAL_CLASS_MEMBER: | 816 case SerializedElementKind.EXTERNAL_CLASS_MEMBER: |
816 case SerializedElementKind.EXTERNAL_CONSTRUCTOR: | 817 case SerializedElementKind.EXTERNAL_CONSTRUCTOR: |
817 break; | 818 break; |
818 } | 819 } |
819 throw new UnsupportedError("Unexpected element kind '${elementKind}."); | 820 throw new UnsupportedError("Unexpected element kind '${elementKind}."); |
820 } | 821 } |
821 } | 822 } |
OLD | NEW |