Revision: 2586
Author: [email protected]
Date: Thu Jul 30 04:53:29 2009
Log: Change the overly-general class named Node to the more specific
AstNode in case we ever want to have some other kind of node.

Split the NODE_LIST macro-generating macro so that we can iterate
concrete subclasses of Statement and concrete subclasses of Expression
separately.
Review URL: http://codereview.chromium.org/159632
http://code.google.com/p/v8/source/detail?r=2586

Modified:
  /branches/bleeding_edge/src/arm/codegen-arm.h
  /branches/bleeding_edge/src/ast.h
  /branches/bleeding_edge/src/codegen.cc
  /branches/bleeding_edge/src/ia32/codegen-ia32.h
  /branches/bleeding_edge/src/parser.cc
  /branches/bleeding_edge/src/prettyprinter.cc
  /branches/bleeding_edge/src/prettyprinter.h
  /branches/bleeding_edge/src/usage-analyzer.cc
  /branches/bleeding_edge/src/x64/codegen-x64.h

=======================================
--- /branches/bleeding_edge/src/arm/codegen-arm.h       Fri Jul  3 05:44:31 2009
+++ /branches/bleeding_edge/src/arm/codegen-arm.h       Thu Jul 30 04:53:29 2009
@@ -374,7 +374,7 @@
    // information.
    void CodeForFunctionPosition(FunctionLiteral* fun);
    void CodeForReturnPosition(FunctionLiteral* fun);
-  void CodeForStatementPosition(Node* node);
+  void CodeForStatementPosition(AstNode* node);
    void CodeForSourcePosition(int pos);

  #ifdef DEBUG
=======================================
--- /branches/bleeding_edge/src/ast.h   Fri Jul  3 01:18:35 2009
+++ /branches/bleeding_edge/src/ast.h   Thu Jul 30 04:53:29 2009
@@ -53,9 +53,8 @@
  // Nodes of the abstract syntax tree. Only concrete classes are
  // enumerated here.

-#define NODE_LIST(V)                            \
+#define STATEMENT_NODE_LIST(V)                  \
    V(Block)                                      \
-  V(Declaration)                                \
    V(ExpressionStatement)                        \
    V(EmptyStatement)                             \
    V(IfStatement)                                \
@@ -69,7 +68,9 @@
    V(ForInStatement)                             \
    V(TryCatch)                                   \
    V(TryFinally)                                 \
-  V(DebuggerStatement)                          \
+  V(DebuggerStatement)
+
+#define EXPRESSION_NODE_LIST(V)                 \
    V(FunctionLiteral)                            \
    V(FunctionBoilerplateLiteral)                 \
    V(Conditional)                                \
@@ -93,6 +94,10 @@
    V(CompareOperation)                           \
    V(ThisFunction)

+#define AST_NODE_LIST(V)                        \
+  V(Declaration)                                \
+  STATEMENT_NODE_LIST(V)                        \
+  EXPRESSION_NODE_LIST(V)

  // Forward declarations
  class TargetCollector;
@@ -108,10 +113,10 @@
  typedef ZoneList<Handle<String> > ZoneStringList;


-class Node: public ZoneObject {
+class AstNode: public ZoneObject {
   public:
-  Node(): statement_pos_(RelocInfo::kNoPosition) { }
-  virtual ~Node() { }
+  AstNode(): statement_pos_(RelocInfo::kNoPosition) { }
+  virtual ~AstNode() { }
    virtual void Accept(AstVisitor* v) = 0;

    // Type testing & conversion.
@@ -143,7 +148,7 @@
  };


-class Statement: public Node {
+class Statement: public AstNode {
   public:
    virtual Statement* AsStatement()  { return this; }
    virtual ReturnStatement* AsReturnStatement() { return NULL; }
@@ -152,7 +157,7 @@
  };


-class Expression: public Node {
+class Expression: public AstNode {
   public:
    virtual Expression* AsExpression()  { return this; }

@@ -240,7 +245,7 @@
  };


-class Declaration: public Node {
+class Declaration: public AstNode {
   public:
    Declaration(VariableProxy* proxy, Variable::Mode mode, FunctionLiteral*  
fun)
        : proxy_(proxy),
@@ -523,7 +528,7 @@

  // NOTE: TargetCollectors are represented as nodes to fit in the target
  // stack in the compiler; this should probably be reworked.
-class TargetCollector: public Node {
+class TargetCollector: public AstNode {
   public:
    explicit TargetCollector(ZoneList<BreakTarget*>* targets)
        : targets_(targets) {
@@ -1678,7 +1683,7 @@
    virtual ~AstVisitor() { }

    // Dispatch
-  void Visit(Node* node) { node->Accept(this); }
+  void Visit(AstNode* node) { node->Accept(this); }

    // Iteration
    virtual void VisitStatements(ZoneList<Statement*>* statements);
=======================================
--- /branches/bleeding_edge/src/codegen.cc      Mon Jun 29 03:45:16 2009
+++ /branches/bleeding_edge/src/codegen.cc      Thu Jul 30 04:53:29 2009
@@ -496,7 +496,7 @@
  }


-void CodeGenerator::CodeForStatementPosition(Node* node) {
+void CodeGenerator::CodeForStatementPosition(AstNode* node) {
    if (FLAG_debug_info) {
      int pos = node->statement_pos();
      if (pos != RelocInfo::kNoPosition) {
=======================================
--- /branches/bleeding_edge/src/ia32/codegen-ia32.h     Mon Jun 29 03:45:16 2009
+++ /branches/bleeding_edge/src/ia32/codegen-ia32.h     Thu Jul 30 04:53:29 2009
@@ -558,7 +558,7 @@
    // information.
    void CodeForFunctionPosition(FunctionLiteral* fun);
    void CodeForReturnPosition(FunctionLiteral* fun);
-  void CodeForStatementPosition(Node* node);
+  void CodeForStatementPosition(AstNode* node);
    void CodeForSourcePosition(int pos);

  #ifdef DEBUG
=======================================
--- /branches/bleeding_edge/src/parser.cc       Wed Jul 22 05:33:16 2009
+++ /branches/bleeding_edge/src/parser.cc       Thu Jul 30 04:53:29 2009
@@ -1059,7 +1059,7 @@

  class Target BASE_EMBEDDED {
   public:
-  Target(Parser* parser, Node* node)
+  Target(Parser* parser, AstNode* node)
        : parser_(parser), node_(node), previous_(parser_->target_stack_) {
      parser_->target_stack_ = this;
    }
@@ -1069,11 +1069,11 @@
    }

    Target* previous() { return previous_; }
-  Node* node() { return node_; }
+  AstNode* node() { return node_; }

   private:
    Parser* parser_;
-  Node* node_;
+  AstNode* node_;
    Target* previous_;
  };

=======================================
--- /branches/bleeding_edge/src/prettyprinter.cc        Wed Jul 29 01:46:28 2009
+++ /branches/bleeding_edge/src/prettyprinter.cc        Thu Jul 30 04:53:29 2009
@@ -417,7 +417,7 @@
  }


-const char* PrettyPrinter::Print(Node* node) {
+const char* PrettyPrinter::Print(AstNode* node) {
    Init();
    Visit(node);
    return output_;
@@ -441,7 +441,7 @@
  }


-void PrettyPrinter::PrintOut(Node* node) {
+void PrettyPrinter::PrintOut(AstNode* node) {
    PrettyPrinter printer;
    PrintF("%s", printer.Print(node));
  }
@@ -700,7 +700,7 @@
  }


-void AstPrinter::PrintIndentedVisit(const char* s, Node* node) {
+void AstPrinter::PrintIndentedVisit(const char* s, AstNode* node) {
    IndentedScope indent(s);
    Visit(node);
  }
=======================================
--- /branches/bleeding_edge/src/prettyprinter.h Mon May 25 03:05:56 2009
+++ /branches/bleeding_edge/src/prettyprinter.h Thu Jul 30 04:53:29 2009
@@ -42,12 +42,12 @@

    // The following routines print a node into a string.
    // The result string is alive as long as the PrettyPrinter is alive.
-  const char* Print(Node* node);
+  const char* Print(AstNode* node);
    const char* PrintExpression(FunctionLiteral* program);
    const char* PrintProgram(FunctionLiteral* program);

    // Print a node to stdout.
-  static void PrintOut(Node* node);
+  static void PrintOut(AstNode* node);

    // Individual nodes
  #define DEF_VISIT(type)                         \
@@ -92,7 +92,7 @@
   private:
    friend class IndentedScope;
    void PrintIndented(const char* txt);
-  void PrintIndentedVisit(const char* s, Node* node);
+  void PrintIndentedVisit(const char* s, AstNode* node);

    void PrintStatements(ZoneList<Statement*>* statements);
    void PrintDeclarations(ZoneList<Declaration*>* declarations);
=======================================
--- /branches/bleeding_edge/src/usage-analyzer.cc       Mon May 25 03:05:56 2009
+++ /branches/bleeding_edge/src/usage-analyzer.cc       Thu Jul 30 04:53:29 2009
@@ -42,7 +42,7 @@

  class UsageComputer: public AstVisitor {
   public:
-  static bool Traverse(Node* node);
+  static bool Traverse(AstNode* node);

    void VisitBlock(Block* node);
    void VisitDeclaration(Declaration* node);
@@ -116,7 +116,7 @@
  //  
----------------------------------------------------------------------------
  // Implementation of UsageComputer

-bool UsageComputer::Traverse(Node* node) {
+bool UsageComputer::Traverse(AstNode* node) {
    UsageComputer uc(InitialWeight, false);
    uc.Visit(node);
    return !uc.HasStackOverflow();
=======================================
--- /branches/bleeding_edge/src/x64/codegen-x64.h       Tue Jul  7 06:17:22 2009
+++ /branches/bleeding_edge/src/x64/codegen-x64.h       Thu Jul 30 04:53:29 2009
@@ -361,7 +361,7 @@

  #define DEF_VISIT(type) \
    void Visit##type(type* node);
-  NODE_LIST(DEF_VISIT)
+  AST_NODE_LIST(DEF_VISIT)
  #undef DEF_VISIT

    // Visit a statement and then spill the virtual frame if control flow can
@@ -548,7 +548,7 @@
    // information.
    void CodeForFunctionPosition(FunctionLiteral* fun);
    void CodeForReturnPosition(FunctionLiteral* fun);
-  void CodeForStatementPosition(Node* node);
+  void CodeForStatementPosition(AstNode* node);
    void CodeForSourcePosition(int pos);

  #ifdef DEBUG

--~--~---------~--~----~------------~-------~--~----~
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
-~----------~----~----~----~------~----~------~--~---

Reply via email to