OLD | NEW |
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 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 var canonicalName = readCanonicalNameReference(); | 516 var canonicalName = readCanonicalNameReference(); |
517 var reference = canonicalName.getReference(); | 517 var reference = canonicalName.getReference(); |
518 Field node = reference.node; | 518 Field node = reference.node; |
519 bool shouldWriteData = node == null || _isReadingLibraryImplementation; | 519 bool shouldWriteData = node == null || _isReadingLibraryImplementation; |
520 if (node == null) { | 520 if (node == null) { |
521 node = new Field(null, reference: reference); | 521 node = new Field(null, reference: reference); |
522 } | 522 } |
523 int fileOffset = readOffset(); | 523 int fileOffset = readOffset(); |
524 int fileEndOffset = readOffset(); | 524 int fileEndOffset = readOffset(); |
525 int flags = readByte(); | 525 int flags = readByte(); |
526 readUInt(); // parent class binary offset. | |
527 var name = readName(); | 526 var name = readName(); |
528 var fileUri = readUriReference(); | 527 var fileUri = readUriReference(); |
529 var documentationComment = readStringOrNullIfEmpty(); | 528 var documentationComment = readStringOrNullIfEmpty(); |
530 var annotations = readAnnotationList(node); | 529 var annotations = readAnnotationList(node); |
531 debugPath.add(node.name?.name ?? 'field'); | 530 debugPath.add(node.name?.name ?? 'field'); |
532 var type = readDartType(); | 531 var type = readDartType(); |
533 var initializer = readExpressionOption(); | 532 var initializer = readExpressionOption(); |
534 int transformerFlags = getAndResetTransformerFlags(); | 533 int transformerFlags = getAndResetTransformerFlags(); |
535 debugPath.removeLast(); | 534 debugPath.removeLast(); |
536 if (shouldWriteData) { | 535 if (shouldWriteData) { |
(...skipping 18 matching lines...) Expand all Loading... |
555 var canonicalName = readCanonicalNameReference(); | 554 var canonicalName = readCanonicalNameReference(); |
556 var reference = canonicalName.getReference(); | 555 var reference = canonicalName.getReference(); |
557 Constructor node = reference.node; | 556 Constructor node = reference.node; |
558 bool shouldWriteData = node == null || _isReadingLibraryImplementation; | 557 bool shouldWriteData = node == null || _isReadingLibraryImplementation; |
559 if (node == null) { | 558 if (node == null) { |
560 node = new Constructor(null, reference: reference); | 559 node = new Constructor(null, reference: reference); |
561 } | 560 } |
562 var fileOffset = readOffset(); | 561 var fileOffset = readOffset(); |
563 var fileEndOffset = readOffset(); | 562 var fileEndOffset = readOffset(); |
564 var flags = readByte(); | 563 var flags = readByte(); |
565 readUInt(); // parent class binary offset. | |
566 var name = readName(); | 564 var name = readName(); |
567 var documentationComment = readStringOrNullIfEmpty(); | 565 var documentationComment = readStringOrNullIfEmpty(); |
568 var annotations = readAnnotationList(node); | 566 var annotations = readAnnotationList(node); |
569 debugPath.add(node.name?.name ?? 'constructor'); | 567 debugPath.add(node.name?.name ?? 'constructor'); |
570 var function = readFunctionNode(); | 568 var function = readFunctionNode(); |
571 pushVariableDeclarations(function.positionalParameters); | 569 pushVariableDeclarations(function.positionalParameters); |
572 pushVariableDeclarations(function.namedParameters); | 570 pushVariableDeclarations(function.namedParameters); |
573 if (shouldWriteData) { | 571 if (shouldWriteData) { |
574 _fillTreeNodeList(node.initializers, readInitializer, node); | 572 _fillTreeNodeList(node.initializers, readInitializer, node); |
575 } else { | 573 } else { |
(...skipping 23 matching lines...) Expand all Loading... |
599 Procedure node = reference.node; | 597 Procedure node = reference.node; |
600 bool shouldWriteData = node == null || _isReadingLibraryImplementation; | 598 bool shouldWriteData = node == null || _isReadingLibraryImplementation; |
601 if (node == null) { | 599 if (node == null) { |
602 node = new Procedure(null, null, null, reference: reference); | 600 node = new Procedure(null, null, null, reference: reference); |
603 } | 601 } |
604 var fileOffset = readOffset(); | 602 var fileOffset = readOffset(); |
605 var fileEndOffset = readOffset(); | 603 var fileEndOffset = readOffset(); |
606 int kindIndex = readByte(); | 604 int kindIndex = readByte(); |
607 var kind = ProcedureKind.values[kindIndex]; | 605 var kind = ProcedureKind.values[kindIndex]; |
608 var flags = readByte(); | 606 var flags = readByte(); |
609 readUInt(); // parent class binary offset. | |
610 var name = readName(); | 607 var name = readName(); |
611 var fileUri = readUriReference(); | 608 var fileUri = readUriReference(); |
612 var documentationComment = readStringOrNullIfEmpty(); | 609 var documentationComment = readStringOrNullIfEmpty(); |
613 var annotations = readAnnotationList(node); | 610 var annotations = readAnnotationList(node); |
614 debugPath.add(node.name?.name ?? 'procedure'); | 611 debugPath.add(node.name?.name ?? 'procedure'); |
615 var function = readFunctionNodeOption(); | 612 var function = readFunctionNodeOption(); |
616 var transformerFlags = getAndResetTransformerFlags(); | 613 var transformerFlags = getAndResetTransformerFlags(); |
617 debugPath.removeLast(); | 614 debugPath.removeLast(); |
618 if (shouldWriteData) { | 615 if (shouldWriteData) { |
619 node.fileOffset = fileOffset; | 616 node.fileOffset = fileOffset; |
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1257 ..fileOffset = offset | 1254 ..fileOffset = offset |
1258 ..fileEqualsOffset = fileEqualsOffset; | 1255 ..fileEqualsOffset = fileEqualsOffset; |
1259 } | 1256 } |
1260 | 1257 |
1261 int readOffset() { | 1258 int readOffset() { |
1262 // Offset is saved as unsigned, | 1259 // Offset is saved as unsigned, |
1263 // but actually ranges from -1 and up (thus the -1) | 1260 // but actually ranges from -1 and up (thus the -1) |
1264 return readUInt() - 1; | 1261 return readUInt() - 1; |
1265 } | 1262 } |
1266 } | 1263 } |
OLD | NEW |