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/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 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
510 VariableMode mode_; | 510 VariableMode mode_; |
511 VariableProxy* proxy_; | 511 VariableProxy* proxy_; |
512 | 512 |
513 // Nested scope from which the declaration originated. | 513 // Nested scope from which the declaration originated. |
514 Scope* scope_; | 514 Scope* scope_; |
515 }; | 515 }; |
516 | 516 |
517 | 517 |
518 class VariableDeclaration final : public Declaration { | 518 class VariableDeclaration final : public Declaration { |
519 public: | 519 public: |
520 InitializationFlag initialization() const { | 520 InitializationFlag initialization() const { return initialization_; } |
521 return mode() == VAR ? kCreatedInitialized : kNeedsInitialization; | |
522 } | |
523 | 521 |
524 private: | 522 private: |
525 friend class AstNodeFactory; | 523 friend class AstNodeFactory; |
526 | 524 |
527 VariableDeclaration(VariableProxy* proxy, VariableMode mode, Scope* scope, | 525 VariableDeclaration(VariableProxy* proxy, VariableMode mode, Scope* scope, |
528 int pos) | 526 InitializationFlag initialization, int pos) |
529 : Declaration(proxy, mode, scope, pos, kVariableDeclaration) {} | 527 : Declaration(proxy, mode, scope, pos, kVariableDeclaration), |
| 528 initialization_(initialization) {} |
| 529 |
| 530 InitializationFlag initialization_; |
530 }; | 531 }; |
531 | 532 |
532 | 533 |
533 class FunctionDeclaration final : public Declaration { | 534 class FunctionDeclaration final : public Declaration { |
534 public: | 535 public: |
535 FunctionLiteral* fun() const { return fun_; } | 536 FunctionLiteral* fun() const { return fun_; } |
536 void set_fun(FunctionLiteral* f) { fun_ = f; } | 537 void set_fun(FunctionLiteral* f) { fun_ = f; } |
537 InitializationFlag initialization() const { return kCreatedInitialized; } | 538 InitializationFlag initialization() const { return kCreatedInitialized; } |
538 | 539 |
539 private: | 540 private: |
(...skipping 2460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3000 | 3001 |
3001 AstValueFactory* ast_value_factory() const { return ast_value_factory_; } | 3002 AstValueFactory* ast_value_factory() const { return ast_value_factory_; } |
3002 void set_ast_value_factory(AstValueFactory* ast_value_factory) { | 3003 void set_ast_value_factory(AstValueFactory* ast_value_factory) { |
3003 ast_value_factory_ = ast_value_factory; | 3004 ast_value_factory_ = ast_value_factory; |
3004 zone_ = ast_value_factory->zone(); | 3005 zone_ = ast_value_factory->zone(); |
3005 } | 3006 } |
3006 | 3007 |
3007 VariableDeclaration* NewVariableDeclaration(VariableProxy* proxy, | 3008 VariableDeclaration* NewVariableDeclaration(VariableProxy* proxy, |
3008 VariableMode mode, Scope* scope, | 3009 VariableMode mode, Scope* scope, |
3009 int pos) { | 3010 int pos) { |
3010 return new (zone_) VariableDeclaration(proxy, mode, scope, pos); | 3011 return NewVariableDeclaration( |
| 3012 proxy, mode, scope, |
| 3013 mode == VAR ? kCreatedInitialized : kNeedsInitialization, pos); |
| 3014 } |
| 3015 |
| 3016 VariableDeclaration* NewVariableDeclaration(VariableProxy* proxy, |
| 3017 VariableMode mode, Scope* scope, |
| 3018 InitializationFlag init, |
| 3019 int pos) { |
| 3020 return new (zone_) VariableDeclaration(proxy, mode, scope, init, pos); |
3011 } | 3021 } |
3012 | 3022 |
3013 FunctionDeclaration* NewFunctionDeclaration(VariableProxy* proxy, | 3023 FunctionDeclaration* NewFunctionDeclaration(VariableProxy* proxy, |
3014 VariableMode mode, | 3024 VariableMode mode, |
3015 FunctionLiteral* fun, | 3025 FunctionLiteral* fun, |
3016 Scope* scope, | 3026 Scope* scope, |
3017 int pos) { | 3027 int pos) { |
3018 return new (zone_) FunctionDeclaration(proxy, mode, fun, scope, pos); | 3028 return new (zone_) FunctionDeclaration(proxy, mode, fun, scope, pos); |
3019 } | 3029 } |
3020 | 3030 |
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3477 : NULL; \ | 3487 : NULL; \ |
3478 } | 3488 } |
3479 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) | 3489 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) |
3480 #undef DECLARE_NODE_FUNCTIONS | 3490 #undef DECLARE_NODE_FUNCTIONS |
3481 | 3491 |
3482 | 3492 |
3483 } // namespace internal | 3493 } // namespace internal |
3484 } // namespace v8 | 3494 } // namespace v8 |
3485 | 3495 |
3486 #endif // V8_AST_AST_H_ | 3496 #endif // V8_AST_AST_H_ |
OLD | NEW |