Reviewers: Yang,

Description:
Unify handling of position info in AST, part 3

* Turn CaseClause into a proper AstNode

[email protected]
BUG=

Please review this at https://codereview.chromium.org/23684058/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files (+47, -13 lines):
  M src/ast.h
  M src/ast.cc
  M src/full-codegen.cc
  M src/hydrogen.cc
  M src/parser.cc
  M src/rewriter.cc
  M src/typing.cc


Index: src/ast.cc
diff --git a/src/ast.cc b/src/ast.cc
index 28c5e767d311b31790a34a4b36bf451da9a96264..818be99db104c4e350786e8d922c49106dcb7d5e 100644
--- a/src/ast.cc
+++ b/src/ast.cc
@@ -1064,9 +1064,9 @@ CaseClause::CaseClause(Isolate* isolate,
                        Expression* label,
                        ZoneList<Statement*>* statements,
                        int pos)
-    : label_(label),
+    : AstNode(pos),
+      label_(label),
       statements_(statements),
-      position_(pos),
       compare_type_(Type::None(), isolate),
       compare_id_(AstNode::GetNextId(isolate)),
       entry_id_(AstNode::GetNextId(isolate)) {
@@ -1108,6 +1108,7 @@ REGULAR_NODE(ContinueStatement)
 REGULAR_NODE(BreakStatement)
 REGULAR_NODE(ReturnStatement)
 REGULAR_NODE(SwitchStatement)
+REGULAR_NODE(CaseClause)
 REGULAR_NODE(Conditional)
 REGULAR_NODE(Literal)
 REGULAR_NODE(ArrayLiteral)
Index: src/ast.h
diff --git a/src/ast.h b/src/ast.h
index b3168d4e326ee9f9432c947e978bcb5379a4dc86..2cd082817989e658ee71112d30f75d6f0ad97eef 100644
--- a/src/ast.h
+++ b/src/ast.h
@@ -117,11 +117,15 @@ namespace internal {
   V(CompareOperation)                           \
   V(ThisFunction)

+#define AUXILIARY_NODE_LIST(V)                  \
+  V(CaseClause)
+
 #define AST_NODE_LIST(V)                        \
   DECLARATION_NODE_LIST(V)                      \
   MODULE_NODE_LIST(V)                           \
   STATEMENT_NODE_LIST(V)                        \
-  EXPRESSION_NODE_LIST(V)
+  EXPRESSION_NODE_LIST(V)                       \
+  AUXILIARY_NODE_LIST(V)

 // Forward declarations
 class AstConstructionVisitor;
@@ -1103,12 +1107,9 @@ class WithStatement V8_FINAL : public Statement {
 };


-class CaseClause V8_FINAL : public ZoneObject {
+class CaseClause V8_FINAL : public AstNode {
  public:
-  CaseClause(Isolate* isolate,
-             Expression* label,
-             ZoneList<Statement*>* statements,
-             int pos);
+  DECLARE_NODE_TYPE(CaseClause)

   bool is_default() const { return label_ == NULL; }
   Expression* label() const {
@@ -1118,9 +1119,6 @@ class CaseClause V8_FINAL : public ZoneObject {
   Label* body_target() { return &body_target_; }
   ZoneList<Statement*>* statements() const { return statements_; }

-  int position() const { return position_; }
-  void set_position(int pos) { position_ = pos; }
-
   BailoutId EntryId() const { return entry_id_; }

   // Type feedback information.
@@ -1129,10 +1127,14 @@ class CaseClause V8_FINAL : public ZoneObject {
   Handle<Type> compare_type() { return compare_type_; }

  private:
+  CaseClause(Isolate* isolate,
+             Expression* label,
+             ZoneList<Statement*>* statements,
+             int pos);
+
   Expression* label_;
   Label body_target_;
   ZoneList<Statement*>* statements_;
-  int position_;
   Handle<Type> compare_type_;

   const TypeFeedbackId compare_id_;
@@ -3043,6 +3045,13 @@ class AstNodeFactory V8_FINAL BASE_EMBEDDED {
     return new(zone_) EmptyStatement(pos);
   }

+  CaseClause* NewCaseClause(
+      Expression* label, ZoneList<Statement*>* statements, int pos) {
+    CaseClause* clause =
+        new(zone_) CaseClause(isolate_, label, statements, pos);
+    VISIT_AND_RETURN(CaseClause, clause)
+  }
+
   Literal* NewLiteral(Handle<Object> handle, int pos) {
     Literal* lit = new(zone_) Literal(isolate_, handle, pos);
     VISIT_AND_RETURN(Literal, lit)
Index: src/full-codegen.cc
diff --git a/src/full-codegen.cc b/src/full-codegen.cc
index 5061a30b543d3660c3f771d4a76740c9cbc33231..23313f4ceaa67b1b06df304e8cb371ff7eaca18a 100644
--- a/src/full-codegen.cc
+++ b/src/full-codegen.cc
@@ -193,6 +193,10 @@ void BreakableStatementChecker::VisitDebuggerStatement(
 }


+void BreakableStatementChecker::VisitCaseClause(CaseClause* clause) {
+}
+
+
void BreakableStatementChecker::VisitFunctionLiteral(FunctionLiteral* expr) {
 }

@@ -1515,6 +1519,11 @@ void FullCodeGenerator::VisitDebuggerStatement(DebuggerStatement* stmt) {
 }


+void FullCodeGenerator::VisitCaseClause(CaseClause* clause) {
+  UNREACHABLE();
+}
+
+
 void FullCodeGenerator::VisitConditional(Conditional* expr) {
   Comment cmnt(masm_, "[ Conditional");
   Label true_case, false_case, done;
Index: src/hydrogen.cc
diff --git a/src/hydrogen.cc b/src/hydrogen.cc
index 7b623b50877d80d371dd2d2dad35d9e9faa38fe9..fee8408a998d315dc44c7df00cfb8957411e8e30 100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -3782,6 +3782,11 @@ void HOptimizedGraphBuilder::VisitDebuggerStatement(DebuggerStatement* stmt) {
 }


+void HOptimizedGraphBuilder::VisitCaseClause(CaseClause* clause) {
+  UNREACHABLE();
+}
+
+
 static Handle<SharedFunctionInfo> SearchSharedFunctionInfo(
     Code* unoptimized_code, FunctionLiteral* expr) {
   int start_position = expr->start_position();
Index: src/parser.cc
diff --git a/src/parser.cc b/src/parser.cc
index 1c5435c0ee8ffc3cb3d9678c1c095a2d33cd7d43..43dcfc63f0e5c966bc77ae809ae22b887cc1e5da 100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -2413,7 +2413,7 @@ CaseClause* Parser::ParseCaseClause(bool* default_seen_ptr, bool* ok) {
     statements->Add(stat, zone());
   }

-  return new(zone()) CaseClause(isolate(), label, statements, pos);
+  return factory()->NewCaseClause(label, statements, pos);
 }


Index: src/rewriter.cc
diff --git a/src/rewriter.cc b/src/rewriter.cc
index 4db4a3054ea3d80eb3ac3e1da59041008cf2a095..70b362fd7d8656b9fd8a137cfcb3cf5139190aa0 100644
--- a/src/rewriter.cc
+++ b/src/rewriter.cc
@@ -207,6 +207,11 @@ void Processor::VisitSwitchStatement(SwitchStatement* node) {
 }


+void Processor::VisitCaseClause(CaseClause* clause) {
+  UNREACHABLE();
+}
+
+
 void Processor::VisitContinueStatement(ContinueStatement* node) {
   is_set_ = false;
 }
Index: src/typing.cc
diff --git a/src/typing.cc b/src/typing.cc
index 34bb64bd7de022f8835c4320db07a64e5aeb9c64..94b0af06fa778bdab693a5bca04cbd09747b351a 100644
--- a/src/typing.cc
+++ b/src/typing.cc
@@ -206,6 +206,11 @@ void AstTyper::VisitSwitchStatement(SwitchStatement* stmt) {
 }


+void AstTyper::VisitCaseClause(CaseClause* clause) {
+  UNREACHABLE();
+}
+
+
 void AstTyper::VisitDoWhileStatement(DoWhileStatement* stmt) {
   // Collect type feedback.
   if (!stmt->cond()->ToBooleanIsTrue()) {


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to