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 #if !defined(DART_PRECOMPILED_RUNTIME) | 4 #if !defined(DART_PRECOMPILED_RUNTIME) |
5 | 5 |
6 #include "platform/globals.h" | 6 #include "platform/globals.h" |
7 #include "vm/flags.h" | 7 #include "vm/flags.h" |
8 #include "vm/growable_array.h" | 8 #include "vm/growable_array.h" |
9 #include "vm/kernel.h" | 9 #include "vm/kernel.h" |
10 #include "vm/kernel_to_il.h" | 10 #include "vm/kernel_to_il.h" |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 MallocGrowableArray<CanonicalName*> canonical_names_; | 321 MallocGrowableArray<CanonicalName*> canonical_names_; |
322 BlockStack<VariableDeclaration> scope_; | 322 BlockStack<VariableDeclaration> scope_; |
323 BlockStack<TypeParameter> type_parameters_; | 323 BlockStack<TypeParameter> type_parameters_; |
324 BlockStack<SwitchCase> switch_cases_; | 324 BlockStack<SwitchCase> switch_cases_; |
325 BlockStack<LabeledStatement>* labels_; | 325 BlockStack<LabeledStatement>* labels_; |
326 }; | 326 }; |
327 | 327 |
328 | 328 |
329 class Reader { | 329 class Reader { |
330 public: | 330 public: |
331 Reader(const uint8_t* buffer, intptr_t size) | 331 Reader(const uint8_t* buffer, int64_t size) |
332 : buffer_(buffer), size_(size), offset_(0) {} | 332 : buffer_(buffer), size_(size), offset_(0) {} |
333 | 333 |
334 uint32_t ReadUInt32() { | 334 uint32_t ReadUInt32() { |
335 ASSERT(offset_ + 4 <= size_); | 335 ASSERT(offset_ + 4 <= size_); |
336 | 336 |
337 uint32_t value = (buffer_[offset_ + 0] << 24) | | 337 uint32_t value = (buffer_[offset_ + 0] << 24) | |
338 (buffer_[offset_ + 1] << 16) | | 338 (buffer_[offset_ + 1] << 16) | |
339 (buffer_[offset_ + 2] << 8) | (buffer_[offset_ + 3] << 0); | 339 (buffer_[offset_ + 2] << 8) | (buffer_[offset_ + 3] << 0); |
340 offset_ += 4; | 340 offset_ += 4; |
341 return value; | 341 return value; |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
494 return name; | 494 return name; |
495 } | 495 } |
496 | 496 |
497 CanonicalName* ReadDefiningCanonicalNameReference(LinkedNode* node_to_link) { | 497 CanonicalName* ReadDefiningCanonicalNameReference(LinkedNode* node_to_link) { |
498 CanonicalName* name = ReadCanonicalNameReference(); | 498 CanonicalName* name = ReadCanonicalNameReference(); |
499 ASSERT(name != NULL); | 499 ASSERT(name != NULL); |
500 name->BindTo(node_to_link); | 500 name->BindTo(node_to_link); |
501 return name; | 501 return name; |
502 } | 502 } |
503 | 503 |
504 intptr_t offset() { return offset_; } | |
505 | |
506 private: | 504 private: |
507 const uint8_t* buffer_; | 505 const uint8_t* buffer_; |
508 intptr_t size_; | 506 int64_t size_; |
509 intptr_t offset_; | 507 int64_t offset_; |
510 ReaderHelper builder_; | 508 ReaderHelper builder_; |
511 TokenPosition max_position_; | 509 TokenPosition max_position_; |
512 TokenPosition min_position_; | 510 TokenPosition min_position_; |
513 intptr_t current_script_id_; | 511 intptr_t current_script_id_; |
514 | 512 |
515 friend class PositionScope; | 513 friend class PositionScope; |
516 }; | 514 }; |
517 | 515 |
518 | 516 |
519 // A helper class that resets the readers min and max positions both upon | 517 // A helper class that resets the readers min and max positions both upon |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
631 TRACE_READ_OFFSET(); | 629 TRACE_READ_OFFSET(); |
632 return String::ReadFromImpl(reader); | 630 return String::ReadFromImpl(reader); |
633 } | 631 } |
634 }; | 632 }; |
635 | 633 |
636 | 634 |
637 class VariableDeclarationImpl { | 635 class VariableDeclarationImpl { |
638 public: | 636 public: |
639 static VariableDeclaration* ReadFrom(Reader* reader) { | 637 static VariableDeclaration* ReadFrom(Reader* reader) { |
640 TRACE_READ_OFFSET(); | 638 TRACE_READ_OFFSET(); |
641 return VariableDeclaration::ReadFromImpl(reader, false); | 639 return VariableDeclaration::ReadFromImpl(reader); |
642 } | 640 } |
643 }; | 641 }; |
644 | 642 |
645 | 643 |
646 String* String::ReadFrom(Reader* reader) { | 644 String* String::ReadFrom(Reader* reader) { |
647 TRACE_READ_OFFSET(); | 645 TRACE_READ_OFFSET(); |
648 return Reference::ReadStringFrom(reader); | 646 return Reference::ReadStringFrom(reader); |
649 } | 647 } |
650 | 648 |
651 | 649 |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
798 | 796 |
799 | 797 |
800 String* Reference::ReadStringFrom(Reader* reader) { | 798 String* Reference::ReadStringFrom(Reader* reader) { |
801 int index = reader->ReadUInt(); | 799 int index = reader->ReadUInt(); |
802 return reader->helper()->program()->string_table().strings()[index]; | 800 return reader->helper()->program()->string_table().strings()[index]; |
803 } | 801 } |
804 | 802 |
805 | 803 |
806 Field* Field::ReadFrom(Reader* reader) { | 804 Field* Field::ReadFrom(Reader* reader) { |
807 TRACE_READ_OFFSET(); | 805 TRACE_READ_OFFSET(); |
808 kernel_offset_ = reader->offset(); // Notice the ReadTag() below. | |
809 Tag tag = reader->ReadTag(); | 806 Tag tag = reader->ReadTag(); |
810 ASSERT(tag == kField); | 807 ASSERT(tag == kField); |
811 | 808 |
812 reader->ReadDefiningCanonicalNameReference(this); | 809 reader->ReadDefiningCanonicalNameReference(this); |
813 position_ = reader->ReadPosition(false); | 810 position_ = reader->ReadPosition(false); |
814 end_position_ = reader->ReadPosition(false); | 811 end_position_ = reader->ReadPosition(false); |
815 flags_ = reader->ReadFlags(); | 812 flags_ = reader->ReadFlags(); |
816 name_ = Name::ReadFrom(reader); | 813 name_ = Name::ReadFrom(reader); |
817 source_uri_index_ = reader->ReadUInt(); | 814 source_uri_index_ = reader->ReadUInt(); |
818 reader->set_current_script_id(source_uri_index_); | 815 reader->set_current_script_id(source_uri_index_); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
915 RedirectingInitializer* init = new RedirectingInitializer(); | 912 RedirectingInitializer* init = new RedirectingInitializer(); |
916 init->target_reference_ = Reference::ReadMemberFrom(reader); | 913 init->target_reference_ = Reference::ReadMemberFrom(reader); |
917 init->arguments_ = Arguments::ReadFrom(reader); | 914 init->arguments_ = Arguments::ReadFrom(reader); |
918 return init; | 915 return init; |
919 } | 916 } |
920 | 917 |
921 | 918 |
922 LocalInitializer* LocalInitializer::ReadFromImpl(Reader* reader) { | 919 LocalInitializer* LocalInitializer::ReadFromImpl(Reader* reader) { |
923 TRACE_READ_OFFSET(); | 920 TRACE_READ_OFFSET(); |
924 LocalInitializer* init = new LocalInitializer(); | 921 LocalInitializer* init = new LocalInitializer(); |
925 init->variable_ = VariableDeclaration::ReadFromImpl(reader, false); | 922 init->variable_ = VariableDeclaration::ReadFromImpl(reader); |
926 return init; | 923 return init; |
927 } | 924 } |
928 | 925 |
929 | 926 |
930 Expression* Expression::ReadFrom(Reader* reader) { | 927 Expression* Expression::ReadFrom(Reader* reader) { |
931 TRACE_READ_OFFSET(); | 928 TRACE_READ_OFFSET(); |
932 uint8_t payload = 0; | 929 uint8_t payload = 0; |
933 Tag tag = reader->ReadTag(&payload); | 930 Tag tag = reader->ReadTag(&payload); |
934 switch (tag) { | 931 switch (tag) { |
935 case kInvalidExpression: | 932 case kInvalidExpression: |
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1383 AwaitExpression* await = new AwaitExpression(); | 1380 AwaitExpression* await = new AwaitExpression(); |
1384 await->operand_ = Expression::ReadFrom(reader); | 1381 await->operand_ = Expression::ReadFrom(reader); |
1385 return await; | 1382 return await; |
1386 } | 1383 } |
1387 | 1384 |
1388 | 1385 |
1389 FunctionExpression* FunctionExpression::ReadFrom(Reader* reader) { | 1386 FunctionExpression* FunctionExpression::ReadFrom(Reader* reader) { |
1390 TRACE_READ_OFFSET(); | 1387 TRACE_READ_OFFSET(); |
1391 VariableScope<ReaderHelper> parameters(reader->helper()); | 1388 VariableScope<ReaderHelper> parameters(reader->helper()); |
1392 FunctionExpression* expr = new FunctionExpression(); | 1389 FunctionExpression* expr = new FunctionExpression(); |
1393 expr->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte. | |
1394 expr->function_ = FunctionNode::ReadFrom(reader); | 1390 expr->function_ = FunctionNode::ReadFrom(reader); |
1395 return expr; | 1391 return expr; |
1396 } | 1392 } |
1397 | 1393 |
1398 | 1394 |
1399 Let* Let::ReadFrom(Reader* reader) { | 1395 Let* Let::ReadFrom(Reader* reader) { |
1400 TRACE_READ_OFFSET(); | 1396 TRACE_READ_OFFSET(); |
1401 VariableScope<ReaderHelper> vars(reader->helper()); | 1397 VariableScope<ReaderHelper> vars(reader->helper()); |
1402 PositionScope scope(reader); | 1398 PositionScope scope(reader); |
1403 | 1399 |
1404 Let* let = new Let(); | 1400 Let* let = new Let(); |
1405 let->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte. | 1401 let->variable_ = VariableDeclaration::ReadFromImpl(reader); |
1406 let->variable_ = VariableDeclaration::ReadFromImpl(reader, false); | |
1407 let->body_ = Expression::ReadFrom(reader); | 1402 let->body_ = Expression::ReadFrom(reader); |
1408 let->position_ = reader->min_position(); | 1403 let->position_ = reader->min_position(); |
1409 let->end_position_ = reader->max_position(); | 1404 let->end_position_ = reader->max_position(); |
1410 | 1405 |
1411 return let; | 1406 return let; |
1412 } | 1407 } |
1413 | 1408 |
1414 | 1409 |
1415 Statement* Statement::ReadFrom(Reader* reader) { | 1410 Statement* Statement::ReadFrom(Reader* reader) { |
1416 TRACE_READ_OFFSET(); | 1411 TRACE_READ_OFFSET(); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1448 return IfStatement::ReadFrom(reader); | 1443 return IfStatement::ReadFrom(reader); |
1449 case kReturnStatement: | 1444 case kReturnStatement: |
1450 return ReturnStatement::ReadFrom(reader); | 1445 return ReturnStatement::ReadFrom(reader); |
1451 case kTryCatch: | 1446 case kTryCatch: |
1452 return TryCatch::ReadFrom(reader); | 1447 return TryCatch::ReadFrom(reader); |
1453 case kTryFinally: | 1448 case kTryFinally: |
1454 return TryFinally::ReadFrom(reader); | 1449 return TryFinally::ReadFrom(reader); |
1455 case kYieldStatement: | 1450 case kYieldStatement: |
1456 return YieldStatement::ReadFrom(reader); | 1451 return YieldStatement::ReadFrom(reader); |
1457 case kVariableDeclaration: | 1452 case kVariableDeclaration: |
1458 return VariableDeclaration::ReadFromImpl(reader, true); | 1453 return VariableDeclaration::ReadFromImpl(reader); |
1459 case kFunctionDeclaration: | 1454 case kFunctionDeclaration: |
1460 return FunctionDeclaration::ReadFrom(reader); | 1455 return FunctionDeclaration::ReadFrom(reader); |
1461 default: | 1456 default: |
1462 UNREACHABLE(); | 1457 UNREACHABLE(); |
1463 } | 1458 } |
1464 return NULL; | 1459 return NULL; |
1465 } | 1460 } |
1466 | 1461 |
1467 | 1462 |
1468 InvalidStatement* InvalidStatement::ReadFrom(Reader* reader) { | 1463 InvalidStatement* InvalidStatement::ReadFrom(Reader* reader) { |
1469 TRACE_READ_OFFSET(); | 1464 TRACE_READ_OFFSET(); |
1470 return new InvalidStatement(); | 1465 return new InvalidStatement(); |
1471 } | 1466 } |
1472 | 1467 |
1473 | 1468 |
1474 ExpressionStatement* ExpressionStatement::ReadFrom(Reader* reader) { | 1469 ExpressionStatement* ExpressionStatement::ReadFrom(Reader* reader) { |
1475 TRACE_READ_OFFSET(); | 1470 TRACE_READ_OFFSET(); |
1476 return new ExpressionStatement(Expression::ReadFrom(reader)); | 1471 return new ExpressionStatement(Expression::ReadFrom(reader)); |
1477 } | 1472 } |
1478 | 1473 |
1479 | 1474 |
1480 Block* Block::ReadFromImpl(Reader* reader) { | 1475 Block* Block::ReadFromImpl(Reader* reader) { |
1481 TRACE_READ_OFFSET(); | 1476 TRACE_READ_OFFSET(); |
1482 PositionScope scope(reader); | 1477 PositionScope scope(reader); |
1483 | 1478 |
1484 VariableScope<ReaderHelper> vars(reader->helper()); | 1479 VariableScope<ReaderHelper> vars(reader->helper()); |
1485 Block* block = new Block(); | 1480 Block* block = new Block(); |
1486 block->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte. | |
1487 block->statements().ReadFromStatic<Statement>(reader); | 1481 block->statements().ReadFromStatic<Statement>(reader); |
1488 block->position_ = reader->min_position(); | 1482 block->position_ = reader->min_position(); |
1489 block->end_position_ = reader->max_position(); | 1483 block->end_position_ = reader->max_position(); |
1490 | 1484 |
1491 return block; | 1485 return block; |
1492 } | 1486 } |
1493 | 1487 |
1494 | 1488 |
1495 EmptyStatement* EmptyStatement::ReadFrom(Reader* reader) { | 1489 EmptyStatement* EmptyStatement::ReadFrom(Reader* reader) { |
1496 TRACE_READ_OFFSET(); | 1490 TRACE_READ_OFFSET(); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1543 return dostmt; | 1537 return dostmt; |
1544 } | 1538 } |
1545 | 1539 |
1546 | 1540 |
1547 ForStatement* ForStatement::ReadFrom(Reader* reader) { | 1541 ForStatement* ForStatement::ReadFrom(Reader* reader) { |
1548 TRACE_READ_OFFSET(); | 1542 TRACE_READ_OFFSET(); |
1549 VariableScope<ReaderHelper> vars(reader->helper()); | 1543 VariableScope<ReaderHelper> vars(reader->helper()); |
1550 PositionScope scope(reader); | 1544 PositionScope scope(reader); |
1551 | 1545 |
1552 ForStatement* forstmt = new ForStatement(); | 1546 ForStatement* forstmt = new ForStatement(); |
1553 forstmt->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte. | |
1554 forstmt->variables_.ReadFromStatic<VariableDeclarationImpl>(reader); | 1547 forstmt->variables_.ReadFromStatic<VariableDeclarationImpl>(reader); |
1555 forstmt->condition_ = reader->ReadOptional<Expression>(); | 1548 forstmt->condition_ = reader->ReadOptional<Expression>(); |
1556 forstmt->updates_.ReadFromStatic<Expression>(reader); | 1549 forstmt->updates_.ReadFromStatic<Expression>(reader); |
1557 forstmt->body_ = Statement::ReadFrom(reader); | 1550 forstmt->body_ = Statement::ReadFrom(reader); |
1558 forstmt->end_position_ = reader->max_position(); | 1551 forstmt->end_position_ = reader->max_position(); |
1559 forstmt->position_ = reader->min_position(); | 1552 forstmt->position_ = reader->min_position(); |
1560 | 1553 |
1561 return forstmt; | 1554 return forstmt; |
1562 } | 1555 } |
1563 | 1556 |
1564 | 1557 |
1565 ForInStatement* ForInStatement::ReadFrom(Reader* reader, bool is_async) { | 1558 ForInStatement* ForInStatement::ReadFrom(Reader* reader, bool is_async) { |
1566 TRACE_READ_OFFSET(); | 1559 TRACE_READ_OFFSET(); |
1567 VariableScope<ReaderHelper> vars(reader->helper()); | 1560 VariableScope<ReaderHelper> vars(reader->helper()); |
1568 PositionScope scope(reader); | 1561 PositionScope scope(reader); |
1569 | 1562 |
1570 ForInStatement* forinstmt = new ForInStatement(); | 1563 ForInStatement* forinstmt = new ForInStatement(); |
1571 forinstmt->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte. | |
1572 forinstmt->is_async_ = is_async; | 1564 forinstmt->is_async_ = is_async; |
1573 forinstmt->position_ = reader->ReadPosition(); | 1565 forinstmt->position_ = reader->ReadPosition(); |
1574 forinstmt->variable_ = VariableDeclaration::ReadFromImpl(reader, false); | 1566 forinstmt->variable_ = VariableDeclaration::ReadFromImpl(reader); |
1575 forinstmt->iterable_ = Expression::ReadFrom(reader); | 1567 forinstmt->iterable_ = Expression::ReadFrom(reader); |
1576 forinstmt->body_ = Statement::ReadFrom(reader); | 1568 forinstmt->body_ = Statement::ReadFrom(reader); |
1577 forinstmt->end_position_ = reader->max_position(); | 1569 forinstmt->end_position_ = reader->max_position(); |
1578 if (!forinstmt->position_.IsReal()) { | 1570 if (!forinstmt->position_.IsReal()) { |
1579 forinstmt->position_ = reader->min_position(); | 1571 forinstmt->position_ = reader->min_position(); |
1580 } | 1572 } |
1581 forinstmt->variable_->set_end_position(forinstmt->position_); | 1573 forinstmt->variable_->set_end_position(forinstmt->position_); |
1582 | 1574 |
1583 return forinstmt; | 1575 return forinstmt; |
1584 } | 1576 } |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1656 return tc; | 1648 return tc; |
1657 } | 1649 } |
1658 | 1650 |
1659 | 1651 |
1660 Catch* Catch::ReadFrom(Reader* reader) { | 1652 Catch* Catch::ReadFrom(Reader* reader) { |
1661 TRACE_READ_OFFSET(); | 1653 TRACE_READ_OFFSET(); |
1662 VariableScope<ReaderHelper> vars(reader->helper()); | 1654 VariableScope<ReaderHelper> vars(reader->helper()); |
1663 PositionScope scope(reader); | 1655 PositionScope scope(reader); |
1664 | 1656 |
1665 Catch* c = new Catch(); | 1657 Catch* c = new Catch(); |
1666 c->kernel_offset_ = reader->offset(); // Catch has no tag. | |
1667 c->guard_ = DartType::ReadFrom(reader); | 1658 c->guard_ = DartType::ReadFrom(reader); |
1668 c->exception_ = | 1659 c->exception_ = |
1669 reader->ReadOptional<VariableDeclaration, VariableDeclarationImpl>(); | 1660 reader->ReadOptional<VariableDeclaration, VariableDeclarationImpl>(); |
1670 c->stack_trace_ = | 1661 c->stack_trace_ = |
1671 reader->ReadOptional<VariableDeclaration, VariableDeclarationImpl>(); | 1662 reader->ReadOptional<VariableDeclaration, VariableDeclarationImpl>(); |
1672 c->body_ = Statement::ReadFrom(reader); | 1663 c->body_ = Statement::ReadFrom(reader); |
1673 c->end_position_ = reader->max_position(); | 1664 c->end_position_ = reader->max_position(); |
1674 c->position_ = reader->min_position(); | 1665 c->position_ = reader->min_position(); |
1675 | 1666 |
1676 return c; | 1667 return c; |
(...skipping 17 matching lines...) Expand all Loading... |
1694 stmt->flags_ = reader->ReadByte(); | 1685 stmt->flags_ = reader->ReadByte(); |
1695 stmt->expression_ = Expression::ReadFrom(reader); | 1686 stmt->expression_ = Expression::ReadFrom(reader); |
1696 return stmt; | 1687 return stmt; |
1697 } | 1688 } |
1698 | 1689 |
1699 | 1690 |
1700 VariableDeclaration* VariableDeclaration::ReadFrom(Reader* reader) { | 1691 VariableDeclaration* VariableDeclaration::ReadFrom(Reader* reader) { |
1701 TRACE_READ_OFFSET(); | 1692 TRACE_READ_OFFSET(); |
1702 Tag tag = reader->ReadTag(); | 1693 Tag tag = reader->ReadTag(); |
1703 ASSERT(tag == kVariableDeclaration); | 1694 ASSERT(tag == kVariableDeclaration); |
1704 return VariableDeclaration::ReadFromImpl(reader, true); | 1695 return VariableDeclaration::ReadFromImpl(reader); |
1705 } | 1696 } |
1706 | 1697 |
1707 | 1698 |
1708 VariableDeclaration* VariableDeclaration::ReadFromImpl(Reader* reader, | 1699 VariableDeclaration* VariableDeclaration::ReadFromImpl(Reader* reader) { |
1709 bool read_tag) { | |
1710 TRACE_READ_OFFSET(); | 1700 TRACE_READ_OFFSET(); |
1711 PositionScope scope(reader); | 1701 PositionScope scope(reader); |
1712 | 1702 |
1713 VariableDeclaration* decl = new VariableDeclaration(); | 1703 VariableDeclaration* decl = new VariableDeclaration(); |
1714 // -1 or -0 depending on whether there's a tag or not. | |
1715 decl->kernel_offset_ = reader->offset() - (read_tag ? 1 : 0); | |
1716 decl->position_ = reader->ReadPosition(); | 1704 decl->position_ = reader->ReadPosition(); |
1717 decl->equals_position_ = reader->ReadPosition(); | 1705 decl->equals_position_ = reader->ReadPosition(); |
1718 decl->flags_ = reader->ReadFlags(); | 1706 decl->flags_ = reader->ReadFlags(); |
1719 decl->name_ = Reference::ReadStringFrom(reader); | 1707 decl->name_ = Reference::ReadStringFrom(reader); |
1720 decl->type_ = DartType::ReadFrom(reader); | 1708 decl->type_ = DartType::ReadFrom(reader); |
1721 decl->initializer_ = reader->ReadOptional<Expression>(); | 1709 decl->initializer_ = reader->ReadOptional<Expression>(); |
1722 | 1710 |
1723 // Go to next token position so it ends *after* the last potentially | 1711 // Go to next token position so it ends *after* the last potentially |
1724 // debuggable position in the initializer. | 1712 // debuggable position in the initializer. |
1725 TokenPosition position = reader->max_position(); | 1713 TokenPosition position = reader->max_position(); |
1726 if (position.IsReal()) position.Next(); | 1714 if (position.IsReal()) position.Next(); |
1727 decl->end_position_ = position; | 1715 decl->end_position_ = position; |
1728 reader->helper()->variables().Push(decl); | 1716 reader->helper()->variables().Push(decl); |
1729 | 1717 |
1730 return decl; | 1718 return decl; |
1731 } | 1719 } |
1732 | 1720 |
1733 | 1721 |
1734 FunctionDeclaration* FunctionDeclaration::ReadFrom(Reader* reader) { | 1722 FunctionDeclaration* FunctionDeclaration::ReadFrom(Reader* reader) { |
1735 TRACE_READ_OFFSET(); | 1723 TRACE_READ_OFFSET(); |
1736 FunctionDeclaration* decl = new FunctionDeclaration(); | 1724 FunctionDeclaration* decl = new FunctionDeclaration(); |
1737 decl->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte. | |
1738 decl->position_ = reader->ReadPosition(); | 1725 decl->position_ = reader->ReadPosition(); |
1739 decl->variable_ = VariableDeclaration::ReadFromImpl(reader, false); | 1726 decl->variable_ = VariableDeclaration::ReadFromImpl(reader); |
1740 VariableScope<ReaderHelper> parameters(reader->helper()); | 1727 VariableScope<ReaderHelper> parameters(reader->helper()); |
1741 decl->function_ = FunctionNode::ReadFrom(reader); | 1728 decl->function_ = FunctionNode::ReadFrom(reader); |
1742 return decl; | 1729 return decl; |
1743 } | 1730 } |
1744 | 1731 |
1745 | 1732 |
1746 Name* Name::ReadFrom(Reader* reader) { | 1733 Name* Name::ReadFrom(Reader* reader) { |
1747 String* string = Reference::ReadStringFrom(reader); | 1734 String* string = Reference::ReadStringFrom(reader); |
1748 if (string->size() >= 1 && string->buffer()[0] == '_') { | 1735 if (string->size() >= 1 && string->buffer()[0] == '_') { |
1749 CanonicalName* library_reference = reader->ReadCanonicalNameReference(); | 1736 CanonicalName* library_reference = reader->ReadCanonicalNameReference(); |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1901 | 1888 |
1902 return program; | 1889 return program; |
1903 } | 1890 } |
1904 | 1891 |
1905 | 1892 |
1906 FunctionNode* FunctionNode::ReadFrom(Reader* reader) { | 1893 FunctionNode* FunctionNode::ReadFrom(Reader* reader) { |
1907 TRACE_READ_OFFSET(); | 1894 TRACE_READ_OFFSET(); |
1908 TypeParameterScope<ReaderHelper> scope(reader->helper()); | 1895 TypeParameterScope<ReaderHelper> scope(reader->helper()); |
1909 | 1896 |
1910 FunctionNode* function = new FunctionNode(); | 1897 FunctionNode* function = new FunctionNode(); |
1911 function->kernel_offset_ = reader->offset(); // FunctionNode has no tag. | |
1912 function->position_ = reader->ReadPosition(); | 1898 function->position_ = reader->ReadPosition(); |
1913 function->end_position_ = reader->ReadPosition(); | 1899 function->end_position_ = reader->ReadPosition(); |
1914 function->async_marker_ = | 1900 function->async_marker_ = |
1915 static_cast<FunctionNode::AsyncMarker>(reader->ReadByte()); | 1901 static_cast<FunctionNode::AsyncMarker>(reader->ReadByte()); |
1916 function->dart_async_marker_ = | 1902 function->dart_async_marker_ = |
1917 static_cast<FunctionNode::AsyncMarker>(reader->ReadByte()); | 1903 static_cast<FunctionNode::AsyncMarker>(reader->ReadByte()); |
1918 function->type_parameters().ReadFrom(reader); | 1904 function->type_parameters().ReadFrom(reader); |
1919 function->required_parameter_count_ = reader->ReadUInt(); | 1905 function->required_parameter_count_ = reader->ReadUInt(); |
1920 function->positional_parameters().ReadFromStatic<VariableDeclarationImpl>( | 1906 function->positional_parameters().ReadFromStatic<VariableDeclarationImpl>( |
1921 reader); | 1907 reader); |
(...skipping 21 matching lines...) Expand all Loading... |
1943 | 1929 |
1944 kernel::Program* ReadPrecompiledKernelFromBuffer(const uint8_t* buffer, | 1930 kernel::Program* ReadPrecompiledKernelFromBuffer(const uint8_t* buffer, |
1945 intptr_t buffer_length) { | 1931 intptr_t buffer_length) { |
1946 kernel::Reader reader(buffer, buffer_length); | 1932 kernel::Reader reader(buffer, buffer_length); |
1947 return kernel::Program::ReadFrom(&reader); | 1933 return kernel::Program::ReadFrom(&reader); |
1948 } | 1934 } |
1949 | 1935 |
1950 | 1936 |
1951 } // namespace dart | 1937 } // namespace dart |
1952 #endif // !defined(DART_PRECOMPILED_RUNTIME) | 1938 #endif // !defined(DART_PRECOMPILED_RUNTIME) |
OLD | NEW |