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

Side by Side Diff: pkg/kernel/lib/binary/ast_to_binary.dart

Issue 3009953003: Store actual Reference(s) for additional exports. (Closed)
Patch Set: Use references, but keep JSON hacks for errors and void/dynamic. Created 3 years, 3 months 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
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 library kernel.ast_to_binary; 4 library kernel.ast_to_binary;
5 5
6 import '../ast.dart'; 6 import '../ast.dart';
7 import '../import_table.dart'; 7 import '../import_table.dart';
8 import 'tag.dart'; 8 import 'tag.dart';
9 import 'dart:convert'; 9 import 'dart:convert';
10 import 'dart:typed_data'; 10 import 'dart:typed_data';
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 visitLibrary(Library node) { 305 visitLibrary(Library node) {
306 insideExternalLibrary = node.isExternal; 306 insideExternalLibrary = node.isExternal;
307 node.binaryOffset = _sink.flushedLength + _sink.length; 307 node.binaryOffset = _sink.flushedLength + _sink.length;
308 writeByte(insideExternalLibrary ? 1 : 0); 308 writeByte(insideExternalLibrary ? 1 : 0);
309 writeCanonicalNameReference(getCanonicalNameOfLibrary(node)); 309 writeCanonicalNameReference(getCanonicalNameOfLibrary(node));
310 writeStringReference(node.name ?? ''); 310 writeStringReference(node.name ?? '');
311 // TODO(jensj): We save (almost) the same URI twice. 311 // TODO(jensj): We save (almost) the same URI twice.
312 writeUriReference(node.fileUri ?? ''); 312 writeUriReference(node.fileUri ?? '');
313 writeAnnotationList(node.annotations); 313 writeAnnotationList(node.annotations);
314 writeLibraryDependencies(node); 314 writeLibraryDependencies(node);
315 writeAdditionalExports(node);
315 writeLibraryParts(node); 316 writeLibraryParts(node);
316 writeNodeList(node.typedefs); 317 writeNodeList(node.typedefs);
317 writeNodeList(node.classes); 318 writeNodeList(node.classes);
318 writeNodeList(node.fields); 319 writeNodeList(node.fields);
319 writeNodeList(node.procedures); 320 writeNodeList(node.procedures);
320 } 321 }
321 322
322 void writeLibraryDependencies(Library library) { 323 void writeLibraryDependencies(Library library) {
323 _libraryDependencyIndex = library.dependencies.isEmpty 324 _libraryDependencyIndex = library.dependencies.isEmpty
324 ? const <LibraryDependency, int>{} 325 ? const <LibraryDependency, int>{}
325 : <LibraryDependency, int>{}; 326 : <LibraryDependency, int>{};
326 writeUInt30(library.dependencies.length); 327 writeUInt30(library.dependencies.length);
327 for (int i = 0; i < library.dependencies.length; ++i) { 328 for (int i = 0; i < library.dependencies.length; ++i) {
328 var importNode = library.dependencies[i]; 329 var importNode = library.dependencies[i];
329 _libraryDependencyIndex[importNode] = i; 330 _libraryDependencyIndex[importNode] = i;
330 writeLibraryDependency(importNode); 331 writeLibraryDependency(importNode);
331 } 332 }
332 } 333 }
333 334
335 void writeAdditionalExports(Library library) {
336 writeUInt30(library.additionalExports.length);
337 for (Reference ref in library.additionalExports) {
338 writeReference(ref);
339 }
340 }
341
334 void writeLibraryDependency(LibraryDependency node) { 342 void writeLibraryDependency(LibraryDependency node) {
335 writeByte(node.flags); 343 writeByte(node.flags);
336 writeNodeList(node.annotations); 344 writeNodeList(node.annotations);
337 writeLibraryReference(node.targetLibrary); 345 writeLibraryReference(node.targetLibrary);
338 writeStringReference(node.name ?? ''); 346 writeStringReference(node.name ?? '');
339 writeNodeList(node.combinators); 347 writeNodeList(node.combinators);
340 } 348 }
341 349
342 void visitCombinator(Combinator node) { 350 void visitCombinator(Combinator node) {
343 writeByte(node.isShow ? 1 : 0); 351 writeByte(node.isShow ? 1 : 0);
(...skipping 1209 matching lines...) Expand 10 before | Expand all | Expand 10 after
1553 _sink.add(_buffer.sublist(0, length)); 1561 _sink.add(_buffer.sublist(0, length));
1554 _buffer = new Uint8List(SIZE); 1562 _buffer = new Uint8List(SIZE);
1555 flushedLength += length; 1563 flushedLength += length;
1556 length = 0; 1564 length = 0;
1557 } 1565 }
1558 1566
1559 void flushAndDestroy() { 1567 void flushAndDestroy() {
1560 _sink.add(_buffer.sublist(0, length)); 1568 _sink.add(_buffer.sublist(0, length));
1561 } 1569 }
1562 } 1570 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698