| OLD | NEW |
| 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/assembler.h" | 8 #include "src/assembler.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 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 542 | 542 |
| 543 | 543 |
| 544 class VariableDeclaration final : public Declaration { | 544 class VariableDeclaration final : public Declaration { |
| 545 public: | 545 public: |
| 546 DECLARE_NODE_TYPE(VariableDeclaration) | 546 DECLARE_NODE_TYPE(VariableDeclaration) |
| 547 | 547 |
| 548 InitializationFlag initialization() const override { | 548 InitializationFlag initialization() const override { |
| 549 return mode() == VAR ? kCreatedInitialized : kNeedsInitialization; | 549 return mode() == VAR ? kCreatedInitialized : kNeedsInitialization; |
| 550 } | 550 } |
| 551 | 551 |
| 552 bool is_class_declaration() const { return is_class_declaration_; } | |
| 553 | |
| 554 // VariableDeclarations can be grouped into consecutive declaration | |
| 555 // groups. Each VariableDeclaration is associated with the start position of | |
| 556 // the group it belongs to. The positions are used for strong mode scope | |
| 557 // checks for classes and functions. | |
| 558 int declaration_group_start() const { return declaration_group_start_; } | |
| 559 | |
| 560 protected: | 552 protected: |
| 561 VariableDeclaration(Zone* zone, VariableProxy* proxy, VariableMode mode, | 553 VariableDeclaration(Zone* zone, VariableProxy* proxy, VariableMode mode, |
| 562 Scope* scope, int pos, bool is_class_declaration = false, | 554 Scope* scope, int pos) |
| 563 int declaration_group_start = -1) | 555 : Declaration(zone, proxy, mode, scope, pos) {} |
| 564 : Declaration(zone, proxy, mode, scope, pos), | |
| 565 is_class_declaration_(is_class_declaration), | |
| 566 declaration_group_start_(declaration_group_start) {} | |
| 567 | |
| 568 bool is_class_declaration_; | |
| 569 int declaration_group_start_; | |
| 570 }; | 556 }; |
| 571 | 557 |
| 572 | 558 |
| 573 class FunctionDeclaration final : public Declaration { | 559 class FunctionDeclaration final : public Declaration { |
| 574 public: | 560 public: |
| 575 DECLARE_NODE_TYPE(FunctionDeclaration) | 561 DECLARE_NODE_TYPE(FunctionDeclaration) |
| 576 | 562 |
| 577 FunctionLiteral* fun() const { return fun_; } | 563 FunctionLiteral* fun() const { return fun_; } |
| 578 void set_fun(FunctionLiteral* f) { fun_ = f; } | 564 void set_fun(FunctionLiteral* f) { fun_ = f; } |
| 579 InitializationFlag initialization() const override { | 565 InitializationFlag initialization() const override { |
| (...skipping 2479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3059 | 3045 |
| 3060 class AstNodeFactory final BASE_EMBEDDED { | 3046 class AstNodeFactory final BASE_EMBEDDED { |
| 3061 public: | 3047 public: |
| 3062 explicit AstNodeFactory(AstValueFactory* ast_value_factory) | 3048 explicit AstNodeFactory(AstValueFactory* ast_value_factory) |
| 3063 : local_zone_(ast_value_factory->zone()), | 3049 : local_zone_(ast_value_factory->zone()), |
| 3064 parser_zone_(ast_value_factory->zone()), | 3050 parser_zone_(ast_value_factory->zone()), |
| 3065 ast_value_factory_(ast_value_factory) {} | 3051 ast_value_factory_(ast_value_factory) {} |
| 3066 | 3052 |
| 3067 AstValueFactory* ast_value_factory() const { return ast_value_factory_; } | 3053 AstValueFactory* ast_value_factory() const { return ast_value_factory_; } |
| 3068 | 3054 |
| 3069 VariableDeclaration* NewVariableDeclaration( | 3055 VariableDeclaration* NewVariableDeclaration(VariableProxy* proxy, |
| 3070 VariableProxy* proxy, VariableMode mode, Scope* scope, int pos, | 3056 VariableMode mode, Scope* scope, |
| 3071 bool is_class_declaration = false, int declaration_group_start = -1) { | 3057 int pos) { |
| 3072 return new (parser_zone_) | 3058 return new (parser_zone_) |
| 3073 VariableDeclaration(parser_zone_, proxy, mode, scope, pos, | 3059 VariableDeclaration(parser_zone_, proxy, mode, scope, pos); |
| 3074 is_class_declaration, declaration_group_start); | |
| 3075 } | 3060 } |
| 3076 | 3061 |
| 3077 FunctionDeclaration* NewFunctionDeclaration(VariableProxy* proxy, | 3062 FunctionDeclaration* NewFunctionDeclaration(VariableProxy* proxy, |
| 3078 VariableMode mode, | 3063 VariableMode mode, |
| 3079 FunctionLiteral* fun, | 3064 FunctionLiteral* fun, |
| 3080 Scope* scope, | 3065 Scope* scope, |
| 3081 int pos) { | 3066 int pos) { |
| 3082 return new (parser_zone_) | 3067 return new (parser_zone_) |
| 3083 FunctionDeclaration(parser_zone_, proxy, mode, fun, scope, pos); | 3068 FunctionDeclaration(parser_zone_, proxy, mode, fun, scope, pos); |
| 3084 } | 3069 } |
| (...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3497 // the parser-level zone. | 3482 // the parser-level zone. |
| 3498 Zone* parser_zone_; | 3483 Zone* parser_zone_; |
| 3499 AstValueFactory* ast_value_factory_; | 3484 AstValueFactory* ast_value_factory_; |
| 3500 }; | 3485 }; |
| 3501 | 3486 |
| 3502 | 3487 |
| 3503 } // namespace internal | 3488 } // namespace internal |
| 3504 } // namespace v8 | 3489 } // namespace v8 |
| 3505 | 3490 |
| 3506 #endif // V8_AST_AST_H_ | 3491 #endif // V8_AST_AST_H_ |
| OLD | NEW |