Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(16)

Side by Side Diff: pkg/analyzer/lib/src/summary/summarize_elements.dart

Issue 1528083002: Reserve element 0 in the references table for `dynamic`. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | pkg/analyzer/test/src/summary/summary_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 serialization.elements; 5 library serialization.elements;
6 6
7 import 'package:analyzer/dart/element/element.dart'; 7 import 'package:analyzer/dart/element/element.dart';
8 import 'package:analyzer/dart/element/type.dart'; 8 import 'package:analyzer/dart/element/type.dart';
9 import 'package:analyzer/src/dart/element/type.dart'; 9 import 'package:analyzer/src/dart/element/type.dart';
10 import 'package:analyzer/src/generated/resolver.dart'; 10 import 'package:analyzer/src/generated/resolver.dart';
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 86
87 /** 87 /**
88 * The prelinked portion of the "references table". This is the list of 88 * The prelinked portion of the "references table". This is the list of
89 * objects which should be written to [PrelinkedUnit.references]. 89 * objects which should be written to [PrelinkedUnit.references].
90 */ 90 */
91 List<PrelinkedReferenceBuilder> prelinkedReferences; 91 List<PrelinkedReferenceBuilder> prelinkedReferences;
92 92
93 //final Map<String, int> prefixIndices = <String, int>{}; 93 //final Map<String, int> prefixIndices = <String, int>{};
94 94
95 /** 95 /**
96 * Index into the "references table" representing `dynamic`, if such an index
97 * exists. `null` if no such entry has been made in the references table
98 * yet.
99 */
100 int dynamicReferenceIndex = null;
101
102 /**
103 * Index into the "references table" representing an unresolved reference, if 96 * Index into the "references table" representing an unresolved reference, if
104 * such an index exists. `null` if no such entry has been made in the 97 * such an index exists. `null` if no such entry has been made in the
105 * references table yet. 98 * references table yet.
106 */ 99 */
107 int unresolvedReferenceIndex = null; 100 int unresolvedReferenceIndex = null;
108 101
109 /** 102 /**
110 * Set of libraries which have been seen so far while visiting the transitive 103 * Set of libraries which have been seen so far while visiting the transitive
111 * closure of exports. 104 * closure of exports.
112 */ 105 */
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 if (libraryElement.name.isNotEmpty) { 140 if (libraryElement.name.isNotEmpty) {
148 b.libraryName = libraryElement.name; 141 b.libraryName = libraryElement.name;
149 } 142 }
150 b.exports = libraryElement.exports.map(serializeExport).toList(); 143 b.exports = libraryElement.exports.map(serializeExport).toList();
151 b.imports = libraryElement.imports.map(serializeImport).toList(); 144 b.imports = libraryElement.imports.map(serializeImport).toList();
152 b.parts = libraryElement.parts 145 b.parts = libraryElement.parts
153 .map( 146 .map(
154 (CompilationUnitElement e) => encodeUnlinkedPart(ctx, uri: e.uri)) 147 (CompilationUnitElement e) => encodeUnlinkedPart(ctx, uri: e.uri))
155 .toList(); 148 .toList();
156 } 149 }
157 unlinkedReferences = <UnlinkedReferenceBuilder>[]; 150 unlinkedReferences = <UnlinkedReferenceBuilder>[
158 prelinkedReferences = <PrelinkedReferenceBuilder>[]; 151 encodeUnlinkedReference(ctx)
152 ];
153 prelinkedReferences = <PrelinkedReferenceBuilder>[
154 encodePrelinkedReference(ctx, kind: PrelinkedReferenceKind.classOrEnum)
155 ];
159 b.classes = element.types.map(serializeClass).toList(); 156 b.classes = element.types.map(serializeClass).toList();
160 b.enums = element.enums.map(serializeEnum).toList(); 157 b.enums = element.enums.map(serializeEnum).toList();
161 b.typedefs = element.functionTypeAliases.map(serializeTypedef).toList(); 158 b.typedefs = element.functionTypeAliases.map(serializeTypedef).toList();
162 List<UnlinkedExecutableBuilder> executables = 159 List<UnlinkedExecutableBuilder> executables =
163 element.functions.map(serializeExecutable).toList(); 160 element.functions.map(serializeExecutable).toList();
164 for (PropertyAccessorElement accessor in element.accessors) { 161 for (PropertyAccessorElement accessor in element.accessors) {
165 if (!accessor.isSynthetic) { 162 if (!accessor.isSynthetic) {
166 executables.add(serializeExecutable(accessor)); 163 executables.add(serializeExecutable(accessor));
167 } 164 }
168 } 165 }
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 int index = dependencies.length; 300 int index = dependencies.length;
304 dependencies.add(encodePrelinkedDependency(ctx, 301 dependencies.add(encodePrelinkedDependency(ctx,
305 uri: dependentLibrary.source.uri.toString())); 302 uri: dependentLibrary.source.uri.toString()));
306 return index; 303 return index;
307 }); 304 });
308 } 305 }
309 306
310 /** 307 /**
311 * Return the index of the entry in the references table 308 * Return the index of the entry in the references table
312 * ([UnlinkedLibrary.references] and [PrelinkedLibrary.references]) 309 * ([UnlinkedLibrary.references] and [PrelinkedLibrary.references])
313 * representing the pseudo-type `dynamic`. A new entry is added to the table 310 * representing the pseudo-type `dynamic`.
314 * if necessary to satisfy the request.
315 */ 311 */
316 int serializeDynamicReference() { 312 int serializeDynamicReference() => 0;
317 if (dynamicReferenceIndex == null) {
318 assert(unlinkedReferences.length == prelinkedReferences.length);
319 dynamicReferenceIndex = unlinkedReferences.length;
320 unlinkedReferences.add(encodeUnlinkedReference(ctx));
321 prelinkedReferences.add(encodePrelinkedReference(ctx,
322 kind: PrelinkedReferenceKind.classOrEnum));
323 }
324 return dynamicReferenceIndex;
325 }
326 313
327 /** 314 /**
328 * Serialize the given [enumElement], creating an [UnlinkedEnum]. 315 * Serialize the given [enumElement], creating an [UnlinkedEnum].
329 */ 316 */
330 UnlinkedEnumBuilder serializeEnum(ClassElement enumElement) { 317 UnlinkedEnumBuilder serializeEnum(ClassElement enumElement) {
331 UnlinkedEnumBuilder b = new UnlinkedEnumBuilder(ctx); 318 UnlinkedEnumBuilder b = new UnlinkedEnumBuilder(ctx);
332 b.name = enumElement.name; 319 b.name = enumElement.name;
333 List<UnlinkedEnumValueBuilder> values = <UnlinkedEnumValueBuilder>[]; 320 List<UnlinkedEnumValueBuilder> values = <UnlinkedEnumValueBuilder>[];
334 for (FieldElement field in enumElement.fields) { 321 for (FieldElement field in enumElement.fields) {
335 if (field.isConst && field.type.element == enumElement) { 322 if (field.isConst && field.type.element == enumElement) {
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 UnlinkedVariableBuilder b = new UnlinkedVariableBuilder(ctx); 560 UnlinkedVariableBuilder b = new UnlinkedVariableBuilder(ctx);
574 b.name = variable.name; 561 b.name = variable.name;
575 b.type = serializeTypeRef(variable.type, variable); 562 b.type = serializeTypeRef(variable.type, variable);
576 b.isStatic = variable.isStatic && variable.enclosingElement is ClassElement; 563 b.isStatic = variable.isStatic && variable.enclosingElement is ClassElement;
577 b.isFinal = variable.isFinal; 564 b.isFinal = variable.isFinal;
578 b.isConst = variable.isConst; 565 b.isConst = variable.isConst;
579 b.hasImplicitType = variable.hasImplicitType; 566 b.hasImplicitType = variable.hasImplicitType;
580 return b; 567 return b;
581 } 568 }
582 } 569 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/test/src/summary/summary_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698