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

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

Issue 2220363004: Redirect Scope::NewTemporary over parser (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') | no next file » | 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 2723 matching lines...) Expand 10 before | Expand all | Expand 10 after
2734 // for a non object. 2734 // for a non object.
2735 // 2735 //
2736 // return expr; 2736 // return expr;
2737 // 2737 //
2738 // Is rewritten as: 2738 // Is rewritten as:
2739 // 2739 //
2740 // return (temp = expr) === undefined ? this : 2740 // return (temp = expr) === undefined ? this :
2741 // %_IsJSReceiver(temp) ? temp : 1; 2741 // %_IsJSReceiver(temp) ? temp : 1;
2742 2742
2743 // temp = expr 2743 // temp = expr
2744 Variable* temp = 2744 Variable* temp = NewTemporary(ast_value_factory()->empty_string());
2745 scope()->NewTemporary(ast_value_factory()->empty_string());
2746 Assignment* assign = factory()->NewAssignment( 2745 Assignment* assign = factory()->NewAssignment(
2747 Token::ASSIGN, factory()->NewVariableProxy(temp), return_value, pos); 2746 Token::ASSIGN, factory()->NewVariableProxy(temp), return_value, pos);
2748 2747
2749 // %_IsJSReceiver(temp) 2748 // %_IsJSReceiver(temp)
2750 ZoneList<Expression*>* is_spec_object_args = 2749 ZoneList<Expression*>* is_spec_object_args =
2751 new (zone()) ZoneList<Expression*>(1, zone()); 2750 new (zone()) ZoneList<Expression*>(1, zone());
2752 is_spec_object_args->Add(factory()->NewVariableProxy(temp), zone()); 2751 is_spec_object_args->Add(factory()->NewVariableProxy(temp), zone());
2753 Expression* is_spec_object_call = factory()->NewCallRuntime( 2752 Expression* is_spec_object_call = factory()->NewCallRuntime(
2754 Runtime::kInlineIsJSReceiver, is_spec_object_args, pos); 2753 Runtime::kInlineIsJSReceiver, is_spec_object_args, pos);
2755 2754
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
2877 2876
2878 Block* switch_block = factory()->NewBlock(NULL, 2, false, kNoSourcePosition); 2877 Block* switch_block = factory()->NewBlock(NULL, 2, false, kNoSourcePosition);
2879 int switch_pos = peek_position(); 2878 int switch_pos = peek_position();
2880 2879
2881 Expect(Token::SWITCH, CHECK_OK); 2880 Expect(Token::SWITCH, CHECK_OK);
2882 Expect(Token::LPAREN, CHECK_OK); 2881 Expect(Token::LPAREN, CHECK_OK);
2883 Expression* tag = ParseExpression(true, CHECK_OK); 2882 Expression* tag = ParseExpression(true, CHECK_OK);
2884 Expect(Token::RPAREN, CHECK_OK); 2883 Expect(Token::RPAREN, CHECK_OK);
2885 2884
2886 Variable* tag_variable = 2885 Variable* tag_variable =
2887 scope()->NewTemporary(ast_value_factory()->dot_switch_tag_string()); 2886 NewTemporary(ast_value_factory()->dot_switch_tag_string());
2888 Assignment* tag_assign = factory()->NewAssignment( 2887 Assignment* tag_assign = factory()->NewAssignment(
2889 Token::ASSIGN, factory()->NewVariableProxy(tag_variable), tag, 2888 Token::ASSIGN, factory()->NewVariableProxy(tag_variable), tag,
2890 tag->position()); 2889 tag->position());
2891 Statement* tag_statement = 2890 Statement* tag_statement =
2892 factory()->NewExpressionStatement(tag_assign, kNoSourcePosition); 2891 factory()->NewExpressionStatement(tag_assign, kNoSourcePosition);
2893 switch_block->statements()->Add(tag_statement, zone()); 2892 switch_block->statements()->Add(tag_statement, zone());
2894 2893
2895 // make statement: undefined; 2894 // make statement: undefined;
2896 // This is needed so the tag isn't returned as the value, in case the switch 2895 // This is needed so the tag isn't returned as the value, in case the switch
2897 // statements don't have a value. 2896 // statements don't have a value.
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
3238 Expression* subject, 3237 Expression* subject,
3239 Statement* body, 3238 Statement* body,
3240 int each_keyword_pos) { 3239 int each_keyword_pos) {
3241 ForOfStatement* for_of = stmt->AsForOfStatement(); 3240 ForOfStatement* for_of = stmt->AsForOfStatement();
3242 if (for_of != NULL) { 3241 if (for_of != NULL) {
3243 const bool finalize = true; 3242 const bool finalize = true;
3244 return InitializeForOfStatement(for_of, each, subject, body, finalize, 3243 return InitializeForOfStatement(for_of, each, subject, body, finalize,
3245 each_keyword_pos); 3244 each_keyword_pos);
3246 } else { 3245 } else {
3247 if (each->IsArrayLiteral() || each->IsObjectLiteral()) { 3246 if (each->IsArrayLiteral() || each->IsObjectLiteral()) {
3248 Variable* temp = 3247 Variable* temp = NewTemporary(ast_value_factory()->empty_string());
3249 scope()->NewTemporary(ast_value_factory()->empty_string());
3250 VariableProxy* temp_proxy = factory()->NewVariableProxy(temp); 3248 VariableProxy* temp_proxy = factory()->NewVariableProxy(temp);
3251 Expression* assign_each = PatternRewriter::RewriteDestructuringAssignment( 3249 Expression* assign_each = PatternRewriter::RewriteDestructuringAssignment(
3252 this, factory()->NewAssignment(Token::ASSIGN, each, temp_proxy, 3250 this, factory()->NewAssignment(Token::ASSIGN, each, temp_proxy,
3253 kNoSourcePosition), 3251 kNoSourcePosition),
3254 scope()); 3252 scope());
3255 auto block = factory()->NewBlock(nullptr, 2, false, kNoSourcePosition); 3253 auto block = factory()->NewBlock(nullptr, 2, false, kNoSourcePosition);
3256 block->statements()->Add( 3254 block->statements()->Add(
3257 factory()->NewExpressionStatement(assign_each, kNoSourcePosition), 3255 factory()->NewExpressionStatement(assign_each, kNoSourcePosition),
3258 zone()); 3256 zone());
3259 block->statements()->Add(body, zone()); 3257 block->statements()->Add(body, zone());
(...skipping 12 matching lines...) Expand all
3272 int next_result_pos) { 3270 int next_result_pos) {
3273 // Create the auxiliary expressions needed for iterating over the iterable, 3271 // Create the auxiliary expressions needed for iterating over the iterable,
3274 // and initialize the given ForOfStatement with them. 3272 // and initialize the given ForOfStatement with them.
3275 // If finalize is true, also instrument the loop with code that performs the 3273 // If finalize is true, also instrument the loop with code that performs the
3276 // proper ES6 iterator finalization. In that case, the result is not 3274 // proper ES6 iterator finalization. In that case, the result is not
3277 // immediately a ForOfStatement. 3275 // immediately a ForOfStatement.
3278 3276
3279 const int nopos = kNoSourcePosition; 3277 const int nopos = kNoSourcePosition;
3280 auto avfactory = ast_value_factory(); 3278 auto avfactory = ast_value_factory();
3281 3279
3282 Variable* iterator = 3280 Variable* iterator = NewTemporary(ast_value_factory()->dot_iterator_string());
3283 scope()->NewTemporary(ast_value_factory()->dot_iterator_string()); 3281 Variable* result = NewTemporary(ast_value_factory()->dot_result_string());
3284 Variable* result = 3282 Variable* completion = NewTemporary(avfactory->empty_string());
3285 scope()->NewTemporary(ast_value_factory()->dot_result_string());
3286 Variable* completion = scope()->NewTemporary(avfactory->empty_string());
3287 3283
3288 // iterator = iterable[Symbol.iterator]() 3284 // iterator = iterable[Symbol.iterator]()
3289 Expression* assign_iterator; 3285 Expression* assign_iterator;
3290 { 3286 {
3291 assign_iterator = factory()->NewAssignment( 3287 assign_iterator = factory()->NewAssignment(
3292 Token::ASSIGN, factory()->NewVariableProxy(iterator), 3288 Token::ASSIGN, factory()->NewVariableProxy(iterator),
3293 GetIterator(iterable, factory(), iterable->position()), 3289 GetIterator(iterable, factory(), iterable->position()),
3294 iterable->position()); 3290 iterable->position());
3295 } 3291 }
3296 3292
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
3332 3328
3333 Block* block = factory()->NewBlock(nullptr, 1, true, nopos); 3329 Block* block = factory()->NewBlock(nullptr, 1, true, nopos);
3334 block->statements()->Add( 3330 block->statements()->Add(
3335 factory()->NewExpressionStatement(assignment, nopos), zone()); 3331 factory()->NewExpressionStatement(assignment, nopos), zone());
3336 set_completion_abrupt = block; 3332 set_completion_abrupt = block;
3337 } 3333 }
3338 3334
3339 // do { let tmp = #result_value; #set_completion_abrupt; tmp } 3335 // do { let tmp = #result_value; #set_completion_abrupt; tmp }
3340 // Expression* result_value (gets overwritten) 3336 // Expression* result_value (gets overwritten)
3341 if (finalize) { 3337 if (finalize) {
3342 Variable* var_tmp = scope()->NewTemporary(avfactory->empty_string()); 3338 Variable* var_tmp = NewTemporary(avfactory->empty_string());
3343 Expression* tmp = factory()->NewVariableProxy(var_tmp); 3339 Expression* tmp = factory()->NewVariableProxy(var_tmp);
3344 Expression* assignment = 3340 Expression* assignment =
3345 factory()->NewAssignment(Token::ASSIGN, tmp, result_value, nopos); 3341 factory()->NewAssignment(Token::ASSIGN, tmp, result_value, nopos);
3346 3342
3347 Block* block = factory()->NewBlock(nullptr, 2, false, nopos); 3343 Block* block = factory()->NewBlock(nullptr, 2, false, nopos);
3348 block->statements()->Add( 3344 block->statements()->Add(
3349 factory()->NewExpressionStatement(assignment, nopos), zone()); 3345 factory()->NewExpressionStatement(assignment, nopos), zone());
3350 block->statements()->Add(set_completion_abrupt, zone()); 3346 block->statements()->Add(set_completion_abrupt, zone());
3351 3347
3352 result_value = factory()->NewDoExpression(block, var_tmp, nopos); 3348 result_value = factory()->NewDoExpression(block, var_tmp, nopos);
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
3442 3438
3443 // Add statement: let/const x = i. 3439 // Add statement: let/const x = i.
3444 outer_block->statements()->Add(init, zone()); 3440 outer_block->statements()->Add(init, zone());
3445 3441
3446 const AstRawString* temp_name = ast_value_factory()->dot_for_string(); 3442 const AstRawString* temp_name = ast_value_factory()->dot_for_string();
3447 3443
3448 // For each lexical variable x: 3444 // For each lexical variable x:
3449 // make statement: temp_x = x. 3445 // make statement: temp_x = x.
3450 for (int i = 0; i < names->length(); i++) { 3446 for (int i = 0; i < names->length(); i++) {
3451 VariableProxy* proxy = NewUnresolved(names->at(i), LET); 3447 VariableProxy* proxy = NewUnresolved(names->at(i), LET);
3452 Variable* temp = scope()->NewTemporary(temp_name); 3448 Variable* temp = NewTemporary(temp_name);
3453 VariableProxy* temp_proxy = factory()->NewVariableProxy(temp); 3449 VariableProxy* temp_proxy = factory()->NewVariableProxy(temp);
3454 Assignment* assignment = factory()->NewAssignment(Token::ASSIGN, temp_proxy, 3450 Assignment* assignment = factory()->NewAssignment(Token::ASSIGN, temp_proxy,
3455 proxy, kNoSourcePosition); 3451 proxy, kNoSourcePosition);
3456 Statement* assignment_statement = 3452 Statement* assignment_statement =
3457 factory()->NewExpressionStatement(assignment, kNoSourcePosition); 3453 factory()->NewExpressionStatement(assignment, kNoSourcePosition);
3458 outer_block->statements()->Add(assignment_statement, zone()); 3454 outer_block->statements()->Add(assignment_statement, zone());
3459 temps.Add(temp, zone()); 3455 temps.Add(temp, zone());
3460 } 3456 }
3461 3457
3462 Variable* first = NULL; 3458 Variable* first = NULL;
3463 // Make statement: first = 1. 3459 // Make statement: first = 1.
3464 if (next) { 3460 if (next) {
3465 first = scope()->NewTemporary(temp_name); 3461 first = NewTemporary(temp_name);
3466 VariableProxy* first_proxy = factory()->NewVariableProxy(first); 3462 VariableProxy* first_proxy = factory()->NewVariableProxy(first);
3467 Expression* const1 = factory()->NewSmiLiteral(1, kNoSourcePosition); 3463 Expression* const1 = factory()->NewSmiLiteral(1, kNoSourcePosition);
3468 Assignment* assignment = factory()->NewAssignment( 3464 Assignment* assignment = factory()->NewAssignment(
3469 Token::ASSIGN, first_proxy, const1, kNoSourcePosition); 3465 Token::ASSIGN, first_proxy, const1, kNoSourcePosition);
3470 Statement* assignment_statement = 3466 Statement* assignment_statement =
3471 factory()->NewExpressionStatement(assignment, kNoSourcePosition); 3467 factory()->NewExpressionStatement(assignment, kNoSourcePosition);
3472 outer_block->statements()->Add(assignment_statement, zone()); 3468 outer_block->statements()->Add(assignment_statement, zone());
3473 } 3469 }
3474 3470
3475 // make statement: undefined; 3471 // make statement: undefined;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
3530 Assignment* assignment = factory()->NewAssignment( 3526 Assignment* assignment = factory()->NewAssignment(
3531 Token::ASSIGN, first_proxy, const0, kNoSourcePosition); 3527 Token::ASSIGN, first_proxy, const0, kNoSourcePosition);
3532 clear_first = 3528 clear_first =
3533 factory()->NewExpressionStatement(assignment, kNoSourcePosition); 3529 factory()->NewExpressionStatement(assignment, kNoSourcePosition);
3534 } 3530 }
3535 Statement* clear_first_or_next = factory()->NewIfStatement( 3531 Statement* clear_first_or_next = factory()->NewIfStatement(
3536 compare, clear_first, next, kNoSourcePosition); 3532 compare, clear_first, next, kNoSourcePosition);
3537 ignore_completion_block->statements()->Add(clear_first_or_next, zone()); 3533 ignore_completion_block->statements()->Add(clear_first_or_next, zone());
3538 } 3534 }
3539 3535
3540 Variable* flag = scope()->NewTemporary(temp_name); 3536 Variable* flag = NewTemporary(temp_name);
3541 // Make statement: flag = 1. 3537 // Make statement: flag = 1.
3542 { 3538 {
3543 VariableProxy* flag_proxy = factory()->NewVariableProxy(flag); 3539 VariableProxy* flag_proxy = factory()->NewVariableProxy(flag);
3544 Expression* const1 = factory()->NewSmiLiteral(1, kNoSourcePosition); 3540 Expression* const1 = factory()->NewSmiLiteral(1, kNoSourcePosition);
3545 Assignment* assignment = factory()->NewAssignment( 3541 Assignment* assignment = factory()->NewAssignment(
3546 Token::ASSIGN, flag_proxy, const1, kNoSourcePosition); 3542 Token::ASSIGN, flag_proxy, const1, kNoSourcePosition);
3547 Statement* assignment_statement = 3543 Statement* assignment_statement =
3548 factory()->NewExpressionStatement(assignment, kNoSourcePosition); 3544 factory()->NewExpressionStatement(assignment, kNoSourcePosition);
3549 ignore_completion_block->statements()->Add(assignment_statement, zone()); 3545 ignore_completion_block->statements()->Add(assignment_statement, zone());
3550 } 3546 }
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
3739 // { 3735 // {
3740 // <let x' be a temporary variable> 3736 // <let x' be a temporary variable>
3741 // for (x' in/of e) { 3737 // for (x' in/of e) {
3742 // let/const/var x; 3738 // let/const/var x;
3743 // x = x'; 3739 // x = x';
3744 // b; 3740 // b;
3745 // } 3741 // }
3746 // let x; // for TDZ 3742 // let x; // for TDZ
3747 // } 3743 // }
3748 3744
3749 Variable* temp = 3745 Variable* temp = NewTemporary(ast_value_factory()->dot_for_string());
3750 scope()->NewTemporary(ast_value_factory()->dot_for_string());
3751 ForEachStatement* loop = 3746 ForEachStatement* loop =
3752 factory()->NewForEachStatement(mode, labels, stmt_pos); 3747 factory()->NewForEachStatement(mode, labels, stmt_pos);
3753 Target target(&this->target_stack_, loop); 3748 Target target(&this->target_stack_, loop);
3754 3749
3755 int each_keyword_position = scanner()->location().beg_pos; 3750 int each_keyword_position = scanner()->location().beg_pos;
3756 3751
3757 Expression* enumerable; 3752 Expression* enumerable;
3758 if (mode == ForEachStatement::ITERATE) { 3753 if (mode == ForEachStatement::ITERATE) {
3759 ExpressionClassifier classifier(this); 3754 ExpressionClassifier classifier(this);
3760 enumerable = ParseAssignmentExpression(true, &classifier, CHECK_OK); 3755 enumerable = ParseAssignmentExpression(true, &classifier, CHECK_OK);
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
4132 bool accept_IN, int pos, bool* ok) { 4127 bool accept_IN, int pos, bool* ok) {
4133 // function async_function() { 4128 // function async_function() {
4134 // try { 4129 // try {
4135 // .generator_object = %CreateGeneratorObject(); 4130 // .generator_object = %CreateGeneratorObject();
4136 // ... function body ... 4131 // ... function body ...
4137 // } catch (e) { 4132 // } catch (e) {
4138 // return Promise.reject(e); 4133 // return Promise.reject(e);
4139 // } 4134 // }
4140 // } 4135 // }
4141 scope->ForceContextAllocation(); 4136 scope->ForceContextAllocation();
4142 Variable* temp = this->scope()->NewTemporary( 4137 Variable* temp =
4143 ast_value_factory()->dot_generator_object_string()); 4138 NewTemporary(ast_value_factory()->dot_generator_object_string());
4144 function_state_->set_generator_object_variable(temp); 4139 function_state_->set_generator_object_variable(temp);
4145 4140
4146 Expression* init_generator_variable = factory()->NewAssignment( 4141 Expression* init_generator_variable = factory()->NewAssignment(
4147 Token::INIT, factory()->NewVariableProxy(temp), 4142 Token::INIT, factory()->NewVariableProxy(temp),
4148 BuildCreateJSGeneratorObject(pos, kind), kNoSourcePosition); 4143 BuildCreateJSGeneratorObject(pos, kind), kNoSourcePosition);
4149 body->Add(factory()->NewExpressionStatement(init_generator_variable, 4144 body->Add(factory()->NewExpressionStatement(init_generator_variable,
4150 kNoSourcePosition), 4145 kNoSourcePosition),
4151 zone()); 4146 zone());
4152 4147
4153 Block* try_block = factory()->NewBlock(NULL, 8, true, kNoSourcePosition); 4148 Block* try_block = factory()->NewBlock(NULL, 8, true, kNoSourcePosition);
(...skipping 17 matching lines...) Expand all
4171 body->Add(BuildRejectPromiseOnException(try_block), zone()); 4166 body->Add(BuildRejectPromiseOnException(try_block), zone());
4172 scope->set_end_position(scanner()->location().end_pos); 4167 scope->set_end_position(scanner()->location().end_pos);
4173 } 4168 }
4174 4169
4175 DoExpression* Parser::ParseDoExpression(bool* ok) { 4170 DoExpression* Parser::ParseDoExpression(bool* ok) {
4176 // AssignmentExpression :: 4171 // AssignmentExpression ::
4177 // do '{' StatementList '}' 4172 // do '{' StatementList '}'
4178 int pos = peek_position(); 4173 int pos = peek_position();
4179 4174
4180 Expect(Token::DO, CHECK_OK); 4175 Expect(Token::DO, CHECK_OK);
4181 Variable* result = 4176 Variable* result = NewTemporary(ast_value_factory()->dot_result_string());
4182 scope()->NewTemporary(ast_value_factory()->dot_result_string());
4183 Block* block = ParseBlock(nullptr, CHECK_OK); 4177 Block* block = ParseBlock(nullptr, CHECK_OK);
4184 DoExpression* expr = factory()->NewDoExpression(block, result, pos); 4178 DoExpression* expr = factory()->NewDoExpression(block, result, pos);
4185 if (!Rewriter::Rewrite(this, GetClosureScope(), expr, ast_value_factory())) { 4179 if (!Rewriter::Rewrite(this, GetClosureScope(), expr, ast_value_factory())) {
4186 *ok = false; 4180 *ok = false;
4187 return nullptr; 4181 return nullptr;
4188 } 4182 }
4189 return expr; 4183 return expr;
4190 } 4184 }
4191 4185
4192 void ParserTraits::ParseArrowFunctionFormalParameterList( 4186 void ParserTraits::ParseArrowFunctionFormalParameterList(
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
4375 if (is_generator) { 4369 if (is_generator) {
4376 // For generators, allocating variables in contexts is currently a win 4370 // For generators, allocating variables in contexts is currently a win
4377 // because it minimizes the work needed to suspend and resume an 4371 // because it minimizes the work needed to suspend and resume an
4378 // activation. The machine code produced for generators (by full-codegen) 4372 // activation. The machine code produced for generators (by full-codegen)
4379 // relies on this forced context allocation, but not in an essential way. 4373 // relies on this forced context allocation, but not in an essential way.
4380 this->scope()->ForceContextAllocation(); 4374 this->scope()->ForceContextAllocation();
4381 4375
4382 // Calling a generator returns a generator object. That object is stored 4376 // Calling a generator returns a generator object. That object is stored
4383 // in a temporary variable, a definition that is used by "yield" 4377 // in a temporary variable, a definition that is used by "yield"
4384 // expressions. This also marks the FunctionState as a generator. 4378 // expressions. This also marks the FunctionState as a generator.
4385 Variable* temp = this->scope()->NewTemporary( 4379 Variable* temp =
4386 ast_value_factory()->dot_generator_object_string()); 4380 NewTemporary(ast_value_factory()->dot_generator_object_string());
4387 function_state.set_generator_object_variable(temp); 4381 function_state.set_generator_object_variable(temp);
4388 } 4382 }
4389 4383
4390 Expect(Token::LPAREN, CHECK_OK); 4384 Expect(Token::LPAREN, CHECK_OK);
4391 int start_position = scanner()->location().beg_pos; 4385 int start_position = scanner()->location().beg_pos;
4392 this->scope()->set_start_position(start_position); 4386 this->scope()->set_start_position(start_position);
4393 ParserFormalParameters formals(scope); 4387 ParserFormalParameters formals(scope);
4394 ParseFormalParameterList(&formals, &formals_classifier, CHECK_OK); 4388 ParseFormalParameterList(&formals, &formals_classifier, CHECK_OK);
4395 arity = formals.Arity(); 4389 arity = formals.Arity();
4396 Expect(Token::RPAREN, CHECK_OK); 4390 Expect(Token::RPAREN, CHECK_OK);
(...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after
5098 // Note that we do not finalize this block scope because it is 5092 // Note that we do not finalize this block scope because it is
5099 // used as a sentinel value indicating an anonymous class. 5093 // used as a sentinel value indicating an anonymous class.
5100 block_state.set_end_position(end_pos); 5094 block_state.set_end_position(end_pos);
5101 5095
5102 if (name != nullptr) { 5096 if (name != nullptr) {
5103 DCHECK_NOT_NULL(proxy); 5097 DCHECK_NOT_NULL(proxy);
5104 proxy->var()->set_initializer_position(end_pos); 5098 proxy->var()->set_initializer_position(end_pos);
5105 } 5099 }
5106 5100
5107 Block* do_block = factory()->NewBlock(nullptr, 1, false, pos); 5101 Block* do_block = factory()->NewBlock(nullptr, 1, false, pos);
5108 Variable* result_var = 5102 Variable* result_var = NewTemporary(ast_value_factory()->empty_string());
5109 scope()->NewTemporary(ast_value_factory()->empty_string());
5110 do_block->set_scope(block_state.FinalizedBlockScope()); 5103 do_block->set_scope(block_state.FinalizedBlockScope());
5111 DoExpression* do_expr = factory()->NewDoExpression(do_block, result_var, pos); 5104 DoExpression* do_expr = factory()->NewDoExpression(do_block, result_var, pos);
5112 5105
5113 ClassLiteral* class_literal = factory()->NewClassLiteral( 5106 ClassLiteral* class_literal = factory()->NewClassLiteral(
5114 proxy, extends, constructor, properties, pos, end_pos); 5107 proxy, extends, constructor, properties, pos, end_pos);
5115 5108
5116 do_block->statements()->Add( 5109 do_block->statements()->Add(
5117 factory()->NewExpressionStatement(class_literal, pos), zone()); 5110 factory()->NewExpressionStatement(class_literal, pos), zone());
5118 do_expr->set_represented_function(constructor); 5111 do_expr->set_represented_function(constructor);
5119 Rewriter::Rewrite(this, GetClosureScope(), do_expr, ast_value_factory()); 5112 Rewriter::Rewrite(this, GetClosureScope(), do_expr, ast_value_factory());
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after
5704 return factory()->NewCallRuntime(Context::REFLECT_CONSTRUCT_INDEX, args, 5697 return factory()->NewCallRuntime(Context::REFLECT_CONSTRUCT_INDEX, args,
5705 pos); 5698 pos);
5706 } else { 5699 } else {
5707 if (function->IsProperty()) { 5700 if (function->IsProperty()) {
5708 // Method calls 5701 // Method calls
5709 if (function->AsProperty()->IsSuperAccess()) { 5702 if (function->AsProperty()->IsSuperAccess()) {
5710 Expression* home = ThisExpression(factory(), kNoSourcePosition); 5703 Expression* home = ThisExpression(factory(), kNoSourcePosition);
5711 args->InsertAt(0, function, zone()); 5704 args->InsertAt(0, function, zone());
5712 args->InsertAt(1, home, zone()); 5705 args->InsertAt(1, home, zone());
5713 } else { 5706 } else {
5714 Variable* temp = 5707 Variable* temp = NewTemporary(ast_value_factory()->empty_string());
5715 scope()->NewTemporary(ast_value_factory()->empty_string());
5716 VariableProxy* obj = factory()->NewVariableProxy(temp); 5708 VariableProxy* obj = factory()->NewVariableProxy(temp);
5717 Assignment* assign_obj = factory()->NewAssignment( 5709 Assignment* assign_obj = factory()->NewAssignment(
5718 Token::ASSIGN, obj, function->AsProperty()->obj(), 5710 Token::ASSIGN, obj, function->AsProperty()->obj(),
5719 kNoSourcePosition); 5711 kNoSourcePosition);
5720 function = factory()->NewProperty( 5712 function = factory()->NewProperty(
5721 assign_obj, function->AsProperty()->key(), kNoSourcePosition); 5713 assign_obj, function->AsProperty()->key(), kNoSourcePosition);
5722 args->InsertAt(0, function, zone()); 5714 args->InsertAt(0, function, zone());
5723 obj = factory()->NewVariableProxy(temp); 5715 obj = factory()->NewVariableProxy(temp);
5724 args->InsertAt(1, obj, zone()); 5716 args->InsertAt(1, obj, zone());
5725 } 5717 }
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
5810 // yield %AsyncFunctionAwait(.generator_object, <operand>) 5802 // yield %AsyncFunctionAwait(.generator_object, <operand>)
5811 Variable* generator_object_variable = 5803 Variable* generator_object_variable =
5812 parser_->function_state_->generator_object_variable(); 5804 parser_->function_state_->generator_object_variable();
5813 5805
5814 // If generator_object_variable is null, 5806 // If generator_object_variable is null,
5815 if (!generator_object_variable) return value; 5807 if (!generator_object_variable) return value;
5816 5808
5817 auto factory = parser_->factory(); 5809 auto factory = parser_->factory();
5818 const int nopos = kNoSourcePosition; 5810 const int nopos = kNoSourcePosition;
5819 5811
5820 Variable* temp_var = parser_->scope()->NewTemporary( 5812 Variable* temp_var =
5821 parser_->ast_value_factory()->empty_string()); 5813 parser_->NewTemporary(parser_->ast_value_factory()->empty_string());
5822 VariableProxy* temp_proxy = factory->NewVariableProxy(temp_var); 5814 VariableProxy* temp_proxy = factory->NewVariableProxy(temp_var);
5823 Block* do_block = factory->NewBlock(nullptr, 2, false, nopos); 5815 Block* do_block = factory->NewBlock(nullptr, 2, false, nopos);
5824 5816
5825 // Wrap value evaluation to provide a break location. 5817 // Wrap value evaluation to provide a break location.
5826 Expression* value_assignment = 5818 Expression* value_assignment =
5827 factory->NewAssignment(Token::ASSIGN, temp_proxy, value, nopos); 5819 factory->NewAssignment(Token::ASSIGN, temp_proxy, value, nopos);
5828 do_block->statements()->Add( 5820 do_block->statements()->Add(
5829 factory->NewExpressionStatement(value_assignment, value->position()), 5821 factory->NewExpressionStatement(value_assignment, value->position()),
5830 zone()); 5822 zone());
5831 5823
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
5954 DCHECK_NOT_NULL(lhs->raw_name()); 5946 DCHECK_NOT_NULL(lhs->raw_name());
5955 result = this->ExpressionFromIdentifier(lhs->raw_name(), lhs->position(), 5947 result = this->ExpressionFromIdentifier(lhs->raw_name(), lhs->position(),
5956 lhs->end_position(), factory()); 5948 lhs->end_position(), factory());
5957 args->Add(left, zone()); 5949 args->Add(left, zone());
5958 args->Add(right, zone()); 5950 args->Add(right, zone());
5959 Expression* call = 5951 Expression* call =
5960 factory()->NewCallRuntime(Context::MATH_POW_INDEX, args, pos); 5952 factory()->NewCallRuntime(Context::MATH_POW_INDEX, args, pos);
5961 return factory()->NewAssignment(Token::ASSIGN, result, call, pos); 5953 return factory()->NewAssignment(Token::ASSIGN, result, call, pos);
5962 } else if (left->IsProperty()) { 5954 } else if (left->IsProperty()) {
5963 Property* prop = left->AsProperty(); 5955 Property* prop = left->AsProperty();
5964 auto temp_obj = scope()->NewTemporary(ast_value_factory()->empty_string()); 5956 auto temp_obj = NewTemporary(ast_value_factory()->empty_string());
5965 auto temp_key = scope()->NewTemporary(ast_value_factory()->empty_string()); 5957 auto temp_key = NewTemporary(ast_value_factory()->empty_string());
5966 Expression* assign_obj = factory()->NewAssignment( 5958 Expression* assign_obj = factory()->NewAssignment(
5967 Token::ASSIGN, factory()->NewVariableProxy(temp_obj), prop->obj(), 5959 Token::ASSIGN, factory()->NewVariableProxy(temp_obj), prop->obj(),
5968 kNoSourcePosition); 5960 kNoSourcePosition);
5969 Expression* assign_key = factory()->NewAssignment( 5961 Expression* assign_key = factory()->NewAssignment(
5970 Token::ASSIGN, factory()->NewVariableProxy(temp_key), prop->key(), 5962 Token::ASSIGN, factory()->NewVariableProxy(temp_key), prop->key(),
5971 kNoSourcePosition); 5963 kNoSourcePosition);
5972 args->Add(factory()->NewProperty(factory()->NewVariableProxy(temp_obj), 5964 args->Add(factory()->NewProperty(factory()->NewVariableProxy(temp_obj),
5973 factory()->NewVariableProxy(temp_key), 5965 factory()->NewVariableProxy(temp_key),
5974 left->position()), 5966 left->position()),
5975 zone()); 5967 zone());
(...skipping 22 matching lines...) Expand all
5998 // $R = [1, 2, 3]; 5990 // $R = [1, 2, 3];
5999 // for ($i of x) %AppendElement($R, $i); 5991 // for ($i of x) %AppendElement($R, $i);
6000 // %AppendElement($R, 4); 5992 // %AppendElement($R, 4);
6001 // for ($j of y) %AppendElement($R, $j); 5993 // for ($j of y) %AppendElement($R, $j);
6002 // %AppendElement($R, 5); 5994 // %AppendElement($R, 5);
6003 // $R 5995 // $R
6004 // } 5996 // }
6005 // where $R, $i and $j are fresh temporary variables. 5997 // where $R, $i and $j are fresh temporary variables.
6006 ZoneList<Expression*>::iterator s = lit->FirstSpread(); 5998 ZoneList<Expression*>::iterator s = lit->FirstSpread();
6007 if (s == lit->EndValue()) return nullptr; // no spread, no rewriting... 5999 if (s == lit->EndValue()) return nullptr; // no spread, no rewriting...
6008 Variable* result = 6000 Variable* result = NewTemporary(ast_value_factory()->dot_result_string());
6009 scope()->NewTemporary(ast_value_factory()->dot_result_string());
6010 // NOTE: The value assigned to R is the whole original array literal, 6001 // NOTE: The value assigned to R is the whole original array literal,
6011 // spreads included. This will be fixed before the rewritten AST is returned. 6002 // spreads included. This will be fixed before the rewritten AST is returned.
6012 // $R = lit 6003 // $R = lit
6013 Expression* init_result = factory()->NewAssignment( 6004 Expression* init_result = factory()->NewAssignment(
6014 Token::INIT, factory()->NewVariableProxy(result), lit, kNoSourcePosition); 6005 Token::INIT, factory()->NewVariableProxy(result), lit, kNoSourcePosition);
6015 Block* do_block = factory()->NewBlock(nullptr, 16, false, kNoSourcePosition); 6006 Block* do_block = factory()->NewBlock(nullptr, 16, false, kNoSourcePosition);
6016 do_block->statements()->Add( 6007 do_block->statements()->Add(
6017 factory()->NewExpressionStatement(init_result, kNoSourcePosition), 6008 factory()->NewExpressionStatement(init_result, kNoSourcePosition),
6018 zone()); 6009 zone());
6019 // Traverse the array literal starting from the first spread. 6010 // Traverse the array literal starting from the first spread.
6020 while (s != lit->EndValue()) { 6011 while (s != lit->EndValue()) {
6021 Expression* value = *s++; 6012 Expression* value = *s++;
6022 Spread* spread = value->AsSpread(); 6013 Spread* spread = value->AsSpread();
6023 if (spread == nullptr) { 6014 if (spread == nullptr) {
6024 // If the element is not a spread, we're adding a single: 6015 // If the element is not a spread, we're adding a single:
6025 // %AppendElement($R, value) 6016 // %AppendElement($R, value)
6026 ZoneList<Expression*>* append_element_args = NewExpressionList(2, zone()); 6017 ZoneList<Expression*>* append_element_args = NewExpressionList(2, zone());
6027 append_element_args->Add(factory()->NewVariableProxy(result), zone()); 6018 append_element_args->Add(factory()->NewVariableProxy(result), zone());
6028 append_element_args->Add(value, zone()); 6019 append_element_args->Add(value, zone());
6029 do_block->statements()->Add( 6020 do_block->statements()->Add(
6030 factory()->NewExpressionStatement( 6021 factory()->NewExpressionStatement(
6031 factory()->NewCallRuntime(Runtime::kAppendElement, 6022 factory()->NewCallRuntime(Runtime::kAppendElement,
6032 append_element_args, kNoSourcePosition), 6023 append_element_args, kNoSourcePosition),
6033 kNoSourcePosition), 6024 kNoSourcePosition),
6034 zone()); 6025 zone());
6035 } else { 6026 } else {
6036 // If it's a spread, we're adding a for/of loop iterating through it. 6027 // If it's a spread, we're adding a for/of loop iterating through it.
6037 Variable* each = 6028 Variable* each = NewTemporary(ast_value_factory()->dot_for_string());
6038 scope()->NewTemporary(ast_value_factory()->dot_for_string());
6039 Expression* subject = spread->expression(); 6029 Expression* subject = spread->expression();
6040 // %AppendElement($R, each) 6030 // %AppendElement($R, each)
6041 Statement* append_body; 6031 Statement* append_body;
6042 { 6032 {
6043 ZoneList<Expression*>* append_element_args = 6033 ZoneList<Expression*>* append_element_args =
6044 NewExpressionList(2, zone()); 6034 NewExpressionList(2, zone());
6045 append_element_args->Add(factory()->NewVariableProxy(result), zone()); 6035 append_element_args->Add(factory()->NewVariableProxy(result), zone());
6046 append_element_args->Add(factory()->NewVariableProxy(each), zone()); 6036 append_element_args->Add(factory()->NewVariableProxy(each), zone());
6047 append_body = factory()->NewExpressionStatement( 6037 append_body = factory()->NewExpressionStatement(
6048 factory()->NewCallRuntime(Runtime::kAppendElement, 6038 factory()->NewCallRuntime(Runtime::kAppendElement,
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
6213 // if (IS_NULL_OR_UNDEFINED(iteratorReturn)) return input; 6203 // if (IS_NULL_OR_UNDEFINED(iteratorReturn)) return input;
6214 // output = %_Call(iteratorReturn, iterator, input); 6204 // output = %_Call(iteratorReturn, iterator, input);
6215 // if (!IS_RECEIVER(output)) %ThrowIterResultNotAnObject(output); 6205 // if (!IS_RECEIVER(output)) %ThrowIterResultNotAnObject(output);
6216 6206
6217 Expression* ParserTraits::RewriteYieldStar( 6207 Expression* ParserTraits::RewriteYieldStar(
6218 Expression* generator, Expression* iterable, int pos) { 6208 Expression* generator, Expression* iterable, int pos) {
6219 const int nopos = kNoSourcePosition; 6209 const int nopos = kNoSourcePosition;
6220 6210
6221 auto factory = parser_->factory(); 6211 auto factory = parser_->factory();
6222 auto avfactory = parser_->ast_value_factory(); 6212 auto avfactory = parser_->ast_value_factory();
6223 auto scope = parser_->scope();
6224 auto zone = parser_->zone(); 6213 auto zone = parser_->zone();
6225 6214
6226 6215
6227 // Forward definition for break/continue statements. 6216 // Forward definition for break/continue statements.
6228 WhileStatement* loop = factory->NewWhileStatement(nullptr, nopos); 6217 WhileStatement* loop = factory->NewWhileStatement(nullptr, nopos);
6229 6218
6230 6219
6231 // let input = undefined; 6220 // let input = undefined;
6232 Variable* var_input = scope->NewTemporary(avfactory->empty_string()); 6221 Variable* var_input = parser_->NewTemporary(avfactory->empty_string());
6233 Statement* initialize_input; 6222 Statement* initialize_input;
6234 { 6223 {
6235 Expression* input_proxy = factory->NewVariableProxy(var_input); 6224 Expression* input_proxy = factory->NewVariableProxy(var_input);
6236 Expression* assignment = factory->NewAssignment( 6225 Expression* assignment = factory->NewAssignment(
6237 Token::ASSIGN, input_proxy, factory->NewUndefinedLiteral(nopos), nopos); 6226 Token::ASSIGN, input_proxy, factory->NewUndefinedLiteral(nopos), nopos);
6238 initialize_input = factory->NewExpressionStatement(assignment, nopos); 6227 initialize_input = factory->NewExpressionStatement(assignment, nopos);
6239 } 6228 }
6240 6229
6241 6230
6242 // let mode = kNext; 6231 // let mode = kNext;
6243 Variable* var_mode = scope->NewTemporary(avfactory->empty_string()); 6232 Variable* var_mode = parser_->NewTemporary(avfactory->empty_string());
6244 Statement* initialize_mode; 6233 Statement* initialize_mode;
6245 { 6234 {
6246 Expression* mode_proxy = factory->NewVariableProxy(var_mode); 6235 Expression* mode_proxy = factory->NewVariableProxy(var_mode);
6247 Expression* knext = factory->NewSmiLiteral(JSGeneratorObject::kNext, nopos); 6236 Expression* knext = factory->NewSmiLiteral(JSGeneratorObject::kNext, nopos);
6248 Expression* assignment = 6237 Expression* assignment =
6249 factory->NewAssignment(Token::ASSIGN, mode_proxy, knext, nopos); 6238 factory->NewAssignment(Token::ASSIGN, mode_proxy, knext, nopos);
6250 initialize_mode = factory->NewExpressionStatement(assignment, nopos); 6239 initialize_mode = factory->NewExpressionStatement(assignment, nopos);
6251 } 6240 }
6252 6241
6253 6242
6254 // let output = undefined; 6243 // let output = undefined;
6255 Variable* var_output = scope->NewTemporary(avfactory->empty_string()); 6244 Variable* var_output = parser_->NewTemporary(avfactory->empty_string());
6256 Statement* initialize_output; 6245 Statement* initialize_output;
6257 { 6246 {
6258 Expression* output_proxy = factory->NewVariableProxy(var_output); 6247 Expression* output_proxy = factory->NewVariableProxy(var_output);
6259 Expression* assignment = factory->NewAssignment( 6248 Expression* assignment = factory->NewAssignment(
6260 Token::ASSIGN, output_proxy, factory->NewUndefinedLiteral(nopos), 6249 Token::ASSIGN, output_proxy, factory->NewUndefinedLiteral(nopos),
6261 nopos); 6250 nopos);
6262 initialize_output = factory->NewExpressionStatement(assignment, nopos); 6251 initialize_output = factory->NewExpressionStatement(assignment, nopos);
6263 } 6252 }
6264 6253
6265 6254
6266 // let iterator = iterable[Symbol.iterator]; 6255 // let iterator = iterable[Symbol.iterator];
6267 Variable* var_iterator = scope->NewTemporary(avfactory->empty_string()); 6256 Variable* var_iterator = parser_->NewTemporary(avfactory->empty_string());
6268 Statement* get_iterator; 6257 Statement* get_iterator;
6269 { 6258 {
6270 Expression* iterator = GetIterator(iterable, factory, nopos); 6259 Expression* iterator = GetIterator(iterable, factory, nopos);
6271 Expression* iterator_proxy = factory->NewVariableProxy(var_iterator); 6260 Expression* iterator_proxy = factory->NewVariableProxy(var_iterator);
6272 Expression* assignment = factory->NewAssignment( 6261 Expression* assignment = factory->NewAssignment(
6273 Token::ASSIGN, iterator_proxy, iterator, nopos); 6262 Token::ASSIGN, iterator_proxy, iterator, nopos);
6274 get_iterator = factory->NewExpressionStatement(assignment, nopos); 6263 get_iterator = factory->NewExpressionStatement(assignment, nopos);
6275 } 6264 }
6276 6265
6277 6266
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
6337 Runtime::kThrowIteratorResultNotAnObject, args, nopos); 6326 Runtime::kThrowIteratorResultNotAnObject, args, nopos);
6338 throw_call = factory->NewExpressionStatement(call, nopos); 6327 throw_call = factory->NewExpressionStatement(call, nopos);
6339 } 6328 }
6340 6329
6341 validate_next_output = factory->NewIfStatement( 6330 validate_next_output = factory->NewIfStatement(
6342 is_receiver_call, factory->NewEmptyStatement(nopos), throw_call, nopos); 6331 is_receiver_call, factory->NewEmptyStatement(nopos), throw_call, nopos);
6343 } 6332 }
6344 6333
6345 6334
6346 // let iteratorThrow = iterator.throw; 6335 // let iteratorThrow = iterator.throw;
6347 Variable* var_throw = scope->NewTemporary(avfactory->empty_string()); 6336 Variable* var_throw = parser_->NewTemporary(avfactory->empty_string());
6348 Statement* get_throw; 6337 Statement* get_throw;
6349 { 6338 {
6350 Expression* iterator_proxy = factory->NewVariableProxy(var_iterator); 6339 Expression* iterator_proxy = factory->NewVariableProxy(var_iterator);
6351 Expression* literal = 6340 Expression* literal =
6352 factory->NewStringLiteral(avfactory->throw_string(), nopos); 6341 factory->NewStringLiteral(avfactory->throw_string(), nopos);
6353 Expression* property = 6342 Expression* property =
6354 factory->NewProperty(iterator_proxy, literal, nopos); 6343 factory->NewProperty(iterator_proxy, literal, nopos);
6355 Expression* throw_proxy = factory->NewVariableProxy(var_throw); 6344 Expression* throw_proxy = factory->NewVariableProxy(var_throw);
6356 Expression* assignment = factory->NewAssignment( 6345 Expression* assignment = factory->NewAssignment(
6357 Token::ASSIGN, throw_proxy, property, nopos); 6346 Token::ASSIGN, throw_proxy, property, nopos);
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
6532 // try { ... } catch(e) { ... } 6521 // try { ... } catch(e) { ... }
6533 Statement* try_catch; 6522 Statement* try_catch;
6534 { 6523 {
6535 Block* try_block = factory->NewBlock(nullptr, 2, false, nopos); 6524 Block* try_block = factory->NewBlock(nullptr, 2, false, nopos);
6536 try_block->statements()->Add(yield_output, zone); 6525 try_block->statements()->Add(yield_output, zone);
6537 try_block->statements()->Add(set_mode_next, zone); 6526 try_block->statements()->Add(set_mode_next, zone);
6538 6527
6539 Block* catch_block = factory->NewBlock(nullptr, 1, false, nopos); 6528 Block* catch_block = factory->NewBlock(nullptr, 1, false, nopos);
6540 catch_block->statements()->Add(set_mode_throw, zone); 6529 catch_block->statements()->Add(set_mode_throw, zone);
6541 6530
6542 Scope* catch_scope = NewScopeWithParent(scope, CATCH_SCOPE); 6531 Scope* catch_scope = NewScope(CATCH_SCOPE);
6543 catch_scope->set_is_hidden(); 6532 catch_scope->set_is_hidden();
6544 const AstRawString* name = avfactory->dot_catch_string(); 6533 const AstRawString* name = avfactory->dot_catch_string();
6545 Variable* catch_variable = 6534 Variable* catch_variable =
6546 catch_scope->DeclareLocal(name, VAR, kCreatedInitialized, 6535 catch_scope->DeclareLocal(name, VAR, kCreatedInitialized,
6547 Variable::NORMAL); 6536 Variable::NORMAL);
6548 6537
6549 try_catch = factory->NewTryCatchStatementForDesugaring( 6538 try_catch = factory->NewTryCatchStatementForDesugaring(
6550 try_block, catch_scope, catch_variable, catch_block, nopos); 6539 try_block, catch_scope, catch_variable, catch_block, nopos);
6551 } 6540 }
6552 6541
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
6624 do_block_->statements()->Add(initialize_output, zone); 6613 do_block_->statements()->Add(initialize_output, zone);
6625 do_block_->statements()->Add(get_iterator, zone); 6614 do_block_->statements()->Add(get_iterator, zone);
6626 do_block_->statements()->Add(validate_iterator, zone); 6615 do_block_->statements()->Add(validate_iterator, zone);
6627 do_block_->statements()->Add(loop, zone); 6616 do_block_->statements()->Add(loop, zone);
6628 do_block_->statements()->Add(maybe_return_value, zone); 6617 do_block_->statements()->Add(maybe_return_value, zone);
6629 6618
6630 Block* do_block = factory->NewBlock(nullptr, 2, false, nopos); 6619 Block* do_block = factory->NewBlock(nullptr, 2, false, nopos);
6631 do_block->statements()->Add(do_block_, zone); 6620 do_block->statements()->Add(do_block_, zone);
6632 do_block->statements()->Add(get_value, zone); 6621 do_block->statements()->Add(get_value, zone);
6633 6622
6634 Variable* dot_result = scope->NewTemporary(avfactory->dot_result_string()); 6623 Variable* dot_result =
6624 parser_->NewTemporary(avfactory->dot_result_string());
6635 yield_star = factory->NewDoExpression(do_block, dot_result, nopos); 6625 yield_star = factory->NewDoExpression(do_block, dot_result, nopos);
6636 Rewriter::Rewrite(parser_, scope->GetClosureScope(), yield_star, avfactory); 6626 Rewriter::Rewrite(parser_, parser_->GetClosureScope(), yield_star,
6627 avfactory);
6637 } 6628 }
6638 6629
6639 return yield_star; 6630 return yield_star;
6640 } 6631 }
6641 6632
6642 Statement* ParserTraits::CheckCallable(Variable* var, Expression* error, 6633 Statement* ParserTraits::CheckCallable(Variable* var, Expression* error,
6643 int pos) { 6634 int pos) {
6644 auto factory = parser_->factory(); 6635 auto factory = parser_->factory();
6645 auto avfactory = parser_->ast_value_factory(); 6636 auto avfactory = parser_->ast_value_factory();
6646 const int nopos = kNoSourcePosition; 6637 const int nopos = kNoSourcePosition;
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
6897 // if (!IS_RECEIVER(output)) { 6888 // if (!IS_RECEIVER(output)) {
6898 // %ThrowIterResultNotAnObject(output); 6889 // %ThrowIterResultNotAnObject(output);
6899 // } 6890 // }
6900 // } 6891 // }
6901 // } 6892 // }
6902 // 6893 //
6903 6894
6904 const int nopos = kNoSourcePosition; 6895 const int nopos = kNoSourcePosition;
6905 auto factory = parser_->factory(); 6896 auto factory = parser_->factory();
6906 auto avfactory = parser_->ast_value_factory(); 6897 auto avfactory = parser_->ast_value_factory();
6907 auto scope = parser_->scope();
6908 auto zone = parser_->zone(); 6898 auto zone = parser_->zone();
6909 6899
6910 6900
6911 // let iteratorReturn = iterator.return; 6901 // let iteratorReturn = iterator.return;
6912 Variable* var_return = scope->NewTemporary(avfactory->empty_string()); 6902 Variable* var_return = parser_->NewTemporary(avfactory->empty_string());
6913 Statement* get_return; 6903 Statement* get_return;
6914 { 6904 {
6915 Expression* iterator_proxy = factory->NewVariableProxy(iterator); 6905 Expression* iterator_proxy = factory->NewVariableProxy(iterator);
6916 Expression* literal = 6906 Expression* literal =
6917 factory->NewStringLiteral(avfactory->return_string(), nopos); 6907 factory->NewStringLiteral(avfactory->return_string(), nopos);
6918 Expression* property = 6908 Expression* property =
6919 factory->NewProperty(iterator_proxy, literal, nopos); 6909 factory->NewProperty(iterator_proxy, literal, nopos);
6920 Expression* return_proxy = factory->NewVariableProxy(var_return); 6910 Expression* return_proxy = factory->NewVariableProxy(var_return);
6921 Expression* assignment = factory->NewAssignment( 6911 Expression* assignment = factory->NewAssignment(
6922 Token::ASSIGN, return_proxy, property, nopos); 6912 Token::ASSIGN, return_proxy, property, nopos);
(...skipping 20 matching lines...) Expand all
6943 6933
6944 Expression* call = 6934 Expression* call =
6945 factory->NewCallRuntime(Runtime::kInlineCall, args, nopos); 6935 factory->NewCallRuntime(Runtime::kInlineCall, args, nopos);
6946 6936
6947 Block* try_block = factory->NewBlock(nullptr, 1, false, nopos); 6937 Block* try_block = factory->NewBlock(nullptr, 1, false, nopos);
6948 try_block->statements()->Add(factory->NewExpressionStatement(call, nopos), 6938 try_block->statements()->Add(factory->NewExpressionStatement(call, nopos),
6949 zone); 6939 zone);
6950 6940
6951 Block* catch_block = factory->NewBlock(nullptr, 0, false, nopos); 6941 Block* catch_block = factory->NewBlock(nullptr, 0, false, nopos);
6952 6942
6953 Scope* catch_scope = NewScopeWithParent(scope, CATCH_SCOPE); 6943 Scope* catch_scope = NewScope(CATCH_SCOPE);
6954 Variable* catch_variable = catch_scope->DeclareLocal( 6944 Variable* catch_variable = catch_scope->DeclareLocal(
6955 avfactory->dot_catch_string(), VAR, kCreatedInitialized, 6945 avfactory->dot_catch_string(), VAR, kCreatedInitialized,
6956 Variable::NORMAL); 6946 Variable::NORMAL);
6957 catch_scope->set_is_hidden(); 6947 catch_scope->set_is_hidden();
6958 6948
6959 try_call_return = factory->NewTryCatchStatement( 6949 try_call_return = factory->NewTryCatchStatement(
6960 try_block, catch_scope, catch_variable, catch_block, nopos); 6950 try_block, catch_scope, catch_variable, catch_block, nopos);
6961 } 6951 }
6962 6952
6963 // let output = %_Call(iteratorReturn, iterator); 6953 // let output = %_Call(iteratorReturn, iterator);
6964 // if (!IS_RECEIVER(output)) { 6954 // if (!IS_RECEIVER(output)) {
6965 // %ThrowIteratorResultNotAnObject(output); 6955 // %ThrowIteratorResultNotAnObject(output);
6966 // } 6956 // }
6967 Block* validate_return; 6957 Block* validate_return;
6968 { 6958 {
6969 Variable* var_output = scope->NewTemporary(avfactory->empty_string()); 6959 Variable* var_output = parser_->NewTemporary(avfactory->empty_string());
6970 Statement* call_return; 6960 Statement* call_return;
6971 { 6961 {
6972 auto args = new (zone) ZoneList<Expression*>(2, zone); 6962 auto args = new (zone) ZoneList<Expression*>(2, zone);
6973 args->Add(factory->NewVariableProxy(var_return), zone); 6963 args->Add(factory->NewVariableProxy(var_return), zone);
6974 args->Add(factory->NewVariableProxy(iterator), zone); 6964 args->Add(factory->NewVariableProxy(iterator), zone);
6975 Expression* call = 6965 Expression* call =
6976 factory->NewCallRuntime(Runtime::kInlineCall, args, nopos); 6966 factory->NewCallRuntime(Runtime::kInlineCall, args, nopos);
6977 6967
6978 Expression* output_proxy = factory->NewVariableProxy(var_output); 6968 Expression* output_proxy = factory->NewVariableProxy(var_output);
6979 Expression* assignment = 6969 Expression* assignment =
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
7103 node->Print(Isolate::Current()); 7093 node->Print(Isolate::Current());
7104 } 7094 }
7105 #endif // DEBUG 7095 #endif // DEBUG
7106 7096
7107 #undef CHECK_OK 7097 #undef CHECK_OK
7108 #undef CHECK_OK_VOID 7098 #undef CHECK_OK_VOID
7109 #undef CHECK_FAILED 7099 #undef CHECK_FAILED
7110 7100
7111 } // namespace internal 7101 } // namespace internal
7112 } // namespace v8 7102 } // namespace v8
OLDNEW
« no previous file with comments | « src/parsing/parser.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698