| 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 '../ast.dart'; | 6 import '../ast.dart'; |
| 7 import 'tag.dart'; | 7 import 'tag.dart'; |
| 8 import 'loader.dart'; | 8 import 'loader.dart'; |
| 9 import 'dart:convert'; | 9 import 'dart:convert'; |
| 10 import 'package:kernel/transformations/flags.dart'; | 10 import 'package:kernel/transformations/flags.dart'; |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 break; | 314 break; |
| 315 case Tag.MixinClass: | 315 case Tag.MixinClass: |
| 316 readMixinClass(node); | 316 readMixinClass(node); |
| 317 break; | 317 break; |
| 318 default: | 318 default: |
| 319 throw fail('Invalid class tag: $tag'); | 319 throw fail('Invalid class tag: $tag'); |
| 320 } | 320 } |
| 321 } | 321 } |
| 322 | 322 |
| 323 void readNormalClass(Class node) { | 323 void readNormalClass(Class node) { |
| 324 node.fileOffset = readOffset(); |
| 324 int flags = readByte(); | 325 int flags = readByte(); |
| 325 node.isAbstract = flags & 0x1 != 0; | 326 node.isAbstract = flags & 0x1 != 0; |
| 326 node.level = _currentLibrary.isExternal | 327 node.level = _currentLibrary.isExternal |
| 327 ? (flags & 0x2 != 0) ? ClassLevel.Type : ClassLevel.Hierarchy | 328 ? (flags & 0x2 != 0) ? ClassLevel.Type : ClassLevel.Hierarchy |
| 328 : ClassLevel.Body; | 329 : ClassLevel.Body; |
| 329 node.name = readStringOrNullIfEmpty(); | 330 node.name = readStringOrNullIfEmpty(); |
| 330 node.fileUri = readUriReference(); | 331 node.fileUri = readUriReference(); |
| 331 node.annotations = readAnnotationList(node); | 332 node.annotations = readAnnotationList(node); |
| 332 debugPath.add(node.name ?? 'normal-class'); | 333 debugPath.add(node.name ?? 'normal-class'); |
| 333 readAndPushTypeParameterList(node.typeParameters, node); | 334 readAndPushTypeParameterList(node.typeParameters, node); |
| 334 node.supertype = readSupertypeOption(); | 335 node.supertype = readSupertypeOption(); |
| 335 _fillNonTreeNodeList(node.implementedTypes, readSupertype); | 336 _fillNonTreeNodeList(node.implementedTypes, readSupertype); |
| 336 _fillLazilyLoadedList(node.fields, (int tag, int index) { | 337 _fillLazilyLoadedList(node.fields, (int tag, int index) { |
| 337 readField(loader.getClassMemberReference(node, tag, index), tag); | 338 readField(loader.getClassMemberReference(node, tag, index), tag); |
| 338 }); | 339 }); |
| 339 _fillLazilyLoadedList(node.constructors, (int tag, int index) { | 340 _fillLazilyLoadedList(node.constructors, (int tag, int index) { |
| 340 readConstructor(loader.getClassMemberReference(node, tag, index), tag); | 341 readConstructor(loader.getClassMemberReference(node, tag, index), tag); |
| 341 }); | 342 }); |
| 342 _fillLazilyLoadedList(node.procedures, (int tag, int index) { | 343 _fillLazilyLoadedList(node.procedures, (int tag, int index) { |
| 343 readProcedure(loader.getClassMemberReference(node, tag, index), tag); | 344 readProcedure(loader.getClassMemberReference(node, tag, index), tag); |
| 344 }); | 345 }); |
| 345 typeParameterStack.length = 0; | 346 typeParameterStack.length = 0; |
| 346 debugPath.removeLast(); | 347 debugPath.removeLast(); |
| 347 } | 348 } |
| 348 | 349 |
| 349 void readMixinClass(Class node) { | 350 void readMixinClass(Class node) { |
| 351 node.fileOffset = readOffset(); |
| 350 int flags = readByte(); | 352 int flags = readByte(); |
| 351 node.isAbstract = flags & 0x1 != 0; | 353 node.isAbstract = flags & 0x1 != 0; |
| 352 node.level = _currentLibrary.isExternal | 354 node.level = _currentLibrary.isExternal |
| 353 ? (flags & 0x2 != 0) ? ClassLevel.Type : ClassLevel.Hierarchy | 355 ? (flags & 0x2 != 0) ? ClassLevel.Type : ClassLevel.Hierarchy |
| 354 : ClassLevel.Body; | 356 : ClassLevel.Body; |
| 355 node.name = readStringOrNullIfEmpty(); | 357 node.name = readStringOrNullIfEmpty(); |
| 356 node.fileUri = readUriReference(); | 358 node.fileUri = readUriReference(); |
| 357 node.annotations = readAnnotationList(node); | 359 node.annotations = readAnnotationList(node); |
| 358 debugPath.add(node.name ?? 'mixin-class'); | 360 debugPath.add(node.name ?? 'mixin-class'); |
| 359 readAndPushTypeParameterList(node.typeParameters, node); | 361 readAndPushTypeParameterList(node.typeParameters, node); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 377 void addTransformerFlag(int flags) { | 379 void addTransformerFlag(int flags) { |
| 378 _transformerFlags |= flags; | 380 _transformerFlags |= flags; |
| 379 } | 381 } |
| 380 | 382 |
| 381 void readField(Field node, int tag) { | 383 void readField(Field node, int tag) { |
| 382 // Note: as with readProcedure and readConstructor, the tag parameter | 384 // Note: as with readProcedure and readConstructor, the tag parameter |
| 383 // is unused, but we pass it in to clarify that the tag has already been | 385 // is unused, but we pass it in to clarify that the tag has already been |
| 384 // consumed from the input. | 386 // consumed from the input. |
| 385 assert(tag == Tag.Field); | 387 assert(tag == Tag.Field); |
| 386 node.fileOffset = readOffset(); | 388 node.fileOffset = readOffset(); |
| 389 node.fileEndOffset = readOffset(); |
| 387 node.flags = readByte(); | 390 node.flags = readByte(); |
| 388 node.name = readName(); | 391 node.name = readName(); |
| 389 node.fileUri = readUriReference(); | 392 node.fileUri = readUriReference(); |
| 390 node.annotations = readAnnotationList(node); | 393 node.annotations = readAnnotationList(node); |
| 391 debugPath.add(node.name?.name ?? 'field'); | 394 debugPath.add(node.name?.name ?? 'field'); |
| 392 node.type = readDartType(); | 395 node.type = readDartType(); |
| 393 node.inferredValue = readOptionalInferredValue(); | 396 node.inferredValue = readOptionalInferredValue(); |
| 394 node.initializer = readExpressionOption(); | 397 node.initializer = readExpressionOption(); |
| 395 node.initializer?.parent = node; | 398 node.initializer?.parent = node; |
| 396 node.transformerFlags = getAndResetTransformerFlags(); | 399 node.transformerFlags = getAndResetTransformerFlags(); |
| 397 debugPath.removeLast(); | 400 debugPath.removeLast(); |
| 398 } | 401 } |
| 399 | 402 |
| 400 void readConstructor(Constructor node, int tag) { | 403 void readConstructor(Constructor node, int tag) { |
| 401 assert(tag == Tag.Constructor); | 404 assert(tag == Tag.Constructor); |
| 405 node.fileOffset = readOffset(); |
| 406 node.fileEndOffset = readOffset(); |
| 402 node.flags = readByte(); | 407 node.flags = readByte(); |
| 403 node.name = readName(); | 408 node.name = readName(); |
| 404 node.annotations = readAnnotationList(node); | 409 node.annotations = readAnnotationList(node); |
| 405 debugPath.add(node.name?.name ?? 'constructor'); | 410 debugPath.add(node.name?.name ?? 'constructor'); |
| 406 node.function = readFunctionNode()..parent = node; | 411 node.function = readFunctionNode()..parent = node; |
| 407 pushVariableDeclarations(node.function.positionalParameters); | 412 pushVariableDeclarations(node.function.positionalParameters); |
| 408 pushVariableDeclarations(node.function.namedParameters); | 413 pushVariableDeclarations(node.function.namedParameters); |
| 409 _fillTreeNodeList(node.initializers, readInitializer, node); | 414 _fillTreeNodeList(node.initializers, readInitializer, node); |
| 410 variableStack.length = 0; | 415 variableStack.length = 0; |
| 411 node.transformerFlags = getAndResetTransformerFlags(); | 416 node.transformerFlags = getAndResetTransformerFlags(); |
| 412 debugPath.removeLast(); | 417 debugPath.removeLast(); |
| 413 } | 418 } |
| 414 | 419 |
| 415 void readProcedure(Procedure node, int tag) { | 420 void readProcedure(Procedure node, int tag) { |
| 416 assert(tag == Tag.Procedure); | 421 assert(tag == Tag.Procedure); |
| 422 node.fileOffset = readOffset(); |
| 423 node.fileEndOffset = readOffset(); |
| 417 int kindIndex = readByte(); | 424 int kindIndex = readByte(); |
| 418 node.kind = ProcedureKind.values[kindIndex]; | 425 node.kind = ProcedureKind.values[kindIndex]; |
| 419 node.flags = readByte(); | 426 node.flags = readByte(); |
| 420 node.name = readName(); | 427 node.name = readName(); |
| 421 node.fileUri = readUriReference(); | 428 node.fileUri = readUriReference(); |
| 422 node.annotations = readAnnotationList(node); | 429 node.annotations = readAnnotationList(node); |
| 423 debugPath.add(node.name?.name ?? 'procedure'); | 430 debugPath.add(node.name?.name ?? 'procedure'); |
| 424 node.function = readFunctionNodeOption(); | 431 node.function = readFunctionNodeOption(); |
| 425 node.function?.parent = node; | 432 node.function?.parent = node; |
| 426 node.transformerFlags = getAndResetTransformerFlags(); | 433 node.transformerFlags = getAndResetTransformerFlags(); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 444 default: | 451 default: |
| 445 throw fail('Invalid initializer tag: $tag'); | 452 throw fail('Invalid initializer tag: $tag'); |
| 446 } | 453 } |
| 447 } | 454 } |
| 448 | 455 |
| 449 FunctionNode readFunctionNodeOption() { | 456 FunctionNode readFunctionNodeOption() { |
| 450 return readAndCheckOptionTag() ? readFunctionNode() : null; | 457 return readAndCheckOptionTag() ? readFunctionNode() : null; |
| 451 } | 458 } |
| 452 | 459 |
| 453 FunctionNode readFunctionNode() { | 460 FunctionNode readFunctionNode() { |
| 461 int offset = readOffset(); |
| 462 int endOffset = readOffset(); |
| 454 AsyncMarker asyncMarker = AsyncMarker.values[readByte()]; | 463 AsyncMarker asyncMarker = AsyncMarker.values[readByte()]; |
| 464 bool debuggable = readByte() == 1 ? true : false; |
| 455 int typeParameterStackHeight = typeParameterStack.length; | 465 int typeParameterStackHeight = typeParameterStack.length; |
| 456 var typeParameters = readAndPushTypeParameterList(); | 466 var typeParameters = readAndPushTypeParameterList(); |
| 457 var requiredParameterCount = readUInt(); | 467 var requiredParameterCount = readUInt(); |
| 458 int variableStackHeight = variableStack.length; | 468 int variableStackHeight = variableStack.length; |
| 459 var positional = readAndPushVariableDeclarationList(); | 469 var positional = readAndPushVariableDeclarationList(); |
| 460 var named = readAndPushVariableDeclarationList(); | 470 var named = readAndPushVariableDeclarationList(); |
| 461 var returnType = readDartType(); | 471 var returnType = readDartType(); |
| 462 var inferredReturnValue = readOptionalInferredValue(); | 472 var inferredReturnValue = readOptionalInferredValue(); |
| 463 int oldLabelStackBase = labelStackBase; | 473 int oldLabelStackBase = labelStackBase; |
| 464 labelStackBase = labelStack.length; | 474 labelStackBase = labelStack.length; |
| 465 var body = readStatementOption(); | 475 var body = readStatementOption(); |
| 466 labelStackBase = oldLabelStackBase; | 476 labelStackBase = oldLabelStackBase; |
| 467 variableStack.length = variableStackHeight; | 477 variableStack.length = variableStackHeight; |
| 468 typeParameterStack.length = typeParameterStackHeight; | 478 typeParameterStack.length = typeParameterStackHeight; |
| 469 return new FunctionNode(body, | 479 return new FunctionNode(body, |
| 470 typeParameters: typeParameters, | 480 typeParameters: typeParameters, |
| 471 requiredParameterCount: requiredParameterCount, | 481 requiredParameterCount: requiredParameterCount, |
| 472 positionalParameters: positional, | 482 positionalParameters: positional, |
| 473 namedParameters: named, | 483 namedParameters: named, |
| 474 returnType: returnType, | 484 returnType: returnType, |
| 475 inferredReturnValue: inferredReturnValue, | 485 inferredReturnValue: inferredReturnValue, |
| 476 asyncMarker: asyncMarker); | 486 asyncMarker: asyncMarker) |
| 487 ..fileOffset = offset |
| 488 ..fileEndOffset = endOffset |
| 489 ..debuggable = debuggable; |
| 477 } | 490 } |
| 478 | 491 |
| 479 void pushVariableDeclaration(VariableDeclaration variable) { | 492 void pushVariableDeclaration(VariableDeclaration variable) { |
| 480 variableStack.add(variable); | 493 variableStack.add(variable); |
| 481 } | 494 } |
| 482 | 495 |
| 483 void pushVariableDeclarations(List<VariableDeclaration> variables) { | 496 void pushVariableDeclarations(List<VariableDeclaration> variables) { |
| 484 variableStack.addAll(variables); | 497 variableStack.addAll(variables); |
| 485 } | 498 } |
| 486 | 499 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 513 | 526 |
| 514 Expression readExpression() { | 527 Expression readExpression() { |
| 515 int tagByte = readByte(); | 528 int tagByte = readByte(); |
| 516 int tag = tagByte & Tag.SpecializedTagHighBit == 0 | 529 int tag = tagByte & Tag.SpecializedTagHighBit == 0 |
| 517 ? tagByte | 530 ? tagByte |
| 518 : (tagByte & Tag.SpecializedTagMask); | 531 : (tagByte & Tag.SpecializedTagMask); |
| 519 switch (tag) { | 532 switch (tag) { |
| 520 case Tag.InvalidExpression: | 533 case Tag.InvalidExpression: |
| 521 return new InvalidExpression(); | 534 return new InvalidExpression(); |
| 522 case Tag.VariableGet: | 535 case Tag.VariableGet: |
| 523 return new VariableGet(readVariableReference(), readDartTypeOption()); | 536 int offset = readOffset(); |
| 537 return new VariableGet(readVariableReference(), readDartTypeOption()) |
| 538 ..fileOffset = offset; |
| 524 case Tag.SpecializedVariableGet: | 539 case Tag.SpecializedVariableGet: |
| 525 int index = tagByte & Tag.SpecializedPayloadMask; | 540 int index = tagByte & Tag.SpecializedPayloadMask; |
| 526 return new VariableGet(variableStack[index]); | 541 int offset = readOffset(); |
| 542 return new VariableGet(variableStack[index])..fileOffset = offset; |
| 527 case Tag.VariableSet: | 543 case Tag.VariableSet: |
| 528 return new VariableSet(readVariableReference(), readExpression()); | 544 int offset = readOffset(); |
| 545 return new VariableSet(readVariableReference(), readExpression()) |
| 546 ..fileOffset = offset; |
| 529 case Tag.SpecializedVariableSet: | 547 case Tag.SpecializedVariableSet: |
| 530 int index = tagByte & Tag.SpecializedPayloadMask; | 548 int index = tagByte & Tag.SpecializedPayloadMask; |
| 531 return new VariableSet(variableStack[index], readExpression()); | 549 int offset = readOffset(); |
| 550 return new VariableSet(variableStack[index], readExpression()) |
| 551 ..fileOffset = offset; |
| 532 case Tag.PropertyGet: | 552 case Tag.PropertyGet: |
| 533 int offset = readOffset(); | 553 int offset = readOffset(); |
| 534 return new PropertyGet( | 554 return new PropertyGet( |
| 535 readExpression(), readName(), readMemberReference(allowNull: true)) | 555 readExpression(), readName(), readMemberReference(allowNull: true)) |
| 536 ..fileOffset = offset; | 556 ..fileOffset = offset; |
| 537 case Tag.PropertySet: | 557 case Tag.PropertySet: |
| 538 int offset = readOffset(); | 558 int offset = readOffset(); |
| 539 return new PropertySet(readExpression(), readName(), readExpression(), | 559 return new PropertySet(readExpression(), readName(), readExpression(), |
| 540 readMemberReference(allowNull: true))..fileOffset = offset; | 560 readMemberReference(allowNull: true))..fileOffset = offset; |
| 541 case Tag.SuperPropertyGet: | 561 case Tag.SuperPropertyGet: |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 590 isConst: true)..fileOffset = offset; | 610 isConst: true)..fileOffset = offset; |
| 591 case Tag.Not: | 611 case Tag.Not: |
| 592 return new Not(readExpression()); | 612 return new Not(readExpression()); |
| 593 case Tag.LogicalExpression: | 613 case Tag.LogicalExpression: |
| 594 return new LogicalExpression(readExpression(), | 614 return new LogicalExpression(readExpression(), |
| 595 logicalOperatorToString(readByte()), readExpression()); | 615 logicalOperatorToString(readByte()), readExpression()); |
| 596 case Tag.ConditionalExpression: | 616 case Tag.ConditionalExpression: |
| 597 return new ConditionalExpression(readExpression(), readExpression(), | 617 return new ConditionalExpression(readExpression(), readExpression(), |
| 598 readExpression(), readDartTypeOption()); | 618 readExpression(), readDartTypeOption()); |
| 599 case Tag.StringConcatenation: | 619 case Tag.StringConcatenation: |
| 600 return new StringConcatenation(readExpressionList()); | 620 int offset = readOffset(); |
| 621 return new StringConcatenation(readExpressionList()) |
| 622 ..fileOffset = offset; |
| 601 case Tag.IsExpression: | 623 case Tag.IsExpression: |
| 602 return new IsExpression(readExpression(), readDartType()); | 624 int offset = readOffset(); |
| 625 return new IsExpression(readExpression(), readDartType()) |
| 626 ..fileOffset = offset; |
| 603 case Tag.AsExpression: | 627 case Tag.AsExpression: |
| 604 return new AsExpression(readExpression(), readDartType()); | 628 return new AsExpression(readExpression(), readDartType()); |
| 605 case Tag.StringLiteral: | 629 case Tag.StringLiteral: |
| 606 return new StringLiteral(readStringReference()); | 630 return new StringLiteral(readStringReference()); |
| 607 case Tag.SpecializedIntLiteral: | 631 case Tag.SpecializedIntLiteral: |
| 608 int biasedValue = tagByte & Tag.SpecializedPayloadMask; | 632 int biasedValue = tagByte & Tag.SpecializedPayloadMask; |
| 609 return new IntLiteral(biasedValue - Tag.SpecializedIntLiteralBias); | 633 return new IntLiteral(biasedValue - Tag.SpecializedIntLiteralBias); |
| 610 case Tag.PositiveIntLiteral: | 634 case Tag.PositiveIntLiteral: |
| 611 return new IntLiteral(readUInt()); | 635 return new IntLiteral(readUInt()); |
| 612 case Tag.NegativeIntLiteral: | 636 case Tag.NegativeIntLiteral: |
| (...skipping 21 matching lines...) Expand all Loading... |
| 634 return new Throw(readExpression())..fileOffset = offset; | 658 return new Throw(readExpression())..fileOffset = offset; |
| 635 case Tag.ListLiteral: | 659 case Tag.ListLiteral: |
| 636 var typeArgument = readDartType(); | 660 var typeArgument = readDartType(); |
| 637 return new ListLiteral(readExpressionList(), | 661 return new ListLiteral(readExpressionList(), |
| 638 typeArgument: typeArgument, isConst: false); | 662 typeArgument: typeArgument, isConst: false); |
| 639 case Tag.ConstListLiteral: | 663 case Tag.ConstListLiteral: |
| 640 var typeArgument = readDartType(); | 664 var typeArgument = readDartType(); |
| 641 return new ListLiteral(readExpressionList(), | 665 return new ListLiteral(readExpressionList(), |
| 642 typeArgument: typeArgument, isConst: true); | 666 typeArgument: typeArgument, isConst: true); |
| 643 case Tag.MapLiteral: | 667 case Tag.MapLiteral: |
| 668 int offset = readOffset(); |
| 644 var keyType = readDartType(); | 669 var keyType = readDartType(); |
| 645 var valueType = readDartType(); | 670 var valueType = readDartType(); |
| 646 return new MapLiteral(readMapEntryList(), | 671 return new MapLiteral(readMapEntryList(), |
| 647 keyType: keyType, valueType: valueType, isConst: false); | 672 keyType: keyType, |
| 673 valueType: valueType, |
| 674 isConst: false)..fileOffset = offset; |
| 648 case Tag.ConstMapLiteral: | 675 case Tag.ConstMapLiteral: |
| 676 int offset = readOffset(); |
| 649 var keyType = readDartType(); | 677 var keyType = readDartType(); |
| 650 var valueType = readDartType(); | 678 var valueType = readDartType(); |
| 651 return new MapLiteral(readMapEntryList(), | 679 return new MapLiteral(readMapEntryList(), |
| 652 keyType: keyType, valueType: valueType, isConst: true); | 680 keyType: keyType, |
| 681 valueType: valueType, |
| 682 isConst: true)..fileOffset = offset; |
| 653 case Tag.AwaitExpression: | 683 case Tag.AwaitExpression: |
| 654 return new AwaitExpression(readExpression()); | 684 return new AwaitExpression(readExpression()); |
| 655 case Tag.FunctionExpression: | 685 case Tag.FunctionExpression: |
| 656 return new FunctionExpression(readFunctionNode()); | 686 return new FunctionExpression(readFunctionNode()); |
| 657 case Tag.Let: | 687 case Tag.Let: |
| 658 var variable = readVariableDeclaration(); | 688 var variable = readVariableDeclaration(); |
| 659 int stackHeight = variableStack.length; | 689 int stackHeight = variableStack.length; |
| 660 pushVariableDeclaration(variable); | 690 pushVariableDeclaration(variable); |
| 661 var body = readExpression(); | 691 var body = readExpression(); |
| 662 variableStack.length = stackHeight; | 692 variableStack.length = stackHeight; |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 748 } | 778 } |
| 749 switchCaseStack.length -= count; | 779 switchCaseStack.length -= count; |
| 750 return new SwitchStatement(expression, cases); | 780 return new SwitchStatement(expression, cases); |
| 751 case Tag.ContinueSwitchStatement: | 781 case Tag.ContinueSwitchStatement: |
| 752 int index = readUInt(); | 782 int index = readUInt(); |
| 753 return new ContinueSwitchStatement(switchCaseStack[index]); | 783 return new ContinueSwitchStatement(switchCaseStack[index]); |
| 754 case Tag.IfStatement: | 784 case Tag.IfStatement: |
| 755 return new IfStatement( | 785 return new IfStatement( |
| 756 readExpression(), readStatement(), readStatementOrNullIfEmpty()); | 786 readExpression(), readStatement(), readStatementOrNullIfEmpty()); |
| 757 case Tag.ReturnStatement: | 787 case Tag.ReturnStatement: |
| 758 return new ReturnStatement(readExpressionOption()); | 788 int offset = readOffset(); |
| 789 return new ReturnStatement(readExpressionOption())..fileOffset = offset; |
| 759 case Tag.TryCatch: | 790 case Tag.TryCatch: |
| 760 return new TryCatch(readStatement(), readCatchList()); | 791 return new TryCatch(readStatement(), readCatchList()); |
| 761 case Tag.TryFinally: | 792 case Tag.TryFinally: |
| 762 return new TryFinally(readStatement(), readStatement()); | 793 return new TryFinally(readStatement(), readStatement()); |
| 763 case Tag.YieldStatement: | 794 case Tag.YieldStatement: |
| 795 int offset = readOffset(); |
| 764 int flags = readByte(); | 796 int flags = readByte(); |
| 765 return new YieldStatement(readExpression(), | 797 return new YieldStatement(readExpression(), |
| 766 isYieldStar: flags & YieldStatement.FlagYieldStar != 0, | 798 isYieldStar: flags & YieldStatement.FlagYieldStar != 0, |
| 767 isNative: flags & YieldStatement.FlagNative != 0); | 799 isNative: flags & YieldStatement.FlagNative != 0) |
| 800 ..fileOffset = offset; |
| 768 case Tag.VariableDeclaration: | 801 case Tag.VariableDeclaration: |
| 769 var variable = readVariableDeclaration(); | 802 var variable = readVariableDeclaration(); |
| 770 variableStack.add(variable); // Will be popped by the enclosing scope. | 803 variableStack.add(variable); // Will be popped by the enclosing scope. |
| 771 return variable; | 804 return variable; |
| 772 case Tag.FunctionDeclaration: | 805 case Tag.FunctionDeclaration: |
| 806 int offset = readOffset(); |
| 773 var variable = readVariableDeclaration(); | 807 var variable = readVariableDeclaration(); |
| 774 variableStack.add(variable); // Will be popped by the enclosing scope. | 808 variableStack.add(variable); // Will be popped by the enclosing scope. |
| 775 var function = readFunctionNode(); | 809 var function = readFunctionNode(); |
| 776 return new FunctionDeclaration(variable, function); | 810 return new FunctionDeclaration(variable, function)..fileOffset = offset; |
| 777 default: | 811 default: |
| 778 throw fail('Invalid statement tag: $tag'); | 812 throw fail('Invalid statement tag: $tag'); |
| 779 } | 813 } |
| 780 } | 814 } |
| 781 | 815 |
| 782 List<Catch> readCatchList() { | 816 List<Catch> readCatchList() { |
| 783 return new List<Catch>.generate(readUInt(), (i) => readCatch()); | 817 return new List<Catch>.generate(readUInt(), (i) => readCatch()); |
| 784 } | 818 } |
| 785 | 819 |
| 786 Catch readCatch() { | 820 Catch readCatch() { |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 918 return readAndCheckOptionTag() ? readAndPushVariableDeclaration() : null; | 952 return readAndCheckOptionTag() ? readAndPushVariableDeclaration() : null; |
| 919 } | 953 } |
| 920 | 954 |
| 921 VariableDeclaration readAndPushVariableDeclaration() { | 955 VariableDeclaration readAndPushVariableDeclaration() { |
| 922 var variable = readVariableDeclaration(); | 956 var variable = readVariableDeclaration(); |
| 923 variableStack.add(variable); | 957 variableStack.add(variable); |
| 924 return variable; | 958 return variable; |
| 925 } | 959 } |
| 926 | 960 |
| 927 VariableDeclaration readVariableDeclaration() { | 961 VariableDeclaration readVariableDeclaration() { |
| 962 int offset = readOffset(); |
| 928 int flags = readByte(); | 963 int flags = readByte(); |
| 929 return new VariableDeclaration(readStringOrNullIfEmpty(), | 964 return new VariableDeclaration(readStringOrNullIfEmpty(), |
| 930 type: readDartType(), | 965 type: readDartType(), |
| 931 inferredValue: readOptionalInferredValue(), | 966 inferredValue: readOptionalInferredValue(), |
| 932 initializer: readExpressionOption(), | 967 initializer: readExpressionOption(), |
| 933 isFinal: flags & 0x1 != 0, | 968 isFinal: flags & 0x1 != 0, |
| 934 isConst: flags & 0x2 != 0); | 969 isConst: flags & 0x2 != 0)..fileOffset = offset; |
| 935 } | 970 } |
| 936 | 971 |
| 937 int readOffset() { | 972 int readOffset() { |
| 938 // Offset is saved as unsigned, | 973 // Offset is saved as unsigned, |
| 939 // but actually ranges from -1 and up (thus the -1) | 974 // but actually ranges from -1 and up (thus the -1) |
| 940 return readUInt() - 1; | 975 return readUInt() - 1; |
| 941 } | 976 } |
| 942 } | 977 } |
| OLD | NEW |