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_H_ | 5 #ifndef V8_AST_H_ |
6 #define V8_AST_H_ | 6 #define V8_AST_H_ |
7 | 7 |
8 #include "src/v8.h" | 8 #include "src/v8.h" |
9 | 9 |
10 #include "src/assembler.h" | 10 #include "src/assembler.h" |
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
563 class VariableDeclaration final : public Declaration { | 563 class VariableDeclaration final : public Declaration { |
564 public: | 564 public: |
565 DECLARE_NODE_TYPE(VariableDeclaration) | 565 DECLARE_NODE_TYPE(VariableDeclaration) |
566 | 566 |
567 InitializationFlag initialization() const override { | 567 InitializationFlag initialization() const override { |
568 return mode() == VAR ? kCreatedInitialized : kNeedsInitialization; | 568 return mode() == VAR ? kCreatedInitialized : kNeedsInitialization; |
569 } | 569 } |
570 | 570 |
571 bool is_class_declaration() const { return is_class_declaration_; } | 571 bool is_class_declaration() const { return is_class_declaration_; } |
572 | 572 |
| 573 // VariableDeclarations can be grouped into consecutive declaration |
| 574 // groups. Each VariableDeclaration is associated with the start position of |
| 575 // the group it belongs to. The positions are used for strong mode scope |
| 576 // checks for classes and functions. |
| 577 int declaration_group_start() const { return declaration_group_start_; } |
| 578 |
573 protected: | 579 protected: |
574 VariableDeclaration(Zone* zone, VariableProxy* proxy, VariableMode mode, | 580 VariableDeclaration(Zone* zone, VariableProxy* proxy, VariableMode mode, |
575 Scope* scope, int pos, bool is_class_declaration = false) | 581 Scope* scope, int pos, bool is_class_declaration = false, |
| 582 int declaration_group_start = -1) |
576 : Declaration(zone, proxy, mode, scope, pos), | 583 : Declaration(zone, proxy, mode, scope, pos), |
577 is_class_declaration_(is_class_declaration) {} | 584 is_class_declaration_(is_class_declaration), |
| 585 declaration_group_start_(declaration_group_start) {} |
578 | 586 |
579 bool is_class_declaration_; | 587 bool is_class_declaration_; |
| 588 int declaration_group_start_; |
580 }; | 589 }; |
581 | 590 |
582 | 591 |
583 class FunctionDeclaration final : public Declaration { | 592 class FunctionDeclaration final : public Declaration { |
584 public: | 593 public: |
585 DECLARE_NODE_TYPE(FunctionDeclaration) | 594 DECLARE_NODE_TYPE(FunctionDeclaration) |
586 | 595 |
587 FunctionLiteral* fun() const { return fun_; } | 596 FunctionLiteral* fun() const { return fun_; } |
588 InitializationFlag initialization() const override { | 597 InitializationFlag initialization() const override { |
589 return kCreatedInitialized; | 598 return kCreatedInitialized; |
(...skipping 2619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3209 // AstNode factory | 3218 // AstNode factory |
3210 | 3219 |
3211 class AstNodeFactory final BASE_EMBEDDED { | 3220 class AstNodeFactory final BASE_EMBEDDED { |
3212 public: | 3221 public: |
3213 explicit AstNodeFactory(AstValueFactory* ast_value_factory) | 3222 explicit AstNodeFactory(AstValueFactory* ast_value_factory) |
3214 : zone_(ast_value_factory->zone()), | 3223 : zone_(ast_value_factory->zone()), |
3215 ast_value_factory_(ast_value_factory) {} | 3224 ast_value_factory_(ast_value_factory) {} |
3216 | 3225 |
3217 VariableDeclaration* NewVariableDeclaration( | 3226 VariableDeclaration* NewVariableDeclaration( |
3218 VariableProxy* proxy, VariableMode mode, Scope* scope, int pos, | 3227 VariableProxy* proxy, VariableMode mode, Scope* scope, int pos, |
3219 bool is_class_declaration = false) { | 3228 bool is_class_declaration = false, int declaration_group_start = -1) { |
3220 return new (zone_) VariableDeclaration(zone_, proxy, mode, scope, pos, | 3229 return new (zone_) |
3221 is_class_declaration); | 3230 VariableDeclaration(zone_, proxy, mode, scope, pos, |
| 3231 is_class_declaration, declaration_group_start); |
3222 } | 3232 } |
3223 | 3233 |
3224 FunctionDeclaration* NewFunctionDeclaration(VariableProxy* proxy, | 3234 FunctionDeclaration* NewFunctionDeclaration(VariableProxy* proxy, |
3225 VariableMode mode, | 3235 VariableMode mode, |
3226 FunctionLiteral* fun, | 3236 FunctionLiteral* fun, |
3227 Scope* scope, | 3237 Scope* scope, |
3228 int pos) { | 3238 int pos) { |
3229 return new (zone_) FunctionDeclaration(zone_, proxy, mode, fun, scope, pos); | 3239 return new (zone_) FunctionDeclaration(zone_, proxy, mode, fun, scope, pos); |
3230 } | 3240 } |
3231 | 3241 |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3580 | 3590 |
3581 private: | 3591 private: |
3582 Zone* zone_; | 3592 Zone* zone_; |
3583 AstValueFactory* ast_value_factory_; | 3593 AstValueFactory* ast_value_factory_; |
3584 }; | 3594 }; |
3585 | 3595 |
3586 | 3596 |
3587 } } // namespace v8::internal | 3597 } } // namespace v8::internal |
3588 | 3598 |
3589 #endif // V8_AST_H_ | 3599 #endif // V8_AST_H_ |
OLD | NEW |