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

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

Issue 2988373002: Store parts in Kernel Library, resynthesize parts in Analyzer. (Closed)
Patch Set: Fixes for review comments. Created 3 years, 4 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
« no previous file with comments | « pkg/kernel/lib/binary/ast_from_binary.dart ('k') | pkg/kernel/lib/visitor.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) 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 writeLibraryParts(node);
315 writeNodeList(node.typedefs); 316 writeNodeList(node.typedefs);
316 writeNodeList(node.classes); 317 writeNodeList(node.classes);
317 writeNodeList(node.fields); 318 writeNodeList(node.fields);
318 writeNodeList(node.procedures); 319 writeNodeList(node.procedures);
319 } 320 }
320 321
321 void writeLibraryDependencies(Library library) { 322 void writeLibraryDependencies(Library library) {
322 _libraryDependencyIndex = library.dependencies.isEmpty 323 _libraryDependencyIndex = library.dependencies.isEmpty
323 ? const <LibraryDependency, int>{} 324 ? const <LibraryDependency, int>{}
324 : <LibraryDependency, int>{}; 325 : <LibraryDependency, int>{};
(...skipping 11 matching lines...) Expand all
336 writeLibraryReference(node.targetLibrary); 337 writeLibraryReference(node.targetLibrary);
337 writeStringReference(node.name ?? ''); 338 writeStringReference(node.name ?? '');
338 writeNodeList(node.combinators); 339 writeNodeList(node.combinators);
339 } 340 }
340 341
341 void visitCombinator(Combinator node) { 342 void visitCombinator(Combinator node) {
342 writeByte(node.isShow ? 1 : 0); 343 writeByte(node.isShow ? 1 : 0);
343 writeStringReferenceList(node.names); 344 writeStringReferenceList(node.names);
344 } 345 }
345 346
347 void writeLibraryParts(Library library) {
348 writeUInt30(library.parts.length);
349 for (int i = 0; i < library.parts.length; ++i) {
350 var partNode = library.parts[i];
351 writeLibraryPart(partNode);
352 }
353 }
354
355 void writeLibraryPart(LibraryPart node) {
356 writeNodeList(node.annotations);
357 writeStringReference(node.fileUri ?? '');
358 }
359
346 void visitTypedef(Typedef node) { 360 void visitTypedef(Typedef node) {
347 writeCanonicalNameReference(getCanonicalNameOfTypedef(node)); 361 writeCanonicalNameReference(getCanonicalNameOfTypedef(node));
348 writeOffset(node.fileOffset); 362 writeOffset(node.fileOffset);
349 writeStringReference(node.name); 363 writeStringReference(node.name);
350 writeUriReference(node.fileUri ?? ''); 364 writeUriReference(node.fileUri ?? '');
351 _typeParameterIndexer.enter(node.typeParameters); 365 _typeParameterIndexer.enter(node.typeParameters);
352 writeNodeList(node.typeParameters); 366 writeNodeList(node.typeParameters);
353 writeNode(node.type); 367 writeNode(node.type);
354 _typeParameterIndexer.exit(node.typeParameters); 368 _typeParameterIndexer.exit(node.typeParameters);
355 } 369 }
(...skipping 1001 matching lines...) Expand 10 before | Expand all | Expand 10 after
1357 putOptional(node.name); 1371 putOptional(node.name);
1358 put('${node.importUri}'); 1372 put('${node.importUri}');
1359 node.visitChildren(this); 1373 node.visitChildren(this);
1360 } 1374 }
1361 1375
1362 visitLibraryDependency(LibraryDependency node) { 1376 visitLibraryDependency(LibraryDependency node) {
1363 putOptional(node.name); 1377 putOptional(node.name);
1364 node.visitChildren(this); 1378 node.visitChildren(this);
1365 } 1379 }
1366 1380
1381 @override
1382 visitLibraryPart(LibraryPart node) {
1383 put(node.fileUri);
1384 node.visitChildren(this);
1385 }
1386
1367 visitCombinator(Combinator node) { 1387 visitCombinator(Combinator node) {
1368 node.names.forEach(put); 1388 node.names.forEach(put);
1369 } 1389 }
1370 1390
1371 visitTypedef(Typedef node) { 1391 visitTypedef(Typedef node) {
1372 put(node.name); 1392 put(node.name);
1373 node.visitChildren(this); 1393 node.visitChildren(this);
1374 } 1394 }
1375 1395
1376 visitClass(Class node) { 1396 visitClass(Class node) {
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
1548 _sink.add(_buffer.sublist(0, length)); 1568 _sink.add(_buffer.sublist(0, length));
1549 _buffer = new Uint8List(SIZE); 1569 _buffer = new Uint8List(SIZE);
1550 flushedLength += length; 1570 flushedLength += length;
1551 length = 0; 1571 length = 0;
1552 } 1572 }
1553 1573
1554 void flushAndDestroy() { 1574 void flushAndDestroy() {
1555 _sink.add(_buffer.sublist(0, length)); 1575 _sink.add(_buffer.sublist(0, length));
1556 } 1576 }
1557 } 1577 }
OLDNEW
« no previous file with comments | « pkg/kernel/lib/binary/ast_from_binary.dart ('k') | pkg/kernel/lib/visitor.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698