OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "src/parsing/preparsed-scope-data.h" |
| 6 |
| 7 namespace v8 { |
| 8 namespace internal { |
| 9 |
| 10 PreParsedScopeData::ScopeScope::ScopeScope(PreParsedScopeData* data, |
| 11 ScopeType scope_type, |
| 12 int start_position, int end_position) |
| 13 : data_(data), |
| 14 previous_scope_(data->current_scope_), |
| 15 inner_scope_count_(0), |
| 16 variable_count_(0) { |
| 17 data->current_scope_ = this; |
| 18 if (previous_scope_ != nullptr) { |
| 19 ++previous_scope_->inner_scope_count_; |
| 20 } |
| 21 |
| 22 data->backing_store_.push_back(scope_type); |
| 23 data->backing_store_.push_back(start_position); |
| 24 data->backing_store_.push_back(end_position); |
| 25 // Reserve space for variable and inner scope count (we don't know yet how |
| 26 // many will be added). |
| 27 index_in_data_ = data->backing_store_.size(); |
| 28 data->backing_store_.push_back(-1); |
| 29 data->backing_store_.push_back(-1); |
| 30 } |
| 31 |
| 32 PreParsedScopeData::ScopeScope::~ScopeScope() { |
| 33 data_->current_scope_ = previous_scope_; |
| 34 data_->backing_store_[index_in_data_] = inner_scope_count_; |
| 35 data_->backing_store_[index_in_data_ + 1] = variable_count_; |
| 36 } |
| 37 |
| 38 } // namespace internal |
| 39 } // namespace v8 |
OLD | NEW |