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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 } | 98 } |
99 mapEncoder.setElement(name, member); | 99 mapEncoder.setElement(name, member); |
100 } | 100 } |
101 } | 101 } |
102 | 102 |
103 /// Serialize the source position of [element] into [encoder]. | 103 /// Serialize the source position of [element] into [encoder]. |
104 static void serializePosition(Element element, ObjectEncoder encoder) { | 104 static void serializePosition(Element element, ObjectEncoder encoder) { |
105 if (element.sourcePosition != null) { | 105 if (element.sourcePosition != null) { |
106 SourceSpan position = element.sourcePosition; | 106 SourceSpan position = element.sourcePosition; |
107 encoder.setInt(Key.OFFSET, position.begin); | 107 encoder.setInt(Key.OFFSET, position.begin); |
108 if (position.uri != element.compilationUnit.script.resourceUri) { | 108 // TODO(johnniwinther): Figure out why the omitted the uri if |
109 // TODO(johnniwinther): What is the base URI in the case? | 109 // `position.uri != element.compilationUnit.script.resourceUri` does not |
110 encoder.setUri(Key.URI, element.library.canonicalUri, position.uri); | 110 // always work, for instance for LinkedHashMap#_literal. |
111 } | 111 // TODO(johnniwinther): What is the base URI in the case? |
| 112 encoder.setUri(Key.URI, element.library.canonicalUri, position.uri); |
112 int length = position.end - position.begin; | 113 int length = position.end - position.begin; |
113 if (element.name.length != length) { | 114 if (element.name.length != length) { |
114 encoder.setInt(Key.LENGTH, length); | 115 encoder.setInt(Key.LENGTH, length); |
115 } | 116 } |
116 } | 117 } |
117 } | 118 } |
118 | 119 |
119 /// Serialize the parameters of [element] into [encoder]. | 120 /// Serialize the parameters of [element] into [encoder]. |
120 static void serializeParameters( | 121 static void serializeParameters( |
121 FunctionElement element, ObjectEncoder encoder) { | 122 FunctionElement element, ObjectEncoder encoder) { |
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
682 return new LocalVariableElementZ(decoder); | 683 return new LocalVariableElementZ(decoder); |
683 case SerializedElementKind.EXTERNAL_LIBRARY: | 684 case SerializedElementKind.EXTERNAL_LIBRARY: |
684 case SerializedElementKind.EXTERNAL_LIBRARY_MEMBER: | 685 case SerializedElementKind.EXTERNAL_LIBRARY_MEMBER: |
685 case SerializedElementKind.EXTERNAL_STATIC_MEMBER: | 686 case SerializedElementKind.EXTERNAL_STATIC_MEMBER: |
686 case SerializedElementKind.EXTERNAL_CONSTRUCTOR: | 687 case SerializedElementKind.EXTERNAL_CONSTRUCTOR: |
687 break; | 688 break; |
688 } | 689 } |
689 throw new UnsupportedError("Unexpected element kind '${elementKind}."); | 690 throw new UnsupportedError("Unexpected element kind '${elementKind}."); |
690 } | 691 } |
691 } | 692 } |
OLD | NEW |