Simplify Scope and ScopePtr conversions.

R=svenpanne@chromium.org

Review URL: https://codereview.chromium.org/643603002

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@24488 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
dslomov@chromium.org 2014-10-09 10:40:18 +00:00
parent 1369a8367a
commit 49e5b0d60c
2 changed files with 7 additions and 35 deletions

View File

@ -352,6 +352,8 @@ class ParserTraits {
// Used by FunctionState and BlockState. // Used by FunctionState and BlockState.
typedef v8::internal::Scope Scope; typedef v8::internal::Scope Scope;
typedef v8::internal::Scope* ScopePtr; typedef v8::internal::Scope* ScopePtr;
inline static Scope* ptr_to_scope(ScopePtr scope) { return scope; }
typedef Variable GeneratorVariable; typedef Variable GeneratorVariable;
typedef v8::internal::Zone Zone; typedef v8::internal::Zone Zone;

View File

@ -150,13 +150,6 @@ class ParserBase : public Traits {
scope_(scope) { scope_(scope) {
*scope_stack_ = scope_; *scope_stack_ = scope_;
} }
BlockState(typename Traits::Type::Scope** scope_stack,
typename Traits::Type::Scope** scope)
: scope_stack_(scope_stack),
outer_scope_(*scope_stack),
scope_(*scope) {
*scope_stack_ = scope_;
}
~BlockState() { *scope_stack_ = outer_scope_; } ~BlockState() { *scope_stack_ = outer_scope_; }
private: private:
@ -171,10 +164,6 @@ class ParserBase : public Traits {
typename Traits::Type::Scope** scope_stack, typename Traits::Type::Scope** scope_stack,
typename Traits::Type::Scope* scope, typename Traits::Type::Scope* scope,
typename Traits::Type::Factory* factory); typename Traits::Type::Factory* factory);
FunctionState(FunctionState** function_state_stack,
typename Traits::Type::Scope** scope_stack,
typename Traits::Type::Scope** scope,
typename Traits::Type::Factory* factory);
~FunctionState(); ~FunctionState();
int NextMaterializedLiteralIndex() { int NextMaterializedLiteralIndex() {
@ -1123,6 +1112,7 @@ class PreParserTraits {
// Used by FunctionState and BlockState. // Used by FunctionState and BlockState.
typedef PreParserScope Scope; typedef PreParserScope Scope;
typedef PreParserScope ScopePtr; typedef PreParserScope ScopePtr;
inline static Scope* ptr_to_scope(ScopePtr& scope) { return &scope; }
// PreParser doesn't need to store generator variables. // PreParser doesn't need to store generator variables.
typedef void GeneratorVariable; typedef void GeneratorVariable;
@ -1577,27 +1567,6 @@ ParserBase<Traits>::FunctionState::FunctionState(
} }
template <class Traits>
ParserBase<Traits>::FunctionState::FunctionState(
FunctionState** function_state_stack,
typename Traits::Type::Scope** scope_stack,
typename Traits::Type::Scope** scope,
typename Traits::Type::Factory* factory)
: next_materialized_literal_index_(JSFunction::kLiteralsPrefixSize),
next_handler_index_(0),
expected_property_count_(0),
is_generator_(false),
generator_object_variable_(NULL),
function_state_stack_(function_state_stack),
outer_function_state_(*function_state_stack),
scope_stack_(scope_stack),
outer_scope_(*scope_stack),
factory_(factory) {
*scope_stack_ = *scope;
*function_state_stack = this;
}
template <class Traits> template <class Traits>
ParserBase<Traits>::FunctionState::~FunctionState() { ParserBase<Traits>::FunctionState::~FunctionState() {
*scope_stack_ = outer_scope_; *scope_stack_ = outer_scope_;
@ -2636,7 +2605,8 @@ typename ParserBase<Traits>::ExpressionT ParserBase<
{ {
typename Traits::Type::Factory function_factory( typename Traits::Type::Factory function_factory(
zone(), this->ast_value_factory(), ast_node_id_gen_); zone(), this->ast_value_factory(), ast_node_id_gen_);
FunctionState function_state(&function_state_, &scope_, &scope, FunctionState function_state(&function_state_, &scope_,
Traits::Type::ptr_to_scope(scope),
&function_factory); &function_factory);
Scanner::Location dupe_error_loc = Scanner::Location::invalid(); Scanner::Location dupe_error_loc = Scanner::Location::invalid();
num_parameters = Traits::DeclareArrowParametersFromExpression( num_parameters = Traits::DeclareArrowParametersFromExpression(
@ -2751,14 +2721,14 @@ typename ParserBase<Traits>::ExpressionT ParserBase<Traits>::ParseClassLiteral(
ExpressionT extends = this->EmptyExpression(); ExpressionT extends = this->EmptyExpression();
if (Check(Token::EXTENDS)) { if (Check(Token::EXTENDS)) {
typename Traits::Type::ScopePtr scope = this->NewScope(scope_, BLOCK_SCOPE); typename Traits::Type::ScopePtr scope = this->NewScope(scope_, BLOCK_SCOPE);
BlockState block_state(&scope_, &scope); BlockState block_state(&scope_, Traits::Type::ptr_to_scope(scope));
scope_->SetStrictMode(STRICT); scope_->SetStrictMode(STRICT);
extends = this->ParseLeftHandSideExpression(CHECK_OK); extends = this->ParseLeftHandSideExpression(CHECK_OK);
} }
// TODO(arv): Implement scopes and name binding in class body only. // TODO(arv): Implement scopes and name binding in class body only.
typename Traits::Type::ScopePtr scope = this->NewScope(scope_, BLOCK_SCOPE); typename Traits::Type::ScopePtr scope = this->NewScope(scope_, BLOCK_SCOPE);
BlockState block_state(&scope_, &scope); BlockState block_state(&scope_, Traits::Type::ptr_to_scope(scope));
scope_->SetStrictMode(STRICT); scope_->SetStrictMode(STRICT);
scope_->SetScopeName(name); scope_->SetScopeName(name);