| 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 24 matching lines...) Expand all  Loading... | 
| 35 // tree. | 35 // tree. | 
| 36 | 36 | 
| 37 | 37 | 
| 38 // ---------------------------------------------------------------------------- | 38 // ---------------------------------------------------------------------------- | 
| 39 // Nodes of the abstract syntax tree. Only concrete classes are | 39 // Nodes of the abstract syntax tree. Only concrete classes are | 
| 40 // enumerated here. | 40 // enumerated here. | 
| 41 | 41 | 
| 42 #define DECLARATION_NODE_LIST(V) \ | 42 #define DECLARATION_NODE_LIST(V) \ | 
| 43   V(VariableDeclaration)         \ | 43   V(VariableDeclaration)         \ | 
| 44   V(FunctionDeclaration)         \ | 44   V(FunctionDeclaration)         \ | 
| 45   V(ModuleDeclaration)           \ |  | 
| 46   V(ImportDeclaration)           \ | 45   V(ImportDeclaration)           \ | 
| 47   V(ExportDeclaration) | 46   V(ExportDeclaration) | 
| 48 | 47 | 
| 49 #define MODULE_NODE_LIST(V)                     \ |  | 
| 50   V(ModuleLiteral)                              \ |  | 
| 51   V(ModulePath)                                 \ |  | 
| 52   V(ModuleUrl) |  | 
| 53 |  | 
| 54 #define STATEMENT_NODE_LIST(V)                  \ | 48 #define STATEMENT_NODE_LIST(V)                  \ | 
| 55   V(Block)                                      \ | 49   V(Block)                                      \ | 
| 56   V(ModuleStatement)                            \ |  | 
| 57   V(ExpressionStatement)                        \ | 50   V(ExpressionStatement)                        \ | 
| 58   V(EmptyStatement)                             \ | 51   V(EmptyStatement)                             \ | 
| 59   V(IfStatement)                                \ | 52   V(IfStatement)                                \ | 
| 60   V(ContinueStatement)                          \ | 53   V(ContinueStatement)                          \ | 
| 61   V(BreakStatement)                             \ | 54   V(BreakStatement)                             \ | 
| 62   V(ReturnStatement)                            \ | 55   V(ReturnStatement)                            \ | 
| 63   V(WithStatement)                              \ | 56   V(WithStatement)                              \ | 
| 64   V(SwitchStatement)                            \ | 57   V(SwitchStatement)                            \ | 
| 65   V(DoWhileStatement)                           \ | 58   V(DoWhileStatement)                           \ | 
| 66   V(WhileStatement)                             \ | 59   V(WhileStatement)                             \ | 
| (...skipping 25 matching lines...) Expand all  Loading... | 
| 92   V(CountOperation)             \ | 85   V(CountOperation)             \ | 
| 93   V(BinaryOperation)            \ | 86   V(BinaryOperation)            \ | 
| 94   V(CompareOperation)           \ | 87   V(CompareOperation)           \ | 
| 95   V(Spread)                     \ | 88   V(Spread)                     \ | 
| 96   V(ThisFunction)               \ | 89   V(ThisFunction)               \ | 
| 97   V(SuperReference)             \ | 90   V(SuperReference)             \ | 
| 98   V(CaseClause) | 91   V(CaseClause) | 
| 99 | 92 | 
| 100 #define AST_NODE_LIST(V)                        \ | 93 #define AST_NODE_LIST(V)                        \ | 
| 101   DECLARATION_NODE_LIST(V)                      \ | 94   DECLARATION_NODE_LIST(V)                      \ | 
| 102   MODULE_NODE_LIST(V)                           \ |  | 
| 103   STATEMENT_NODE_LIST(V)                        \ | 95   STATEMENT_NODE_LIST(V)                        \ | 
| 104   EXPRESSION_NODE_LIST(V) | 96   EXPRESSION_NODE_LIST(V) | 
| 105 | 97 | 
| 106 // Forward declarations | 98 // Forward declarations | 
| 107 class AstNodeFactory; | 99 class AstNodeFactory; | 
| 108 class AstVisitor; | 100 class AstVisitor; | 
| 109 class Declaration; | 101 class Declaration; | 
| 110 class Module; | 102 class Module; | 
| 111 class BreakableStatement; | 103 class BreakableStatement; | 
| 112 class Expression; | 104 class Expression; | 
| (...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 610         fun_(fun) { | 602         fun_(fun) { | 
| 611     DCHECK(mode == VAR || mode == LET || mode == CONST); | 603     DCHECK(mode == VAR || mode == LET || mode == CONST); | 
| 612     DCHECK(fun != NULL); | 604     DCHECK(fun != NULL); | 
| 613   } | 605   } | 
| 614 | 606 | 
| 615  private: | 607  private: | 
| 616   FunctionLiteral* fun_; | 608   FunctionLiteral* fun_; | 
| 617 }; | 609 }; | 
| 618 | 610 | 
| 619 | 611 | 
| 620 class ModuleDeclaration final : public Declaration { |  | 
| 621  public: |  | 
| 622   DECLARE_NODE_TYPE(ModuleDeclaration) |  | 
| 623 |  | 
| 624   Module* module() const { return module_; } |  | 
| 625   InitializationFlag initialization() const override { |  | 
| 626     return kCreatedInitialized; |  | 
| 627   } |  | 
| 628 |  | 
| 629  protected: |  | 
| 630   ModuleDeclaration(Zone* zone, VariableProxy* proxy, Module* module, |  | 
| 631                     Scope* scope, int pos) |  | 
| 632       : Declaration(zone, proxy, CONST, scope, pos), module_(module) {} |  | 
| 633 |  | 
| 634  private: |  | 
| 635   Module* module_; |  | 
| 636 }; |  | 
| 637 |  | 
| 638 |  | 
| 639 class ImportDeclaration final : public Declaration { | 612 class ImportDeclaration final : public Declaration { | 
| 640  public: | 613  public: | 
| 641   DECLARE_NODE_TYPE(ImportDeclaration) | 614   DECLARE_NODE_TYPE(ImportDeclaration) | 
| 642 | 615 | 
| 643   const AstRawString* import_name() const { return import_name_; } | 616   const AstRawString* import_name() const { return import_name_; } | 
| 644   const AstRawString* module_specifier() const { return module_specifier_; } | 617   const AstRawString* module_specifier() const { return module_specifier_; } | 
| 645   void set_module_specifier(const AstRawString* module_specifier) { | 618   void set_module_specifier(const AstRawString* module_specifier) { | 
| 646     DCHECK(module_specifier_ == NULL); | 619     DCHECK(module_specifier_ == NULL); | 
| 647     module_specifier_ = module_specifier; | 620     module_specifier_ = module_specifier; | 
| 648   } | 621   } | 
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 688       : AstNode(pos), descriptor_(ModuleDescriptor::New(zone)), body_(NULL) {} | 661       : AstNode(pos), descriptor_(ModuleDescriptor::New(zone)), body_(NULL) {} | 
| 689   Module(Zone* zone, ModuleDescriptor* descriptor, int pos, Block* body = NULL) | 662   Module(Zone* zone, ModuleDescriptor* descriptor, int pos, Block* body = NULL) | 
| 690       : AstNode(pos), descriptor_(descriptor), body_(body) {} | 663       : AstNode(pos), descriptor_(descriptor), body_(body) {} | 
| 691 | 664 | 
| 692  private: | 665  private: | 
| 693   ModuleDescriptor* descriptor_; | 666   ModuleDescriptor* descriptor_; | 
| 694   Block* body_; | 667   Block* body_; | 
| 695 }; | 668 }; | 
| 696 | 669 | 
| 697 | 670 | 
| 698 class ModuleLiteral final : public Module { |  | 
| 699  public: |  | 
| 700   DECLARE_NODE_TYPE(ModuleLiteral) |  | 
| 701 |  | 
| 702  protected: |  | 
| 703   ModuleLiteral(Zone* zone, Block* body, ModuleDescriptor* descriptor, int pos) |  | 
| 704       : Module(zone, descriptor, pos, body) {} |  | 
| 705 }; |  | 
| 706 |  | 
| 707 |  | 
| 708 class ModulePath final : public Module { |  | 
| 709  public: |  | 
| 710   DECLARE_NODE_TYPE(ModulePath) |  | 
| 711 |  | 
| 712   Module* module() const { return module_; } |  | 
| 713   Handle<String> name() const { return name_->string(); } |  | 
| 714 |  | 
| 715  protected: |  | 
| 716   ModulePath(Zone* zone, Module* module, const AstRawString* name, int pos) |  | 
| 717       : Module(zone, pos), module_(module), name_(name) {} |  | 
| 718 |  | 
| 719  private: |  | 
| 720   Module* module_; |  | 
| 721   const AstRawString* name_; |  | 
| 722 }; |  | 
| 723 |  | 
| 724 |  | 
| 725 class ModuleUrl final : public Module { |  | 
| 726  public: |  | 
| 727   DECLARE_NODE_TYPE(ModuleUrl) |  | 
| 728 |  | 
| 729   Handle<String> url() const { return url_; } |  | 
| 730 |  | 
| 731  protected: |  | 
| 732   ModuleUrl(Zone* zone, Handle<String> url, int pos) |  | 
| 733       : Module(zone, pos), url_(url) { |  | 
| 734   } |  | 
| 735 |  | 
| 736  private: |  | 
| 737   Handle<String> url_; |  | 
| 738 }; |  | 
| 739 |  | 
| 740 |  | 
| 741 class ModuleStatement final : public Statement { |  | 
| 742  public: |  | 
| 743   DECLARE_NODE_TYPE(ModuleStatement) |  | 
| 744 |  | 
| 745   Block* body() const { return body_; } |  | 
| 746 |  | 
| 747  protected: |  | 
| 748   ModuleStatement(Zone* zone, Block* body, int pos) |  | 
| 749       : Statement(zone, pos), body_(body) {} |  | 
| 750 |  | 
| 751  private: |  | 
| 752   Block* body_; |  | 
| 753 }; |  | 
| 754 |  | 
| 755 |  | 
| 756 class IterationStatement : public BreakableStatement { | 671 class IterationStatement : public BreakableStatement { | 
| 757  public: | 672  public: | 
| 758   // Type testing & conversion. | 673   // Type testing & conversion. | 
| 759   IterationStatement* AsIterationStatement() final { return this; } | 674   IterationStatement* AsIterationStatement() final { return this; } | 
| 760 | 675 | 
| 761   Statement* body() const { return body_; } | 676   Statement* body() const { return body_; } | 
| 762 | 677 | 
| 763   static int num_ids() { return parent_num_ids() + 1; } | 678   static int num_ids() { return parent_num_ids() + 1; } | 
| 764   BailoutId OsrEntryId() const { return BailoutId(local_id(0)); } | 679   BailoutId OsrEntryId() const { return BailoutId(local_id(0)); } | 
| 765   virtual BailoutId ContinueId() const = 0; | 680   virtual BailoutId ContinueId() const = 0; | 
| (...skipping 2468 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 3234   } | 3149   } | 
| 3235 | 3150 | 
| 3236   FunctionDeclaration* NewFunctionDeclaration(VariableProxy* proxy, | 3151   FunctionDeclaration* NewFunctionDeclaration(VariableProxy* proxy, | 
| 3237                                               VariableMode mode, | 3152                                               VariableMode mode, | 
| 3238                                               FunctionLiteral* fun, | 3153                                               FunctionLiteral* fun, | 
| 3239                                               Scope* scope, | 3154                                               Scope* scope, | 
| 3240                                               int pos) { | 3155                                               int pos) { | 
| 3241     return new (zone_) FunctionDeclaration(zone_, proxy, mode, fun, scope, pos); | 3156     return new (zone_) FunctionDeclaration(zone_, proxy, mode, fun, scope, pos); | 
| 3242   } | 3157   } | 
| 3243 | 3158 | 
| 3244   ModuleDeclaration* NewModuleDeclaration(VariableProxy* proxy, |  | 
| 3245                                           Module* module, |  | 
| 3246                                           Scope* scope, |  | 
| 3247                                           int pos) { |  | 
| 3248     return new (zone_) ModuleDeclaration(zone_, proxy, module, scope, pos); |  | 
| 3249   } |  | 
| 3250 |  | 
| 3251   ImportDeclaration* NewImportDeclaration(VariableProxy* proxy, | 3159   ImportDeclaration* NewImportDeclaration(VariableProxy* proxy, | 
| 3252                                           const AstRawString* import_name, | 3160                                           const AstRawString* import_name, | 
| 3253                                           const AstRawString* module_specifier, | 3161                                           const AstRawString* module_specifier, | 
| 3254                                           Scope* scope, int pos) { | 3162                                           Scope* scope, int pos) { | 
| 3255     return new (zone_) ImportDeclaration(zone_, proxy, import_name, | 3163     return new (zone_) ImportDeclaration(zone_, proxy, import_name, | 
| 3256                                          module_specifier, scope, pos); | 3164                                          module_specifier, scope, pos); | 
| 3257   } | 3165   } | 
| 3258 | 3166 | 
| 3259   ExportDeclaration* NewExportDeclaration(VariableProxy* proxy, | 3167   ExportDeclaration* NewExportDeclaration(VariableProxy* proxy, | 
| 3260                                           Scope* scope, | 3168                                           Scope* scope, | 
| 3261                                           int pos) { | 3169                                           int pos) { | 
| 3262     return new (zone_) ExportDeclaration(zone_, proxy, scope, pos); | 3170     return new (zone_) ExportDeclaration(zone_, proxy, scope, pos); | 
| 3263   } | 3171   } | 
| 3264 | 3172 | 
| 3265   ModuleLiteral* NewModuleLiteral(Block* body, ModuleDescriptor* descriptor, |  | 
| 3266                                   int pos) { |  | 
| 3267     return new (zone_) ModuleLiteral(zone_, body, descriptor, pos); |  | 
| 3268   } |  | 
| 3269 |  | 
| 3270   ModulePath* NewModulePath(Module* origin, const AstRawString* name, int pos) { |  | 
| 3271     return new (zone_) ModulePath(zone_, origin, name, pos); |  | 
| 3272   } |  | 
| 3273 |  | 
| 3274   ModuleUrl* NewModuleUrl(Handle<String> url, int pos) { |  | 
| 3275     return new (zone_) ModuleUrl(zone_, url, pos); |  | 
| 3276   } |  | 
| 3277 |  | 
| 3278   Block* NewBlock(ZoneList<const AstRawString*>* labels, | 3173   Block* NewBlock(ZoneList<const AstRawString*>* labels, | 
| 3279                   int capacity, | 3174                   int capacity, | 
| 3280                   bool is_initializer_block, | 3175                   bool is_initializer_block, | 
| 3281                   int pos) { | 3176                   int pos) { | 
| 3282     return new (zone_) | 3177     return new (zone_) | 
| 3283         Block(zone_, labels, capacity, is_initializer_block, pos); | 3178         Block(zone_, labels, capacity, is_initializer_block, pos); | 
| 3284   } | 3179   } | 
| 3285 | 3180 | 
| 3286 #define STATEMENT_WITH_LABELS(NodeType)                                     \ | 3181 #define STATEMENT_WITH_LABELS(NodeType)                                     \ | 
| 3287   NodeType* New##NodeType(ZoneList<const AstRawString*>* labels, int pos) { \ | 3182   NodeType* New##NodeType(ZoneList<const AstRawString*>* labels, int pos) { \ | 
| (...skipping 13 matching lines...) Expand all  Loading... | 
| 3301         return new (zone_) ForInStatement(zone_, labels, pos); | 3196         return new (zone_) ForInStatement(zone_, labels, pos); | 
| 3302       } | 3197       } | 
| 3303       case ForEachStatement::ITERATE: { | 3198       case ForEachStatement::ITERATE: { | 
| 3304         return new (zone_) ForOfStatement(zone_, labels, pos); | 3199         return new (zone_) ForOfStatement(zone_, labels, pos); | 
| 3305       } | 3200       } | 
| 3306     } | 3201     } | 
| 3307     UNREACHABLE(); | 3202     UNREACHABLE(); | 
| 3308     return NULL; | 3203     return NULL; | 
| 3309   } | 3204   } | 
| 3310 | 3205 | 
| 3311   ModuleStatement* NewModuleStatement(Block* body, int pos) { |  | 
| 3312     return new (zone_) ModuleStatement(zone_, body, pos); |  | 
| 3313   } |  | 
| 3314 |  | 
| 3315   ExpressionStatement* NewExpressionStatement(Expression* expression, int pos) { | 3206   ExpressionStatement* NewExpressionStatement(Expression* expression, int pos) { | 
| 3316     return new (zone_) ExpressionStatement(zone_, expression, pos); | 3207     return new (zone_) ExpressionStatement(zone_, expression, pos); | 
| 3317   } | 3208   } | 
| 3318 | 3209 | 
| 3319   ContinueStatement* NewContinueStatement(IterationStatement* target, int pos) { | 3210   ContinueStatement* NewContinueStatement(IterationStatement* target, int pos) { | 
| 3320     return new (zone_) ContinueStatement(zone_, target, pos); | 3211     return new (zone_) ContinueStatement(zone_, target, pos); | 
| 3321   } | 3212   } | 
| 3322 | 3213 | 
| 3323   BreakStatement* NewBreakStatement(BreakableStatement* target, int pos) { | 3214   BreakStatement* NewBreakStatement(BreakableStatement* target, int pos) { | 
| 3324     return new (zone_) BreakStatement(zone_, target, pos); | 3215     return new (zone_) BreakStatement(zone_, target, pos); | 
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 3592 | 3483 | 
| 3593  private: | 3484  private: | 
| 3594   Zone* zone_; | 3485   Zone* zone_; | 
| 3595   AstValueFactory* ast_value_factory_; | 3486   AstValueFactory* ast_value_factory_; | 
| 3596 }; | 3487 }; | 
| 3597 | 3488 | 
| 3598 | 3489 | 
| 3599 } }  // namespace v8::internal | 3490 } }  // namespace v8::internal | 
| 3600 | 3491 | 
| 3601 #endif  // V8_AST_H_ | 3492 #endif  // V8_AST_H_ | 
| OLD | NEW | 
|---|