Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Side by Side Diff: src/parsing/preparser.h

Issue 2209573002: Separate Scope into DeclarationScope and Scope (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Move has_simple_parameters_ to DeclarationScope Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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(Scope* scope) 577 explicit PreParserFormalParameters(DeclarationScope* 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
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(Scope* scope, PreParserIdentifier parameter, 923 void DeclareFormalParameter(DeclarationScope* scope,
924 PreParserIdentifier parameter,
924 Type::ExpressionClassifier* classifier) { 925 Type::ExpressionClassifier* classifier) {
925 if (!classifier->is_simple_parameter_list()) { 926 if (!classifier->is_simple_parameter_list()) {
926 scope->SetHasNonSimpleParameters(); 927 scope->SetHasNonSimpleParameters();
927 } 928 }
928 } 929 }
929 930
930 void CheckConflictingVarDeclarations(Scope* scope, bool* ok) {} 931 void CheckConflictingVarDeclarations(Scope* scope, bool* ok) {}
931 932
932 // Temporary glue; these functions will move to ParserBase. 933 // Temporary glue; these functions will move to ParserBase.
933 PreParserExpression ParseV8Intrinsic(bool* ok); 934 PreParserExpression ParseV8Intrinsic(bool* ok);
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
1038 // captured the syntax error), and false if a stack-overflow happened 1039 // captured the syntax error), and false if a stack-overflow happened
1039 // during parsing. 1040 // during parsing.
1040 PreParseResult PreParseProgram(int* materialized_literals = 0, 1041 PreParseResult PreParseProgram(int* materialized_literals = 0,
1041 bool is_module = false) { 1042 bool is_module = false) {
1042 DCHECK_NULL(scope_state_); 1043 DCHECK_NULL(scope_state_);
1043 Scope* scope = NewScriptScope(); 1044 Scope* scope = NewScriptScope();
1044 1045
1045 // ModuleDeclarationInstantiation for Source Text Module Records creates a 1046 // ModuleDeclarationInstantiation for Source Text Module Records creates a
1046 // new Module Environment Record whose outer lexical environment record is 1047 // new Module Environment Record whose outer lexical environment record is
1047 // the global scope. 1048 // the global scope.
1048 if (is_module) { 1049 if (is_module) scope = NewModuleScope(scope);
1049 scope = NewScopeWithParent(scope, MODULE_SCOPE);
1050 }
1051 1050
1052 FunctionState top_scope(&function_state_, &scope_state_, scope, 1051 FunctionState top_scope(&function_state_, &scope_state_, scope,
1053 kNormalFunction); 1052 kNormalFunction);
1054 bool ok = true; 1053 bool ok = true;
1055 int start_position = scanner()->peek_location().beg_pos; 1054 int start_position = scanner()->peek_location().beg_pos;
1056 parsing_module_ = is_module; 1055 parsing_module_ = is_module;
1057 ParseStatementList(Token::EOS, &ok); 1056 ParseStatementList(Token::EOS, &ok);
1058 if (stack_overflow()) return kPreParseStackOverflow; 1057 if (stack_overflow()) return kPreParseStackOverflow;
1059 if (!ok) { 1058 if (!ok) {
1060 ReportUnexpectedToken(scanner()->current_token()); 1059 ReportUnexpectedToken(scanner()->current_token());
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
1265 const PreParserFormalParameters& parameters, FunctionKind kind, 1264 const PreParserFormalParameters& parameters, FunctionKind kind,
1266 FunctionLiteral::FunctionType function_type, bool* ok) { 1265 FunctionLiteral::FunctionType function_type, bool* ok) {
1267 return pre_parser_->ParseEagerFunctionBody(function_name, pos, parameters, 1266 return pre_parser_->ParseEagerFunctionBody(function_name, pos, parameters,
1268 kind, function_type, ok); 1267 kind, function_type, ok);
1269 } 1268 }
1270 1269
1271 } // namespace internal 1270 } // namespace internal
1272 } // namespace v8 1271 } // namespace v8
1273 1272
1274 #endif // V8_PARSING_PREPARSER_H 1273 #endif // V8_PARSING_PREPARSER_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698