| 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" |
| 11 #include "src/globals.h" | 11 #include "src/globals.h" |
| 12 #include "src/parsing/parser-base.h" | 12 #include "src/parsing/parser-base.h" |
| 13 #include "src/parsing/parsing.h" |
| 13 #include "src/parsing/preparse-data-format.h" | 14 #include "src/parsing/preparse-data-format.h" |
| 14 #include "src/parsing/preparse-data.h" | 15 #include "src/parsing/preparse-data.h" |
| 15 #include "src/parsing/preparser.h" | 16 #include "src/parsing/preparser.h" |
| 16 #include "src/pending-compilation-error-handler.h" | 17 #include "src/pending-compilation-error-handler.h" |
| 17 #include "src/utils.h" | 18 #include "src/utils.h" |
| 18 | 19 |
| 19 namespace v8 { | 20 namespace v8 { |
| 20 | 21 |
| 21 class ScriptCompiler; | 22 class ScriptCompiler; |
| 22 | 23 |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 explicit Parser(ParseInfo* info); | 201 explicit Parser(ParseInfo* info); |
| 201 ~Parser() { | 202 ~Parser() { |
| 202 delete reusable_preparser_; | 203 delete reusable_preparser_; |
| 203 reusable_preparser_ = NULL; | 204 reusable_preparser_ = NULL; |
| 204 delete cached_parse_data_; | 205 delete cached_parse_data_; |
| 205 cached_parse_data_ = NULL; | 206 cached_parse_data_ = NULL; |
| 206 } | 207 } |
| 207 | 208 |
| 208 static bool const IsPreParser() { return false; } | 209 static bool const IsPreParser() { return false; } |
| 209 | 210 |
| 210 // Parses the source code represented by the compilation info and sets its | |
| 211 // function literal. Returns false (and deallocates any allocated AST | |
| 212 // nodes) if parsing failed. | |
| 213 static bool ParseStatic(ParseInfo* info); | |
| 214 bool Parse(ParseInfo* info); | |
| 215 void ParseOnBackground(ParseInfo* info); | 211 void ParseOnBackground(ParseInfo* info); |
| 216 | 212 |
| 217 // Deserialize the scope chain prior to parsing in which the script is going | 213 // Deserialize the scope chain prior to parsing in which the script is going |
| 218 // to be executed. If the script is a top-level script, or the scope chain | 214 // to be executed. If the script is a top-level script, or the scope chain |
| 219 // consists of only a native context, maybe_outer_scope_info should be an | 215 // consists of only a native context, maybe_outer_scope_info should be an |
| 220 // empty handle. | 216 // empty handle. |
| 221 // | 217 // |
| 222 // This only deserializes the scope chain, but doesn't connect the scopes to | 218 // This only deserializes the scope chain, but doesn't connect the scopes to |
| 223 // their corresponding scope infos. Therefore, looking up variables in the | 219 // their corresponding scope infos. Therefore, looking up variables in the |
| 224 // deserialized scopes is not possible. | 220 // deserialized scopes is not possible. |
| 225 void DeserializeScopeChain(ParseInfo* info, | 221 void DeserializeScopeChain(ParseInfo* info, |
| 226 MaybeHandle<ScopeInfo> maybe_outer_scope_info); | 222 MaybeHandle<ScopeInfo> maybe_outer_scope_info); |
| 227 | 223 |
| 228 // Handle errors detected during parsing, move statistics to Isolate, | 224 // Handle errors detected during parsing, move statistics to Isolate, |
| 229 // internalize strings (move them to the heap). | 225 // internalize strings (move them to the heap). |
| 230 void Internalize(Isolate* isolate, Handle<Script> script, bool error); | 226 void Internalize(Isolate* isolate, Handle<Script> script, bool error); |
| 231 void HandleSourceURLComments(Isolate* isolate, Handle<Script> script); | 227 void HandleSourceURLComments(Isolate* isolate, Handle<Script> script); |
| 232 | 228 |
| 233 private: | 229 private: |
| 234 friend class ParserBase<Parser>; | 230 friend class ParserBase<Parser>; |
| 235 friend class v8::internal::ExpressionClassifier<ParserTypes<Parser>>; | 231 friend class v8::internal::ExpressionClassifier<ParserTypes<Parser>>; |
| 232 friend bool v8::internal::parsing::ParseProgram(ParseInfo*); |
| 233 friend bool v8::internal::parsing::ParseFunction(ParseInfo*); |
| 236 | 234 |
| 237 bool AllowsLazyParsingWithoutUnresolvedVariables() const { | 235 bool AllowsLazyParsingWithoutUnresolvedVariables() const { |
| 238 return scope()->AllowsLazyParsingWithoutUnresolvedVariables( | 236 return scope()->AllowsLazyParsingWithoutUnresolvedVariables( |
| 239 original_scope_); | 237 original_scope_); |
| 240 } | 238 } |
| 241 | 239 |
| 242 bool parse_lazily() const { return mode_ == PARSE_LAZILY; } | 240 bool parse_lazily() const { return mode_ == PARSE_LAZILY; } |
| 243 enum Mode { PARSE_LAZILY, PARSE_EAGERLY }; | 241 enum Mode { PARSE_LAZILY, PARSE_EAGERLY }; |
| 244 | 242 |
| 245 class ParsingModeScope BASE_EMBEDDED { | 243 class ParsingModeScope BASE_EMBEDDED { |
| (...skipping 946 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1192 | 1190 |
| 1193 private: | 1191 private: |
| 1194 ParserTarget** variable_; | 1192 ParserTarget** variable_; |
| 1195 ParserTarget* previous_; | 1193 ParserTarget* previous_; |
| 1196 }; | 1194 }; |
| 1197 | 1195 |
| 1198 } // namespace internal | 1196 } // namespace internal |
| 1199 } // namespace v8 | 1197 } // namespace v8 |
| 1200 | 1198 |
| 1201 #endif // V8_PARSING_PARSER_H_ | 1199 #endif // V8_PARSING_PARSER_H_ |
| OLD | NEW |