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

Unified Diff: src/ast/ast.cc

Issue 2142233003: Templatize AstVisitor with its subclass (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Addressed comments Created 4 years, 5 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
« no previous file with comments | « src/ast/ast.h ('k') | src/ast/ast-expression-rewriter.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ast/ast.cc
diff --git a/src/ast/ast.cc b/src/ast/ast.cc
index a10055a98f561554d7fb53d3ce7d4ba6e07e35dc..82739f1d4c290e3cf8fdcca2f59031f831e92d2e 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
@@ -182,7 +173,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)),
@@ -191,18 +182,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);
@@ -255,10 +244,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)),
@@ -266,7 +254,6 @@ Assignment::Assignment(Zone* zone, Token::Value op, Expression* target,
value_(value),
binary_operation_(NULL) {}
-
void Assignment::AssignFeedbackVectorSlots(Isolate* isolate,
FeedbackVectorSpec* spec,
FeedbackVectorSlotCache* cache) {
@@ -931,36 +918,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) \
@@ -1263,7 +1220,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()) {}
« no previous file with comments | « src/ast/ast.h ('k') | src/ast/ast-expression-rewriter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698