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

Side by Side Diff: src/parsing/parser.cc

Issue 2245133003: [style] Rename some enum values with 'k' prefix (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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
« no previous file with comments | « src/parsing/parser.h ('k') | src/parsing/parser-base.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "src/parsing/parser.h" 5 #include "src/parsing/parser.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "src/api.h" 9 #include "src/api.h"
10 #include "src/ast/ast.h" 10 #include "src/ast/ast.h"
(...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after
761 default: 761 default:
762 DCHECK(false); 762 DCHECK(false);
763 } 763 }
764 return NULL; 764 return NULL;
765 } 765 }
766 766
767 Expression* ParserTraits::ExpressionFromIdentifier(const AstRawString* name, 767 Expression* ParserTraits::ExpressionFromIdentifier(const AstRawString* name,
768 int start_position, 768 int start_position,
769 int end_position, 769 int end_position,
770 InferName infer) { 770 InferName infer) {
771 if (infer == InferName::Yes && parser_->fni_ != NULL) { 771 if (infer == InferName::kYes && parser_->fni_ != NULL) {
772 parser_->fni_->PushVariableName(name); 772 parser_->fni_->PushVariableName(name);
773 } 773 }
774 return parser_->NewUnresolved(name, start_position, end_position); 774 return parser_->NewUnresolved(name, start_position, end_position);
775 } 775 }
776 776
777 777
778 Expression* ParserTraits::ExpressionFromString(int pos, Scanner* scanner, 778 Expression* ParserTraits::ExpressionFromString(int pos, Scanner* scanner,
779 AstNodeFactory* factory) { 779 AstNodeFactory* factory) {
780 const AstRawString* symbol = GetSymbol(scanner); 780 const AstRawString* symbol = GetSymbol(scanner);
781 if (parser_->fni_ != NULL) parser_->fni_->PushLiteralName(symbol); 781 if (parser_->fni_ != NULL) parser_->fni_->PushLiteralName(symbol);
(...skipping 3323 matching lines...) Expand 10 before | Expand all | Expand 10 after
4105 } 4105 }
4106 4106
4107 AddFormalParameter(parameters, expr, initializer, end_pos, is_rest); 4107 AddFormalParameter(parameters, expr, initializer, end_pos, is_rest);
4108 } 4108 }
4109 4109
4110 void ParserTraits::ParseAsyncArrowSingleExpressionBody( 4110 void ParserTraits::ParseAsyncArrowSingleExpressionBody(
4111 ZoneList<Statement*>* body, bool accept_IN, 4111 ZoneList<Statement*>* body, bool accept_IN,
4112 Type::ExpressionClassifier* classifier, int pos, bool* ok) { 4112 Type::ExpressionClassifier* classifier, int pos, bool* ok) {
4113 parser_->DesugarAsyncFunctionBody( 4113 parser_->DesugarAsyncFunctionBody(
4114 parser_->ast_value_factory()->empty_string(), parser_->scope(), body, 4114 parser_->ast_value_factory()->empty_string(), parser_->scope(), body,
4115 classifier, kAsyncArrowFunction, FunctionBody::SingleExpression, 4115 classifier, kAsyncArrowFunction,
4116 accept_IN, pos, ok); 4116 Parser::FunctionBodyType::kSingleExpression, accept_IN, pos, ok);
4117 } 4117 }
4118 4118
4119 void Parser::DesugarAsyncFunctionBody(const AstRawString* function_name, 4119 void Parser::DesugarAsyncFunctionBody(const AstRawString* function_name,
4120 Scope* scope, ZoneList<Statement*>* body, 4120 Scope* scope, ZoneList<Statement*>* body,
4121 ExpressionClassifier* classifier, 4121 ExpressionClassifier* classifier,
4122 FunctionKind kind, FunctionBody body_type, 4122 FunctionKind kind,
4123 FunctionBodyType body_type,
4123 bool accept_IN, int pos, bool* ok) { 4124 bool accept_IN, int pos, bool* ok) {
4124 // function async_function() { 4125 // function async_function() {
4125 // try { 4126 // try {
4126 // .generator_object = %CreateGeneratorObject(); 4127 // .generator_object = %CreateGeneratorObject();
4127 // ... function body ... 4128 // ... function body ...
4128 // } catch (e) { 4129 // } catch (e) {
4129 // return Promise.reject(e); 4130 // return Promise.reject(e);
4130 // } 4131 // }
4131 // } 4132 // }
4132 scope->ForceContextAllocation(); 4133 scope->ForceContextAllocation();
4133 Variable* temp = 4134 Variable* temp =
4134 NewTemporary(ast_value_factory()->dot_generator_object_string()); 4135 NewTemporary(ast_value_factory()->dot_generator_object_string());
4135 function_state_->set_generator_object_variable(temp); 4136 function_state_->set_generator_object_variable(temp);
4136 4137
4137 Expression* init_generator_variable = factory()->NewAssignment( 4138 Expression* init_generator_variable = factory()->NewAssignment(
4138 Token::INIT, factory()->NewVariableProxy(temp), 4139 Token::INIT, factory()->NewVariableProxy(temp),
4139 BuildCreateJSGeneratorObject(pos, kind), kNoSourcePosition); 4140 BuildCreateJSGeneratorObject(pos, kind), kNoSourcePosition);
4140 body->Add(factory()->NewExpressionStatement(init_generator_variable, 4141 body->Add(factory()->NewExpressionStatement(init_generator_variable,
4141 kNoSourcePosition), 4142 kNoSourcePosition),
4142 zone()); 4143 zone());
4143 4144
4144 Block* try_block = factory()->NewBlock(NULL, 8, true, kNoSourcePosition); 4145 Block* try_block = factory()->NewBlock(NULL, 8, true, kNoSourcePosition);
4145 4146
4146 ZoneList<Statement*>* inner_body = try_block->statements(); 4147 ZoneList<Statement*>* inner_body = try_block->statements();
4147 4148
4148 Expression* return_value = nullptr; 4149 Expression* return_value = nullptr;
4149 if (body_type == FunctionBody::Normal) { 4150 if (body_type == FunctionBodyType::kNormal) {
4150 ParseStatementList(inner_body, Token::RBRACE, CHECK_OK_VOID); 4151 ParseStatementList(inner_body, Token::RBRACE, CHECK_OK_VOID);
4151 return_value = factory()->NewUndefinedLiteral(kNoSourcePosition); 4152 return_value = factory()->NewUndefinedLiteral(kNoSourcePosition);
4152 } else { 4153 } else {
4153 return_value = 4154 return_value =
4154 ParseAssignmentExpression(accept_IN, classifier, CHECK_OK_VOID); 4155 ParseAssignmentExpression(accept_IN, classifier, CHECK_OK_VOID);
4155 ParserTraits::RewriteNonPattern(classifier, CHECK_OK_VOID); 4156 ParserTraits::RewriteNonPattern(classifier, CHECK_OK_VOID);
4156 } 4157 }
4157 4158
4158 return_value = BuildPromiseResolve(return_value, return_value->position()); 4159 return_value = BuildPromiseResolve(return_value, return_value->position());
4159 inner_body->Add( 4160 inner_body->Add(
(...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after
4862 Runtime::kInlineGeneratorClose, args, kNoSourcePosition); 4863 Runtime::kInlineGeneratorClose, args, kNoSourcePosition);
4863 finally_block->statements()->Add( 4864 finally_block->statements()->Add(
4864 factory()->NewExpressionStatement(call, kNoSourcePosition), zone()); 4865 factory()->NewExpressionStatement(call, kNoSourcePosition), zone());
4865 4866
4866 body->Add(factory()->NewTryFinallyStatement(try_block, finally_block, 4867 body->Add(factory()->NewTryFinallyStatement(try_block, finally_block,
4867 kNoSourcePosition), 4868 kNoSourcePosition),
4868 zone()); 4869 zone());
4869 } else if (IsAsyncFunction(kind)) { 4870 } else if (IsAsyncFunction(kind)) {
4870 const bool accept_IN = true; 4871 const bool accept_IN = true;
4871 DesugarAsyncFunctionBody(function_name, inner_scope, body, nullptr, kind, 4872 DesugarAsyncFunctionBody(function_name, inner_scope, body, nullptr, kind,
4872 FunctionBody::Normal, accept_IN, pos, CHECK_OK); 4873 FunctionBodyType::kNormal, accept_IN, pos,
4874 CHECK_OK);
4873 } else { 4875 } else {
4874 ParseStatementList(body, Token::RBRACE, CHECK_OK); 4876 ParseStatementList(body, Token::RBRACE, CHECK_OK);
4875 } 4877 }
4876 4878
4877 if (IsSubclassConstructor(kind)) { 4879 if (IsSubclassConstructor(kind)) {
4878 body->Add(factory()->NewReturnStatement( 4880 body->Add(factory()->NewReturnStatement(
4879 this->ThisExpression(kNoSourcePosition), kNoSourcePosition), 4881 this->ThisExpression(kNoSourcePosition), kNoSourcePosition),
4880 zone()); 4882 zone());
4881 } 4883 }
4882 } 4884 }
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
5033 const bool has_extends = extends != nullptr; 5035 const bool has_extends = extends != nullptr;
5034 while (peek() != Token::RBRACE) { 5036 while (peek() != Token::RBRACE) {
5035 if (Check(Token::SEMICOLON)) continue; 5037 if (Check(Token::SEMICOLON)) continue;
5036 FuncNameInferrer::State fni_state(fni_); 5038 FuncNameInferrer::State fni_state(fni_);
5037 const bool in_class = true; 5039 const bool in_class = true;
5038 bool is_computed_name = false; // Classes do not care about computed 5040 bool is_computed_name = false; // Classes do not care about computed
5039 // property names here. 5041 // property names here.
5040 ExpressionClassifier property_classifier(this); 5042 ExpressionClassifier property_classifier(this);
5041 const AstRawString* property_name = nullptr; 5043 const AstRawString* property_name = nullptr;
5042 ObjectLiteral::Property* property = ParsePropertyDefinition( 5044 ObjectLiteral::Property* property = ParsePropertyDefinition(
5043 &checker, in_class, has_extends, MethodKind::Normal, &is_computed_name, 5045 &checker, in_class, has_extends, MethodKind::kNormal, &is_computed_name,
5044 &has_seen_constructor, &property_classifier, &property_name, CHECK_OK); 5046 &has_seen_constructor, &property_classifier, &property_name, CHECK_OK);
5045 RewriteNonPattern(&property_classifier, CHECK_OK); 5047 RewriteNonPattern(&property_classifier, CHECK_OK);
5046 if (classifier != nullptr) { 5048 if (classifier != nullptr) {
5047 classifier->Accumulate(&property_classifier, 5049 classifier->Accumulate(&property_classifier,
5048 ExpressionClassifier::ExpressionProductions); 5050 ExpressionClassifier::ExpressionProductions);
5049 } 5051 }
5050 5052
5051 if (has_seen_constructor && constructor == nullptr) { 5053 if (has_seen_constructor && constructor == nullptr) {
5052 constructor = GetPropertyValue(property)->AsFunctionLiteral(); 5054 constructor = GetPropertyValue(property)->AsFunctionLiteral();
5053 DCHECK_NOT_NULL(constructor); 5055 DCHECK_NOT_NULL(constructor);
(...skipping 2019 matching lines...) Expand 10 before | Expand all | Expand 10 after
7073 node->Print(Isolate::Current()); 7075 node->Print(Isolate::Current());
7074 } 7076 }
7075 #endif // DEBUG 7077 #endif // DEBUG
7076 7078
7077 #undef CHECK_OK 7079 #undef CHECK_OK
7078 #undef CHECK_OK_VOID 7080 #undef CHECK_OK_VOID
7079 #undef CHECK_FAILED 7081 #undef CHECK_FAILED
7080 7082
7081 } // namespace internal 7083 } // namespace internal
7082 } // namespace v8 7084 } // namespace v8
OLDNEW
« no previous file with comments | « src/parsing/parser.h ('k') | src/parsing/parser-base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698