Commit 4faa0ae8 authored by Andy Wingo's avatar Andy Wingo

Remove AstConstructionVisitor/AstNullVisitor

R=svenpanne@chromium.org
BUG=

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

Cr-Commit-Position: refs/heads/master@{#25357}
parent 27cc3c68
...@@ -1001,110 +1001,6 @@ CaseClause::CaseClause(Zone* zone, Expression* label, ...@@ -1001,110 +1001,6 @@ CaseClause::CaseClause(Zone* zone, Expression* label,
compare_type_(Type::None(zone)) {} compare_type_(Type::None(zone)) {}
#define REGULAR_NODE(NodeType) \
void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \
}
#define REGULAR_NODE_WITH_FEEDBACK_SLOTS(NodeType) \
void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \
}
#define DONT_OPTIMIZE_NODE(NodeType) \
void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \
}
#define DONT_OPTIMIZE_NODE_WITH_FEEDBACK_SLOTS(NodeType) \
void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \
}
#define DONT_TURBOFAN_NODE(NodeType) \
void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \
}
#define DONT_TURBOFAN_NODE_WITH_FEEDBACK_SLOTS(NodeType) \
void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \
}
#define DONT_SELFOPTIMIZE_NODE(NodeType) \
void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \
}
#define DONT_SELFOPTIMIZE_NODE_WITH_FEEDBACK_SLOTS(NodeType) \
void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \
}
#define DONT_CACHE_NODE(NodeType) \
void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \
}
REGULAR_NODE(VariableDeclaration)
REGULAR_NODE(FunctionDeclaration)
REGULAR_NODE(Block)
REGULAR_NODE(ExpressionStatement)
REGULAR_NODE(EmptyStatement)
REGULAR_NODE(IfStatement)
REGULAR_NODE(ContinueStatement)
REGULAR_NODE(BreakStatement)
REGULAR_NODE(ReturnStatement)
REGULAR_NODE(SwitchStatement)
REGULAR_NODE(CaseClause)
REGULAR_NODE(Conditional)
REGULAR_NODE(Literal)
REGULAR_NODE(ArrayLiteral)
REGULAR_NODE(ObjectLiteral)
REGULAR_NODE(RegExpLiteral)
REGULAR_NODE(FunctionLiteral)
REGULAR_NODE(Assignment)
REGULAR_NODE(Throw)
REGULAR_NODE(UnaryOperation)
REGULAR_NODE(CountOperation)
REGULAR_NODE(BinaryOperation)
REGULAR_NODE(CompareOperation)
REGULAR_NODE(ThisFunction)
REGULAR_NODE_WITH_FEEDBACK_SLOTS(Call)
REGULAR_NODE_WITH_FEEDBACK_SLOTS(CallNew)
REGULAR_NODE_WITH_FEEDBACK_SLOTS(Property)
// In theory, for VariableProxy we'd have to add:
// if (node->var()->IsLookupSlot())
// set_dont_optimize_reason(kReferenceToAVariableWhichRequiresDynamicLookup);
// But node->var() is usually not bound yet at VariableProxy creation time, and
// LOOKUP variables only result from constructs that cannot be inlined anyway.
REGULAR_NODE_WITH_FEEDBACK_SLOTS(VariableProxy)
// We currently do not optimize any modules.
DONT_OPTIMIZE_NODE(ModuleDeclaration)
DONT_OPTIMIZE_NODE(ImportDeclaration)
DONT_OPTIMIZE_NODE(ExportDeclaration)
DONT_OPTIMIZE_NODE(ModuleVariable)
DONT_OPTIMIZE_NODE(ModulePath)
DONT_OPTIMIZE_NODE(ModuleUrl)
DONT_OPTIMIZE_NODE(ModuleStatement)
DONT_OPTIMIZE_NODE(WithStatement)
DONT_OPTIMIZE_NODE(DebuggerStatement)
DONT_OPTIMIZE_NODE(NativeFunctionLiteral)
DONT_OPTIMIZE_NODE_WITH_FEEDBACK_SLOTS(Yield)
// TODO(turbofan): Remove the dont_turbofan_reason once this list is empty.
// This list must be kept in sync with Pipeline::GenerateCode.
DONT_TURBOFAN_NODE(ForOfStatement)
DONT_TURBOFAN_NODE(TryCatchStatement)
DONT_TURBOFAN_NODE(TryFinallyStatement)
DONT_TURBOFAN_NODE(ClassLiteral)
DONT_TURBOFAN_NODE_WITH_FEEDBACK_SLOTS(SuperReference)
DONT_SELFOPTIMIZE_NODE(DoWhileStatement)
DONT_SELFOPTIMIZE_NODE(WhileStatement)
DONT_SELFOPTIMIZE_NODE(ForStatement)
DONT_SELFOPTIMIZE_NODE_WITH_FEEDBACK_SLOTS(ForInStatement)
DONT_CACHE_NODE(ModuleLiteral)
void AstConstructionVisitor::VisitCallRuntime(CallRuntime* node) {
}
#undef REGULAR_NODE
#undef DONT_OPTIMIZE_NODE
#undef DONT_SELFOPTIMIZE_NODE
#undef DONT_CACHE_NODE
uint32_t Literal::Hash() { uint32_t Literal::Hash() {
return raw_value()->IsString() return raw_value()->IsString()
? raw_value()->AsString()->hash() ? raw_value()->AsString()->hash()
......
This diff is collapsed.
...@@ -287,8 +287,7 @@ FunctionLiteral* Parser::DefaultConstructor(bool call_super, Scope* scope, ...@@ -287,8 +287,7 @@ FunctionLiteral* Parser::DefaultConstructor(bool call_super, Scope* scope,
ZoneList<Statement*>* body = NULL; ZoneList<Statement*>* body = NULL;
{ {
AstNodeFactory<AstConstructionVisitor> function_factory( AstNodeFactory function_factory(ast_value_factory());
ast_value_factory());
FunctionState function_state(&function_state_, &scope_, function_scope, FunctionState function_state(&function_state_, &scope_, function_scope,
&function_factory); &function_factory);
...@@ -460,7 +459,7 @@ Expression* ParserTraits::MarkExpressionAsAssigned(Expression* expression) { ...@@ -460,7 +459,7 @@ Expression* ParserTraits::MarkExpressionAsAssigned(Expression* expression) {
bool ParserTraits::ShortcutNumericLiteralBinaryExpression( bool ParserTraits::ShortcutNumericLiteralBinaryExpression(
Expression** x, Expression* y, Token::Value op, int pos, Expression** x, Expression* y, Token::Value op, int pos,
AstNodeFactory<AstConstructionVisitor>* factory) { AstNodeFactory* factory) {
if ((*x)->AsLiteral() && (*x)->AsLiteral()->raw_value()->IsNumber() && if ((*x)->AsLiteral() && (*x)->AsLiteral()->raw_value()->IsNumber() &&
y->AsLiteral() && y->AsLiteral()->raw_value()->IsNumber()) { y->AsLiteral() && y->AsLiteral()->raw_value()->IsNumber()) {
double x_val = (*x)->AsLiteral()->raw_value()->AsNumber(); double x_val = (*x)->AsLiteral()->raw_value()->AsNumber();
...@@ -518,9 +517,9 @@ bool ParserTraits::ShortcutNumericLiteralBinaryExpression( ...@@ -518,9 +517,9 @@ bool ParserTraits::ShortcutNumericLiteralBinaryExpression(
} }
Expression* ParserTraits::BuildUnaryExpression( Expression* ParserTraits::BuildUnaryExpression(Expression* expression,
Expression* expression, Token::Value op, int pos, Token::Value op, int pos,
AstNodeFactory<AstConstructionVisitor>* factory) { AstNodeFactory* factory) {
DCHECK(expression != NULL); DCHECK(expression != NULL);
if (expression->IsLiteral()) { if (expression->IsLiteral()) {
const AstValue* literal = expression->AsLiteral()->raw_value(); const AstValue* literal = expression->AsLiteral()->raw_value();
...@@ -674,13 +673,13 @@ const AstRawString* ParserTraits::GetNextSymbol(Scanner* scanner) { ...@@ -674,13 +673,13 @@ const AstRawString* ParserTraits::GetNextSymbol(Scanner* scanner) {
} }
Expression* ParserTraits::ThisExpression( Expression* ParserTraits::ThisExpression(Scope* scope, AstNodeFactory* factory,
Scope* scope, AstNodeFactory<AstConstructionVisitor>* factory, int pos) { int pos) {
return factory->NewVariableProxy(scope->receiver(), pos); return factory->NewVariableProxy(scope->receiver(), pos);
} }
Expression* ParserTraits::SuperReference( Expression* ParserTraits::SuperReference(Scope* scope, AstNodeFactory* factory,
Scope* scope, AstNodeFactory<AstConstructionVisitor>* factory, int pos) { int pos) {
return factory->NewSuperReference( return factory->NewSuperReference(
ThisExpression(scope, factory, pos)->AsVariableProxy(), ThisExpression(scope, factory, pos)->AsVariableProxy(),
pos); pos);
...@@ -689,22 +688,20 @@ Expression* ParserTraits::SuperReference( ...@@ -689,22 +688,20 @@ Expression* ParserTraits::SuperReference(
Expression* ParserTraits::ClassExpression( Expression* ParserTraits::ClassExpression(
const AstRawString* name, Expression* extends, Expression* constructor, const AstRawString* name, Expression* extends, Expression* constructor,
ZoneList<ObjectLiteral::Property*>* properties, int start_position, ZoneList<ObjectLiteral::Property*>* properties, int start_position,
int end_position, AstNodeFactory<AstConstructionVisitor>* factory) { int end_position, AstNodeFactory* factory) {
return factory->NewClassLiteral(name, extends, constructor, properties, return factory->NewClassLiteral(name, extends, constructor, properties,
start_position, end_position); start_position, end_position);
} }
Expression* ParserTraits::DefaultConstructor(bool call_super, Scope* scope, Expression* ParserTraits::DefaultConstructor(bool call_super, Scope* scope,
int pos, int end_pos) { int pos, int end_pos) {
return parser_->DefaultConstructor(call_super, scope, pos, end_pos); return parser_->DefaultConstructor(call_super, scope, pos, end_pos);
} }
Literal* ParserTraits::ExpressionFromLiteral( Literal* ParserTraits::ExpressionFromLiteral(Token::Value token, int pos,
Token::Value token, int pos,
Scanner* scanner, Scanner* scanner,
AstNodeFactory<AstConstructionVisitor>* factory) { AstNodeFactory* factory) {
switch (token) { switch (token) {
case Token::NULL_LITERAL: case Token::NULL_LITERAL:
return factory->NewNullLiteral(pos); return factory->NewNullLiteral(pos);
...@@ -723,9 +720,9 @@ Literal* ParserTraits::ExpressionFromLiteral( ...@@ -723,9 +720,9 @@ Literal* ParserTraits::ExpressionFromLiteral(
} }
Expression* ParserTraits::ExpressionFromIdentifier( Expression* ParserTraits::ExpressionFromIdentifier(const AstRawString* name,
const AstRawString* name, int pos, Scope* scope, int pos, Scope* scope,
AstNodeFactory<AstConstructionVisitor>* factory) { AstNodeFactory* factory) {
if (parser_->fni_ != NULL) parser_->fni_->PushVariableName(name); if (parser_->fni_ != NULL) parser_->fni_->PushVariableName(name);
// The name may refer to a module instance object, so its type is unknown. // The name may refer to a module instance object, so its type is unknown.
#ifdef DEBUG #ifdef DEBUG
...@@ -737,17 +734,16 @@ Expression* ParserTraits::ExpressionFromIdentifier( ...@@ -737,17 +734,16 @@ Expression* ParserTraits::ExpressionFromIdentifier(
} }
Expression* ParserTraits::ExpressionFromString( Expression* ParserTraits::ExpressionFromString(int pos, Scanner* scanner,
int pos, Scanner* scanner, AstNodeFactory* factory) {
AstNodeFactory<AstConstructionVisitor>* factory) {
const AstRawString* symbol = GetSymbol(scanner); const AstRawString* symbol = GetSymbol(scanner);
if (parser_->fni_ != NULL) parser_->fni_->PushLiteralName(symbol); if (parser_->fni_ != NULL) parser_->fni_->PushLiteralName(symbol);
return factory->NewStringLiteral(symbol, pos); return factory->NewStringLiteral(symbol, pos);
} }
Expression* ParserTraits::GetIterator( Expression* ParserTraits::GetIterator(Expression* iterable,
Expression* iterable, AstNodeFactory<AstConstructionVisitor>* factory) { AstNodeFactory* factory) {
Expression* iterator_symbol_literal = Expression* iterator_symbol_literal =
factory->NewSymbolLiteral("iterator_symbol", RelocInfo::kNoPosition); factory->NewSymbolLiteral("iterator_symbol", RelocInfo::kNoPosition);
int pos = iterable->position(); int pos = iterable->position();
...@@ -759,8 +755,8 @@ Expression* ParserTraits::GetIterator( ...@@ -759,8 +755,8 @@ Expression* ParserTraits::GetIterator(
} }
Literal* ParserTraits::GetLiteralTheHole( Literal* ParserTraits::GetLiteralTheHole(int position,
int position, AstNodeFactory<AstConstructionVisitor>* factory) { AstNodeFactory* factory) {
return factory->NewTheHoleLiteral(RelocInfo::kNoPosition); return factory->NewTheHoleLiteral(RelocInfo::kNoPosition);
} }
...@@ -924,8 +920,7 @@ FunctionLiteral* Parser::DoParseProgram(CompilationInfo* info, Scope** scope, ...@@ -924,8 +920,7 @@ FunctionLiteral* Parser::DoParseProgram(CompilationInfo* info, Scope** scope,
ParsingModeScope parsing_mode(this, mode); ParsingModeScope parsing_mode(this, mode);
// Enters 'scope'. // Enters 'scope'.
AstNodeFactory<AstConstructionVisitor> function_factory( AstNodeFactory function_factory(ast_value_factory());
ast_value_factory());
FunctionState function_state(&function_state_, &scope_, *scope, FunctionState function_state(&function_state_, &scope_, *scope,
&function_factory); &function_factory);
...@@ -1036,8 +1031,7 @@ FunctionLiteral* Parser::ParseLazy(Utf16CharacterStream* source) { ...@@ -1036,8 +1031,7 @@ FunctionLiteral* Parser::ParseLazy(Utf16CharacterStream* source) {
zone()); zone());
} }
original_scope_ = scope; original_scope_ = scope;
AstNodeFactory<AstConstructionVisitor> function_factory( AstNodeFactory function_factory(ast_value_factory());
ast_value_factory());
FunctionState function_state(&function_state_, &scope_, scope, FunctionState function_state(&function_state_, &scope_, scope,
&function_factory); &function_factory);
DCHECK(scope->strict_mode() == SLOPPY || info()->strict_mode() == STRICT); DCHECK(scope->strict_mode() == SLOPPY || info()->strict_mode() == STRICT);
...@@ -3549,8 +3543,7 @@ FunctionLiteral* Parser::ParseFunctionLiteral( ...@@ -3549,8 +3543,7 @@ FunctionLiteral* Parser::ParseFunctionLiteral(
: FunctionLiteral::kNotParenthesized; : FunctionLiteral::kNotParenthesized;
// Parse function body. // Parse function body.
{ {
AstNodeFactory<AstConstructionVisitor> function_factory( AstNodeFactory function_factory(ast_value_factory());
ast_value_factory());
FunctionState function_state(&function_state_, &scope_, scope, FunctionState function_state(&function_state_, &scope_, scope,
&function_factory); &function_factory);
scope_->SetScopeName(function_name); scope_->SetScopeName(function_name);
......
...@@ -373,7 +373,7 @@ class ParserTraits { ...@@ -373,7 +373,7 @@ class ParserTraits {
typedef ZoneList<v8::internal::Statement*>* StatementList; typedef ZoneList<v8::internal::Statement*>* StatementList;
// For constructing objects returned by the traversing functions. // For constructing objects returned by the traversing functions.
typedef AstNodeFactory<AstConstructionVisitor> Factory; typedef AstNodeFactory Factory;
}; };
explicit ParserTraits(Parser* parser) : parser_(parser) {} explicit ParserTraits(Parser* parser) : parser_(parser) {}
...@@ -451,9 +451,9 @@ class ParserTraits { ...@@ -451,9 +451,9 @@ class ParserTraits {
// Returns true if we have a binary expression between two numeric // Returns true if we have a binary expression between two numeric
// literals. In that case, *x will be changed to an expression which is the // literals. In that case, *x will be changed to an expression which is the
// computed value. // computed value.
bool ShortcutNumericLiteralBinaryExpression( bool ShortcutNumericLiteralBinaryExpression(Expression** x, Expression* y,
Expression** x, Expression* y, Token::Value op, int pos, Token::Value op, int pos,
AstNodeFactory<AstConstructionVisitor>* factory); AstNodeFactory* factory);
// Rewrites the following types of unary expressions: // Rewrites the following types of unary expressions:
// not <literal> -> true / false // not <literal> -> true / false
...@@ -466,9 +466,8 @@ class ParserTraits { ...@@ -466,9 +466,8 @@ class ParserTraits {
// + foo -> foo * 1 // + foo -> foo * 1
// - foo -> foo * (-1) // - foo -> foo * (-1)
// ~ foo -> foo ^(~0) // ~ foo -> foo ^(~0)
Expression* BuildUnaryExpression( Expression* BuildUnaryExpression(Expression* expression, Token::Value op,
Expression* expression, Token::Value op, int pos, int pos, AstNodeFactory* factory);
AstNodeFactory<AstConstructionVisitor>* factory);
// Generate AST node that throws a ReferenceError with the given type. // Generate AST node that throws a ReferenceError with the given type.
Expression* NewThrowReferenceError(const char* type, int pos); Expression* NewThrowReferenceError(const char* type, int pos);
...@@ -528,38 +527,32 @@ class ParserTraits { ...@@ -528,38 +527,32 @@ class ParserTraits {
V8_INLINE const AstRawString* EmptyIdentifierString(); V8_INLINE const AstRawString* EmptyIdentifierString();
// Odd-ball literal creators. // Odd-ball literal creators.
Literal* GetLiteralTheHole(int position, Literal* GetLiteralTheHole(int position, AstNodeFactory* factory);
AstNodeFactory<AstConstructionVisitor>* factory);
// Producing data during the recursive descent. // Producing data during the recursive descent.
const AstRawString* GetSymbol(Scanner* scanner); const AstRawString* GetSymbol(Scanner* scanner);
const AstRawString* GetNextSymbol(Scanner* scanner); const AstRawString* GetNextSymbol(Scanner* scanner);
const AstRawString* GetNumberAsSymbol(Scanner* scanner); const AstRawString* GetNumberAsSymbol(Scanner* scanner);
Expression* ThisExpression(Scope* scope, Expression* ThisExpression(Scope* scope, AstNodeFactory* factory,
AstNodeFactory<AstConstructionVisitor>* factory,
int pos = RelocInfo::kNoPosition); int pos = RelocInfo::kNoPosition);
Expression* SuperReference(Scope* scope, Expression* SuperReference(Scope* scope, AstNodeFactory* factory,
AstNodeFactory<AstConstructionVisitor>* factory,
int pos = RelocInfo::kNoPosition); int pos = RelocInfo::kNoPosition);
Expression* ClassExpression(const AstRawString* name, Expression* extends, Expression* ClassExpression(const AstRawString* name, Expression* extends,
Expression* constructor, Expression* constructor,
ZoneList<ObjectLiteral::Property*>* properties, ZoneList<ObjectLiteral::Property*>* properties,
int start_position, int end_position, int start_position, int end_position,
AstNodeFactory<AstConstructionVisitor>* factory); AstNodeFactory* factory);
Expression* DefaultConstructor(bool call_super, Scope* scope, int pos, Expression* DefaultConstructor(bool call_super, Scope* scope, int pos,
int end_pos); int end_pos);
Literal* ExpressionFromLiteral( Literal* ExpressionFromLiteral(Token::Value token, int pos, Scanner* scanner,
Token::Value token, int pos, Scanner* scanner, AstNodeFactory* factory);
AstNodeFactory<AstConstructionVisitor>* factory); Expression* ExpressionFromIdentifier(const AstRawString* name, int pos,
Expression* ExpressionFromIdentifier( Scope* scope, AstNodeFactory* factory);
const AstRawString* name, int pos, Scope* scope, Expression* ExpressionFromString(int pos, Scanner* scanner,
AstNodeFactory<AstConstructionVisitor>* factory); AstNodeFactory* factory);
Expression* ExpressionFromString( Expression* GetIterator(Expression* iterable, AstNodeFactory* factory);
int pos, Scanner* scanner,
AstNodeFactory<AstConstructionVisitor>* factory);
Expression* GetIterator(Expression* iterable,
AstNodeFactory<AstConstructionVisitor>* factory);
ZoneList<v8::internal::Expression*>* NewExpressionList(int size, Zone* zone) { ZoneList<v8::internal::Expression*>* NewExpressionList(int size, Zone* zone) {
return new(zone) ZoneList<v8::internal::Expression*>(size, zone); return new(zone) ZoneList<v8::internal::Expression*>(size, zone);
} }
......
...@@ -29,9 +29,7 @@ class Processor: public AstVisitor { ...@@ -29,9 +29,7 @@ class Processor: public AstVisitor {
void Process(ZoneList<Statement*>* statements); void Process(ZoneList<Statement*>* statements);
bool result_assigned() const { return result_assigned_; } bool result_assigned() const { return result_assigned_; }
AstNodeFactory<AstNullVisitor>* factory() { AstNodeFactory* factory() { return &factory_; }
return &factory_;
}
private: private:
Variable* result_; Variable* result_;
...@@ -49,7 +47,7 @@ class Processor: public AstVisitor { ...@@ -49,7 +47,7 @@ class Processor: public AstVisitor {
bool is_set_; bool is_set_;
bool in_try_; bool in_try_;
AstNodeFactory<AstNullVisitor> factory_; AstNodeFactory factory_;
Expression* SetResult(Expression* value) { Expression* SetResult(Expression* value) {
result_assigned_ = true; result_assigned_ = true;
......
...@@ -277,7 +277,7 @@ bool Scope::Analyze(CompilationInfo* info) { ...@@ -277,7 +277,7 @@ bool Scope::Analyze(CompilationInfo* info) {
// Allocate the variables. // Allocate the variables.
{ {
AstNodeFactory<AstNullVisitor> ast_node_factory(info->ast_value_factory()); AstNodeFactory ast_node_factory(info->ast_value_factory());
if (!top->AllocateVariables(info, &ast_node_factory)) return false; if (!top->AllocateVariables(info, &ast_node_factory)) return false;
} }
...@@ -424,7 +424,7 @@ Variable* Scope::LookupLocal(const AstRawString* name) { ...@@ -424,7 +424,7 @@ Variable* Scope::LookupLocal(const AstRawString* name) {
Variable* Scope::LookupFunctionVar(const AstRawString* name, Variable* Scope::LookupFunctionVar(const AstRawString* name,
AstNodeFactory<AstNullVisitor>* factory) { AstNodeFactory* factory) {
if (function_ != NULL && function_->proxy()->raw_name() == name) { if (function_ != NULL && function_->proxy()->raw_name() == name) {
return function_->proxy()->var(); return function_->proxy()->var();
} else if (!scope_info_.is_null()) { } else if (!scope_info_.is_null()) {
...@@ -643,8 +643,7 @@ void Scope::CollectStackAndContextLocals(ZoneList<Variable*>* stack_locals, ...@@ -643,8 +643,7 @@ void Scope::CollectStackAndContextLocals(ZoneList<Variable*>* stack_locals,
} }
bool Scope::AllocateVariables(CompilationInfo* info, bool Scope::AllocateVariables(CompilationInfo* info, AstNodeFactory* factory) {
AstNodeFactory<AstNullVisitor>* factory) {
// 1) Propagate scope information. // 1) Propagate scope information.
bool outer_scope_calls_sloppy_eval = false; bool outer_scope_calls_sloppy_eval = false;
if (outer_scope_ != NULL) { if (outer_scope_ != NULL) {
...@@ -981,7 +980,7 @@ Variable* Scope::NonLocal(const AstRawString* name, VariableMode mode) { ...@@ -981,7 +980,7 @@ Variable* Scope::NonLocal(const AstRawString* name, VariableMode mode) {
Variable* Scope::LookupRecursive(VariableProxy* proxy, Variable* Scope::LookupRecursive(VariableProxy* proxy,
BindingKind* binding_kind, BindingKind* binding_kind,
AstNodeFactory<AstNullVisitor>* factory) { AstNodeFactory* factory) {
DCHECK(binding_kind != NULL); DCHECK(binding_kind != NULL);
if (already_resolved() && is_with_scope()) { if (already_resolved() && is_with_scope()) {
// Short-cut: if the scope is deserialized from a scope info, variable // Short-cut: if the scope is deserialized from a scope info, variable
...@@ -1043,9 +1042,8 @@ Variable* Scope::LookupRecursive(VariableProxy* proxy, ...@@ -1043,9 +1042,8 @@ Variable* Scope::LookupRecursive(VariableProxy* proxy,
} }
bool Scope::ResolveVariable(CompilationInfo* info, bool Scope::ResolveVariable(CompilationInfo* info, VariableProxy* proxy,
VariableProxy* proxy, AstNodeFactory* factory) {
AstNodeFactory<AstNullVisitor>* factory) {
DCHECK(info->script_scope()->is_script_scope()); DCHECK(info->script_scope()->is_script_scope());
// If the proxy is already resolved there's nothing to do // If the proxy is already resolved there's nothing to do
...@@ -1152,9 +1150,8 @@ bool Scope::ResolveVariable(CompilationInfo* info, ...@@ -1152,9 +1150,8 @@ bool Scope::ResolveVariable(CompilationInfo* info,
} }
bool Scope::ResolveVariablesRecursively( bool Scope::ResolveVariablesRecursively(CompilationInfo* info,
CompilationInfo* info, AstNodeFactory* factory) {
AstNodeFactory<AstNullVisitor>* factory) {
DCHECK(info->script_scope()->is_script_scope()); DCHECK(info->script_scope()->is_script_scope());
// Resolve unresolved variables for this scope. // Resolve unresolved variables for this scope.
......
...@@ -108,7 +108,7 @@ class Scope: public ZoneObject { ...@@ -108,7 +108,7 @@ class Scope: public ZoneObject {
// the name of named function literal is kept in an intermediate scope // the name of named function literal is kept in an intermediate scope
// in between this scope and the next outer scope.) // in between this scope and the next outer scope.)
Variable* LookupFunctionVar(const AstRawString* name, Variable* LookupFunctionVar(const AstRawString* name,
AstNodeFactory<AstNullVisitor>* factory); AstNodeFactory* factory);
// Lookup a variable in this scope or outer scopes. // Lookup a variable in this scope or outer scopes.
// Returns the variable or NULL if not found. // Returns the variable or NULL if not found.
...@@ -141,8 +141,7 @@ class Scope: public ZoneObject { ...@@ -141,8 +141,7 @@ class Scope: public ZoneObject {
Variable* DeclareDynamicGlobal(const AstRawString* name); Variable* DeclareDynamicGlobal(const AstRawString* name);
// Create a new unresolved variable. // Create a new unresolved variable.
template<class Visitor> VariableProxy* NewUnresolved(AstNodeFactory* factory,
VariableProxy* NewUnresolved(AstNodeFactory<Visitor>* factory,
const AstRawString* name, const AstRawString* name,
Interface* interface = Interface::NewValue(), Interface* interface = Interface::NewValue(),
int position = RelocInfo::kNoPosition) { int position = RelocInfo::kNoPosition) {
...@@ -594,16 +593,14 @@ class Scope: public ZoneObject { ...@@ -594,16 +593,14 @@ class Scope: public ZoneObject {
// Lookup a variable reference given by name recursively starting with this // Lookup a variable reference given by name recursively starting with this
// scope. If the code is executed because of a call to 'eval', the context // scope. If the code is executed because of a call to 'eval', the context
// parameter should be set to the calling context of 'eval'. // parameter should be set to the calling context of 'eval'.
Variable* LookupRecursive(VariableProxy* proxy, Variable* LookupRecursive(VariableProxy* proxy, BindingKind* binding_kind,
BindingKind* binding_kind, AstNodeFactory* factory);
AstNodeFactory<AstNullVisitor>* factory);
MUST_USE_RESULT MUST_USE_RESULT
bool ResolveVariable(CompilationInfo* info, bool ResolveVariable(CompilationInfo* info, VariableProxy* proxy,
VariableProxy* proxy, AstNodeFactory* factory);
AstNodeFactory<AstNullVisitor>* factory);
MUST_USE_RESULT MUST_USE_RESULT
bool ResolveVariablesRecursively(CompilationInfo* info, bool ResolveVariablesRecursively(CompilationInfo* info,
AstNodeFactory<AstNullVisitor>* factory); AstNodeFactory* factory);
// Scope analysis. // Scope analysis.
void PropagateScopeInfo(bool outer_scope_calls_sloppy_eval); void PropagateScopeInfo(bool outer_scope_calls_sloppy_eval);
...@@ -632,8 +629,7 @@ class Scope: public ZoneObject { ...@@ -632,8 +629,7 @@ class Scope: public ZoneObject {
// parameter is the context in which eval was called. In all other // parameter is the context in which eval was called. In all other
// cases the context parameter is an empty handle. // cases the context parameter is an empty handle.
MUST_USE_RESULT MUST_USE_RESULT
bool AllocateVariables(CompilationInfo* info, bool AllocateVariables(CompilationInfo* info, AstNodeFactory* factory);
AstNodeFactory<AstNullVisitor>* factory);
private: private:
// Construct a scope based on the scope info. // Construct a scope based on the scope info.
......
...@@ -41,7 +41,7 @@ TEST(List) { ...@@ -41,7 +41,7 @@ TEST(List) {
Isolate* isolate = CcTest::i_isolate(); Isolate* isolate = CcTest::i_isolate();
Zone zone(isolate); Zone zone(isolate);
AstValueFactory value_factory(&zone, 0); AstValueFactory value_factory(&zone, 0);
AstNodeFactory<AstNullVisitor> factory(&value_factory); AstNodeFactory factory(&value_factory);
AstNode* node = factory.NewEmptyStatement(RelocInfo::kNoPosition); AstNode* node = factory.NewEmptyStatement(RelocInfo::kNoPosition);
list->Add(node); list->Add(node);
CHECK_EQ(1, list->length()); CHECK_EQ(1, list->length());
......
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