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 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
459 var canonicalName = readCanonicalNameReference(); | 459 var canonicalName = readCanonicalNameReference(); |
460 var reference = canonicalName.getReference(); | 460 var reference = canonicalName.getReference(); |
461 Field node = reference.node; | 461 Field node = reference.node; |
462 bool shouldWriteData = node == null || _isReadingLibraryImplementation; | 462 bool shouldWriteData = node == null || _isReadingLibraryImplementation; |
463 if (node == null) { | 463 if (node == null) { |
464 node = new Field(null, reference: reference); | 464 node = new Field(null, reference: reference); |
465 } | 465 } |
466 int fileOffset = readOffset(); | 466 int fileOffset = readOffset(); |
467 int fileEndOffset = readOffset(); | 467 int fileEndOffset = readOffset(); |
468 int flags = readByte(); | 468 int flags = readByte(); |
| 469 readUInt(); // parent class binary offset. |
469 var name = readName(); | 470 var name = readName(); |
470 var fileUri = readUriReference(); | 471 var fileUri = readUriReference(); |
471 var annotations = readAnnotationList(node); | 472 var annotations = readAnnotationList(node); |
472 debugPath.add(node.name?.name ?? 'field'); | 473 debugPath.add(node.name?.name ?? 'field'); |
473 var type = readDartType(); | 474 var type = readDartType(); |
474 var initializer = readExpressionOption(); | 475 var initializer = readExpressionOption(); |
475 int transformerFlags = getAndResetTransformerFlags(); | 476 int transformerFlags = getAndResetTransformerFlags(); |
476 debugPath.removeLast(); | 477 debugPath.removeLast(); |
477 if (shouldWriteData) { | 478 if (shouldWriteData) { |
478 node.fileOffset = fileOffset; | 479 node.fileOffset = fileOffset; |
(...skipping 16 matching lines...) Expand all Loading... |
495 var canonicalName = readCanonicalNameReference(); | 496 var canonicalName = readCanonicalNameReference(); |
496 var reference = canonicalName.getReference(); | 497 var reference = canonicalName.getReference(); |
497 Constructor node = reference.node; | 498 Constructor node = reference.node; |
498 bool shouldWriteData = node == null || _isReadingLibraryImplementation; | 499 bool shouldWriteData = node == null || _isReadingLibraryImplementation; |
499 if (node == null) { | 500 if (node == null) { |
500 node = new Constructor(null, reference: reference); | 501 node = new Constructor(null, reference: reference); |
501 } | 502 } |
502 var fileOffset = readOffset(); | 503 var fileOffset = readOffset(); |
503 var fileEndOffset = readOffset(); | 504 var fileEndOffset = readOffset(); |
504 var flags = readByte(); | 505 var flags = readByte(); |
| 506 readUInt(); // parent class binary offset. |
505 var name = readName(); | 507 var name = readName(); |
506 var annotations = readAnnotationList(node); | 508 var annotations = readAnnotationList(node); |
507 debugPath.add(node.name?.name ?? 'constructor'); | 509 debugPath.add(node.name?.name ?? 'constructor'); |
508 var function = readFunctionNode(); | 510 var function = readFunctionNode(); |
509 pushVariableDeclarations(function.positionalParameters); | 511 pushVariableDeclarations(function.positionalParameters); |
510 pushVariableDeclarations(function.namedParameters); | 512 pushVariableDeclarations(function.namedParameters); |
511 _fillTreeNodeList(node.initializers, readInitializer, node); | 513 _fillTreeNodeList(node.initializers, readInitializer, node); |
512 variableStack.length = 0; | 514 variableStack.length = 0; |
513 var transformerFlags = getAndResetTransformerFlags(); | 515 var transformerFlags = getAndResetTransformerFlags(); |
514 debugPath.removeLast(); | 516 debugPath.removeLast(); |
(...skipping 17 matching lines...) Expand all Loading... |
532 Procedure node = reference.node; | 534 Procedure node = reference.node; |
533 bool shouldWriteData = node == null || _isReadingLibraryImplementation; | 535 bool shouldWriteData = node == null || _isReadingLibraryImplementation; |
534 if (node == null) { | 536 if (node == null) { |
535 node = new Procedure(null, null, null, reference: reference); | 537 node = new Procedure(null, null, null, reference: reference); |
536 } | 538 } |
537 var fileOffset = readOffset(); | 539 var fileOffset = readOffset(); |
538 var fileEndOffset = readOffset(); | 540 var fileEndOffset = readOffset(); |
539 int kindIndex = readByte(); | 541 int kindIndex = readByte(); |
540 var kind = ProcedureKind.values[kindIndex]; | 542 var kind = ProcedureKind.values[kindIndex]; |
541 var flags = readByte(); | 543 var flags = readByte(); |
| 544 readUInt(); // parent class binary offset. |
542 var name = readName(); | 545 var name = readName(); |
543 var fileUri = readUriReference(); | 546 var fileUri = readUriReference(); |
544 var annotations = readAnnotationList(node); | 547 var annotations = readAnnotationList(node); |
545 debugPath.add(node.name?.name ?? 'procedure'); | 548 debugPath.add(node.name?.name ?? 'procedure'); |
546 var function = readFunctionNodeOption(); | 549 var function = readFunctionNodeOption(); |
547 var transformerFlags = getAndResetTransformerFlags(); | 550 var transformerFlags = getAndResetTransformerFlags(); |
548 debugPath.removeLast(); | 551 debugPath.removeLast(); |
549 if (shouldWriteData) { | 552 if (shouldWriteData) { |
550 node.fileOffset = fileOffset; | 553 node.fileOffset = fileOffset; |
551 node.fileEndOffset = fileEndOffset; | 554 node.fileEndOffset = fileEndOffset; |
(...skipping 28 matching lines...) Expand all Loading... |
580 default: | 583 default: |
581 throw fail('Invalid initializer tag: $tag'); | 584 throw fail('Invalid initializer tag: $tag'); |
582 } | 585 } |
583 } | 586 } |
584 | 587 |
585 FunctionNode readFunctionNodeOption() { | 588 FunctionNode readFunctionNodeOption() { |
586 return readAndCheckOptionTag() ? readFunctionNode() : null; | 589 return readAndCheckOptionTag() ? readFunctionNode() : null; |
587 } | 590 } |
588 | 591 |
589 FunctionNode readFunctionNode() { | 592 FunctionNode readFunctionNode() { |
| 593 int tag = readByte(); |
| 594 assert(tag == Tag.FunctionNode); |
590 int offset = readOffset(); | 595 int offset = readOffset(); |
591 int endOffset = readOffset(); | 596 int endOffset = readOffset(); |
592 AsyncMarker asyncMarker = AsyncMarker.values[readByte()]; | 597 AsyncMarker asyncMarker = AsyncMarker.values[readByte()]; |
593 AsyncMarker dartAsyncMarker = AsyncMarker.values[readByte()]; | 598 AsyncMarker dartAsyncMarker = AsyncMarker.values[readByte()]; |
594 int typeParameterStackHeight = typeParameterStack.length; | 599 int typeParameterStackHeight = typeParameterStack.length; |
595 var typeParameters = readAndPushTypeParameterList(); | 600 var typeParameters = readAndPushTypeParameterList(); |
596 var requiredParameterCount = readUInt(); | 601 var requiredParameterCount = readUInt(); |
597 int variableStackHeight = variableStack.length; | 602 int variableStackHeight = variableStack.length; |
598 var positional = readAndPushVariableDeclarationList(); | 603 var positional = readAndPushVariableDeclarationList(); |
599 var named = readAndPushVariableDeclarationList(); | 604 var named = readAndPushVariableDeclarationList(); |
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1172 ..fileOffset = offset | 1177 ..fileOffset = offset |
1173 ..fileEqualsOffset = fileEqualsOffset; | 1178 ..fileEqualsOffset = fileEqualsOffset; |
1174 } | 1179 } |
1175 | 1180 |
1176 int readOffset() { | 1181 int readOffset() { |
1177 // Offset is saved as unsigned, | 1182 // Offset is saved as unsigned, |
1178 // but actually ranges from -1 and up (thus the -1) | 1183 // but actually ranges from -1 and up (thus the -1) |
1179 return readUInt() - 1; | 1184 return readUInt() - 1; |
1180 } | 1185 } |
1181 } | 1186 } |
OLD | NEW |