Chromium Code Reviews| Index: src/ast/ast.h |
| diff --git a/src/ast/ast.h b/src/ast/ast.h |
| index 1457a315c6531c490c6757f4901a3ede7b110072..9a70a6a31400816499e09d570ac5d64a7a1a0e91 100644 |
| --- a/src/ast/ast.h |
| +++ b/src/ast/ast.h |
| @@ -131,10 +131,6 @@ typedef ZoneList<Handle<String>> ZoneStringList; |
| typedef ZoneList<Handle<Object>> ZoneObjectList; |
| -#define DECLARE_NODE_TYPE(type) \ |
| - friend class AstNodeFactory; |
| - |
| - |
| class FeedbackVectorSlotCache { |
| public: |
| explicit FeedbackVectorSlotCache(Zone* zone) |
| @@ -432,7 +428,7 @@ class BreakableStatement : public Statement { |
| class Block final : public BreakableStatement { |
| public: |
| - DECLARE_NODE_TYPE(Block) |
| + friend class AstNodeFactory; |
|
adamk
2016/08/05 21:52:35
I think we generally put friend declarations in th
|
| ZoneList<Statement*>* statements() { return &statements_; } |
| bool ignore_completion_value() const { return ignore_completion_value_; } |
| @@ -468,7 +464,7 @@ class Block final : public BreakableStatement { |
| class DoExpression final : public Expression { |
| public: |
| - DECLARE_NODE_TYPE(DoExpression) |
| + friend class AstNodeFactory; |
| Block* block() { return block_; } |
| void set_block(Block* b) { block_ = b; } |
| @@ -525,7 +521,7 @@ class Declaration : public AstNode { |
| class VariableDeclaration final : public Declaration { |
| public: |
| - DECLARE_NODE_TYPE(VariableDeclaration) |
| + friend class AstNodeFactory; |
| InitializationFlag initialization() const { |
| return mode() == VAR ? kCreatedInitialized : kNeedsInitialization; |
| @@ -540,7 +536,7 @@ class VariableDeclaration final : public Declaration { |
| class FunctionDeclaration final : public Declaration { |
| public: |
| - DECLARE_NODE_TYPE(FunctionDeclaration) |
| + friend class AstNodeFactory; |
| FunctionLiteral* fun() const { return fun_; } |
| void set_fun(FunctionLiteral* f) { fun_ = f; } |
| @@ -600,7 +596,7 @@ class IterationStatement : public BreakableStatement { |
| class DoWhileStatement final : public IterationStatement { |
| public: |
| - DECLARE_NODE_TYPE(DoWhileStatement) |
| + friend class AstNodeFactory; |
| void Initialize(Expression* cond, Statement* body) { |
| IterationStatement::Initialize(body); |
| @@ -629,7 +625,7 @@ class DoWhileStatement final : public IterationStatement { |
| class WhileStatement final : public IterationStatement { |
| public: |
| - DECLARE_NODE_TYPE(WhileStatement) |
| + friend class AstNodeFactory; |
| void Initialize(Expression* cond, Statement* body) { |
| IterationStatement::Initialize(body); |
| @@ -658,7 +654,7 @@ class WhileStatement final : public IterationStatement { |
| class ForStatement final : public IterationStatement { |
| public: |
| - DECLARE_NODE_TYPE(ForStatement) |
| + friend class AstNodeFactory; |
| void Initialize(Statement* init, |
| Expression* cond, |
| @@ -722,7 +718,7 @@ class ForEachStatement : public IterationStatement { |
| class ForInStatement final : public ForEachStatement { |
| public: |
| - DECLARE_NODE_TYPE(ForInStatement) |
| + friend class AstNodeFactory; |
| void Initialize(Expression* each, Expression* subject, Statement* body) { |
| ForEachStatement::Initialize(body); |
| @@ -784,7 +780,7 @@ class ForInStatement final : public ForEachStatement { |
| class ForOfStatement final : public ForEachStatement { |
| public: |
| - DECLARE_NODE_TYPE(ForOfStatement) |
| + friend class AstNodeFactory; |
| void Initialize(Statement* body, Variable* iterator, |
| Expression* assign_iterator, Expression* next_result, |
| @@ -855,7 +851,7 @@ class ForOfStatement final : public ForEachStatement { |
| class ExpressionStatement final : public Statement { |
| public: |
| - DECLARE_NODE_TYPE(ExpressionStatement) |
| + friend class AstNodeFactory; |
| void set_expression(Expression* e) { expression_ = e; } |
| Expression* expression() const { return expression_; } |
| @@ -882,7 +878,7 @@ class JumpStatement : public Statement { |
| class ContinueStatement final : public JumpStatement { |
| public: |
| - DECLARE_NODE_TYPE(ContinueStatement) |
| + friend class AstNodeFactory; |
| IterationStatement* target() const { return target_; } |
| @@ -897,7 +893,7 @@ class ContinueStatement final : public JumpStatement { |
| class BreakStatement final : public JumpStatement { |
| public: |
| - DECLARE_NODE_TYPE(BreakStatement) |
| + friend class AstNodeFactory; |
| BreakableStatement* target() const { return target_; } |
| @@ -912,7 +908,7 @@ class BreakStatement final : public JumpStatement { |
| class ReturnStatement final : public JumpStatement { |
| public: |
| - DECLARE_NODE_TYPE(ReturnStatement) |
| + friend class AstNodeFactory; |
| Expression* expression() const { return expression_; } |
| @@ -929,7 +925,7 @@ class ReturnStatement final : public JumpStatement { |
| class WithStatement final : public Statement { |
| public: |
| - DECLARE_NODE_TYPE(WithStatement) |
| + friend class AstNodeFactory; |
| Scope* scope() { return scope_; } |
| Expression* expression() const { return expression_; } |
| @@ -969,7 +965,7 @@ class WithStatement final : public Statement { |
| class CaseClause final : public Expression { |
| public: |
| - DECLARE_NODE_TYPE(CaseClause) |
| + friend class AstNodeFactory; |
| bool is_default() const { return label_ == NULL; } |
| Expression* label() const { |
| @@ -1004,7 +1000,7 @@ class CaseClause final : public Expression { |
| class SwitchStatement final : public BreakableStatement { |
| public: |
| - DECLARE_NODE_TYPE(SwitchStatement) |
| + friend class AstNodeFactory; |
| void Initialize(Expression* tag, ZoneList<CaseClause*>* cases) { |
| tag_ = tag; |
| @@ -1036,7 +1032,7 @@ class SwitchStatement final : public BreakableStatement { |
| // given if-statement has a then- or an else-part containing code. |
| class IfStatement final : public Statement { |
| public: |
| - DECLARE_NODE_TYPE(IfStatement) |
| + friend class AstNodeFactory; |
| bool HasThenStatement() const { return !then_statement()->IsEmpty(); } |
| bool HasElseStatement() const { return !else_statement()->IsEmpty(); } |
| @@ -1122,7 +1118,7 @@ class TryStatement : public Statement { |
| class TryCatchStatement final : public TryStatement { |
| public: |
| - DECLARE_NODE_TYPE(TryCatchStatement) |
| + friend class AstNodeFactory; |
| Scope* scope() { return scope_; } |
| Variable* variable() { return variable_; } |
| @@ -1163,7 +1159,7 @@ class TryCatchStatement final : public TryStatement { |
| class TryFinallyStatement final : public TryStatement { |
| public: |
| - DECLARE_NODE_TYPE(TryFinallyStatement) |
| + friend class AstNodeFactory; |
| Block* finally_block() const { return finally_block_; } |
| void set_finally_block(Block* b) { finally_block_ = b; } |
| @@ -1181,7 +1177,7 @@ class TryFinallyStatement final : public TryStatement { |
| class DebuggerStatement final : public Statement { |
| public: |
| - DECLARE_NODE_TYPE(DebuggerStatement) |
| + friend class AstNodeFactory; |
| void set_base_id(int id) { base_id_ = id; } |
| static int num_ids() { return parent_num_ids() + 1; } |
| @@ -1207,7 +1203,7 @@ class DebuggerStatement final : public Statement { |
| class EmptyStatement final : public Statement { |
| public: |
| - DECLARE_NODE_TYPE(EmptyStatement) |
| + friend class AstNodeFactory; |
| protected: |
| EmptyStatement(Zone* zone, int pos) : Statement(zone, pos, kEmptyStatement) {} |
| @@ -1220,7 +1216,7 @@ class EmptyStatement final : public Statement { |
| // from one statement to another during parsing. |
| class SloppyBlockFunctionStatement final : public Statement { |
| public: |
| - DECLARE_NODE_TYPE(SloppyBlockFunctionStatement) |
| + friend class AstNodeFactory; |
| Statement* statement() const { return statement_; } |
| void set_statement(Statement* statement) { statement_ = statement; } |
| @@ -1239,7 +1235,7 @@ class SloppyBlockFunctionStatement final : public Statement { |
| class Literal final : public Expression { |
| public: |
| - DECLARE_NODE_TYPE(Literal) |
| + friend class AstNodeFactory; |
| bool IsPropertyName() const { return value_->IsPropertyName(); } |
| @@ -1406,7 +1402,7 @@ class ObjectLiteral final : public MaterializedLiteral { |
| public: |
| typedef ObjectLiteralProperty Property; |
| - DECLARE_NODE_TYPE(ObjectLiteral) |
| + friend class AstNodeFactory; |
| Handle<FixedArray> constant_properties() const { |
| return constant_properties_; |
| @@ -1526,7 +1522,7 @@ class AccessorTable |
| // Node for capturing a regexp literal. |
| class RegExpLiteral final : public MaterializedLiteral { |
| public: |
| - DECLARE_NODE_TYPE(RegExpLiteral) |
| + friend class AstNodeFactory; |
| Handle<String> pattern() const { return pattern_->string(); } |
| int flags() const { return flags_; } |
| @@ -1550,7 +1546,7 @@ class RegExpLiteral final : public MaterializedLiteral { |
| // for minimizing the work when constructing it at runtime. |
| class ArrayLiteral final : public MaterializedLiteral { |
| public: |
| - DECLARE_NODE_TYPE(ArrayLiteral) |
| + friend class AstNodeFactory; |
| Handle<FixedArray> constant_elements() const { return constant_elements_; } |
| ElementsKind constant_elements_kind() const { |
| @@ -1625,7 +1621,7 @@ class ArrayLiteral final : public MaterializedLiteral { |
| class VariableProxy final : public Expression { |
| public: |
| - DECLARE_NODE_TYPE(VariableProxy) |
| + friend class AstNodeFactory; |
| bool IsValidReferenceExpression() const { |
| return !is_this() && !is_new_target(); |
| @@ -1729,7 +1725,7 @@ enum LhsKind { |
| class Property final : public Expression { |
| public: |
| - DECLARE_NODE_TYPE(Property) |
| + friend class AstNodeFactory; |
| bool IsValidReferenceExpression() const { return true; } |
| @@ -1823,7 +1819,7 @@ class Property final : public Expression { |
| class Call final : public Expression { |
| public: |
| - DECLARE_NODE_TYPE(Call) |
| + friend class AstNodeFactory; |
| Expression* expression() const { return expression_; } |
| ZoneList<Expression*>* arguments() const { return arguments_; } |
| @@ -1945,7 +1941,7 @@ class Call final : public Expression { |
| class CallNew final : public Expression { |
| public: |
| - DECLARE_NODE_TYPE(CallNew) |
| + friend class AstNodeFactory; |
| Expression* expression() const { return expression_; } |
| ZoneList<Expression*>* arguments() const { return arguments_; } |
| @@ -2014,7 +2010,7 @@ class CallNew final : public Expression { |
| // implemented in JavaScript (see "v8natives.js"). |
| class CallRuntime final : public Expression { |
| public: |
| - DECLARE_NODE_TYPE(CallRuntime) |
| + friend class AstNodeFactory; |
| ZoneList<Expression*>* arguments() const { return arguments_; } |
| bool is_jsruntime() const { return function_ == NULL; } |
| @@ -2062,7 +2058,7 @@ class CallRuntime final : public Expression { |
| class UnaryOperation final : public Expression { |
| public: |
| - DECLARE_NODE_TYPE(UnaryOperation) |
| + friend class AstNodeFactory; |
| Token::Value op() const { return op_; } |
| Expression* expression() const { return expression_; } |
| @@ -2095,7 +2091,7 @@ class UnaryOperation final : public Expression { |
| class BinaryOperation final : public Expression { |
| public: |
| - DECLARE_NODE_TYPE(BinaryOperation) |
| + friend class AstNodeFactory; |
| Token::Value op() const { return static_cast<Token::Value>(op_); } |
| Expression* left() const { return left_; } |
| @@ -2165,7 +2161,7 @@ class BinaryOperation final : public Expression { |
| class CountOperation final : public Expression { |
| public: |
| - DECLARE_NODE_TYPE(CountOperation) |
| + friend class AstNodeFactory; |
| bool is_prefix() const { return IsPrefixField::decode(bit_field_); } |
| bool is_postfix() const { return !is_prefix(); } |
| @@ -2238,7 +2234,7 @@ class CountOperation final : public Expression { |
| class CompareOperation final : public Expression { |
| public: |
| - DECLARE_NODE_TYPE(CompareOperation) |
| + friend class AstNodeFactory; |
| Token::Value op() const { return op_; } |
| Expression* left() const { return left_; } |
| @@ -2285,7 +2281,7 @@ class CompareOperation final : public Expression { |
| class Spread final : public Expression { |
| public: |
| - DECLARE_NODE_TYPE(Spread) |
| + friend class AstNodeFactory; |
| Expression* expression() const { return expression_; } |
| void set_expression(Expression* e) { expression_ = e; } |
| @@ -2311,7 +2307,7 @@ class Spread final : public Expression { |
| class Conditional final : public Expression { |
| public: |
| - DECLARE_NODE_TYPE(Conditional) |
| + friend class AstNodeFactory; |
| Expression* condition() const { return condition_; } |
| Expression* then_expression() const { return then_expression_; } |
| @@ -2350,7 +2346,7 @@ class Conditional final : public Expression { |
| class Assignment final : public Expression { |
| public: |
| - DECLARE_NODE_TYPE(Assignment) |
| + friend class AstNodeFactory; |
| Assignment* AsSimpleAssignment() { return !is_compound() ? this : NULL; } |
| @@ -2443,7 +2439,7 @@ class Assignment final : public Expression { |
| // node is not a RewritableExpression. |
| class RewritableExpression : public Expression { |
| public: |
| - DECLARE_NODE_TYPE(RewritableExpression) |
| + friend class AstNodeFactory; |
| Expression* expression() const { return expr_; } |
| bool is_rewritten() const { return is_rewritten_; } |
| @@ -2478,7 +2474,7 @@ class RewritableExpression : public Expression { |
| // desired, must be done beforehand (see the parser). |
| class Yield final : public Expression { |
| public: |
| - DECLARE_NODE_TYPE(Yield) |
| + friend class AstNodeFactory; |
| enum OnException { kOnExceptionThrow, kOnExceptionRethrow }; |
| @@ -2512,7 +2508,7 @@ class Yield final : public Expression { |
| class Throw final : public Expression { |
| public: |
| - DECLARE_NODE_TYPE(Throw) |
| + friend class AstNodeFactory; |
| Expression* exception() const { return exception_; } |
| void set_exception(Expression* e) { exception_ = e; } |
| @@ -2539,7 +2535,7 @@ class FunctionLiteral final : public Expression { |
| enum EagerCompileHint { kShouldEagerCompile, kShouldLazyCompile }; |
| - DECLARE_NODE_TYPE(FunctionLiteral) |
| + friend class AstNodeFactory; |
| Handle<String> name() const { return raw_name_->string(); } |
| const AstString* raw_name() const { return raw_name_; } |
| @@ -2724,7 +2720,7 @@ class ClassLiteral final : public Expression { |
| public: |
| typedef ObjectLiteralProperty Property; |
| - DECLARE_NODE_TYPE(ClassLiteral) |
| + friend class AstNodeFactory; |
| VariableProxy* class_variable_proxy() const { return class_variable_proxy_; } |
| Expression* extends() const { return extends_; } |
| @@ -2788,7 +2784,7 @@ class ClassLiteral final : public Expression { |
| class NativeFunctionLiteral final : public Expression { |
| public: |
| - DECLARE_NODE_TYPE(NativeFunctionLiteral) |
| + friend class AstNodeFactory; |
| Handle<String> name() const { return name_->string(); } |
| v8::Extension* extension() const { return extension_; } |
| @@ -2808,7 +2804,7 @@ class NativeFunctionLiteral final : public Expression { |
| class ThisFunction final : public Expression { |
| public: |
| - DECLARE_NODE_TYPE(ThisFunction) |
| + friend class AstNodeFactory; |
| protected: |
| ThisFunction(Zone* zone, int pos) : Expression(zone, pos, kThisFunction) {} |
| @@ -2817,7 +2813,7 @@ class ThisFunction final : public Expression { |
| class SuperPropertyReference final : public Expression { |
| public: |
| - DECLARE_NODE_TYPE(SuperPropertyReference) |
| + friend class AstNodeFactory; |
| VariableProxy* this_var() const { return this_var_; } |
| void set_this_var(VariableProxy* v) { this_var_ = v; } |
| @@ -2842,7 +2838,7 @@ class SuperPropertyReference final : public Expression { |
| class SuperCallReference final : public Expression { |
| public: |
| - DECLARE_NODE_TYPE(SuperCallReference) |
| + friend class AstNodeFactory; |
| VariableProxy* this_var() const { return this_var_; } |
| void set_this_var(VariableProxy* v) { this_var_ = v; } |
| @@ -2875,7 +2871,7 @@ class SuperCallReference final : public Expression { |
| // arguments and is not actually a valid expression. |
| class EmptyParentheses final : public Expression { |
| public: |
| - DECLARE_NODE_TYPE(EmptyParentheses) |
| + friend class AstNodeFactory; |
| private: |
| EmptyParentheses(Zone* zone, int pos) |
| @@ -2883,8 +2879,6 @@ class EmptyParentheses final : public Expression { |
| }; |
| -#undef DECLARE_NODE_TYPE |
| - |
| // ---------------------------------------------------------------------------- |
| // Basic visitor |