Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(333)

Unified Diff: src/parsing/preparsed-scope-data.cc

Issue 2650703003: [parser]: Skipping inner funcs / initial implemetation of storing scope analysis data from preparse… (Closed)
Patch Set: code review (vogelheim) Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/parsing/preparsed-scope-data.cc
diff --git a/src/parsing/preparsed-scope-data.cc b/src/parsing/preparsed-scope-data.cc
new file mode 100644
index 0000000000000000000000000000000000000000..ef69f805104ab3ee471be71aceb9a433fa47b3a1
--- /dev/null
+++ b/src/parsing/preparsed-scope-data.cc
@@ -0,0 +1,39 @@
+// Copyright 2017 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "src/parsing/preparsed-scope-data.h"
+
+namespace v8 {
+namespace internal {
+
+PreParsedScopeData::ScopeScope::ScopeScope(PreParsedScopeData* data,
+ ScopeType scope_type,
+ int start_position, int end_position)
+ : data_(data),
+ previous_scope_(data->current_scope_),
+ inner_scope_count_(0),
+ variable_count_(0) {
+ data->current_scope_ = this;
+ if (previous_scope_ != nullptr) {
+ ++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
+ }
+
+ data->backing_store_.push_back(scope_type);
+ data->backing_store_.push_back(start_position);
+ data->backing_store_.push_back(end_position);
+ // Reserve space for variable and inner scope count (we don't know yet how
+ // many will be added).
+ index_in_data_ = data->backing_store_.size();
+ 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.
+ data->backing_store_.push_back(0);
+}
+
+PreParsedScopeData::ScopeScope::~ScopeScope() {
+ data_->current_scope_ = previous_scope_;
+ data_->backing_store_[index_in_data_] = inner_scope_count_;
+ data_->backing_store_[index_in_data_ + 1] = variable_count_;
+}
+
+} // namespace internal
+} // namespace v8

Powered by Google App Engine
This is Rietveld 408576698