| OLD | NEW |
| 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 3593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3604 // () => ... | 3604 // () => ... |
| 3605 if (expression == NULL) return true; | 3605 if (expression == NULL) return true; |
| 3606 | 3606 |
| 3607 // Too many parentheses around expression: | 3607 // Too many parentheses around expression: |
| 3608 // (( ... )) => ... | 3608 // (( ... )) => ... |
| 3609 if (expression->is_multi_parenthesized()) return false; | 3609 if (expression->is_multi_parenthesized()) return false; |
| 3610 | 3610 |
| 3611 // Case for a single parameter: | 3611 // Case for a single parameter: |
| 3612 // (foo) => ... | 3612 // (foo) => ... |
| 3613 // foo => ... | 3613 // foo => ... |
| 3614 bool is_rest; |
| 3615 if ((is_rest = expression->IsSpread())) { |
| 3616 expression = expression->AsSpread()->expression(); |
| 3617 } |
| 3614 if (expression->IsVariableProxy()) { | 3618 if (expression->IsVariableProxy()) { |
| 3615 if (expression->AsVariableProxy()->is_this()) return false; | 3619 if (expression->AsVariableProxy()->is_this()) return false; |
| 3616 | 3620 |
| 3617 const AstRawString* raw_name = expression->AsVariableProxy()->raw_name(); | 3621 const AstRawString* raw_name = expression->AsVariableProxy()->raw_name(); |
| 3618 if (traits->IsEvalOrArguments(raw_name) || | 3622 if (traits->IsEvalOrArguments(raw_name) || |
| 3619 traits->IsFutureStrictReserved(raw_name)) | 3623 traits->IsFutureStrictReserved(raw_name)) |
| 3620 return false; | 3624 return false; |
| 3621 | 3625 |
| 3622 if (scope->IsDeclared(raw_name)) { | 3626 if (scope->IsDeclared(raw_name)) { |
| 3623 *dupe_loc = Scanner::Location( | 3627 *dupe_loc = Scanner::Location( |
| 3624 expression->position(), expression->position() + raw_name->length()); | 3628 expression->position(), expression->position() + raw_name->length()); |
| 3625 return false; | 3629 return false; |
| 3626 } | 3630 } |
| 3627 | 3631 |
| 3628 scope->DeclareParameter(raw_name, VAR); | 3632 scope->DeclareParameter(raw_name, VAR, is_rest); |
| 3629 ++(*num_params); | 3633 ++(*num_params); |
| 3630 return true; | 3634 return true; |
| 3631 } | 3635 } |
| 3632 | 3636 |
| 3633 // Case for more than one parameter: | 3637 // Case for more than one parameter: |
| 3634 // (foo, bar [, ...]) => ... | 3638 // (foo, bar [, ...]) => ... |
| 3635 if (expression->IsBinaryOperation()) { | 3639 if (expression->IsBinaryOperation()) { |
| 3636 BinaryOperation* binop = expression->AsBinaryOperation(); | 3640 BinaryOperation* binop = expression->AsBinaryOperation(); |
| 3637 if (binop->op() != Token::COMMA || binop->left()->is_parenthesized() || | 3641 if (binop->op() != Token::COMMA || binop->left()->is_parenthesized() || |
| 3638 binop->right()->is_parenthesized()) | 3642 binop->right()->is_parenthesized()) |
| (...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4171 VariableProxy* proxy = NULL; | 4175 VariableProxy* proxy = NULL; |
| 4172 if (name != NULL) { | 4176 if (name != NULL) { |
| 4173 proxy = NewUnresolved(name, CONST); | 4177 proxy = NewUnresolved(name, CONST); |
| 4174 Declaration* declaration = | 4178 Declaration* declaration = |
| 4175 factory()->NewVariableDeclaration(proxy, CONST, block_scope, pos); | 4179 factory()->NewVariableDeclaration(proxy, CONST, block_scope, pos); |
| 4176 Declare(declaration, true, CHECK_OK); | 4180 Declare(declaration, true, CHECK_OK); |
| 4177 } | 4181 } |
| 4178 | 4182 |
| 4179 Expression* extends = NULL; | 4183 Expression* extends = NULL; |
| 4180 if (Check(Token::EXTENDS)) { | 4184 if (Check(Token::EXTENDS)) { |
| 4185 const bool maybeArrow = false; |
| 4181 block_scope->set_start_position(scanner()->location().end_pos); | 4186 block_scope->set_start_position(scanner()->location().end_pos); |
| 4182 extends = ParseLeftHandSideExpression(CHECK_OK); | 4187 extends = ParseLeftHandSideExpression(maybeArrow, CHECK_OK); |
| 4183 } else { | 4188 } else { |
| 4184 block_scope->set_start_position(scanner()->location().end_pos); | 4189 block_scope->set_start_position(scanner()->location().end_pos); |
| 4185 } | 4190 } |
| 4186 | 4191 |
| 4187 | 4192 |
| 4188 ClassLiteralChecker checker(this); | 4193 ClassLiteralChecker checker(this); |
| 4189 ZoneList<ObjectLiteral::Property*>* properties = NewPropertyList(4, zone()); | 4194 ZoneList<ObjectLiteral::Property*>* properties = NewPropertyList(4, zone()); |
| 4190 FunctionLiteral* constructor = NULL; | 4195 FunctionLiteral* constructor = NULL; |
| 4191 bool has_seen_constructor = false; | 4196 bool has_seen_constructor = false; |
| 4192 | 4197 |
| (...skipping 1318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5511 } else { | 5516 } else { |
| 5512 const uc16* data = reinterpret_cast<const uc16*>(raw_string->raw_data()); | 5517 const uc16* data = reinterpret_cast<const uc16*>(raw_string->raw_data()); |
| 5513 running_hash = StringHasher::ComputeRunningHash(running_hash, data, | 5518 running_hash = StringHasher::ComputeRunningHash(running_hash, data, |
| 5514 raw_string->length()); | 5519 raw_string->length()); |
| 5515 } | 5520 } |
| 5516 } | 5521 } |
| 5517 | 5522 |
| 5518 return running_hash; | 5523 return running_hash; |
| 5519 } | 5524 } |
| 5520 } } // namespace v8::internal | 5525 } } // namespace v8::internal |
| OLD | NEW |