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_PREPARSER_H | 5 #ifndef V8_PREPARSER_H |
6 #define V8_PREPARSER_H | 6 #define V8_PREPARSER_H |
7 | 7 |
8 #include "src/v8.h" | 8 #include "src/v8.h" |
9 | 9 |
10 #include "src/func-name-inferrer.h" | 10 #include "src/func-name-inferrer.h" |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 function_state_(NULL), | 76 function_state_(NULL), |
77 extension_(extension), | 77 extension_(extension), |
78 fni_(NULL), | 78 fni_(NULL), |
79 log_(log), | 79 log_(log), |
80 mode_(PARSE_EAGERLY), // Lazy mode must be set explicitly. | 80 mode_(PARSE_EAGERLY), // Lazy mode must be set explicitly. |
81 stack_limit_(stack_limit), | 81 stack_limit_(stack_limit), |
82 scanner_(scanner), | 82 scanner_(scanner), |
83 stack_overflow_(false), | 83 stack_overflow_(false), |
84 allow_lazy_(false), | 84 allow_lazy_(false), |
85 allow_natives_syntax_(false), | 85 allow_natives_syntax_(false), |
86 allow_generators_(false), | |
87 allow_arrow_functions_(false), | 86 allow_arrow_functions_(false), |
88 allow_harmony_object_literals_(false), | 87 allow_harmony_object_literals_(false), |
89 zone_(zone), | 88 zone_(zone), |
90 ast_node_id_gen_(ast_node_id_gen) {} | 89 ast_node_id_gen_(ast_node_id_gen) {} |
91 | 90 |
92 // Getters that indicate whether certain syntactical constructs are | 91 // Getters that indicate whether certain syntactical constructs are |
93 // allowed to be parsed by this instance of the parser. | 92 // allowed to be parsed by this instance of the parser. |
94 bool allow_lazy() const { return allow_lazy_; } | 93 bool allow_lazy() const { return allow_lazy_; } |
95 bool allow_natives_syntax() const { return allow_natives_syntax_; } | 94 bool allow_natives_syntax() const { return allow_natives_syntax_; } |
96 bool allow_generators() const { return allow_generators_; } | |
97 bool allow_arrow_functions() const { return allow_arrow_functions_; } | 95 bool allow_arrow_functions() const { return allow_arrow_functions_; } |
98 bool allow_modules() const { return scanner()->HarmonyModules(); } | 96 bool allow_modules() const { return scanner()->HarmonyModules(); } |
99 bool allow_harmony_scoping() const { return scanner()->HarmonyScoping(); } | 97 bool allow_harmony_scoping() const { return scanner()->HarmonyScoping(); } |
100 bool allow_harmony_numeric_literals() const { | 98 bool allow_harmony_numeric_literals() const { |
101 return scanner()->HarmonyNumericLiterals(); | 99 return scanner()->HarmonyNumericLiterals(); |
102 } | 100 } |
103 bool allow_classes() const { return scanner()->HarmonyClasses(); } | 101 bool allow_classes() const { return scanner()->HarmonyClasses(); } |
104 bool allow_harmony_object_literals() const { | 102 bool allow_harmony_object_literals() const { |
105 return allow_harmony_object_literals_; | 103 return allow_harmony_object_literals_; |
106 } | 104 } |
107 | 105 |
108 // Setters that determine whether certain syntactical constructs are | 106 // Setters that determine whether certain syntactical constructs are |
109 // allowed to be parsed by this instance of the parser. | 107 // allowed to be parsed by this instance of the parser. |
110 void set_allow_lazy(bool allow) { allow_lazy_ = allow; } | 108 void set_allow_lazy(bool allow) { allow_lazy_ = allow; } |
111 void set_allow_natives_syntax(bool allow) { allow_natives_syntax_ = allow; } | 109 void set_allow_natives_syntax(bool allow) { allow_natives_syntax_ = allow; } |
112 void set_allow_generators(bool allow) { allow_generators_ = allow; } | |
113 void set_allow_arrow_functions(bool allow) { allow_arrow_functions_ = allow; } | 110 void set_allow_arrow_functions(bool allow) { allow_arrow_functions_ = allow; } |
114 void set_allow_modules(bool allow) { scanner()->SetHarmonyModules(allow); } | 111 void set_allow_modules(bool allow) { scanner()->SetHarmonyModules(allow); } |
115 void set_allow_harmony_scoping(bool allow) { | 112 void set_allow_harmony_scoping(bool allow) { |
116 scanner()->SetHarmonyScoping(allow); | 113 scanner()->SetHarmonyScoping(allow); |
117 } | 114 } |
118 void set_allow_harmony_numeric_literals(bool allow) { | 115 void set_allow_harmony_numeric_literals(bool allow) { |
119 scanner()->SetHarmonyNumericLiterals(allow); | 116 scanner()->SetHarmonyNumericLiterals(allow); |
120 } | 117 } |
121 void set_allow_classes(bool allow) { scanner()->SetHarmonyClasses(allow); } | 118 void set_allow_classes(bool allow) { scanner()->SetHarmonyClasses(allow); } |
122 void set_allow_harmony_object_literals(bool allow) { | 119 void set_allow_harmony_object_literals(bool allow) { |
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
576 ParserRecorder* log_; | 573 ParserRecorder* log_; |
577 Mode mode_; | 574 Mode mode_; |
578 uintptr_t stack_limit_; | 575 uintptr_t stack_limit_; |
579 | 576 |
580 private: | 577 private: |
581 Scanner* scanner_; | 578 Scanner* scanner_; |
582 bool stack_overflow_; | 579 bool stack_overflow_; |
583 | 580 |
584 bool allow_lazy_; | 581 bool allow_lazy_; |
585 bool allow_natives_syntax_; | 582 bool allow_natives_syntax_; |
586 bool allow_generators_; | |
587 bool allow_arrow_functions_; | 583 bool allow_arrow_functions_; |
588 bool allow_harmony_object_literals_; | 584 bool allow_harmony_object_literals_; |
589 | 585 |
590 typename Traits::Type::Zone* zone_; // Only used by Parser. | 586 typename Traits::Type::Zone* zone_; // Only used by Parser. |
591 AstNode::IdGen* ast_node_id_gen_; | 587 AstNode::IdGen* ast_node_id_gen_; |
592 }; | 588 }; |
593 | 589 |
594 | 590 |
595 class PreParserIdentifier { | 591 class PreParserIdentifier { |
596 public: | 592 public: |
(...skipping 1812 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2409 | 2405 |
2410 // The '[' Expression ']' and '.' Identifier parts are parsed by | 2406 // The '[' Expression ']' and '.' Identifier parts are parsed by |
2411 // ParseMemberExpressionContinuation, and the Arguments part is parsed by the | 2407 // ParseMemberExpressionContinuation, and the Arguments part is parsed by the |
2412 // caller. | 2408 // caller. |
2413 | 2409 |
2414 // Parse the initial primary or function expression. | 2410 // Parse the initial primary or function expression. |
2415 ExpressionT result = this->EmptyExpression(); | 2411 ExpressionT result = this->EmptyExpression(); |
2416 if (peek() == Token::FUNCTION) { | 2412 if (peek() == Token::FUNCTION) { |
2417 Consume(Token::FUNCTION); | 2413 Consume(Token::FUNCTION); |
2418 int function_token_position = position(); | 2414 int function_token_position = position(); |
2419 bool is_generator = allow_generators() && Check(Token::MUL); | 2415 bool is_generator = Check(Token::MUL); |
2420 IdentifierT name = this->EmptyIdentifier(); | 2416 IdentifierT name = this->EmptyIdentifier(); |
2421 bool is_strict_reserved_name = false; | 2417 bool is_strict_reserved_name = false; |
2422 Scanner::Location function_name_location = Scanner::Location::invalid(); | 2418 Scanner::Location function_name_location = Scanner::Location::invalid(); |
2423 FunctionLiteral::FunctionType function_type = | 2419 FunctionLiteral::FunctionType function_type = |
2424 FunctionLiteral::ANONYMOUS_EXPRESSION; | 2420 FunctionLiteral::ANONYMOUS_EXPRESSION; |
2425 if (peek_any_identifier()) { | 2421 if (peek_any_identifier()) { |
2426 name = ParseIdentifierOrStrictReservedWord(&is_strict_reserved_name, | 2422 name = ParseIdentifierOrStrictReservedWord(&is_strict_reserved_name, |
2427 CHECK_OK); | 2423 CHECK_OK); |
2428 function_name_location = scanner()->location(); | 2424 function_name_location = scanner()->location(); |
2429 function_type = FunctionLiteral::NAMED_EXPRESSION; | 2425 function_type = FunctionLiteral::NAMED_EXPRESSION; |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2659 DCHECK(IsAccessorAccessorConflict(old_type, type)); | 2655 DCHECK(IsAccessorAccessorConflict(old_type, type)); |
2660 // Both accessors of the same type. | 2656 // Both accessors of the same type. |
2661 parser()->ReportMessage("accessor_get_set"); | 2657 parser()->ReportMessage("accessor_get_set"); |
2662 } | 2658 } |
2663 *ok = false; | 2659 *ok = false; |
2664 } | 2660 } |
2665 } | 2661 } |
2666 } } // v8::internal | 2662 } } // v8::internal |
2667 | 2663 |
2668 #endif // V8_PREPARSER_H | 2664 #endif // V8_PREPARSER_H |
OLD | NEW |