| 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_PREPARSER_H | 5 #ifndef V8_PARSING_PREPARSER_H |
| 6 #define V8_PARSING_PREPARSER_H | 6 #define V8_PARSING_PREPARSER_H |
| 7 | 7 |
| 8 #include "src/ast/scopes.h" | 8 #include "src/ast/scopes.h" |
| 9 #include "src/bailout-reason.h" | 9 #include "src/bailout-reason.h" |
| 10 #include "src/base/hashmap.h" | 10 #include "src/base/hashmap.h" |
| (...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 567 // dummy method right in this class. | 567 // dummy method right in this class. |
| 568 PreParserFactory* visitor() { return this; } | 568 PreParserFactory* visitor() { return this; } |
| 569 int* ast_properties() { | 569 int* ast_properties() { |
| 570 static int dummy = 42; | 570 static int dummy = 42; |
| 571 return &dummy; | 571 return &dummy; |
| 572 } | 572 } |
| 573 }; | 573 }; |
| 574 | 574 |
| 575 | 575 |
| 576 struct PreParserFormalParameters : FormalParametersBase { | 576 struct PreParserFormalParameters : FormalParametersBase { |
| 577 explicit PreParserFormalParameters(DeclarationScope* scope) | 577 explicit PreParserFormalParameters(Scope* scope) |
| 578 : FormalParametersBase(scope) {} | 578 : FormalParametersBase(scope) {} |
| 579 int arity = 0; | 579 int arity = 0; |
| 580 | 580 |
| 581 int Arity() const { return arity; } | 581 int Arity() const { return arity; } |
| 582 PreParserIdentifier at(int i) { return PreParserIdentifier(); } // Dummy | 582 PreParserIdentifier at(int i) { return PreParserIdentifier(); } // Dummy |
| 583 }; | 583 }; |
| 584 | 584 |
| 585 | 585 |
| 586 class PreParser; | 586 class PreParser; |
| 587 | 587 |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 913 static bool IsTaggedTemplate(const PreParserExpression tag) { | 913 static bool IsTaggedTemplate(const PreParserExpression tag) { |
| 914 return !tag.IsNoTemplateTag(); | 914 return !tag.IsNoTemplateTag(); |
| 915 } | 915 } |
| 916 | 916 |
| 917 void AddFormalParameter(PreParserFormalParameters* parameters, | 917 void AddFormalParameter(PreParserFormalParameters* parameters, |
| 918 PreParserExpression pattern, | 918 PreParserExpression pattern, |
| 919 PreParserExpression initializer, | 919 PreParserExpression initializer, |
| 920 int initializer_end_position, bool is_rest) { | 920 int initializer_end_position, bool is_rest) { |
| 921 ++parameters->arity; | 921 ++parameters->arity; |
| 922 } | 922 } |
| 923 void DeclareFormalParameter(DeclarationScope* scope, | 923 void DeclareFormalParameter(Scope* scope, PreParserIdentifier parameter, |
| 924 PreParserIdentifier parameter, | |
| 925 Type::ExpressionClassifier* classifier) { | 924 Type::ExpressionClassifier* classifier) { |
| 926 if (!classifier->is_simple_parameter_list()) { | 925 if (!classifier->is_simple_parameter_list()) { |
| 927 scope->SetHasNonSimpleParameters(); | 926 scope->SetHasNonSimpleParameters(); |
| 928 } | 927 } |
| 929 } | 928 } |
| 930 | 929 |
| 931 void CheckConflictingVarDeclarations(Scope* scope, bool* ok) {} | 930 void CheckConflictingVarDeclarations(Scope* scope, bool* ok) {} |
| 932 | 931 |
| 933 // Temporary glue; these functions will move to ParserBase. | 932 // Temporary glue; these functions will move to ParserBase. |
| 934 PreParserExpression ParseV8Intrinsic(bool* ok); | 933 PreParserExpression ParseV8Intrinsic(bool* ok); |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1039 // captured the syntax error), and false if a stack-overflow happened | 1038 // captured the syntax error), and false if a stack-overflow happened |
| 1040 // during parsing. | 1039 // during parsing. |
| 1041 PreParseResult PreParseProgram(int* materialized_literals = 0, | 1040 PreParseResult PreParseProgram(int* materialized_literals = 0, |
| 1042 bool is_module = false) { | 1041 bool is_module = false) { |
| 1043 DCHECK_NULL(scope_state_); | 1042 DCHECK_NULL(scope_state_); |
| 1044 Scope* scope = NewScriptScope(); | 1043 Scope* scope = NewScriptScope(); |
| 1045 | 1044 |
| 1046 // ModuleDeclarationInstantiation for Source Text Module Records creates a | 1045 // ModuleDeclarationInstantiation for Source Text Module Records creates a |
| 1047 // new Module Environment Record whose outer lexical environment record is | 1046 // new Module Environment Record whose outer lexical environment record is |
| 1048 // the global scope. | 1047 // the global scope. |
| 1049 if (is_module) scope = NewModuleScope(scope); | 1048 if (is_module) { |
| 1049 scope = NewScopeWithParent(scope, MODULE_SCOPE); |
| 1050 } |
| 1050 | 1051 |
| 1051 FunctionState top_scope(&function_state_, &scope_state_, scope, | 1052 FunctionState top_scope(&function_state_, &scope_state_, scope, |
| 1052 kNormalFunction); | 1053 kNormalFunction); |
| 1053 bool ok = true; | 1054 bool ok = true; |
| 1054 int start_position = scanner()->peek_location().beg_pos; | 1055 int start_position = scanner()->peek_location().beg_pos; |
| 1055 parsing_module_ = is_module; | 1056 parsing_module_ = is_module; |
| 1056 ParseStatementList(Token::EOS, &ok); | 1057 ParseStatementList(Token::EOS, &ok); |
| 1057 if (stack_overflow()) return kPreParseStackOverflow; | 1058 if (stack_overflow()) return kPreParseStackOverflow; |
| 1058 if (!ok) { | 1059 if (!ok) { |
| 1059 ReportUnexpectedToken(scanner()->current_token()); | 1060 ReportUnexpectedToken(scanner()->current_token()); |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1264 const PreParserFormalParameters& parameters, FunctionKind kind, | 1265 const PreParserFormalParameters& parameters, FunctionKind kind, |
| 1265 FunctionLiteral::FunctionType function_type, bool* ok) { | 1266 FunctionLiteral::FunctionType function_type, bool* ok) { |
| 1266 return pre_parser_->ParseEagerFunctionBody(function_name, pos, parameters, | 1267 return pre_parser_->ParseEagerFunctionBody(function_name, pos, parameters, |
| 1267 kind, function_type, ok); | 1268 kind, function_type, ok); |
| 1268 } | 1269 } |
| 1269 | 1270 |
| 1270 } // namespace internal | 1271 } // namespace internal |
| 1271 } // namespace v8 | 1272 } // namespace v8 |
| 1272 | 1273 |
| 1273 #endif // V8_PARSING_PREPARSER_H | 1274 #endif // V8_PARSING_PREPARSER_H |
| OLD | NEW |