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

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

Issue 2135983002: Version 5.2.361.39 (cherry-pick) (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@5.2
Patch Set: Created 4 years, 5 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 | « include/v8-version.h ('k') | test/mjsunit/harmony/function-sent.js » ('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 "src/api.h" 7 #include "src/api.h"
8 #include "src/ast/ast.h" 8 #include "src/ast/ast.h"
9 #include "src/ast/ast-expression-rewriter.h" 9 #include "src/ast/ast-expression-rewriter.h"
10 #include "src/ast/ast-expression-visitor.h" 10 #include "src/ast/ast-expression-visitor.h"
(...skipping 5938 matching lines...) Expand 10 before | Expand all | Expand 10 after
5949 // mode = kNext; 5949 // mode = kNext;
5950 // } catch (error) { 5950 // } catch (error) {
5951 // mode = kThrow; 5951 // mode = kThrow;
5952 // } 5952 // }
5953 // } finally { 5953 // } finally {
5954 // input = function.sent; 5954 // input = function.sent;
5955 // continue; 5955 // continue;
5956 // } 5956 // }
5957 // } 5957 // }
5958 // 5958 //
5959 // output.value; 5959 // if (mode === kReturn) {
5960 // return {value: output.value, done: true};
5961 // }
5962 // output.value
5960 // } 5963 // }
5961 // 5964 //
5962 // IteratorClose(iterator) expands to the following: 5965 // IteratorClose(iterator) expands to the following:
5963 // 5966 //
5964 // let iteratorReturn = iterator.return; 5967 // let iteratorReturn = iterator.return;
5965 // if (IS_NULL_OR_UNDEFINED(iteratorReturn)) return; 5968 // if (IS_NULL_OR_UNDEFINED(iteratorReturn)) return;
5966 // let output = %_Call(iteratorReturn, iterator); 5969 // let output = %_Call(iteratorReturn, iterator);
5967 // if (!IS_RECEIVER(output)) %ThrowIterResultNotAnObject(output); 5970 // if (!IS_RECEIVER(output)) %ThrowIterResultNotAnObject(output);
5968 // 5971 //
5969 // IteratorClose(iterator, input, output) expands to the following: 5972 // IteratorClose(iterator, input, output) expands to the following:
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
6245 Statement* get_input; 6248 Statement* get_input;
6246 { 6249 {
6247 Expression* function_sent = FunctionSentExpression(scope, factory, nopos); 6250 Expression* function_sent = FunctionSentExpression(scope, factory, nopos);
6248 Expression* input_proxy = factory->NewVariableProxy(var_input); 6251 Expression* input_proxy = factory->NewVariableProxy(var_input);
6249 Expression* assignment = factory->NewAssignment( 6252 Expression* assignment = factory->NewAssignment(
6250 Token::ASSIGN, input_proxy, function_sent, nopos); 6253 Token::ASSIGN, input_proxy, function_sent, nopos);
6251 get_input = factory->NewExpressionStatement(assignment, nopos); 6254 get_input = factory->NewExpressionStatement(assignment, nopos);
6252 } 6255 }
6253 6256
6254 6257
6255 // output.value; 6258 // if (mode === kReturn) {
6259 // return {value: output.value, done: true};
6260 // }
6261 Statement* maybe_return_value;
6262 {
6263 Expression* mode_proxy = factory->NewVariableProxy(var_mode);
6264 Expression* kreturn =
6265 factory->NewSmiLiteral(JSGeneratorObject::kReturn, nopos);
6266 Expression* condition = factory->NewCompareOperation(
6267 Token::EQ_STRICT, mode_proxy, kreturn, nopos);
6268
6269 Expression* output_proxy = factory->NewVariableProxy(var_output);
6270 Expression* literal =
6271 factory->NewStringLiteral(avfactory->value_string(), nopos);
6272 Expression* property = factory->NewProperty(output_proxy, literal, nopos);
6273 Statement* return_value =
6274 factory->NewReturnStatement(BuildIteratorResult(property, true), nopos);
6275
6276 maybe_return_value = factory->NewIfStatement(
6277 condition, return_value, factory->NewEmptyStatement(nopos), nopos);
6278 }
6279
6280
6281 // output.value
6256 Statement* get_value; 6282 Statement* get_value;
6257 { 6283 {
6258 Expression* output_proxy = factory->NewVariableProxy(var_output); 6284 Expression* output_proxy = factory->NewVariableProxy(var_output);
6259 Expression* literal = 6285 Expression* literal =
6260 factory->NewStringLiteral(avfactory->value_string(), nopos); 6286 factory->NewStringLiteral(avfactory->value_string(), nopos);
6261 Expression* property = factory->NewProperty(output_proxy, literal, nopos); 6287 Expression* property = factory->NewProperty(output_proxy, literal, nopos);
6262 get_value = factory->NewExpressionStatement(property, nopos); 6288 get_value = factory->NewExpressionStatement(property, nopos);
6263 } 6289 }
6264 6290
6265 6291
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
6348 loop->Initialize(factory->NewBooleanLiteral(true, nopos), loop_body); 6374 loop->Initialize(factory->NewBooleanLiteral(true, nopos), loop_body);
6349 } 6375 }
6350 6376
6351 6377
6352 // do { ... } 6378 // do { ... }
6353 DoExpression* yield_star; 6379 DoExpression* yield_star;
6354 { 6380 {
6355 // The rewriter needs to process the get_value statement only, hence we 6381 // The rewriter needs to process the get_value statement only, hence we
6356 // put the preceding statements into an init block. 6382 // put the preceding statements into an init block.
6357 6383
6358 Block* do_block_ = factory->NewBlock(nullptr, 6, true, nopos); 6384 Block* do_block_ = factory->NewBlock(nullptr, 7, true, nopos);
6359 do_block_->statements()->Add(initialize_input, zone); 6385 do_block_->statements()->Add(initialize_input, zone);
6360 do_block_->statements()->Add(initialize_mode, zone); 6386 do_block_->statements()->Add(initialize_mode, zone);
6361 do_block_->statements()->Add(initialize_output, zone); 6387 do_block_->statements()->Add(initialize_output, zone);
6362 do_block_->statements()->Add(get_iterator, zone); 6388 do_block_->statements()->Add(get_iterator, zone);
6363 do_block_->statements()->Add(validate_iterator, zone); 6389 do_block_->statements()->Add(validate_iterator, zone);
6364 do_block_->statements()->Add(loop, zone); 6390 do_block_->statements()->Add(loop, zone);
6391 do_block_->statements()->Add(maybe_return_value, zone);
6365 6392
6366 Block* do_block = factory->NewBlock(nullptr, 2, false, nopos); 6393 Block* do_block = factory->NewBlock(nullptr, 2, false, nopos);
6367 do_block->statements()->Add(do_block_, zone); 6394 do_block->statements()->Add(do_block_, zone);
6368 do_block->statements()->Add(get_value, zone); 6395 do_block->statements()->Add(get_value, zone);
6369 6396
6370 Variable* dot_result = scope->NewTemporary(avfactory->dot_result_string()); 6397 Variable* dot_result = scope->NewTemporary(avfactory->dot_result_string());
6371 yield_star = factory->NewDoExpression(do_block, dot_result, nopos); 6398 yield_star = factory->NewDoExpression(do_block, dot_result, nopos);
6372 Rewriter::Rewrite(parser_, yield_star, avfactory); 6399 Rewriter::Rewrite(parser_, yield_star, avfactory);
6373 } 6400 }
6374 6401
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after
6927 try_block, target); 6954 try_block, target);
6928 final_loop = target; 6955 final_loop = target;
6929 } 6956 }
6930 6957
6931 return final_loop; 6958 return final_loop;
6932 } 6959 }
6933 6960
6934 6961
6935 } // namespace internal 6962 } // namespace internal
6936 } // namespace v8 6963 } // namespace v8
OLDNEW
« no previous file with comments | « include/v8-version.h ('k') | test/mjsunit/harmony/function-sent.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698