Chromium Code Reviews| Index: src/ast/ast.cc |
| diff --git a/src/ast/ast.cc b/src/ast/ast.cc |
| index ef47feea0669c013dc6942a606be79def2181e9a..95ec0444dc10e210c5e683397a97e33158e1b7e0 100644 |
| --- a/src/ast/ast.cc |
| +++ b/src/ast/ast.cc |
| @@ -23,15 +23,6 @@ namespace v8 { |
| namespace internal { |
| // ---------------------------------------------------------------------------- |
| -// All the Accept member functions for each syntax tree node type. |
| - |
| -#define DECL_ACCEPT(type) \ |
| - void type::Accept(AstVisitor* v) { v->Visit##type(this); } |
| -AST_NODE_LIST(DECL_ACCEPT) |
| -#undef DECL_ACCEPT |
| - |
| - |
| -// ---------------------------------------------------------------------------- |
| // Implementation of other node functionality. |
| #ifdef DEBUG |
| @@ -47,35 +38,42 @@ void AstNode::PrettyPrint(Isolate* isolate) { |
| #endif // DEBUG |
| +#define RETURN_NODE(Node) \ |
|
Igor Sheludko
2016/07/14 16:39:54
This and below changes should have already been in
Toon Verwaest
2016/07/15 07:07:19
Acknowledged.
|
| + case k##Node: \ |
| + return reinterpret_cast<Node*>(this); |
| + |
| IterationStatement* AstNode::AsIterationStatement() { |
| -#define TEST_ITERATION(Name) \ |
| - if (Is##Name()) return As##Name(); |
| - ITERATION_NODE_LIST(TEST_ITERATION) |
| -#undef TEST_ITERATION |
| - return nullptr; |
| + switch (node_type()) { |
| + ITERATION_NODE_LIST(RETURN_NODE); |
| + default: |
| + return nullptr; |
| + } |
| } |
| BreakableStatement* AstNode::AsBreakableStatement() { |
| -#define TEST_BREAKABLE(Name) \ |
| - if (Is##Name()) return As##Name(); |
| - BREAKABLE_NODE_LIST(TEST_BREAKABLE) |
| -#undef TEST_BREAKABLE |
| - return AsIterationStatement(); |
| + switch (node_type()) { |
| + BREAKABLE_NODE_LIST(RETURN_NODE); |
| + ITERATION_NODE_LIST(RETURN_NODE); |
| + default: |
| + return nullptr; |
| + } |
| } |
| MaterializedLiteral* AstNode::AsMaterializedLiteral() { |
| -#define TEST_LITERAL(Name) \ |
| - if (Is##Name()) return As##Name(); |
| - LITERAL_NODE_LIST(TEST_LITERAL) |
| -#undef TEST_LITERAL |
| - return nullptr; |
| + switch (node_type()) { |
| + LITERAL_NODE_LIST(RETURN_NODE); |
| + default: |
| + return nullptr; |
| + } |
| } |
| +#undef RETURN_NODE |
| + |
| InitializationFlag Declaration::initialization() const { |
| switch (node_type()) { |
| -#define GENERATE_CASE(Name) \ |
| - case k##Name: \ |
| - return reinterpret_cast<const Name*>(this)->initialization(); |
| +#define GENERATE_CASE(Node) \ |
| + case k##Node: \ |
| + return reinterpret_cast<const Node*>(this)->initialization(); |
| DECLARATION_NODE_LIST(GENERATE_CASE); |
| #undef GENERATE_CASE |
| default: |
| @@ -166,7 +164,7 @@ bool Statement::IsJump() const { |
| VariableProxy::VariableProxy(Zone* zone, Variable* var, int start_position, |
| int end_position) |
| - : Expression(zone, start_position), |
| + : Expression(zone, start_position, kVariableProxy), |
| bit_field_(IsThisField::encode(var->is_this()) | |
| IsAssignedField::encode(false) | |
| IsResolvedField::encode(false)), |
| @@ -175,18 +173,16 @@ VariableProxy::VariableProxy(Zone* zone, Variable* var, int start_position, |
| BindTo(var); |
| } |
| - |
| VariableProxy::VariableProxy(Zone* zone, const AstRawString* name, |
| Variable::Kind variable_kind, int start_position, |
| int end_position) |
| - : Expression(zone, start_position), |
| + : Expression(zone, start_position, kVariableProxy), |
| bit_field_(IsThisField::encode(variable_kind == Variable::THIS) | |
| IsAssignedField::encode(false) | |
| IsResolvedField::encode(false)), |
| raw_name_(name), |
| end_position_(end_position) {} |
| - |
| void VariableProxy::BindTo(Variable* var) { |
| DCHECK((is_this() && var->is_this()) || raw_name() == var->raw_name()); |
| set_var(var); |
| @@ -239,10 +235,9 @@ void ForInStatement::AssignFeedbackVectorSlots(Isolate* isolate, |
| for_in_feedback_slot_ = spec->AddGeneralSlot(); |
| } |
| - |
| Assignment::Assignment(Zone* zone, Token::Value op, Expression* target, |
| Expression* value, int pos) |
| - : Expression(zone, pos), |
| + : Expression(zone, pos, kAssignment), |
| bit_field_( |
| IsUninitializedField::encode(false) | KeyTypeField::encode(ELEMENT) | |
| StoreModeField::encode(STANDARD_STORE) | TokenField::encode(op)), |
| @@ -250,7 +245,6 @@ Assignment::Assignment(Zone* zone, Token::Value op, Expression* target, |
| value_(value), |
| binary_operation_(NULL) {} |
| - |
| void Assignment::AssignFeedbackVectorSlots(Isolate* isolate, |
| FeedbackVectorSpec* spec, |
| FeedbackVectorSlotCache* cache) { |
| @@ -859,36 +853,6 @@ Call::CallType Call::GetCallType(Isolate* isolate) const { |
| // ---------------------------------------------------------------------------- |
| -// Implementation of AstVisitor |
| - |
| -void AstVisitor::VisitDeclarations(ZoneList<Declaration*>* declarations) { |
| - for (int i = 0; i < declarations->length(); i++) { |
| - Visit(declarations->at(i)); |
| - } |
| -} |
| - |
| - |
| -void AstVisitor::VisitStatements(ZoneList<Statement*>* statements) { |
| - for (int i = 0; i < statements->length(); i++) { |
| - Statement* stmt = statements->at(i); |
| - Visit(stmt); |
| - if (stmt->IsJump()) break; |
| - } |
| -} |
| - |
| - |
| -void AstVisitor::VisitExpressions(ZoneList<Expression*>* expressions) { |
| - for (int i = 0; i < expressions->length(); i++) { |
| - // The variable statement visiting code may pass NULL expressions |
| - // to this code. Maybe this should be handled by introducing an |
| - // undefined expression or literal? Revisit this code if this |
| - // changes |
| - Expression* expression = expressions->at(i); |
| - if (expression != NULL) Visit(expression); |
| - } |
| -} |
| - |
| -// ---------------------------------------------------------------------------- |
| // Implementation of AstTraversalVisitor |
| #define RECURSE(call) \ |
| @@ -1191,7 +1155,7 @@ void AstTraversalVisitor::VisitRewritableExpression( |
| CaseClause::CaseClause(Zone* zone, Expression* label, |
| ZoneList<Statement*>* statements, int pos) |
| - : Expression(zone, pos), |
| + : Expression(zone, pos, kCaseClause), |
| label_(label), |
| statements_(statements), |
| compare_type_(Type::None()) {} |