| OLD | NEW |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 | 4 |
| 5 #ifndef RUNTIME_VM_KERNEL_BINARY_H_ | 5 #ifndef RUNTIME_VM_KERNEL_BINARY_H_ |
| 6 #define RUNTIME_VM_KERNEL_BINARY_H_ | 6 #define RUNTIME_VM_KERNEL_BINARY_H_ |
| 7 | 7 |
| 8 #if !defined(DART_PRECOMPILED_RUNTIME) | 8 #if !defined(DART_PRECOMPILED_RUNTIME) |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 BlockStack<VariableDeclaration> scope_; | 323 BlockStack<VariableDeclaration> scope_; |
| 324 BlockStack<TypeParameter> type_parameters_; | 324 BlockStack<TypeParameter> type_parameters_; |
| 325 BlockStack<SwitchCase> switch_cases_; | 325 BlockStack<SwitchCase> switch_cases_; |
| 326 BlockStack<LabeledStatement>* labels_; | 326 BlockStack<LabeledStatement>* labels_; |
| 327 }; | 327 }; |
| 328 | 328 |
| 329 | 329 |
| 330 class Reader { | 330 class Reader { |
| 331 public: | 331 public: |
| 332 Reader(const uint8_t* buffer, intptr_t size) | 332 Reader(const uint8_t* buffer, intptr_t size) |
| 333 : buffer_(buffer), size_(size), offset_(0) {} | 333 : buffer_(buffer), size_(size), offset_(0), string_data_offset_(-1) {} |
| 334 | 334 |
| 335 uint32_t ReadUInt32() { | 335 uint32_t ReadUInt32() { |
| 336 ASSERT(offset_ + 4 <= size_); | 336 ASSERT(offset_ + 4 <= size_); |
| 337 | 337 |
| 338 uint32_t value = (buffer_[offset_ + 0] << 24) | | 338 uint32_t value = (buffer_[offset_ + 0] << 24) | |
| 339 (buffer_[offset_ + 1] << 16) | | 339 (buffer_[offset_ + 1] << 16) | |
| 340 (buffer_[offset_ + 2] << 8) | (buffer_[offset_ + 3] << 0); | 340 (buffer_[offset_ + 2] << 8) | (buffer_[offset_ + 3] << 0); |
| 341 offset_ += 4; | 341 offset_ += 4; |
| 342 return value; | 342 return value; |
| 343 } | 343 } |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 496 ASSERT(name != NULL); | 496 ASSERT(name != NULL); |
| 497 return name; | 497 return name; |
| 498 } | 498 } |
| 499 | 499 |
| 500 intptr_t offset() { return offset_; } | 500 intptr_t offset() { return offset_; } |
| 501 void set_offset(intptr_t offset) { offset_ = offset; } | 501 void set_offset(intptr_t offset) { offset_ = offset; } |
| 502 intptr_t size() { return size_; } | 502 intptr_t size() { return size_; } |
| 503 | 503 |
| 504 const uint8_t* buffer() { return buffer_; } | 504 const uint8_t* buffer() { return buffer_; } |
| 505 | 505 |
| 506 intptr_t string_data_offset() { return string_data_offset_; } |
| 507 void MarkStringDataOffset() { |
| 508 ASSERT(string_data_offset_ == -1); |
| 509 string_data_offset_ = offset_; |
| 510 } |
| 511 |
| 512 uint8_t CharacterAt(String* str, intptr_t index) { |
| 513 ASSERT(index < str->size()); |
| 514 return buffer_[string_data_offset_ + str->offset() + index]; |
| 515 } |
| 516 |
| 506 private: | 517 private: |
| 507 const uint8_t* buffer_; | 518 const uint8_t* buffer_; |
| 508 intptr_t size_; | 519 intptr_t size_; |
| 509 intptr_t offset_; | 520 intptr_t offset_; |
| 510 ReaderHelper builder_; | 521 ReaderHelper builder_; |
| 511 TokenPosition max_position_; | 522 TokenPosition max_position_; |
| 512 TokenPosition min_position_; | 523 TokenPosition min_position_; |
| 513 intptr_t current_script_id_; | 524 intptr_t current_script_id_; |
| 514 | 525 |
| 526 intptr_t string_data_offset_; |
| 527 |
| 515 friend class PositionScope; | 528 friend class PositionScope; |
| 516 }; | 529 }; |
| 517 | 530 |
| 518 | 531 |
| 519 // A helper class that resets the readers min and max positions both upon | 532 // A helper class that resets the readers min and max positions both upon |
| 520 // initialization and upon destruction, i.e. when created the min an max | 533 // initialization and upon destruction, i.e. when created the min an max |
| 521 // positions will be reset to "noSource", when destructing the min and max will | 534 // positions will be reset to "noSource", when destructing the min and max will |
| 522 // be reset to have they value they would have had, if they hadn't been reset in | 535 // be reset to have they value they would have had, if they hadn't been reset in |
| 523 // the first place. | 536 // the first place. |
| 524 class PositionScope { | 537 class PositionScope { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 543 Reader* reader_; | 556 Reader* reader_; |
| 544 TokenPosition min_; | 557 TokenPosition min_; |
| 545 TokenPosition max_; | 558 TokenPosition max_; |
| 546 }; | 559 }; |
| 547 | 560 |
| 548 } // namespace kernel | 561 } // namespace kernel |
| 549 } // namespace dart | 562 } // namespace dart |
| 550 | 563 |
| 551 #endif // !defined(DART_PRECOMPILED_RUNTIME) | 564 #endif // !defined(DART_PRECOMPILED_RUNTIME) |
| 552 #endif // RUNTIME_VM_KERNEL_BINARY_H_ | 565 #endif // RUNTIME_VM_KERNEL_BINARY_H_ |
| OLD | NEW |