Chromium Code Reviews

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

Issue 2457393003: Thread decls-list through Declaration (Closed)
Patch Set: rename Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
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-types.h" 8 #include "src/ast/ast-types.h"
9 #include "src/ast/ast-value-factory.h" 9 #include "src/ast/ast-value-factory.h"
10 #include "src/ast/modules.h" 10 #include "src/ast/modules.h"
(...skipping 491 matching lines...)
502 int local_id(int n) const { return base_id() + parent_num_ids() + n; } 502 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
503 503
504 Block* block_; 504 Block* block_;
505 VariableProxy* result_; 505 VariableProxy* result_;
506 FunctionLiteral* represented_function_; 506 FunctionLiteral* represented_function_;
507 }; 507 };
508 508
509 509
510 class Declaration : public AstNode { 510 class Declaration : public AstNode {
511 public: 511 public:
512 typedef ThreadedList<Declaration> List;
513
512 VariableProxy* proxy() const { return proxy_; } 514 VariableProxy* proxy() const { return proxy_; }
513 Scope* scope() const { return scope_; } 515 Scope* scope() const { return scope_; }
516 Declaration** next() { return &next_; }
adamk 2016/10/31 20:34:23 Should this be called anywhere other than inside T
514 517
515 protected: 518 protected:
516 Declaration(VariableProxy* proxy, Scope* scope, int pos, NodeType type) 519 Declaration(VariableProxy* proxy, Scope* scope, int pos, NodeType type)
517 : AstNode(pos, type), proxy_(proxy), scope_(scope) {} 520 : AstNode(pos, type), proxy_(proxy), scope_(scope), next_(nullptr) {}
518 521
519 static const uint8_t kNextBitFieldIndex = AstNode::kNextBitFieldIndex; 522 static const uint8_t kNextBitFieldIndex = AstNode::kNextBitFieldIndex;
520 523
521 private: 524 private:
522 VariableProxy* proxy_; 525 VariableProxy* proxy_;
523
524 // Nested scope from which the declaration originated. 526 // Nested scope from which the declaration originated.
525 Scope* scope_; 527 Scope* scope_;
528 // Declarations list threaded through the declarations.
529 Declaration* next_;
526 }; 530 };
527 531
528 532
529 class VariableDeclaration final : public Declaration { 533 class VariableDeclaration final : public Declaration {
530 private: 534 private:
531 friend class AstNodeFactory; 535 friend class AstNodeFactory;
532 536
533 VariableDeclaration(VariableProxy* proxy, Scope* scope, int pos) 537 VariableDeclaration(VariableProxy* proxy, Scope* scope, int pos)
534 : Declaration(proxy, scope, pos, kVariableDeclaration) {} 538 : Declaration(proxy, scope, pos, kVariableDeclaration) {}
535 }; 539 };
(...skipping 2415 matching lines...)
2951 // ---------------------------------------------------------------------------- 2955 // ----------------------------------------------------------------------------
2952 // Basic visitor 2956 // Basic visitor
2953 // Sub-class should parametrize AstVisitor with itself, e.g.: 2957 // Sub-class should parametrize AstVisitor with itself, e.g.:
2954 // class SpecificVisitor : public AstVisitor<SpecificVisitor> { ... } 2958 // class SpecificVisitor : public AstVisitor<SpecificVisitor> { ... }
2955 2959
2956 template <class Subclass> 2960 template <class Subclass>
2957 class AstVisitor BASE_EMBEDDED { 2961 class AstVisitor BASE_EMBEDDED {
2958 public: 2962 public:
2959 void Visit(AstNode* node) { impl()->Visit(node); } 2963 void Visit(AstNode* node) { impl()->Visit(node); }
2960 2964
2961 void VisitDeclarations(ZoneList<Declaration*>* declarations) { 2965 void VisitDeclarations(Declaration::List* declarations) {
2962 for (int i = 0; i < declarations->length(); i++) { 2966 for (Declaration* decl : *declarations) Visit(decl);
2963 Visit(declarations->at(i));
2964 }
2965 } 2967 }
2966 2968
2967 void VisitStatements(ZoneList<Statement*>* statements) { 2969 void VisitStatements(ZoneList<Statement*>* statements) {
2968 for (int i = 0; i < statements->length(); i++) { 2970 for (int i = 0; i < statements->length(); i++) {
2969 Statement* stmt = statements->at(i); 2971 Statement* stmt = statements->at(i);
2970 Visit(stmt); 2972 Visit(stmt);
2971 if (stmt->IsJump()) break; 2973 if (stmt->IsJump()) break;
2972 } 2974 }
2973 } 2975 }
2974 2976
(...skipping 619 matching lines...)
3594 : NULL; \ 3596 : NULL; \
3595 } 3597 }
3596 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) 3598 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS)
3597 #undef DECLARE_NODE_FUNCTIONS 3599 #undef DECLARE_NODE_FUNCTIONS
3598 3600
3599 3601
3600 } // namespace internal 3602 } // namespace internal
3601 } // namespace v8 3603 } // namespace v8
3602 3604
3603 #endif // V8_AST_AST_H_ 3605 #endif // V8_AST_AST_H_
OLDNEW

Powered by Google App Engine