Chromium Code Reviews| 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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 175 cached_parse_data_ = NULL; | 175 cached_parse_data_ = NULL; |
| 176 } | 176 } |
| 177 | 177 |
| 178 // Parses the source code represented by the compilation info and sets its | 178 // Parses the source code represented by the compilation info and sets its |
| 179 // function literal. Returns false (and deallocates any allocated AST | 179 // function literal. Returns false (and deallocates any allocated AST |
| 180 // nodes) if parsing failed. | 180 // nodes) if parsing failed. |
| 181 static bool ParseStatic(ParseInfo* info); | 181 static bool ParseStatic(ParseInfo* info); |
| 182 bool Parse(ParseInfo* info); | 182 bool Parse(ParseInfo* info); |
| 183 void ParseOnBackground(ParseInfo* info); | 183 void ParseOnBackground(ParseInfo* info); |
| 184 | 184 |
| 185 void DeserializeScopeChain(ParseInfo* info, Handle<Context> context, | 185 void InspectScopeChain(ParseInfo* info, Handle<ScopeInfo> scope_info); |
|
marja
2016/09/12 07:50:33
Pls add a comment explaining what this does.
jochen (gone - plz use gerrit)
2016/09/12 08:18:18
done
| |
| 186 Scope::DeserializationMode deserialization_mode); | |
| 187 | 186 |
| 188 // Handle errors detected during parsing, move statistics to Isolate, | 187 // Handle errors detected during parsing, move statistics to Isolate, |
| 189 // internalize strings (move them to the heap). | 188 // internalize strings (move them to the heap). |
| 190 void Internalize(Isolate* isolate, Handle<Script> script, bool error); | 189 void Internalize(Isolate* isolate, Handle<Script> script, bool error); |
| 191 void HandleSourceURLComments(Isolate* isolate, Handle<Script> script); | 190 void HandleSourceURLComments(Isolate* isolate, Handle<Script> script); |
| 192 | 191 |
| 193 private: | 192 private: |
| 194 friend class ParserBase<Parser>; | 193 friend class ParserBase<Parser>; |
| 195 friend class v8::internal::ExpressionClassifier<ParserTypes<Parser>>; | 194 friend class v8::internal::ExpressionClassifier<ParserTypes<Parser>>; |
| 196 | 195 |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 441 // | 440 // |
| 442 // The var declarations are hoisted to the function scope, but originate from | 441 // The var declarations are hoisted to the function scope, but originate from |
| 443 // a scope where the name has also been let bound or the var declaration is | 442 // a scope where the name has also been let bound or the var declaration is |
| 444 // hoisted over such a scope. | 443 // hoisted over such a scope. |
| 445 void CheckConflictingVarDeclarations(Scope* scope, bool* ok); | 444 void CheckConflictingVarDeclarations(Scope* scope, bool* ok); |
| 446 | 445 |
| 447 // Insert initializer statements for var-bindings shadowing parameter bindings | 446 // Insert initializer statements for var-bindings shadowing parameter bindings |
| 448 // from a non-simple parameter list. | 447 // from a non-simple parameter list. |
| 449 void InsertShadowingVarBindingInitializers(Block* block); | 448 void InsertShadowingVarBindingInitializers(Block* block); |
| 450 | 449 |
| 451 // Implement sloppy block-scoped functions, ES2015 Annex B 3.3 | |
| 452 void InsertSloppyBlockFunctionVarBindings(DeclarationScope* scope, | |
| 453 bool* ok); | |
| 454 | |
| 455 VariableProxy* NewUnresolved(const AstRawString* name, int begin_pos, | 450 VariableProxy* NewUnresolved(const AstRawString* name, int begin_pos, |
| 456 int end_pos = kNoSourcePosition, | 451 int end_pos = kNoSourcePosition, |
| 457 VariableKind kind = NORMAL_VARIABLE); | 452 VariableKind kind = NORMAL_VARIABLE); |
| 458 VariableProxy* NewUnresolved(const AstRawString* name); | 453 VariableProxy* NewUnresolved(const AstRawString* name); |
| 459 Variable* Declare(Declaration* declaration, | 454 Variable* Declare(Declaration* declaration, |
| 460 DeclarationDescriptor::Kind declaration_kind, | 455 DeclarationDescriptor::Kind declaration_kind, |
| 461 VariableMode mode, InitializationFlag init, bool* ok, | 456 VariableMode mode, InitializationFlag init, bool* ok, |
| 462 Scope* declaration_scope = nullptr); | 457 Scope* declaration_scope = nullptr); |
| 463 Declaration* DeclareVariable(const AstRawString* name, VariableMode mode, | 458 Declaration* DeclareVariable(const AstRawString* name, VariableMode mode, |
| 464 int pos, bool* ok); | 459 int pos, bool* ok); |
| (...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1033 } | 1028 } |
| 1034 | 1029 |
| 1035 V8_INLINE void CountUsage(v8::Isolate::UseCounterFeature feature) { | 1030 V8_INLINE void CountUsage(v8::Isolate::UseCounterFeature feature) { |
| 1036 ++use_counts_[feature]; | 1031 ++use_counts_[feature]; |
| 1037 } | 1032 } |
| 1038 | 1033 |
| 1039 // Parser's private field members. | 1034 // Parser's private field members. |
| 1040 | 1035 |
| 1041 Scanner scanner_; | 1036 Scanner scanner_; |
| 1042 PreParser* reusable_preparser_; | 1037 PreParser* reusable_preparser_; |
| 1043 Scope* original_scope_; // for ES5 function declarations in sloppy eval | |
| 1044 | |
| 1045 friend class ParserTarget; | 1038 friend class ParserTarget; |
| 1046 friend class ParserTargetScope; | 1039 friend class ParserTargetScope; |
| 1047 ParserTarget* target_stack_; // for break, continue statements | 1040 ParserTarget* target_stack_; // for break, continue statements |
| 1048 | |
| 1049 ScriptCompiler::CompileOptions compile_options_; | 1041 ScriptCompiler::CompileOptions compile_options_; |
| 1050 ParseData* cached_parse_data_; | 1042 ParseData* cached_parse_data_; |
| 1051 | 1043 |
| 1052 PendingCompilationErrorHandler pending_error_handler_; | 1044 PendingCompilationErrorHandler pending_error_handler_; |
| 1053 | 1045 |
| 1054 // Other information which will be stored in Parser and moved to Isolate after | 1046 // Other information which will be stored in Parser and moved to Isolate after |
| 1055 // parsing. | 1047 // parsing. |
| 1056 int use_counts_[v8::Isolate::kUseCounterFeatureCount]; | 1048 int use_counts_[v8::Isolate::kUseCounterFeatureCount]; |
| 1057 int total_preparse_skipped_; | 1049 int total_preparse_skipped_; |
| 1058 HistogramTimer* pre_parse_timer_; | 1050 HistogramTimer* pre_parse_timer_; |
| 1059 | 1051 |
| 1060 bool parsing_on_main_thread_; | 1052 bool parsing_on_main_thread_; |
| 1061 | 1053 |
| 1062 #ifdef DEBUG | 1054 #ifdef DEBUG |
| 1063 void Print(AstNode* node); | 1055 void Print(AstNode* node); |
| 1064 #endif // DEBUG | 1056 #endif // DEBUG |
| 1065 }; | 1057 }; |
| 1066 | 1058 |
| 1067 } // namespace internal | 1059 } // namespace internal |
| 1068 } // namespace v8 | 1060 } // namespace v8 |
| 1069 | 1061 |
| 1070 #endif // V8_PARSING_PARSER_H_ | 1062 #endif // V8_PARSING_PARSER_H_ |
| OLD | NEW |