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