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_; | |
jochen (gone - plz use gerrit)
2017/01/25 11:16:01
inner_scope_count_ is just one-level down, right?
marja
2017/01/25 11:50:28
Yes. Why?
jochen (gone - plz use gerrit)
2017/01/25 12:01:22
just wanted to verify I understood the code correc
| |
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(0); | |
jochen (gone - plz use gerrit)
2017/01/25 11:16:01
maybe use -1, so it's easier to debug... right now
marja
2017/01/25 11:50:28
Done.
| |
29 data->backing_store_.push_back(0); | |
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 |