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 1103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1114 } | 1114 } |
1115 | 1115 |
1116 V8_INLINE ZoneList<Expression*>* GetNonPatternList() const { | 1116 V8_INLINE ZoneList<Expression*>* GetNonPatternList() const { |
1117 return function_state_->non_patterns_to_rewrite(); | 1117 return function_state_->non_patterns_to_rewrite(); |
1118 } | 1118 } |
1119 | 1119 |
1120 V8_INLINE void CountUsage(v8::Isolate::UseCounterFeature feature) { | 1120 V8_INLINE void CountUsage(v8::Isolate::UseCounterFeature feature) { |
1121 ++use_counts_[feature]; | 1121 ++use_counts_[feature]; |
1122 } | 1122 } |
1123 | 1123 |
| 1124 // Returns true iff we're parsing the first function literal during |
| 1125 // CreateDynamicFunction(). |
| 1126 V8_INLINE bool ParsingDynamicFunctionDeclaration() const { |
| 1127 return parameters_end_pos_ != kNoSourcePosition; |
| 1128 } |
| 1129 |
1124 // Parser's private field members. | 1130 // Parser's private field members. |
1125 friend class DiscardableZoneScope; // Uses reusable_preparser_. | 1131 friend class DiscardableZoneScope; // Uses reusable_preparser_. |
1126 // FIXME(marja): Make reusable_preparser_ always use its own temp Zone (call | 1132 // FIXME(marja): Make reusable_preparser_ always use its own temp Zone (call |
1127 // DeleteAll after each function), so this won't be needed. | 1133 // DeleteAll after each function), so this won't be needed. |
1128 | 1134 |
1129 Scanner scanner_; | 1135 Scanner scanner_; |
1130 PreParser* reusable_preparser_; | 1136 PreParser* reusable_preparser_; |
1131 Scope* original_scope_; // for ES5 function declarations in sloppy eval | 1137 Scope* original_scope_; // for ES5 function declarations in sloppy eval |
1132 Mode mode_; | 1138 Mode mode_; |
1133 | 1139 |
1134 friend class ParserTarget; | 1140 friend class ParserTarget; |
1135 friend class ParserTargetScope; | 1141 friend class ParserTargetScope; |
1136 ParserTarget* target_stack_; // for break, continue statements | 1142 ParserTarget* target_stack_; // for break, continue statements |
1137 | 1143 |
1138 ScriptCompiler::CompileOptions compile_options_; | 1144 ScriptCompiler::CompileOptions compile_options_; |
1139 ParseData* cached_parse_data_; | 1145 ParseData* cached_parse_data_; |
1140 | 1146 |
1141 PendingCompilationErrorHandler pending_error_handler_; | 1147 PendingCompilationErrorHandler pending_error_handler_; |
1142 | 1148 |
1143 // Other information which will be stored in Parser and moved to Isolate after | 1149 // Other information which will be stored in Parser and moved to Isolate after |
1144 // parsing. | 1150 // parsing. |
1145 int use_counts_[v8::Isolate::kUseCounterFeatureCount]; | 1151 int use_counts_[v8::Isolate::kUseCounterFeatureCount]; |
1146 int total_preparse_skipped_; | 1152 int total_preparse_skipped_; |
1147 bool allow_lazy_; | 1153 bool allow_lazy_; |
1148 bool temp_zoned_; | 1154 bool temp_zoned_; |
1149 ParserLogger* log_; | 1155 ParserLogger* log_; |
1150 | 1156 |
1151 PreParsedScopeData* preparsed_scope_data_; | 1157 PreParsedScopeData* preparsed_scope_data_; |
| 1158 |
| 1159 // If not kNoSourcePosition, indicates that the first function literal |
| 1160 // encountered is a dynamic function, see CreateDynamicFunction(). This field |
| 1161 // indicates the correct position of the ')' that closes the parameter list. |
| 1162 // After that ')' is encountered, this field is reset to kNoSourcePosition. |
| 1163 int parameters_end_pos_; |
1152 }; | 1164 }; |
1153 | 1165 |
1154 // ---------------------------------------------------------------------------- | 1166 // ---------------------------------------------------------------------------- |
1155 // Target is a support class to facilitate manipulation of the | 1167 // Target is a support class to facilitate manipulation of the |
1156 // Parser's target_stack_ (the stack of potential 'break' and | 1168 // Parser's target_stack_ (the stack of potential 'break' and |
1157 // 'continue' statement targets). Upon construction, a new target is | 1169 // 'continue' statement targets). Upon construction, a new target is |
1158 // added; it is removed upon destruction. | 1170 // added; it is removed upon destruction. |
1159 | 1171 |
1160 class ParserTarget BASE_EMBEDDED { | 1172 class ParserTarget BASE_EMBEDDED { |
1161 public: | 1173 public: |
(...skipping 27 matching lines...) Expand all Loading... |
1189 | 1201 |
1190 private: | 1202 private: |
1191 ParserTarget** variable_; | 1203 ParserTarget** variable_; |
1192 ParserTarget* previous_; | 1204 ParserTarget* previous_; |
1193 }; | 1205 }; |
1194 | 1206 |
1195 } // namespace internal | 1207 } // namespace internal |
1196 } // namespace v8 | 1208 } // namespace v8 |
1197 | 1209 |
1198 #endif // V8_PARSING_PARSER_H_ | 1210 #endif // V8_PARSING_PARSER_H_ |
OLD | NEW |