| 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/allocation.h" | 8 #include "src/allocation.h" |
| 9 #include "src/ast/ast.h" | 9 #include "src/ast/ast.h" |
| 10 #include "src/ast/scopes.h" | 10 #include "src/ast/scopes.h" |
| (...skipping 937 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 948 ScriptCompiler::CompileOptions compile_options() const { | 948 ScriptCompiler::CompileOptions compile_options() const { |
| 949 return compile_options_; | 949 return compile_options_; |
| 950 } | 950 } |
| 951 bool consume_cached_parse_data() const { | 951 bool consume_cached_parse_data() const { |
| 952 return compile_options_ == ScriptCompiler::kConsumeParserCache && | 952 return compile_options_ == ScriptCompiler::kConsumeParserCache && |
| 953 cached_parse_data_ != NULL; | 953 cached_parse_data_ != NULL; |
| 954 } | 954 } |
| 955 bool produce_cached_parse_data() const { | 955 bool produce_cached_parse_data() const { |
| 956 return compile_options_ == ScriptCompiler::kProduceParserCache; | 956 return compile_options_ == ScriptCompiler::kProduceParserCache; |
| 957 } | 957 } |
| 958 Scope* DeclarationScope(VariableMode mode) { | |
| 959 return IsLexicalVariableMode(mode) | |
| 960 ? scope_ : scope_->DeclarationScope(); | |
| 961 } | |
| 962 | 958 |
| 963 // All ParseXXX functions take as the last argument an *ok parameter | 959 // All ParseXXX functions take as the last argument an *ok parameter |
| 964 // which is set to false if parsing failed; it is unchanged otherwise. | 960 // which is set to false if parsing failed; it is unchanged otherwise. |
| 965 // By making the 'exception handling' explicit, we are forced to check | 961 // By making the 'exception handling' explicit, we are forced to check |
| 966 // for failure at the call sites. | 962 // for failure at the call sites. |
| 967 void* ParseStatementList(ZoneList<Statement*>* body, int end_token, bool* ok); | 963 void* ParseStatementList(ZoneList<Statement*>* body, int end_token, bool* ok); |
| 968 Statement* ParseStatementListItem(bool* ok); | 964 Statement* ParseStatementListItem(bool* ok); |
| 969 void* ParseModuleItemList(ZoneList<Statement*>* body, bool* ok); | 965 void* ParseModuleItemList(ZoneList<Statement*>* body, bool* ok); |
| 970 Statement* ParseModuleItem(bool* ok); | 966 Statement* ParseModuleItem(bool* ok); |
| 971 const AstRawString* ParseModuleSpecifier(bool* ok); | 967 const AstRawString* ParseModuleSpecifier(bool* ok); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 988 Statement* ParseNativeDeclaration(bool* ok); | 984 Statement* ParseNativeDeclaration(bool* ok); |
| 989 Block* ParseBlock(ZoneList<const AstRawString*>* labels, bool* ok); | 985 Block* ParseBlock(ZoneList<const AstRawString*>* labels, bool* ok); |
| 990 Block* ParseVariableStatement(VariableDeclarationContext var_context, | 986 Block* ParseVariableStatement(VariableDeclarationContext var_context, |
| 991 ZoneList<const AstRawString*>* names, | 987 ZoneList<const AstRawString*>* names, |
| 992 bool* ok); | 988 bool* ok); |
| 993 DoExpression* ParseDoExpression(bool* ok); | 989 DoExpression* ParseDoExpression(bool* ok); |
| 994 | 990 |
| 995 struct DeclarationDescriptor { | 991 struct DeclarationDescriptor { |
| 996 enum Kind { NORMAL, PARAMETER }; | 992 enum Kind { NORMAL, PARAMETER }; |
| 997 Parser* parser; | 993 Parser* parser; |
| 998 Scope* declaration_scope; | |
| 999 Scope* scope; | 994 Scope* scope; |
| 1000 Scope* hoist_scope; | 995 Scope* hoist_scope; |
| 1001 VariableMode mode; | 996 VariableMode mode; |
| 1002 bool is_const; | |
| 1003 bool needs_init; | 997 bool needs_init; |
| 1004 int declaration_pos; | 998 int declaration_pos; |
| 1005 int initialization_pos; | 999 int initialization_pos; |
| 1006 Kind declaration_kind; | 1000 Kind declaration_kind; |
| 1007 }; | 1001 }; |
| 1008 | 1002 |
| 1009 struct DeclarationParsingResult { | 1003 struct DeclarationParsingResult { |
| 1010 struct Declaration { | 1004 struct Declaration { |
| 1011 Declaration(Expression* pattern, int initializer_position, | 1005 Declaration(Expression* pattern, int initializer_position, |
| 1012 Expression* initializer) | 1006 Expression* initializer) |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1403 | 1397 |
| 1404 DoExpression* ParserTraits::ParseDoExpression(bool* ok) { | 1398 DoExpression* ParserTraits::ParseDoExpression(bool* ok) { |
| 1405 return parser_->ParseDoExpression(ok); | 1399 return parser_->ParseDoExpression(ok); |
| 1406 } | 1400 } |
| 1407 | 1401 |
| 1408 | 1402 |
| 1409 } // namespace internal | 1403 } // namespace internal |
| 1410 } // namespace v8 | 1404 } // namespace v8 |
| 1411 | 1405 |
| 1412 #endif // V8_PARSING_PARSER_H_ | 1406 #endif // V8_PARSING_PARSER_H_ |
| OLD | NEW |