| 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 483 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 int64_t offset() { return offset_; } |
| 505 |
| 504 private: | 506 private: |
| 505 const uint8_t* buffer_; | 507 const uint8_t* buffer_; |
| 506 int64_t size_; | 508 int64_t size_; |
| 507 int64_t offset_; | 509 int64_t offset_; |
| 508 ReaderHelper builder_; | 510 ReaderHelper builder_; |
| 509 TokenPosition max_position_; | 511 TokenPosition max_position_; |
| 510 TokenPosition min_position_; | 512 TokenPosition min_position_; |
| 511 intptr_t current_script_id_; | 513 intptr_t current_script_id_; |
| 512 | 514 |
| 513 friend class PositionScope; | 515 friend class PositionScope; |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 799 int index = reader->ReadUInt(); | 801 int index = reader->ReadUInt(); |
| 800 return reader->helper()->program()->string_table().strings()[index]; | 802 return reader->helper()->program()->string_table().strings()[index]; |
| 801 } | 803 } |
| 802 | 804 |
| 803 | 805 |
| 804 Field* Field::ReadFrom(Reader* reader) { | 806 Field* Field::ReadFrom(Reader* reader) { |
| 805 TRACE_READ_OFFSET(); | 807 TRACE_READ_OFFSET(); |
| 806 Tag tag = reader->ReadTag(); | 808 Tag tag = reader->ReadTag(); |
| 807 ASSERT(tag == kField); | 809 ASSERT(tag == kField); |
| 808 | 810 |
| 811 kernelFileOffset_ = reader->offset(); |
| 809 reader->ReadDefiningCanonicalNameReference(this); | 812 reader->ReadDefiningCanonicalNameReference(this); |
| 810 position_ = reader->ReadPosition(false); | 813 position_ = reader->ReadPosition(false); |
| 811 end_position_ = reader->ReadPosition(false); | 814 end_position_ = reader->ReadPosition(false); |
| 812 flags_ = reader->ReadFlags(); | 815 flags_ = reader->ReadFlags(); |
| 813 name_ = Name::ReadFrom(reader); | 816 name_ = Name::ReadFrom(reader); |
| 814 source_uri_index_ = reader->ReadUInt(); | 817 source_uri_index_ = reader->ReadUInt(); |
| 815 reader->set_current_script_id(source_uri_index_); | 818 reader->set_current_script_id(source_uri_index_); |
| 816 reader->record_token_position(position_); | 819 reader->record_token_position(position_); |
| 817 reader->record_token_position(end_position_); | 820 reader->record_token_position(end_position_); |
| 818 annotations_.ReadFromStatic<Expression>(reader); | 821 annotations_.ReadFromStatic<Expression>(reader); |
| (...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1380 TRACE_READ_OFFSET(); | 1383 TRACE_READ_OFFSET(); |
| 1381 AwaitExpression* await = new AwaitExpression(); | 1384 AwaitExpression* await = new AwaitExpression(); |
| 1382 await->operand_ = Expression::ReadFrom(reader); | 1385 await->operand_ = Expression::ReadFrom(reader); |
| 1383 return await; | 1386 return await; |
| 1384 } | 1387 } |
| 1385 | 1388 |
| 1386 | 1389 |
| 1387 FunctionExpression* FunctionExpression::ReadFrom(Reader* reader) { | 1390 FunctionExpression* FunctionExpression::ReadFrom(Reader* reader) { |
| 1388 TRACE_READ_OFFSET(); | 1391 TRACE_READ_OFFSET(); |
| 1389 VariableScope<ReaderHelper> parameters(reader->helper()); | 1392 VariableScope<ReaderHelper> parameters(reader->helper()); |
| 1390 FunctionExpression* expr = new FunctionExpression(); | 1393 FunctionExpression* expr = new FunctionExpression(reader->offset()); |
| 1391 expr->function_ = FunctionNode::ReadFrom(reader); | 1394 expr->function_ = FunctionNode::ReadFrom(reader); |
| 1392 return expr; | 1395 return expr; |
| 1393 } | 1396 } |
| 1394 | 1397 |
| 1395 | 1398 |
| 1396 Let* Let::ReadFrom(Reader* reader) { | 1399 Let* Let::ReadFrom(Reader* reader) { |
| 1397 TRACE_READ_OFFSET(); | 1400 TRACE_READ_OFFSET(); |
| 1398 VariableScope<ReaderHelper> vars(reader->helper()); | 1401 VariableScope<ReaderHelper> vars(reader->helper()); |
| 1399 PositionScope scope(reader); | 1402 PositionScope scope(reader); |
| 1400 | 1403 |
| 1401 Let* let = new Let(); | 1404 Let* let = new Let(reader->offset()); |
| 1402 let->variable_ = VariableDeclaration::ReadFromImpl(reader); | 1405 let->variable_ = VariableDeclaration::ReadFromImpl(reader); |
| 1403 let->body_ = Expression::ReadFrom(reader); | 1406 let->body_ = Expression::ReadFrom(reader); |
| 1404 let->position_ = reader->min_position(); | 1407 let->position_ = reader->min_position(); |
| 1405 let->end_position_ = reader->max_position(); | 1408 let->end_position_ = reader->max_position(); |
| 1406 | 1409 |
| 1407 return let; | 1410 return let; |
| 1408 } | 1411 } |
| 1409 | 1412 |
| 1410 | 1413 |
| 1411 Statement* Statement::ReadFrom(Reader* reader) { | 1414 Statement* Statement::ReadFrom(Reader* reader) { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1471 TRACE_READ_OFFSET(); | 1474 TRACE_READ_OFFSET(); |
| 1472 return new ExpressionStatement(Expression::ReadFrom(reader)); | 1475 return new ExpressionStatement(Expression::ReadFrom(reader)); |
| 1473 } | 1476 } |
| 1474 | 1477 |
| 1475 | 1478 |
| 1476 Block* Block::ReadFromImpl(Reader* reader) { | 1479 Block* Block::ReadFromImpl(Reader* reader) { |
| 1477 TRACE_READ_OFFSET(); | 1480 TRACE_READ_OFFSET(); |
| 1478 PositionScope scope(reader); | 1481 PositionScope scope(reader); |
| 1479 | 1482 |
| 1480 VariableScope<ReaderHelper> vars(reader->helper()); | 1483 VariableScope<ReaderHelper> vars(reader->helper()); |
| 1481 Block* block = new Block(); | 1484 Block* block = new Block(reader->offset()); |
| 1482 block->statements().ReadFromStatic<Statement>(reader); | 1485 block->statements().ReadFromStatic<Statement>(reader); |
| 1483 block->position_ = reader->min_position(); | 1486 block->position_ = reader->min_position(); |
| 1484 block->end_position_ = reader->max_position(); | 1487 block->end_position_ = reader->max_position(); |
| 1485 | 1488 |
| 1486 return block; | 1489 return block; |
| 1487 } | 1490 } |
| 1488 | 1491 |
| 1489 | 1492 |
| 1490 EmptyStatement* EmptyStatement::ReadFrom(Reader* reader) { | 1493 EmptyStatement* EmptyStatement::ReadFrom(Reader* reader) { |
| 1491 TRACE_READ_OFFSET(); | 1494 TRACE_READ_OFFSET(); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1537 dostmt->condition_ = Expression::ReadFrom(reader); | 1540 dostmt->condition_ = Expression::ReadFrom(reader); |
| 1538 return dostmt; | 1541 return dostmt; |
| 1539 } | 1542 } |
| 1540 | 1543 |
| 1541 | 1544 |
| 1542 ForStatement* ForStatement::ReadFrom(Reader* reader) { | 1545 ForStatement* ForStatement::ReadFrom(Reader* reader) { |
| 1543 TRACE_READ_OFFSET(); | 1546 TRACE_READ_OFFSET(); |
| 1544 VariableScope<ReaderHelper> vars(reader->helper()); | 1547 VariableScope<ReaderHelper> vars(reader->helper()); |
| 1545 PositionScope scope(reader); | 1548 PositionScope scope(reader); |
| 1546 | 1549 |
| 1547 ForStatement* forstmt = new ForStatement(); | 1550 ForStatement* forstmt = new ForStatement(reader->offset()); |
| 1548 forstmt->variables_.ReadFromStatic<VariableDeclarationImpl>(reader); | 1551 forstmt->variables_.ReadFromStatic<VariableDeclarationImpl>(reader); |
| 1549 forstmt->condition_ = reader->ReadOptional<Expression>(); | 1552 forstmt->condition_ = reader->ReadOptional<Expression>(); |
| 1550 forstmt->updates_.ReadFromStatic<Expression>(reader); | 1553 forstmt->updates_.ReadFromStatic<Expression>(reader); |
| 1551 forstmt->body_ = Statement::ReadFrom(reader); | 1554 forstmt->body_ = Statement::ReadFrom(reader); |
| 1552 forstmt->end_position_ = reader->max_position(); | 1555 forstmt->end_position_ = reader->max_position(); |
| 1553 forstmt->position_ = reader->min_position(); | 1556 forstmt->position_ = reader->min_position(); |
| 1554 | 1557 |
| 1555 return forstmt; | 1558 return forstmt; |
| 1556 } | 1559 } |
| 1557 | 1560 |
| 1558 | 1561 |
| 1559 ForInStatement* ForInStatement::ReadFrom(Reader* reader, bool is_async) { | 1562 ForInStatement* ForInStatement::ReadFrom(Reader* reader, bool is_async) { |
| 1560 TRACE_READ_OFFSET(); | 1563 TRACE_READ_OFFSET(); |
| 1561 VariableScope<ReaderHelper> vars(reader->helper()); | 1564 VariableScope<ReaderHelper> vars(reader->helper()); |
| 1562 PositionScope scope(reader); | 1565 PositionScope scope(reader); |
| 1563 | 1566 |
| 1564 ForInStatement* forinstmt = new ForInStatement(); | 1567 ForInStatement* forinstmt = new ForInStatement(reader->offset()); |
| 1565 forinstmt->is_async_ = is_async; | 1568 forinstmt->is_async_ = is_async; |
| 1566 forinstmt->position_ = reader->ReadPosition(); | 1569 forinstmt->position_ = reader->ReadPosition(); |
| 1567 forinstmt->variable_ = VariableDeclaration::ReadFromImpl(reader); | 1570 forinstmt->variable_ = VariableDeclaration::ReadFromImpl(reader); |
| 1568 forinstmt->iterable_ = Expression::ReadFrom(reader); | 1571 forinstmt->iterable_ = Expression::ReadFrom(reader); |
| 1569 forinstmt->body_ = Statement::ReadFrom(reader); | 1572 forinstmt->body_ = Statement::ReadFrom(reader); |
| 1570 forinstmt->end_position_ = reader->max_position(); | 1573 forinstmt->end_position_ = reader->max_position(); |
| 1571 if (!forinstmt->position_.IsReal()) { | 1574 if (!forinstmt->position_.IsReal()) { |
| 1572 forinstmt->position_ = reader->min_position(); | 1575 forinstmt->position_ = reader->min_position(); |
| 1573 } | 1576 } |
| 1574 forinstmt->variable_->set_end_position(forinstmt->position_); | 1577 forinstmt->variable_->set_end_position(forinstmt->position_); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1648 | 1651 |
| 1649 return tc; | 1652 return tc; |
| 1650 } | 1653 } |
| 1651 | 1654 |
| 1652 | 1655 |
| 1653 Catch* Catch::ReadFrom(Reader* reader) { | 1656 Catch* Catch::ReadFrom(Reader* reader) { |
| 1654 TRACE_READ_OFFSET(); | 1657 TRACE_READ_OFFSET(); |
| 1655 VariableScope<ReaderHelper> vars(reader->helper()); | 1658 VariableScope<ReaderHelper> vars(reader->helper()); |
| 1656 PositionScope scope(reader); | 1659 PositionScope scope(reader); |
| 1657 | 1660 |
| 1658 Catch* c = new Catch(); | 1661 Catch* c = new Catch(reader->offset()); |
| 1659 c->guard_ = DartType::ReadFrom(reader); | 1662 c->guard_ = DartType::ReadFrom(reader); |
| 1660 c->exception_ = | 1663 c->exception_ = |
| 1661 reader->ReadOptional<VariableDeclaration, VariableDeclarationImpl>(); | 1664 reader->ReadOptional<VariableDeclaration, VariableDeclarationImpl>(); |
| 1662 c->stack_trace_ = | 1665 c->stack_trace_ = |
| 1663 reader->ReadOptional<VariableDeclaration, VariableDeclarationImpl>(); | 1666 reader->ReadOptional<VariableDeclaration, VariableDeclarationImpl>(); |
| 1664 c->body_ = Statement::ReadFrom(reader); | 1667 c->body_ = Statement::ReadFrom(reader); |
| 1665 c->end_position_ = reader->max_position(); | 1668 c->end_position_ = reader->max_position(); |
| 1666 c->position_ = reader->min_position(); | 1669 c->position_ = reader->min_position(); |
| 1667 | 1670 |
| 1668 return c; | 1671 return c; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1694 Tag tag = reader->ReadTag(); | 1697 Tag tag = reader->ReadTag(); |
| 1695 ASSERT(tag == kVariableDeclaration); | 1698 ASSERT(tag == kVariableDeclaration); |
| 1696 return VariableDeclaration::ReadFromImpl(reader); | 1699 return VariableDeclaration::ReadFromImpl(reader); |
| 1697 } | 1700 } |
| 1698 | 1701 |
| 1699 | 1702 |
| 1700 VariableDeclaration* VariableDeclaration::ReadFromImpl(Reader* reader) { | 1703 VariableDeclaration* VariableDeclaration::ReadFromImpl(Reader* reader) { |
| 1701 TRACE_READ_OFFSET(); | 1704 TRACE_READ_OFFSET(); |
| 1702 PositionScope scope(reader); | 1705 PositionScope scope(reader); |
| 1703 | 1706 |
| 1704 VariableDeclaration* decl = new VariableDeclaration(); | 1707 VariableDeclaration* decl = new VariableDeclaration(reader->offset()); |
| 1705 decl->position_ = reader->ReadPosition(); | 1708 decl->position_ = reader->ReadPosition(); |
| 1706 decl->equals_position_ = reader->ReadPosition(); | 1709 decl->equals_position_ = reader->ReadPosition(); |
| 1707 decl->flags_ = reader->ReadFlags(); | 1710 decl->flags_ = reader->ReadFlags(); |
| 1708 decl->name_ = Reference::ReadStringFrom(reader); | 1711 decl->name_ = Reference::ReadStringFrom(reader); |
| 1709 decl->type_ = DartType::ReadFrom(reader); | 1712 decl->type_ = DartType::ReadFrom(reader); |
| 1710 decl->inferred_value_ = reader->ReadOptional<InferredValue>(); | 1713 decl->inferred_value_ = reader->ReadOptional<InferredValue>(); |
| 1711 decl->initializer_ = reader->ReadOptional<Expression>(); | 1714 decl->initializer_ = reader->ReadOptional<Expression>(); |
| 1712 | 1715 |
| 1713 // Go to next token position so it ends *after* the last potentially | 1716 // Go to next token position so it ends *after* the last potentially |
| 1714 // debuggable position in the initializer. | 1717 // debuggable position in the initializer. |
| 1715 TokenPosition position = reader->max_position(); | 1718 TokenPosition position = reader->max_position(); |
| 1716 if (position.IsReal()) position.Next(); | 1719 if (position.IsReal()) position.Next(); |
| 1717 decl->end_position_ = position; | 1720 decl->end_position_ = position; |
| 1718 reader->helper()->variables().Push(decl); | 1721 reader->helper()->variables().Push(decl); |
| 1719 | 1722 |
| 1720 return decl; | 1723 return decl; |
| 1721 } | 1724 } |
| 1722 | 1725 |
| 1723 | 1726 |
| 1724 FunctionDeclaration* FunctionDeclaration::ReadFrom(Reader* reader) { | 1727 FunctionDeclaration* FunctionDeclaration::ReadFrom(Reader* reader) { |
| 1725 TRACE_READ_OFFSET(); | 1728 TRACE_READ_OFFSET(); |
| 1726 FunctionDeclaration* decl = new FunctionDeclaration(); | 1729 FunctionDeclaration* decl = new FunctionDeclaration(reader->offset()); |
| 1727 decl->position_ = reader->ReadPosition(); | 1730 decl->position_ = reader->ReadPosition(); |
| 1728 decl->variable_ = VariableDeclaration::ReadFromImpl(reader); | 1731 decl->variable_ = VariableDeclaration::ReadFromImpl(reader); |
| 1729 VariableScope<ReaderHelper> parameters(reader->helper()); | 1732 VariableScope<ReaderHelper> parameters(reader->helper()); |
| 1730 decl->function_ = FunctionNode::ReadFrom(reader); | 1733 decl->function_ = FunctionNode::ReadFrom(reader); |
| 1731 return decl; | 1734 return decl; |
| 1732 } | 1735 } |
| 1733 | 1736 |
| 1734 | 1737 |
| 1735 Name* Name::ReadFrom(Reader* reader) { | 1738 Name* Name::ReadFrom(Reader* reader) { |
| 1736 String* string = Reference::ReadStringFrom(reader); | 1739 String* string = Reference::ReadStringFrom(reader); |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1898 #endif | 1901 #endif |
| 1899 | 1902 |
| 1900 return program; | 1903 return program; |
| 1901 } | 1904 } |
| 1902 | 1905 |
| 1903 | 1906 |
| 1904 FunctionNode* FunctionNode::ReadFrom(Reader* reader) { | 1907 FunctionNode* FunctionNode::ReadFrom(Reader* reader) { |
| 1905 TRACE_READ_OFFSET(); | 1908 TRACE_READ_OFFSET(); |
| 1906 TypeParameterScope<ReaderHelper> scope(reader->helper()); | 1909 TypeParameterScope<ReaderHelper> scope(reader->helper()); |
| 1907 | 1910 |
| 1908 FunctionNode* function = new FunctionNode(); | 1911 FunctionNode* function = new FunctionNode(reader->offset()); |
| 1909 function->position_ = reader->ReadPosition(); | 1912 function->position_ = reader->ReadPosition(); |
| 1910 function->end_position_ = reader->ReadPosition(); | 1913 function->end_position_ = reader->ReadPosition(); |
| 1911 function->async_marker_ = | 1914 function->async_marker_ = |
| 1912 static_cast<FunctionNode::AsyncMarker>(reader->ReadByte()); | 1915 static_cast<FunctionNode::AsyncMarker>(reader->ReadByte()); |
| 1913 function->dart_async_marker_ = | 1916 function->dart_async_marker_ = |
| 1914 static_cast<FunctionNode::AsyncMarker>(reader->ReadByte()); | 1917 static_cast<FunctionNode::AsyncMarker>(reader->ReadByte()); |
| 1915 function->type_parameters().ReadFrom(reader); | 1918 function->type_parameters().ReadFrom(reader); |
| 1916 function->required_parameter_count_ = reader->ReadUInt(); | 1919 function->required_parameter_count_ = reader->ReadUInt(); |
| 1917 function->positional_parameters().ReadFromStatic<VariableDeclarationImpl>( | 1920 function->positional_parameters().ReadFromStatic<VariableDeclarationImpl>( |
| 1918 reader); | 1921 reader); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1941 | 1944 |
| 1942 kernel::Program* ReadPrecompiledKernelFromBuffer(const uint8_t* buffer, | 1945 kernel::Program* ReadPrecompiledKernelFromBuffer(const uint8_t* buffer, |
| 1943 intptr_t buffer_length) { | 1946 intptr_t buffer_length) { |
| 1944 kernel::Reader reader(buffer, buffer_length); | 1947 kernel::Reader reader(buffer, buffer_length); |
| 1945 return kernel::Program::ReadFrom(&reader); | 1948 return kernel::Program::ReadFrom(&reader); |
| 1946 } | 1949 } |
| 1947 | 1950 |
| 1948 | 1951 |
| 1949 } // namespace dart | 1952 } // namespace dart |
| 1950 #endif // !defined(DART_PRECOMPILED_RUNTIME) | 1953 #endif // !defined(DART_PRECOMPILED_RUNTIME) |
| OLD | NEW |