Commit 03e43811 authored by marja's avatar marja Committed by Commit bot

[parser] Skipping inner funcs: add variable names into the data for test purposes.

(Only in debug mode.)

BUG=v8:5516

Review-Url: https://codereview.chromium.org/2657943003
Cr-Commit-Position: refs/heads/master@{#42696}
parent 439a8edc
......@@ -2178,10 +2178,7 @@ void Scope::CollectVariableData(PreParsedScopeData* data) {
PreParsedScopeData::ScopeScope scope_scope(data, scope_type(),
start_position(), end_position());
for (Variable* local : locals_) {
if (local->mode() == VAR || local->mode() == LET ||
local->mode() == CONST) {
scope_scope.AddVariable(local->location(), local->maybe_assigned());
}
scope_scope.MaybeAddVariable(local);
}
for (Scope* inner = inner_scope_; inner != nullptr; inner = inner->sibling_) {
inner->CollectVariableData(data);
......
......@@ -4,6 +4,9 @@
#include "src/parsing/preparsed-scope-data.h"
#include "src/ast/variables.h"
#include "src/objects-inl.h"
namespace v8 {
namespace internal {
......@@ -35,11 +38,20 @@ PreParsedScopeData::ScopeScope::~ScopeScope() {
data_->backing_store_[index_in_data_ + 1] = variable_count_;
}
void PreParsedScopeData::ScopeScope::AddVariable(VariableLocation location,
bool maybe_assigned) {
data_->backing_store_.push_back(location);
data_->backing_store_.push_back(maybe_assigned);
++variable_count_;
void PreParsedScopeData::ScopeScope::MaybeAddVariable(Variable* var) {
if (var->mode() == VAR || var->mode() == LET || var->mode() == CONST) {
#ifdef DEBUG
// For tests (which check that the data is about the same variables).
const AstRawString* name = var->raw_name();
data_->backing_store_.push_back(name->length());
for (int i = 0; i < name->length(); ++i) {
data_->backing_store_.push_back(name->raw_data()[i]);
}
#endif
data_->backing_store_.push_back(var->location());
data_->backing_store_.push_back(var->maybe_assigned());
++variable_count_;
}
}
} // namespace internal
......
......@@ -23,7 +23,7 @@ class PreParsedScopeData {
int start_position, int end_position);
~ScopeScope();
void AddVariable(VariableLocation location, bool maybe_assigned);
void MaybeAddVariable(Variable* var);
private:
PreParsedScopeData* data_;
......
......@@ -8724,6 +8724,14 @@ class ScopeTestHelper {
for (Variable* local : scope->locals_) {
if (local->mode() == VAR || local->mode() == LET ||
local->mode() == CONST) {
#ifdef DEBUG
const AstRawString* local_name = local->raw_name();
int name_length = data->backing_store_[index++];
CHECK_EQ(name_length, local_name->length());
for (int i = 0; i < name_length; ++i) {
CHECK_EQ(data->backing_store_[index++], local_name->raw_data()[i]);
}
#endif
CHECK_EQ(data->backing_store_[index++], local->location());
CHECK_EQ(data->backing_store_[index++], local->maybe_assigned());
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment