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

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

Issue 2991993002: Reapply 47ecf72 after it was reverted in e431e93e872d9a1c97a5177ebb09d5416f1d659a. (Closed)
Patch Set: 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/ast.dart ('k') | pkg/kernel/lib/binary/ast_to_binary.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_from_binary; 4 library kernel.ast_from_binary;
5 5
6 import 'dart:convert'; 6 import 'dart:convert';
7 import 'dart:typed_data'; 7 import 'dart:typed_data';
8 8
9 import '../ast.dart'; 9 import '../ast.dart';
10 import '../transformations/flags.dart'; 10 import '../transformations/flags.dart';
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 bool shouldWriteData = node == null || _isReadingLibraryImplementation; 518 bool shouldWriteData = node == null || _isReadingLibraryImplementation;
519 if (node == null) { 519 if (node == null) {
520 node = new Field(null, reference: reference); 520 node = new Field(null, reference: reference);
521 } 521 }
522 int fileOffset = readOffset(); 522 int fileOffset = readOffset();
523 int fileEndOffset = readOffset(); 523 int fileEndOffset = readOffset();
524 int flags = readByte(); 524 int flags = readByte();
525 readUInt(); // parent class binary offset. 525 readUInt(); // parent class binary offset.
526 var name = readName(); 526 var name = readName();
527 var fileUri = readUriReference(); 527 var fileUri = readUriReference();
528 var documentationComment = readStringOrNullIfEmpty();
528 var annotations = readAnnotationList(node); 529 var annotations = readAnnotationList(node);
529 debugPath.add(node.name?.name ?? 'field'); 530 debugPath.add(node.name?.name ?? 'field');
530 var type = readDartType(); 531 var type = readDartType();
531 var initializer = readExpressionOption(); 532 var initializer = readExpressionOption();
532 int transformerFlags = getAndResetTransformerFlags(); 533 int transformerFlags = getAndResetTransformerFlags();
533 debugPath.removeLast(); 534 debugPath.removeLast();
534 if (shouldWriteData) { 535 if (shouldWriteData) {
535 node.fileOffset = fileOffset; 536 node.fileOffset = fileOffset;
536 node.fileEndOffset = fileEndOffset; 537 node.fileEndOffset = fileEndOffset;
537 node.flags = flags; 538 node.flags = flags;
538 node.name = name; 539 node.name = name;
539 node.fileUri = fileUri; 540 node.fileUri = fileUri;
541 node.documentationComment = documentationComment;
540 node.annotations = annotations; 542 node.annotations = annotations;
541 node.type = type; 543 node.type = type;
542 node.initializer = initializer; 544 node.initializer = initializer;
543 node.initializer?.parent = node; 545 node.initializer?.parent = node;
544 node.transformerFlags = transformerFlags; 546 node.transformerFlags = transformerFlags;
545 } 547 }
546 return node; 548 return node;
547 } 549 }
548 550
549 Constructor readConstructor() { 551 Constructor readConstructor() {
550 int tag = readByte(); 552 int tag = readByte();
551 assert(tag == Tag.Constructor); 553 assert(tag == Tag.Constructor);
552 var canonicalName = readCanonicalNameReference(); 554 var canonicalName = readCanonicalNameReference();
553 var reference = canonicalName.getReference(); 555 var reference = canonicalName.getReference();
554 Constructor node = reference.node; 556 Constructor node = reference.node;
555 bool shouldWriteData = node == null || _isReadingLibraryImplementation; 557 bool shouldWriteData = node == null || _isReadingLibraryImplementation;
556 if (node == null) { 558 if (node == null) {
557 node = new Constructor(null, reference: reference); 559 node = new Constructor(null, reference: reference);
558 } 560 }
559 var fileOffset = readOffset(); 561 var fileOffset = readOffset();
560 var fileEndOffset = readOffset(); 562 var fileEndOffset = readOffset();
561 var flags = readByte(); 563 var flags = readByte();
562 readUInt(); // parent class binary offset. 564 readUInt(); // parent class binary offset.
563 var name = readName(); 565 var name = readName();
566 var documentationComment = readStringOrNullIfEmpty();
564 var annotations = readAnnotationList(node); 567 var annotations = readAnnotationList(node);
565 debugPath.add(node.name?.name ?? 'constructor'); 568 debugPath.add(node.name?.name ?? 'constructor');
566 var function = readFunctionNode(); 569 var function = readFunctionNode();
567 pushVariableDeclarations(function.positionalParameters); 570 pushVariableDeclarations(function.positionalParameters);
568 pushVariableDeclarations(function.namedParameters); 571 pushVariableDeclarations(function.namedParameters);
569 if (shouldWriteData) { 572 if (shouldWriteData) {
570 _fillTreeNodeList(node.initializers, readInitializer, node); 573 _fillTreeNodeList(node.initializers, readInitializer, node);
571 } else { 574 } else {
572 _skipNodeList(readInitializer); 575 _skipNodeList(readInitializer);
573 } 576 }
574 variableStack.length = 0; 577 variableStack.length = 0;
575 var transformerFlags = getAndResetTransformerFlags(); 578 var transformerFlags = getAndResetTransformerFlags();
576 debugPath.removeLast(); 579 debugPath.removeLast();
577 if (shouldWriteData) { 580 if (shouldWriteData) {
578 node.fileOffset = fileOffset; 581 node.fileOffset = fileOffset;
579 node.fileEndOffset = fileEndOffset; 582 node.fileEndOffset = fileEndOffset;
580 node.flags = flags; 583 node.flags = flags;
581 node.name = name; 584 node.name = name;
585 node.documentationComment = documentationComment;
582 node.annotations = annotations; 586 node.annotations = annotations;
583 node.function = function..parent = node; 587 node.function = function..parent = node;
584 node.transformerFlags = transformerFlags; 588 node.transformerFlags = transformerFlags;
585 } 589 }
586 return node; 590 return node;
587 } 591 }
588 592
589 Procedure readProcedure() { 593 Procedure readProcedure() {
590 int tag = readByte(); 594 int tag = readByte();
591 assert(tag == Tag.Procedure); 595 assert(tag == Tag.Procedure);
592 var canonicalName = readCanonicalNameReference(); 596 var canonicalName = readCanonicalNameReference();
593 var reference = canonicalName.getReference(); 597 var reference = canonicalName.getReference();
594 Procedure node = reference.node; 598 Procedure node = reference.node;
595 bool shouldWriteData = node == null || _isReadingLibraryImplementation; 599 bool shouldWriteData = node == null || _isReadingLibraryImplementation;
596 if (node == null) { 600 if (node == null) {
597 node = new Procedure(null, null, null, reference: reference); 601 node = new Procedure(null, null, null, reference: reference);
598 } 602 }
599 var fileOffset = readOffset(); 603 var fileOffset = readOffset();
600 var fileEndOffset = readOffset(); 604 var fileEndOffset = readOffset();
601 int kindIndex = readByte(); 605 int kindIndex = readByte();
602 var kind = ProcedureKind.values[kindIndex]; 606 var kind = ProcedureKind.values[kindIndex];
603 var flags = readByte(); 607 var flags = readByte();
604 readUInt(); // parent class binary offset. 608 readUInt(); // parent class binary offset.
605 var name = readName(); 609 var name = readName();
606 var fileUri = readUriReference(); 610 var fileUri = readUriReference();
611 var documentationComment = readStringOrNullIfEmpty();
607 var annotations = readAnnotationList(node); 612 var annotations = readAnnotationList(node);
608 debugPath.add(node.name?.name ?? 'procedure'); 613 debugPath.add(node.name?.name ?? 'procedure');
609 var function = readFunctionNodeOption(); 614 var function = readFunctionNodeOption();
610 var transformerFlags = getAndResetTransformerFlags(); 615 var transformerFlags = getAndResetTransformerFlags();
611 debugPath.removeLast(); 616 debugPath.removeLast();
612 if (shouldWriteData) { 617 if (shouldWriteData) {
613 node.fileOffset = fileOffset; 618 node.fileOffset = fileOffset;
614 node.fileEndOffset = fileEndOffset; 619 node.fileEndOffset = fileEndOffset;
615 node.kind = kind; 620 node.kind = kind;
616 node.flags = flags; 621 node.flags = flags;
617 node.name = name; 622 node.name = name;
618 node.fileUri = fileUri; 623 node.fileUri = fileUri;
624 node.documentationComment = documentationComment;
619 node.annotations = annotations; 625 node.annotations = annotations;
620 node.function = function; 626 node.function = function;
621 node.function?.parent = node; 627 node.function?.parent = node;
622 node.transformerFlags = transformerFlags; 628 node.transformerFlags = transformerFlags;
623 } 629 }
624 return node; 630 return node;
625 } 631 }
626 632
627 Initializer readInitializer() { 633 Initializer readInitializer() {
628 int tag = readByte(); 634 int tag = readByte();
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after
1248 ..fileOffset = offset 1254 ..fileOffset = offset
1249 ..fileEqualsOffset = fileEqualsOffset; 1255 ..fileEqualsOffset = fileEqualsOffset;
1250 } 1256 }
1251 1257
1252 int readOffset() { 1258 int readOffset() {
1253 // Offset is saved as unsigned, 1259 // Offset is saved as unsigned,
1254 // but actually ranges from -1 and up (thus the -1) 1260 // but actually ranges from -1 and up (thus the -1)
1255 return readUInt() - 1; 1261 return readUInt() - 1;
1256 } 1262 }
1257 } 1263 }
OLDNEW
« no previous file with comments | « pkg/kernel/lib/ast.dart ('k') | pkg/kernel/lib/binary/ast_to_binary.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698