Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(326)

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

Issue 2108193003: [modules] AST and parser rework. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@anonymous-declarations
Patch Set: . Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
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-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 21 matching lines...) Expand all
32 // allocation and constant-time deallocation of the entire syntax 32 // allocation and constant-time deallocation of the entire syntax
33 // tree. 33 // tree.
34 34
35 35
36 // ---------------------------------------------------------------------------- 36 // ----------------------------------------------------------------------------
37 // Nodes of the abstract syntax tree. Only concrete classes are 37 // Nodes of the abstract syntax tree. Only concrete classes are
38 // enumerated here. 38 // enumerated here.
39 39
40 #define DECLARATION_NODE_LIST(V) \ 40 #define DECLARATION_NODE_LIST(V) \
41 V(VariableDeclaration) \ 41 V(VariableDeclaration) \
42 V(FunctionDeclaration) \ 42 V(FunctionDeclaration)
43 V(ImportDeclaration)
44 43
45 #define STATEMENT_NODE_LIST(V) \ 44 #define STATEMENT_NODE_LIST(V) \
46 V(Block) \ 45 V(Block) \
47 V(ExpressionStatement) \ 46 V(ExpressionStatement) \
48 V(EmptyStatement) \ 47 V(EmptyStatement) \
49 V(SloppyBlockFunctionStatement) \ 48 V(SloppyBlockFunctionStatement) \
50 V(IfStatement) \ 49 V(IfStatement) \
51 V(ContinueStatement) \ 50 V(ContinueStatement) \
52 V(BreakStatement) \ 51 V(BreakStatement) \
53 V(ReturnStatement) \ 52 V(ReturnStatement) \
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 fun_(fun) { 556 fun_(fun) {
558 DCHECK(mode == VAR || mode == LET || mode == CONST); 557 DCHECK(mode == VAR || mode == LET || mode == CONST);
559 DCHECK(fun != NULL); 558 DCHECK(fun != NULL);
560 } 559 }
561 560
562 private: 561 private:
563 FunctionLiteral* fun_; 562 FunctionLiteral* fun_;
564 }; 563 };
565 564
566 565
567 class ImportDeclaration final : public Declaration {
568 public:
569 DECLARE_NODE_TYPE(ImportDeclaration)
570
571 const AstRawString* import_name() const { return import_name_; }
572 const AstRawString* module_specifier() const { return module_specifier_; }
573 void set_module_specifier(const AstRawString* module_specifier) {
574 DCHECK(module_specifier_ == NULL);
575 module_specifier_ = module_specifier;
576 }
577 InitializationFlag initialization() const override {
578 return kNeedsInitialization;
579 }
580
581 protected:
582 ImportDeclaration(Zone* zone, VariableProxy* proxy,
583 const AstRawString* import_name,
584 const AstRawString* module_specifier, Scope* scope, int pos)
585 : Declaration(zone, proxy, CONST, scope, pos),
586 import_name_(import_name),
587 module_specifier_(module_specifier) {}
588
589 private:
590 const AstRawString* import_name_;
591 const AstRawString* module_specifier_;
592 };
593
594
595 class Module : public AstNode {
596 public:
597 ModuleDescriptor* descriptor() const { return descriptor_; }
598 Block* body() const { return body_; }
599
600 protected:
601 Module(Zone* zone, int pos)
602 : AstNode(pos), descriptor_(ModuleDescriptor::New(zone)), body_(NULL) {}
603 Module(Zone* zone, ModuleDescriptor* descriptor, int pos, Block* body = NULL)
604 : AstNode(pos), descriptor_(descriptor), body_(body) {}
605
606 private:
607 ModuleDescriptor* descriptor_;
608 Block* body_;
609 };
610
611
612 class IterationStatement : public BreakableStatement { 566 class IterationStatement : public BreakableStatement {
613 public: 567 public:
614 // Type testing & conversion. 568 // Type testing & conversion.
615 IterationStatement* AsIterationStatement() final { return this; } 569 IterationStatement* AsIterationStatement() final { return this; }
616 570
617 Statement* body() const { return body_; } 571 Statement* body() const { return body_; }
618 void set_body(Statement* s) { body_ = s; } 572 void set_body(Statement* s) { body_ = s; }
619 573
620 int yield_count() const { return yield_count_; } 574 int yield_count() const { return yield_count_; }
621 int first_yield_id() const { return first_yield_id_; } 575 int first_yield_id() const { return first_yield_id_; }
(...skipping 2476 matching lines...) Expand 10 before | Expand all | Expand 10 after
3098 3052
3099 FunctionDeclaration* NewFunctionDeclaration(VariableProxy* proxy, 3053 FunctionDeclaration* NewFunctionDeclaration(VariableProxy* proxy,
3100 VariableMode mode, 3054 VariableMode mode,
3101 FunctionLiteral* fun, 3055 FunctionLiteral* fun,
3102 Scope* scope, 3056 Scope* scope,
3103 int pos) { 3057 int pos) {
3104 return new (parser_zone_) 3058 return new (parser_zone_)
3105 FunctionDeclaration(parser_zone_, proxy, mode, fun, scope, pos); 3059 FunctionDeclaration(parser_zone_, proxy, mode, fun, scope, pos);
3106 } 3060 }
3107 3061
3108 ImportDeclaration* NewImportDeclaration(VariableProxy* proxy,
3109 const AstRawString* import_name,
3110 const AstRawString* module_specifier,
3111 Scope* scope, int pos) {
3112 return new (parser_zone_) ImportDeclaration(
3113 parser_zone_, proxy, import_name, module_specifier, scope, pos);
3114 }
3115
3116 Block* NewBlock(ZoneList<const AstRawString*>* labels, int capacity, 3062 Block* NewBlock(ZoneList<const AstRawString*>* labels, int capacity,
3117 bool ignore_completion_value, int pos) { 3063 bool ignore_completion_value, int pos) {
3118 return new (local_zone_) 3064 return new (local_zone_)
3119 Block(local_zone_, labels, capacity, ignore_completion_value, pos); 3065 Block(local_zone_, labels, capacity, ignore_completion_value, pos);
3120 } 3066 }
3121 3067
3122 #define STATEMENT_WITH_LABELS(NodeType) \ 3068 #define STATEMENT_WITH_LABELS(NodeType) \
3123 NodeType* New##NodeType(ZoneList<const AstRawString*>* labels, int pos) { \ 3069 NodeType* New##NodeType(ZoneList<const AstRawString*>* labels, int pos) { \
3124 return new (local_zone_) NodeType(local_zone_, labels, pos); \ 3070 return new (local_zone_) NodeType(local_zone_, labels, pos); \
3125 } 3071 }
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
3567 : NULL; \ 3513 : NULL; \
3568 } 3514 }
3569 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) 3515 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS)
3570 #undef DECLARE_NODE_FUNCTIONS 3516 #undef DECLARE_NODE_FUNCTIONS
3571 3517
3572 3518
3573 } // namespace internal 3519 } // namespace internal
3574 } // namespace v8 3520 } // namespace v8
3575 3521
3576 #endif // V8_AST_AST_H_ 3522 #endif // V8_AST_AST_H_
OLDNEW
« no previous file with comments | « src/asmjs/typing-asm.cc ('k') | src/ast/ast.cc » ('j') | src/ast/modules.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698