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/parsing/parser-base.h" | 10 #include "src/parsing/parser-base.h" |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 cached_parse_data_ = NULL; | 177 cached_parse_data_ = NULL; |
178 } | 178 } |
179 | 179 |
180 // Parses the source code represented by the compilation info and sets its | 180 // Parses the source code represented by the compilation info and sets its |
181 // function literal. Returns false (and deallocates any allocated AST | 181 // function literal. Returns false (and deallocates any allocated AST |
182 // nodes) if parsing failed. | 182 // nodes) if parsing failed. |
183 static bool ParseStatic(ParseInfo* info); | 183 static bool ParseStatic(ParseInfo* info); |
184 bool Parse(ParseInfo* info); | 184 bool Parse(ParseInfo* info); |
185 void ParseOnBackground(ParseInfo* info); | 185 void ParseOnBackground(ParseInfo* info); |
186 | 186 |
187 void DeserializeScopeChain(ParseInfo* info, Handle<Context> context, | 187 // Deserialize the scope chain prior to parsing in which the script is going |
188 Scope::DeserializationMode deserialization_mode); | 188 // to be executed. If the script is a top-level script, or the scope chain |
| 189 // consists of only a native context, maybe_context should be an empty |
| 190 // handle. |
| 191 // |
| 192 // This only deserializes the scope chain, but doesn't connect the scopes to |
| 193 // their corresponding scope infos. Therefore, looking up variables in the |
| 194 // deserialized scopes is not possible. |
| 195 void DeserializeScopeChain(ParseInfo* info, |
| 196 MaybeHandle<Context> maybe_context); |
189 | 197 |
190 // Handle errors detected during parsing, move statistics to Isolate, | 198 // Handle errors detected during parsing, move statistics to Isolate, |
191 // internalize strings (move them to the heap). | 199 // internalize strings (move them to the heap). |
192 void Internalize(Isolate* isolate, Handle<Script> script, bool error); | 200 void Internalize(Isolate* isolate, Handle<Script> script, bool error); |
193 void HandleSourceURLComments(Isolate* isolate, Handle<Script> script); | 201 void HandleSourceURLComments(Isolate* isolate, Handle<Script> script); |
194 | 202 |
195 private: | 203 private: |
196 friend class ParserBase<Parser>; | 204 friend class ParserBase<Parser>; |
197 friend class v8::internal::ExpressionClassifier<ParserTypes<Parser>>; | 205 friend class v8::internal::ExpressionClassifier<ParserTypes<Parser>>; |
198 | 206 |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
426 // The var declarations are hoisted to the function scope, but originate from | 434 // The var declarations are hoisted to the function scope, but originate from |
427 // a scope where the name has also been let bound or the var declaration is | 435 // a scope where the name has also been let bound or the var declaration is |
428 // hoisted over such a scope. | 436 // hoisted over such a scope. |
429 void CheckConflictingVarDeclarations(Scope* scope, bool* ok); | 437 void CheckConflictingVarDeclarations(Scope* scope, bool* ok); |
430 | 438 |
431 // Insert initializer statements for var-bindings shadowing parameter bindings | 439 // Insert initializer statements for var-bindings shadowing parameter bindings |
432 // from a non-simple parameter list. | 440 // from a non-simple parameter list. |
433 void InsertShadowingVarBindingInitializers(Block* block); | 441 void InsertShadowingVarBindingInitializers(Block* block); |
434 | 442 |
435 // Implement sloppy block-scoped functions, ES2015 Annex B 3.3 | 443 // Implement sloppy block-scoped functions, ES2015 Annex B 3.3 |
436 void InsertSloppyBlockFunctionVarBindings(DeclarationScope* scope, | 444 void InsertSloppyBlockFunctionVarBindings(DeclarationScope* scope); |
437 bool* ok); | |
438 | 445 |
439 VariableProxy* NewUnresolved(const AstRawString* name, int begin_pos, | 446 VariableProxy* NewUnresolved(const AstRawString* name, int begin_pos, |
440 int end_pos = kNoSourcePosition, | 447 int end_pos = kNoSourcePosition, |
441 VariableKind kind = NORMAL_VARIABLE); | 448 VariableKind kind = NORMAL_VARIABLE); |
442 VariableProxy* NewUnresolved(const AstRawString* name); | 449 VariableProxy* NewUnresolved(const AstRawString* name); |
443 Variable* Declare(Declaration* declaration, | 450 Variable* Declare(Declaration* declaration, |
444 DeclarationDescriptor::Kind declaration_kind, | 451 DeclarationDescriptor::Kind declaration_kind, |
445 VariableMode mode, InitializationFlag init, bool* ok, | 452 VariableMode mode, InitializationFlag init, bool* ok, |
446 Scope* declaration_scope = nullptr); | 453 Scope* declaration_scope = nullptr); |
447 Declaration* DeclareVariable(const AstRawString* name, VariableMode mode, | 454 Declaration* DeclareVariable(const AstRawString* name, VariableMode mode, |
(...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1073 | 1080 |
1074 #ifdef DEBUG | 1081 #ifdef DEBUG |
1075 void Print(AstNode* node); | 1082 void Print(AstNode* node); |
1076 #endif // DEBUG | 1083 #endif // DEBUG |
1077 }; | 1084 }; |
1078 | 1085 |
1079 } // namespace internal | 1086 } // namespace internal |
1080 } // namespace v8 | 1087 } // namespace v8 |
1081 | 1088 |
1082 #endif // V8_PARSING_PARSER_H_ | 1089 #endif // V8_PARSING_PARSER_H_ |
OLD | NEW |