Reviewers: Sven Panne,

Description:
Slightly simplify declaration of node types.


[email protected]
BUG=


Please review this at https://chromiumcodereview.appspot.com/10886010/

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

Affected files:
  M src/ast.h


Index: src/ast.h
diff --git a/src/ast.h b/src/ast.h
index 32d87bd732d07c33318a7c8631a8487bdf9e7ea5..dc6795de8c7fdd48d8c9aa610007d33109531777 100644
--- a/src/ast.h
+++ b/src/ast.h
@@ -158,7 +158,8 @@ typedef ZoneList<Handle<Object> > ZoneObjectList;

 #define DECLARE_NODE_TYPE(type)                                         \
   virtual void Accept(AstVisitor* v);                                   \
-  virtual AstNode::Type node_type() const { return AstNode::k##type; }
+  virtual AstNode::Type node_type() const { return AstNode::k##type; }  \
+  template<class> friend class AstNodeFactory;


 enum AstPropertiesFlag {
@@ -419,8 +420,6 @@ class Block: public BreakableStatement {
   void set_scope(Scope* scope) { scope_ = scope; }

  protected:
-  template<class> friend class AstNodeFactory;
-
   Block(Isolate* isolate,
         ZoneStringList* labels,
         int capacity,
@@ -478,8 +477,6 @@ class VariableDeclaration: public Declaration {
   }

  protected:
-  template<class> friend class AstNodeFactory;
-
   VariableDeclaration(VariableProxy* proxy,
                       VariableMode mode,
                       Scope* scope)
@@ -499,8 +496,6 @@ class FunctionDeclaration: public Declaration {
   virtual bool IsInlineable() const;

  protected:
-  template<class> friend class AstNodeFactory;
-
   FunctionDeclaration(VariableProxy* proxy,
                       VariableMode mode,
                       FunctionLiteral* fun,
@@ -527,8 +522,6 @@ class ModuleDeclaration: public Declaration {
   }

  protected:
-  template<class> friend class AstNodeFactory;
-
   ModuleDeclaration(VariableProxy* proxy,
                     Module* module,
                     Scope* scope)
@@ -551,8 +544,6 @@ class ImportDeclaration: public Declaration {
   }

  protected:
-  template<class> friend class AstNodeFactory;
-
   ImportDeclaration(VariableProxy* proxy,
                     Module* module,
                     Scope* scope)
@@ -574,8 +565,6 @@ class ExportDeclaration: public Declaration {
   }

  protected:
-  template<class> friend class AstNodeFactory;
-
   ExportDeclaration(VariableProxy* proxy, Scope* scope)
       : Declaration(proxy, LET, scope) {}
 };
@@ -605,8 +594,6 @@ class ModuleLiteral: public Module {
   DECLARE_NODE_TYPE(ModuleLiteral)

  protected:
-  template<class> friend class AstNodeFactory;
-
ModuleLiteral(Block* body, Interface* interface) : Module(interface, body) {}
 };

@@ -618,8 +605,6 @@ class ModuleVariable: public Module {
   VariableProxy* proxy() const { return proxy_; }

  protected:
-  template<class> friend class AstNodeFactory;
-
   inline explicit ModuleVariable(VariableProxy* proxy);

  private:
@@ -635,8 +620,6 @@ class ModulePath: public Module {
   Handle<String> name() const { return name_; }

  protected:
-  template<class> friend class AstNodeFactory;
-
   ModulePath(Module* module, Handle<String> name, Zone* zone)
       : Module(zone),
         module_(module),
@@ -656,8 +639,6 @@ class ModuleUrl: public Module {
   Handle<String> url() const { return url_; }

  protected:
-  template<class> friend class AstNodeFactory;
-
   ModuleUrl(Handle<String> url, Zone* zone)
       : Module(zone), url_(url) {
   }
@@ -720,8 +701,6 @@ class DoWhileStatement: public IterationStatement {
   BailoutId BackEdgeId() const { return back_edge_id_; }

  protected:
-  template<class> friend class AstNodeFactory;
-
   DoWhileStatement(Isolate* isolate, ZoneStringList* labels)
       : IterationStatement(isolate, labels),
         cond_(NULL),
@@ -760,8 +739,6 @@ class WhileStatement: public IterationStatement {
   BailoutId BodyId() const { return body_id_; }

  protected:
-  template<class> friend class AstNodeFactory;
-
   WhileStatement(Isolate* isolate, ZoneStringList* labels)
       : IterationStatement(isolate, labels),
         cond_(NULL),
@@ -811,8 +788,6 @@ class ForStatement: public IterationStatement {
   void set_loop_variable(Variable* var) { loop_variable_ = var; }

  protected:
-  template<class> friend class AstNodeFactory;
-
   ForStatement(Isolate* isolate, ZoneStringList* labels)
       : IterationStatement(isolate, labels),
         init_(NULL),
@@ -857,8 +832,6 @@ class ForInStatement: public IterationStatement {
   TypeFeedbackId ForInFeedbackId() const { return reuse(PrepareId()); }

  protected:
-  template<class> friend class AstNodeFactory;
-
   ForInStatement(Isolate* isolate, ZoneStringList* labels)
       : IterationStatement(isolate, labels),
         each_(NULL),
@@ -883,8 +856,6 @@ class ExpressionStatement: public Statement {
   Expression* expression() const { return expression_; }

  protected:
-  template<class> friend class AstNodeFactory;
-
   explicit ExpressionStatement(Expression* expression)
       : expression_(expression) { }

@@ -900,8 +871,6 @@ class ContinueStatement: public Statement {
   IterationStatement* target() const { return target_; }

  protected:
-  template<class> friend class AstNodeFactory;
-
   explicit ContinueStatement(IterationStatement* target)
       : target_(target) { }

@@ -917,8 +886,6 @@ class BreakStatement: public Statement {
   BreakableStatement* target() const { return target_; }

  protected:
-  template<class> friend class AstNodeFactory;
-
   explicit BreakStatement(BreakableStatement* target)
       : target_(target) { }

@@ -934,8 +901,6 @@ class ReturnStatement: public Statement {
   Expression* expression() const { return expression_; }

  protected:
-  template<class> friend class AstNodeFactory;
-
   explicit ReturnStatement(Expression* expression)
       : expression_(expression) { }

@@ -952,8 +917,6 @@ class WithStatement: public Statement {
   Statement* statement() const { return statement_; }

  protected:
-  template<class> friend class AstNodeFactory;
-
   WithStatement(Expression* expression, Statement* statement)
       : expression_(expression),
         statement_(statement) { }
@@ -1023,8 +986,6 @@ class SwitchStatement: public BreakableStatement {
   ZoneList<CaseClause*>* cases() const { return cases_; }

  protected:
-  template<class> friend class AstNodeFactory;
-
   SwitchStatement(Isolate* isolate, ZoneStringList* labels)
       : BreakableStatement(isolate, labels, TARGET_FOR_ANONYMOUS),
         tag_(NULL),
@@ -1057,8 +1018,6 @@ class IfStatement: public Statement {
   BailoutId ElseId() const { return else_id_; }

  protected:
-  template<class> friend class AstNodeFactory;
-
   IfStatement(Isolate* isolate,
               Expression* condition,
               Statement* then_statement,
@@ -1138,8 +1097,6 @@ class TryCatchStatement: public TryStatement {
   Block* catch_block() const { return catch_block_; }

  protected:
-  template<class> friend class AstNodeFactory;
-
   TryCatchStatement(int index,
                     Block* try_block,
                     Scope* scope,
@@ -1165,8 +1122,6 @@ class TryFinallyStatement: public TryStatement {
   Block* finally_block() const { return finally_block_; }

  protected:
-  template<class> friend class AstNodeFactory;
-
   TryFinallyStatement(int index, Block* try_block, Block* finally_block)
       : TryStatement(index, try_block),
         finally_block_(finally_block) { }
@@ -1181,8 +1136,6 @@ class DebuggerStatement: public Statement {
   DECLARE_NODE_TYPE(DebuggerStatement)

  protected:
-  template<class> friend class AstNodeFactory;
-
   DebuggerStatement() {}
 };

@@ -1192,8 +1145,6 @@ class EmptyStatement: public Statement {
   DECLARE_NODE_TYPE(EmptyStatement)

  protected:
-  template<class> friend class AstNodeFactory;
-
   EmptyStatement() {}
 };

@@ -1247,8 +1198,6 @@ class Literal: public Expression {
   TypeFeedbackId LiteralFeedbackId() const { return reuse(id()); }

  protected:
-  template<class> friend class AstNodeFactory;
-
   Literal(Isolate* isolate, Handle<Object> handle)
       : Expression(isolate),
         handle_(handle) { }
@@ -1366,8 +1315,6 @@ class ObjectLiteral: public MaterializedLiteral {
   };

  protected:
-  template<class> friend class AstNodeFactory;
-
   ObjectLiteral(Isolate* isolate,
                 Handle<FixedArray> constant_properties,
                 ZoneList<Property*>* properties,
@@ -1399,8 +1346,6 @@ class RegExpLiteral: public MaterializedLiteral {
   Handle<String> flags() const { return flags_; }

  protected:
-  template<class> friend class AstNodeFactory;
-
   RegExpLiteral(Isolate* isolate,
                 Handle<String> pattern,
                 Handle<String> flags,
@@ -1429,8 +1374,6 @@ class ArrayLiteral: public MaterializedLiteral {
   }

  protected:
-  template<class> friend class AstNodeFactory;
-
   ArrayLiteral(Isolate* isolate,
                Handle<FixedArray> constant_elements,
                ZoneList<Expression*>* values,
@@ -1481,8 +1424,6 @@ class VariableProxy: public Expression {
   void BindTo(Variable* var);

  protected:
-  template<class> friend class AstNodeFactory;
-
   VariableProxy(Isolate* isolate, Variable* var);

   VariableProxy(Isolate* isolate,
@@ -1528,8 +1469,6 @@ class Property: public Expression {
   TypeFeedbackId PropertyFeedbackId() { return reuse(id()); }

  protected:
-  template<class> friend class AstNodeFactory;
-
   Property(Isolate* isolate,
            Expression* obj,
            Expression* key,
@@ -1596,8 +1535,6 @@ class Call: public Expression {
 #endif

  protected:
-  template<class> friend class AstNodeFactory;
-
   Call(Isolate* isolate,
        Expression* expression,
        ZoneList<Expression*>* arguments,
@@ -1643,8 +1580,6 @@ class CallNew: public Expression {
   BailoutId ReturnId() const { return return_id_; }

  protected:
-  template<class> friend class AstNodeFactory;
-
   CallNew(Isolate* isolate,
           Expression* expression,
           ZoneList<Expression*>* arguments,
@@ -1684,8 +1619,6 @@ class CallRuntime: public Expression {
   TypeFeedbackId CallRuntimeFeedbackId() const { return reuse(id()); }

  protected:
-  template<class> friend class AstNodeFactory;
-
   CallRuntime(Isolate* isolate,
               Handle<String> name,
               const Runtime::Function* function,
@@ -1718,8 +1651,6 @@ class UnaryOperation: public Expression {
   TypeFeedbackId UnaryOperationFeedbackId() const { return reuse(id()); }

  protected:
-  template<class> friend class AstNodeFactory;
-
   UnaryOperation(Isolate* isolate,
                  Token::Value op,
                  Expression* expression,
@@ -1761,8 +1692,6 @@ class BinaryOperation: public Expression {
   TypeFeedbackId BinaryOperationFeedbackId() const { return reuse(id()); }

  protected:
-  template<class> friend class AstNodeFactory;
-
   BinaryOperation(Isolate* isolate,
                   Token::Value op,
                   Expression* left,
@@ -1815,8 +1744,6 @@ class CountOperation: public Expression {
   TypeFeedbackId CountStoreFeedbackId() const { return reuse(id()); }

  protected:
-  template<class> friend class AstNodeFactory;
-
   CountOperation(Isolate* isolate,
                  Token::Value op,
                  bool is_prefix,
@@ -1863,8 +1790,6 @@ class CompareOperation: public Expression {
   bool IsLiteralCompareNull(Expression** expr);

  protected:
-  template<class> friend class AstNodeFactory;
-
   CompareOperation(Isolate* isolate,
                    Token::Value op,
                    Expression* left,
@@ -1905,8 +1830,6 @@ class Conditional: public Expression {
   BailoutId ElseId() const { return else_id_; }

  protected:
-  template<class> friend class AstNodeFactory;
-
   Conditional(Isolate* isolate,
               Expression* condition,
               Expression* then_expression,
@@ -1968,8 +1891,6 @@ class Assignment: public Expression {
   virtual SmallMapList* GetReceiverTypes() { return &receiver_types_; }

  protected:
-  template<class> friend class AstNodeFactory;
-
   Assignment(Isolate* isolate,
              Token::Value op,
              Expression* target,
@@ -2009,8 +1930,6 @@ class Throw: public Expression {
   virtual int position() const { return pos_; }

  protected:
-  template<class> friend class AstNodeFactory;
-
   Throw(Isolate* isolate, Expression* exception, int pos)
       : Expression(isolate), exception_(exception), pos_(pos) {}

@@ -2110,8 +2029,6 @@ class FunctionLiteral: public Expression {
   }

  protected:
-  template<class> friend class AstNodeFactory;
-
   FunctionLiteral(Isolate* isolate,
                   Handle<String> name,
                   Scope* scope,
@@ -2182,8 +2099,6 @@ class SharedFunctionInfoLiteral: public Expression {
   }

  protected:
-  template<class> friend class AstNodeFactory;
-
   SharedFunctionInfoLiteral(
       Isolate* isolate,
       Handle<SharedFunctionInfo> shared_function_info)
@@ -2200,8 +2115,6 @@ class ThisFunction: public Expression {
   DECLARE_NODE_TYPE(ThisFunction)

  protected:
-  template<class> friend class AstNodeFactory;
-
   explicit ThisFunction(Isolate* isolate): Expression(isolate) {}
 };



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

Reply via email to