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_PARSING_PARSER_H_ | 5 #ifndef V8_PARSING_PARSER_H_ |
6 #define V8_PARSING_PARSER_H_ | 6 #define V8_PARSING_PARSER_H_ |
7 | 7 |
8 #include "src/ast/ast.h" | 8 #include "src/ast/ast.h" |
9 #include "src/ast/scopes.h" | 9 #include "src/ast/scopes.h" |
10 #include "src/base/compiler-specific.h" | 10 #include "src/base/compiler-specific.h" |
(...skipping 1090 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1101 } | 1101 } |
1102 | 1102 |
1103 V8_INLINE ZoneList<Expression*>* GetNonPatternList() const { | 1103 V8_INLINE ZoneList<Expression*>* GetNonPatternList() const { |
1104 return function_state_->non_patterns_to_rewrite(); | 1104 return function_state_->non_patterns_to_rewrite(); |
1105 } | 1105 } |
1106 | 1106 |
1107 V8_INLINE void CountUsage(v8::Isolate::UseCounterFeature feature) { | 1107 V8_INLINE void CountUsage(v8::Isolate::UseCounterFeature feature) { |
1108 ++use_counts_[feature]; | 1108 ++use_counts_[feature]; |
1109 } | 1109 } |
1110 | 1110 |
1111 // Returns true iff we're parsing the first function literal during | |
1112 // CreateDynamicFunction(). | |
1113 V8_INLINE bool ParsingDynamicFunctionDeclaration() const { | |
Dan Ehrenberg
2017/01/14 00:04:44
Nit: How about IsParsingDynamicFunctionDeclaration
| |
1114 return parameters_end_pos_ != kNoSourcePosition; | |
1115 } | |
1116 | |
1111 // Parser's private field members. | 1117 // Parser's private field members. |
1112 friend class DiscardableZoneScope; // Uses reusable_preparser_. | 1118 friend class DiscardableZoneScope; // Uses reusable_preparser_. |
1113 // FIXME(marja): Make reusable_preparser_ always use its own temp Zone (call | 1119 // FIXME(marja): Make reusable_preparser_ always use its own temp Zone (call |
1114 // DeleteAll after each function), so this won't be needed. | 1120 // DeleteAll after each function), so this won't be needed. |
1115 | 1121 |
1116 Scanner scanner_; | 1122 Scanner scanner_; |
1117 PreParser* reusable_preparser_; | 1123 PreParser* reusable_preparser_; |
1118 Scope* original_scope_; // for ES5 function declarations in sloppy eval | 1124 Scope* original_scope_; // for ES5 function declarations in sloppy eval |
1119 Mode mode_; | 1125 Mode mode_; |
1120 | 1126 |
1121 friend class ParserTarget; | 1127 friend class ParserTarget; |
1122 friend class ParserTargetScope; | 1128 friend class ParserTargetScope; |
1123 ParserTarget* target_stack_; // for break, continue statements | 1129 ParserTarget* target_stack_; // for break, continue statements |
1124 | 1130 |
1125 ScriptCompiler::CompileOptions compile_options_; | 1131 ScriptCompiler::CompileOptions compile_options_; |
1126 ParseData* cached_parse_data_; | 1132 ParseData* cached_parse_data_; |
1127 | 1133 |
1128 PendingCompilationErrorHandler pending_error_handler_; | 1134 PendingCompilationErrorHandler pending_error_handler_; |
1129 | 1135 |
1130 // Other information which will be stored in Parser and moved to Isolate after | 1136 // Other information which will be stored in Parser and moved to Isolate after |
1131 // parsing. | 1137 // parsing. |
1132 int use_counts_[v8::Isolate::kUseCounterFeatureCount]; | 1138 int use_counts_[v8::Isolate::kUseCounterFeatureCount]; |
1133 int total_preparse_skipped_; | 1139 int total_preparse_skipped_; |
1134 bool allow_lazy_; | 1140 bool allow_lazy_; |
1135 bool temp_zoned_; | 1141 bool temp_zoned_; |
1136 ParserLogger* log_; | 1142 ParserLogger* log_; |
1143 | |
1144 // If not kNoSourcePosition, indicates that the first function literal | |
1145 // encountered is a dynamic function, see CreateDynamicFunction(). This field | |
1146 // indicates the correct position of the ')' that closes the parameter list. | |
1147 // After that ')' is encountered, this field is reset to kNoSourcePosition. | |
1148 int parameters_end_pos_; | |
1137 }; | 1149 }; |
1138 | 1150 |
1139 // ---------------------------------------------------------------------------- | 1151 // ---------------------------------------------------------------------------- |
1140 // Target is a support class to facilitate manipulation of the | 1152 // Target is a support class to facilitate manipulation of the |
1141 // Parser's target_stack_ (the stack of potential 'break' and | 1153 // Parser's target_stack_ (the stack of potential 'break' and |
1142 // 'continue' statement targets). Upon construction, a new target is | 1154 // 'continue' statement targets). Upon construction, a new target is |
1143 // added; it is removed upon destruction. | 1155 // added; it is removed upon destruction. |
1144 | 1156 |
1145 class ParserTarget BASE_EMBEDDED { | 1157 class ParserTarget BASE_EMBEDDED { |
1146 public: | 1158 public: |
(...skipping 27 matching lines...) Expand all Loading... | |
1174 | 1186 |
1175 private: | 1187 private: |
1176 ParserTarget** variable_; | 1188 ParserTarget** variable_; |
1177 ParserTarget* previous_; | 1189 ParserTarget* previous_; |
1178 }; | 1190 }; |
1179 | 1191 |
1180 } // namespace internal | 1192 } // namespace internal |
1181 } // namespace v8 | 1193 } // namespace v8 |
1182 | 1194 |
1183 #endif // V8_PARSING_PARSER_H_ | 1195 #endif // V8_PARSING_PARSER_H_ |
OLD | NEW |