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

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

Issue 2226223002: [ast][parser] Remove redundant Declaration::mode_. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase 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 | src/ast/prettyprinter.cc » ('j') | 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 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 488
489 Block* block_; 489 Block* block_;
490 VariableProxy* result_; 490 VariableProxy* result_;
491 FunctionLiteral* represented_function_; 491 FunctionLiteral* represented_function_;
492 }; 492 };
493 493
494 494
495 class Declaration : public AstNode { 495 class Declaration : public AstNode {
496 public: 496 public:
497 VariableProxy* proxy() const { return proxy_; } 497 VariableProxy* proxy() const { return proxy_; }
498 VariableMode mode() const { return mode_; }
499 Scope* scope() const { return scope_; } 498 Scope* scope() const { return scope_; }
500 499
501 protected: 500 protected:
502 Declaration(VariableProxy* proxy, VariableMode mode, Scope* scope, int pos, 501 Declaration(VariableProxy* proxy, Scope* scope, int pos, NodeType type)
503 NodeType type) 502 : AstNode(pos, type), proxy_(proxy), scope_(scope) {}
504 : AstNode(pos, type), mode_(mode), proxy_(proxy), scope_(scope) {
505 DCHECK(IsDeclaredVariableMode(mode));
506 }
507 503
508 private: 504 private:
509 VariableMode mode_;
510 VariableProxy* proxy_; 505 VariableProxy* proxy_;
511 506
512 // Nested scope from which the declaration originated. 507 // Nested scope from which the declaration originated.
513 Scope* scope_; 508 Scope* scope_;
514 }; 509 };
515 510
516 511
517 class VariableDeclaration final : public Declaration { 512 class VariableDeclaration final : public Declaration {
518 private: 513 private:
519 friend class AstNodeFactory; 514 friend class AstNodeFactory;
520 515
521 VariableDeclaration(VariableProxy* proxy, VariableMode mode, Scope* scope, 516 VariableDeclaration(VariableProxy* proxy, Scope* scope, int pos)
522 int pos) 517 : Declaration(proxy, scope, pos, kVariableDeclaration) {}
523 : Declaration(proxy, mode, scope, pos, kVariableDeclaration) {}
524 }; 518 };
525 519
526 520
527 class FunctionDeclaration final : public Declaration { 521 class FunctionDeclaration final : public Declaration {
528 public: 522 public:
529 FunctionLiteral* fun() const { return fun_; } 523 FunctionLiteral* fun() const { return fun_; }
530 void set_fun(FunctionLiteral* f) { fun_ = f; } 524 void set_fun(FunctionLiteral* f) { fun_ = f; }
531 525
532 private: 526 private:
533 friend class AstNodeFactory; 527 friend class AstNodeFactory;
534 528
535 FunctionDeclaration(VariableProxy* proxy, VariableMode mode, 529 FunctionDeclaration(VariableProxy* proxy, FunctionLiteral* fun, Scope* scope,
536 FunctionLiteral* fun, Scope* scope, int pos) 530 int pos)
537 : Declaration(proxy, mode, scope, pos, kFunctionDeclaration), fun_(fun) { 531 : Declaration(proxy, scope, pos, kFunctionDeclaration), fun_(fun) {
538 DCHECK(mode == VAR || mode == LET || mode == CONST);
539 DCHECK(fun != NULL); 532 DCHECK(fun != NULL);
540 } 533 }
541 534
542 FunctionLiteral* fun_; 535 FunctionLiteral* fun_;
543 }; 536 };
544 537
545 538
546 class IterationStatement : public BreakableStatement { 539 class IterationStatement : public BreakableStatement {
547 public: 540 public:
548 Statement* body() const { return body_; } 541 Statement* body() const { return body_; }
(...skipping 2446 matching lines...) Expand 10 before | Expand all | Expand 10 after
2995 } 2988 }
2996 } 2989 }
2997 2990
2998 AstValueFactory* ast_value_factory() const { return ast_value_factory_; } 2991 AstValueFactory* ast_value_factory() const { return ast_value_factory_; }
2999 void set_ast_value_factory(AstValueFactory* ast_value_factory) { 2992 void set_ast_value_factory(AstValueFactory* ast_value_factory) {
3000 ast_value_factory_ = ast_value_factory; 2993 ast_value_factory_ = ast_value_factory;
3001 zone_ = ast_value_factory->zone(); 2994 zone_ = ast_value_factory->zone();
3002 } 2995 }
3003 2996
3004 VariableDeclaration* NewVariableDeclaration(VariableProxy* proxy, 2997 VariableDeclaration* NewVariableDeclaration(VariableProxy* proxy,
3005 VariableMode mode, Scope* scope, 2998 Scope* scope, int pos) {
3006 int pos) { 2999 return new (zone_) VariableDeclaration(proxy, scope, pos);
3007 return new (zone_) VariableDeclaration(proxy, mode, scope, pos);
3008 } 3000 }
3009 3001
3010 FunctionDeclaration* NewFunctionDeclaration(VariableProxy* proxy, 3002 FunctionDeclaration* NewFunctionDeclaration(VariableProxy* proxy,
3011 VariableMode mode,
3012 FunctionLiteral* fun, 3003 FunctionLiteral* fun,
3013 Scope* scope, 3004 Scope* scope, int pos) {
3014 int pos) { 3005 return new (zone_) FunctionDeclaration(proxy, fun, scope, pos);
3015 return new (zone_) FunctionDeclaration(proxy, mode, fun, scope, pos);
3016 } 3006 }
3017 3007
3018 Block* NewBlock(ZoneList<const AstRawString*>* labels, int capacity, 3008 Block* NewBlock(ZoneList<const AstRawString*>* labels, int capacity,
3019 bool ignore_completion_value, int pos) { 3009 bool ignore_completion_value, int pos) {
3020 return new (zone_) 3010 return new (zone_)
3021 Block(zone_, labels, capacity, ignore_completion_value, pos); 3011 Block(zone_, labels, capacity, ignore_completion_value, pos);
3022 } 3012 }
3023 3013
3024 #define STATEMENT_WITH_LABELS(NodeType) \ 3014 #define STATEMENT_WITH_LABELS(NodeType) \
3025 NodeType* New##NodeType(ZoneList<const AstRawString*>* labels, int pos) { \ 3015 NodeType* New##NodeType(ZoneList<const AstRawString*>* labels, int pos) { \
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
3474 : NULL; \ 3464 : NULL; \
3475 } 3465 }
3476 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) 3466 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS)
3477 #undef DECLARE_NODE_FUNCTIONS 3467 #undef DECLARE_NODE_FUNCTIONS
3478 3468
3479 3469
3480 } // namespace internal 3470 } // namespace internal
3481 } // namespace v8 3471 } // namespace v8
3482 3472
3483 #endif // V8_AST_AST_H_ 3473 #endif // V8_AST_AST_H_
OLDNEW
« no previous file with comments | « no previous file | src/ast/prettyprinter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698