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

Side by Side Diff: src/ast/ast.h

Issue 2219853002: Cleanup: Declaration doesn't need to know Zone. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 4 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_AST_AST_H_ 5 #ifndef V8_AST_AST_H_
6 #define V8_AST_AST_H_ 6 #define V8_AST_AST_H_
7 7
8 #include "src/ast/ast-value-factory.h" 8 #include "src/ast/ast-value-factory.h"
9 #include "src/ast/modules.h" 9 #include "src/ast/modules.h"
10 #include "src/ast/variables.h" 10 #include "src/ast/variables.h"
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 501
502 502
503 class Declaration : public AstNode { 503 class Declaration : public AstNode {
504 public: 504 public:
505 VariableProxy* proxy() const { return proxy_; } 505 VariableProxy* proxy() const { return proxy_; }
506 VariableMode mode() const { return mode_; } 506 VariableMode mode() const { return mode_; }
507 Scope* scope() const { return scope_; } 507 Scope* scope() const { return scope_; }
508 InitializationFlag initialization() const; 508 InitializationFlag initialization() const;
509 509
510 protected: 510 protected:
511 Declaration(Zone* zone, VariableProxy* proxy, VariableMode mode, Scope* scope, 511 Declaration(VariableProxy* proxy, VariableMode mode, Scope* scope, int pos,
512 int pos, NodeType type) 512 NodeType type)
513 : AstNode(pos, type), mode_(mode), proxy_(proxy), scope_(scope) { 513 : AstNode(pos, type), mode_(mode), proxy_(proxy), scope_(scope) {
514 DCHECK(IsDeclaredVariableMode(mode)); 514 DCHECK(IsDeclaredVariableMode(mode));
515 } 515 }
516 516
517 private: 517 private:
518 VariableMode mode_; 518 VariableMode mode_;
519 VariableProxy* proxy_; 519 VariableProxy* proxy_;
520 520
521 // Nested scope from which the declaration originated. 521 // Nested scope from which the declaration originated.
522 Scope* scope_; 522 Scope* scope_;
523 }; 523 };
524 524
525 525
526 class VariableDeclaration final : public Declaration { 526 class VariableDeclaration final : public Declaration {
527 public: 527 public:
528 DECLARE_NODE_TYPE(VariableDeclaration) 528 DECLARE_NODE_TYPE(VariableDeclaration)
529 529
530 InitializationFlag initialization() const { 530 InitializationFlag initialization() const {
531 return mode() == VAR ? kCreatedInitialized : kNeedsInitialization; 531 return mode() == VAR ? kCreatedInitialized : kNeedsInitialization;
532 } 532 }
533 533
534 protected: 534 protected:
535 VariableDeclaration(Zone* zone, VariableProxy* proxy, VariableMode mode, 535 VariableDeclaration(VariableProxy* proxy, VariableMode mode, Scope* scope,
536 Scope* scope, int pos) 536 int pos)
537 : Declaration(zone, proxy, mode, scope, pos, kVariableDeclaration) {} 537 : Declaration(proxy, mode, scope, pos, kVariableDeclaration) {}
538 }; 538 };
539 539
540 540
541 class FunctionDeclaration final : public Declaration { 541 class FunctionDeclaration final : public Declaration {
542 public: 542 public:
543 DECLARE_NODE_TYPE(FunctionDeclaration) 543 DECLARE_NODE_TYPE(FunctionDeclaration)
544 544
545 FunctionLiteral* fun() const { return fun_; } 545 FunctionLiteral* fun() const { return fun_; }
546 void set_fun(FunctionLiteral* f) { fun_ = f; } 546 void set_fun(FunctionLiteral* f) { fun_ = f; }
547 InitializationFlag initialization() const { return kCreatedInitialized; } 547 InitializationFlag initialization() const { return kCreatedInitialized; }
548 548
549 protected: 549 protected:
550 FunctionDeclaration(Zone* zone, VariableProxy* proxy, VariableMode mode, 550 FunctionDeclaration(VariableProxy* proxy, VariableMode mode,
551 FunctionLiteral* fun, Scope* scope, int pos) 551 FunctionLiteral* fun, Scope* scope, int pos)
552 : Declaration(zone, proxy, mode, scope, pos, kFunctionDeclaration), 552 : Declaration(proxy, mode, scope, pos, kFunctionDeclaration), fun_(fun) {
553 fun_(fun) {
554 DCHECK(mode == VAR || mode == LET || mode == CONST); 553 DCHECK(mode == VAR || mode == LET || mode == CONST);
555 DCHECK(fun != NULL); 554 DCHECK(fun != NULL);
556 } 555 }
557 556
558 private: 557 private:
559 FunctionLiteral* fun_; 558 FunctionLiteral* fun_;
560 }; 559 };
561 560
562 561
563 class IterationStatement : public BreakableStatement { 562 class IterationStatement : public BreakableStatement {
(...skipping 2489 matching lines...) Expand 10 before | Expand all | Expand 10 after
3053 3052
3054 AstValueFactory* ast_value_factory() const { return ast_value_factory_; } 3053 AstValueFactory* ast_value_factory() const { return ast_value_factory_; }
3055 void set_ast_value_factory(AstValueFactory* ast_value_factory) { 3054 void set_ast_value_factory(AstValueFactory* ast_value_factory) {
3056 ast_value_factory_ = ast_value_factory; 3055 ast_value_factory_ = ast_value_factory;
3057 zone_ = ast_value_factory->zone(); 3056 zone_ = ast_value_factory->zone();
3058 } 3057 }
3059 3058
3060 VariableDeclaration* NewVariableDeclaration(VariableProxy* proxy, 3059 VariableDeclaration* NewVariableDeclaration(VariableProxy* proxy,
3061 VariableMode mode, Scope* scope, 3060 VariableMode mode, Scope* scope,
3062 int pos) { 3061 int pos) {
3063 return new (zone_) VariableDeclaration(zone_, proxy, mode, scope, pos); 3062 return new (zone_) VariableDeclaration(proxy, mode, scope, pos);
3064 } 3063 }
3065 3064
3066 FunctionDeclaration* NewFunctionDeclaration(VariableProxy* proxy, 3065 FunctionDeclaration* NewFunctionDeclaration(VariableProxy* proxy,
3067 VariableMode mode, 3066 VariableMode mode,
3068 FunctionLiteral* fun, 3067 FunctionLiteral* fun,
3069 Scope* scope, 3068 Scope* scope,
3070 int pos) { 3069 int pos) {
3071 return new (zone_) FunctionDeclaration(zone_, proxy, mode, fun, scope, pos); 3070 return new (zone_) FunctionDeclaration(proxy, mode, fun, scope, pos);
3072 } 3071 }
3073 3072
3074 Block* NewBlock(ZoneList<const AstRawString*>* labels, int capacity, 3073 Block* NewBlock(ZoneList<const AstRawString*>* labels, int capacity,
3075 bool ignore_completion_value, int pos) { 3074 bool ignore_completion_value, int pos) {
3076 return new (zone_) 3075 return new (zone_)
3077 Block(zone_, labels, capacity, ignore_completion_value, pos); 3076 Block(zone_, labels, capacity, ignore_completion_value, pos);
3078 } 3077 }
3079 3078
3080 #define STATEMENT_WITH_LABELS(NodeType) \ 3079 #define STATEMENT_WITH_LABELS(NodeType) \
3081 NodeType* New##NodeType(ZoneList<const AstRawString*>* labels, int pos) { \ 3080 NodeType* New##NodeType(ZoneList<const AstRawString*>* labels, int pos) { \
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
3530 : NULL; \ 3529 : NULL; \
3531 } 3530 }
3532 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) 3531 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS)
3533 #undef DECLARE_NODE_FUNCTIONS 3532 #undef DECLARE_NODE_FUNCTIONS
3534 3533
3535 3534
3536 } // namespace internal 3535 } // namespace internal
3537 } // namespace v8 3536 } // namespace v8
3538 3537
3539 #endif // V8_AST_AST_H_ 3538 #endif // V8_AST_AST_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698