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

Side by Side Diff: src/parser.cc

Issue 987083003: [es6] support rest parameters in arrow functions (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix preparser bug Created 5 years, 9 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 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/api.h" 7 #include "src/api.h"
8 #include "src/ast.h" 8 #include "src/ast.h"
9 #include "src/bailout-reason.h" 9 #include "src/bailout-reason.h"
10 #include "src/base/platform/platform.h" 10 #include "src/base/platform/platform.h"
(...skipping 3535 matching lines...) Expand 10 before | Expand all | Expand 10 after
3546 // () => ... 3546 // () => ...
3547 if (expression == NULL) return true; 3547 if (expression == NULL) return true;
3548 3548
3549 // Too many parentheses around expression: 3549 // Too many parentheses around expression:
3550 // (( ... )) => ... 3550 // (( ... )) => ...
3551 if (expression->is_multi_parenthesized()) return false; 3551 if (expression->is_multi_parenthesized()) return false;
3552 3552
3553 // Case for a single parameter: 3553 // Case for a single parameter:
3554 // (foo) => ... 3554 // (foo) => ...
3555 // foo => ... 3555 // foo => ...
3556 bool is_rest = false;
arv (Not doing code reviews) 2015/03/10 13:44:02 Maybe this should go after the IsVariableProxy che
3557 if (expression->IsSpreadOperation()) {
3558 expression = expression->AsSpreadOperation()->expression();
3559 is_rest = true;
3560 }
3556 if (expression->IsVariableProxy()) { 3561 if (expression->IsVariableProxy()) {
3557 if (expression->AsVariableProxy()->is_this()) return false; 3562 if (expression->AsVariableProxy()->is_this()) return false;
3558 3563
3559 const AstRawString* raw_name = expression->AsVariableProxy()->raw_name(); 3564 const AstRawString* raw_name = expression->AsVariableProxy()->raw_name();
3560 if (traits->IsEvalOrArguments(raw_name) || 3565 if (traits->IsEvalOrArguments(raw_name) ||
3561 traits->IsFutureStrictReserved(raw_name)) 3566 traits->IsFutureStrictReserved(raw_name))
3562 return false; 3567 return false;
3563 3568
3564 if (scope->IsDeclared(raw_name)) { 3569 if (scope->IsDeclared(raw_name)) {
3565 *dupe_loc = Scanner::Location( 3570 *dupe_loc = Scanner::Location(
3566 expression->position(), expression->position() + raw_name->length()); 3571 expression->position(), expression->position() + raw_name->length());
3567 return false; 3572 return false;
3568 } 3573 }
3569 3574
3570 scope->DeclareParameter(raw_name, VAR); 3575 scope->DeclareParameter(raw_name, VAR, is_rest);
3571 ++(*num_params); 3576 ++(*num_params);
3572 return true; 3577 return true;
3573 } 3578 }
3574 3579
3575 // Case for more than one parameter: 3580 // Case for more than one parameter:
3576 // (foo, bar [, ...]) => ... 3581 // (foo, bar [, ...]) => ...
3577 if (expression->IsBinaryOperation()) { 3582 if (expression->IsBinaryOperation()) {
3578 BinaryOperation* binop = expression->AsBinaryOperation(); 3583 BinaryOperation* binop = expression->AsBinaryOperation();
3579 if (binop->op() != Token::COMMA || binop->left()->is_parenthesized() || 3584 if (binop->op() != Token::COMMA || binop->left()->is_parenthesized() ||
3580 binop->right()->is_parenthesized()) 3585 binop->right()->is_parenthesized())
(...skipping 1869 matching lines...) Expand 10 before | Expand all | Expand 10 after
5450 } else { 5455 } else {
5451 const uc16* data = reinterpret_cast<const uc16*>(raw_string->raw_data()); 5456 const uc16* data = reinterpret_cast<const uc16*>(raw_string->raw_data());
5452 running_hash = StringHasher::ComputeRunningHash(running_hash, data, 5457 running_hash = StringHasher::ComputeRunningHash(running_hash, data,
5453 raw_string->length()); 5458 raw_string->length());
5454 } 5459 }
5455 } 5460 }
5456 5461
5457 return running_hash; 5462 return running_hash;
5458 } 5463 }
5459 } } // namespace v8::internal 5464 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698