OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 | 56 |
57 | 57 |
58 // ---------------------------------------------------------------------------- | 58 // ---------------------------------------------------------------------------- |
59 // Nodes of the abstract syntax tree. Only concrete classes are | 59 // Nodes of the abstract syntax tree. Only concrete classes are |
60 // enumerated here. | 60 // enumerated here. |
61 | 61 |
62 #define DECLARATION_NODE_LIST(V) \ | 62 #define DECLARATION_NODE_LIST(V) \ |
63 V(VariableDeclaration) \ | 63 V(VariableDeclaration) \ |
64 V(FunctionDeclaration) \ | 64 V(FunctionDeclaration) \ |
65 V(ModuleDeclaration) \ | 65 V(ModuleDeclaration) \ |
| 66 V(ImportDeclaration) \ |
| 67 V(ExportDeclaration) \ |
66 | 68 |
67 #define MODULE_NODE_LIST(V) \ | 69 #define MODULE_NODE_LIST(V) \ |
68 V(ModuleLiteral) \ | 70 V(ModuleLiteral) \ |
69 V(ModuleVariable) \ | 71 V(ModuleVariable) \ |
70 V(ModulePath) \ | 72 V(ModulePath) \ |
71 V(ModuleUrl) | 73 V(ModuleUrl) |
72 | 74 |
73 #define STATEMENT_NODE_LIST(V) \ | 75 #define STATEMENT_NODE_LIST(V) \ |
74 V(Block) \ | 76 V(Block) \ |
75 V(ExpressionStatement) \ | 77 V(ExpressionStatement) \ |
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
537 Scope* scope) | 539 Scope* scope) |
538 : Declaration(proxy, LET, scope), | 540 : Declaration(proxy, LET, scope), |
539 module_(module) { | 541 module_(module) { |
540 } | 542 } |
541 | 543 |
542 private: | 544 private: |
543 Module* module_; | 545 Module* module_; |
544 }; | 546 }; |
545 | 547 |
546 | 548 |
| 549 class ImportDeclaration: public Declaration { |
| 550 public: |
| 551 DECLARE_NODE_TYPE(ImportDeclaration) |
| 552 |
| 553 Module* module() const { return module_; } |
| 554 virtual InitializationFlag initialization() const { |
| 555 return kCreatedInitialized; |
| 556 } |
| 557 |
| 558 protected: |
| 559 template<class> friend class AstNodeFactory; |
| 560 |
| 561 ImportDeclaration(VariableProxy* proxy, |
| 562 Module* module, |
| 563 Scope* scope) |
| 564 : Declaration(proxy, LET, scope), |
| 565 module_(module) { |
| 566 } |
| 567 |
| 568 private: |
| 569 Module* module_; |
| 570 }; |
| 571 |
| 572 |
| 573 class ExportDeclaration: public Declaration { |
| 574 public: |
| 575 DECLARE_NODE_TYPE(ExportDeclaration) |
| 576 |
| 577 virtual InitializationFlag initialization() const { |
| 578 return kCreatedInitialized; |
| 579 } |
| 580 |
| 581 protected: |
| 582 template<class> friend class AstNodeFactory; |
| 583 |
| 584 ExportDeclaration(VariableProxy* proxy, |
| 585 Scope* scope) |
| 586 : Declaration(proxy, LET, scope) { |
| 587 } |
| 588 }; |
| 589 |
| 590 |
547 class Module: public AstNode { | 591 class Module: public AstNode { |
548 // TODO(rossberg): stuff to come... | 592 // TODO(rossberg): stuff to come... |
549 protected: | 593 protected: |
550 Module() {} | 594 Module() {} |
551 }; | 595 }; |
552 | 596 |
553 | 597 |
554 class ModuleLiteral: public Module { | 598 class ModuleLiteral: public Module { |
555 public: | 599 public: |
556 DECLARE_NODE_TYPE(ModuleLiteral) | 600 DECLARE_NODE_TYPE(ModuleLiteral) |
(...skipping 2016 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2573 } | 2617 } |
2574 | 2618 |
2575 ModuleDeclaration* NewModuleDeclaration(VariableProxy* proxy, | 2619 ModuleDeclaration* NewModuleDeclaration(VariableProxy* proxy, |
2576 Module* module, | 2620 Module* module, |
2577 Scope* scope) { | 2621 Scope* scope) { |
2578 ModuleDeclaration* decl = | 2622 ModuleDeclaration* decl = |
2579 new(zone_) ModuleDeclaration(proxy, module, scope); | 2623 new(zone_) ModuleDeclaration(proxy, module, scope); |
2580 VISIT_AND_RETURN(ModuleDeclaration, decl) | 2624 VISIT_AND_RETURN(ModuleDeclaration, decl) |
2581 } | 2625 } |
2582 | 2626 |
| 2627 ImportDeclaration* NewImportDeclaration(VariableProxy* proxy, |
| 2628 Module* module, |
| 2629 Scope* scope) { |
| 2630 ImportDeclaration* decl = |
| 2631 new(zone_) ImportDeclaration(proxy, module, scope); |
| 2632 VISIT_AND_RETURN(ImportDeclaration, decl) |
| 2633 } |
| 2634 |
| 2635 ExportDeclaration* NewExportDeclaration(VariableProxy* proxy, |
| 2636 Scope* scope) { |
| 2637 ExportDeclaration* decl = |
| 2638 new(zone_) ExportDeclaration(proxy, scope); |
| 2639 VISIT_AND_RETURN(ExportDeclaration, decl) |
| 2640 } |
| 2641 |
2583 ModuleLiteral* NewModuleLiteral(Block* body) { | 2642 ModuleLiteral* NewModuleLiteral(Block* body) { |
2584 ModuleLiteral* module = new(zone_) ModuleLiteral(body); | 2643 ModuleLiteral* module = new(zone_) ModuleLiteral(body); |
2585 VISIT_AND_RETURN(ModuleLiteral, module) | 2644 VISIT_AND_RETURN(ModuleLiteral, module) |
2586 } | 2645 } |
2587 | 2646 |
2588 ModuleVariable* NewModuleVariable(VariableProxy* proxy) { | 2647 ModuleVariable* NewModuleVariable(VariableProxy* proxy) { |
2589 ModuleVariable* module = new(zone_) ModuleVariable(proxy); | 2648 ModuleVariable* module = new(zone_) ModuleVariable(proxy); |
2590 VISIT_AND_RETURN(ModuleVariable, module) | 2649 VISIT_AND_RETURN(ModuleVariable, module) |
2591 } | 2650 } |
2592 | 2651 |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2873 private: | 2932 private: |
2874 Isolate* isolate_; | 2933 Isolate* isolate_; |
2875 Zone* zone_; | 2934 Zone* zone_; |
2876 Visitor visitor_; | 2935 Visitor visitor_; |
2877 }; | 2936 }; |
2878 | 2937 |
2879 | 2938 |
2880 } } // namespace v8::internal | 2939 } } // namespace v8::internal |
2881 | 2940 |
2882 #endif // V8_AST_H_ | 2941 #endif // V8_AST_H_ |
OLD | NEW |