Changeset 192603 in webkit for trunk/Source/JavaScriptCore/parser/Parser.cpp
- Timestamp:
- Nov 18, 2015, 5:26:36 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/parser/Parser.cpp
r192597 r192603 668 668 669 669 template <typename LexerType> 670 template <class TreeBuilder> TreeDestructuringPattern Parser<LexerType>::createBindingPattern(TreeBuilder& context, DestructuringKind kind, ExportType exportType, const Identifier& name, int depth,JSToken token, AssignmentContext bindingContext, const Identifier** duplicateIdentifier)670 template <class TreeBuilder> TreeDestructuringPattern Parser<LexerType>::createBindingPattern(TreeBuilder& context, DestructuringKind kind, ExportType exportType, const Identifier& name, JSToken token, AssignmentContext bindingContext, const Identifier** duplicateIdentifier) 671 671 { 672 672 ASSERT(!name.isNull()); … … 686 686 } 687 687 } else if (kind == DestructureToParameters) { 688 if (depth) { 689 auto bindingResult = declareBoundParameter(&name); 690 if (bindingResult == Scope::StrictBindingFailed && strictMode()) { 691 semanticFailIfTrue(isEvalOrArguments(&name), "Cannot destructure to a parameter name '", name.impl(), "' in strict mode"); 692 if (m_lastFunctionName && name == *m_lastFunctionName) 693 semanticFail("Cannot destructure to '", name.impl(), "' as it shadows the name of a strict mode function"); 694 semanticFailureDueToKeyword("bound parameter name"); 695 if (hasDeclaredParameter(name)) 696 semanticFail("Cannot destructure to '", name.impl(), "' as it has already been declared"); 697 semanticFail("Cannot bind to a parameter named '", name.impl(), "' in strict mode"); 698 } 699 if (bindingResult == Scope::BindingFailed) { 700 semanticFailureDueToKeyword("bound parameter name"); 701 if (hasDeclaredParameter(name)) 702 semanticFail("Cannot destructure to '", name.impl(), "' as it has already been declared"); 703 semanticFail("Cannot destructure to a parameter named '", name.impl(), "'"); 704 } 705 } else { 706 DeclarationResultMask declarationResult = declareParameter(&name); 707 if ((declarationResult & DeclarationResult::InvalidStrictMode) && strictMode()) { 708 semanticFailIfTrue(isEvalOrArguments(&name), "Cannot destructure to a parameter name '", name.impl(), "' in strict mode"); 709 if (m_lastFunctionName && name == *m_lastFunctionName) 710 semanticFail("Cannot declare a parameter named '", name.impl(), "' as it shadows the name of a strict mode function"); 711 semanticFailureDueToKeyword("parameter name"); 712 if (hasDeclaredParameter(name)) 713 semanticFail("Cannot declare a parameter named '", name.impl(), "' in strict mode as it has already been declared"); 714 semanticFail("Cannot declare a parameter named '", name.impl(), "' in strict mode"); 715 } 716 if (declarationResult & DeclarationResult::InvalidDuplicateDeclaration) { 717 // It's not always an error to define a duplicate parameter. 718 // It's only an error when there are default parameter values or destructuring parameters. 719 // We note this value now so we can check it later. 720 if (duplicateIdentifier) 721 *duplicateIdentifier = &name; 722 } 688 DeclarationResultMask declarationResult = declareParameter(&name); 689 if ((declarationResult & DeclarationResult::InvalidStrictMode) && strictMode()) { 690 semanticFailIfTrue(isEvalOrArguments(&name), "Cannot destructure to a parameter name '", name.impl(), "' in strict mode"); 691 if (m_lastFunctionName && name == *m_lastFunctionName) 692 semanticFail("Cannot declare a parameter named '", name.impl(), "' as it shadows the name of a strict mode function"); 693 semanticFailureDueToKeyword("parameter name"); 694 if (hasDeclaredParameter(name)) 695 semanticFail("Cannot declare a parameter named '", name.impl(), "' in strict mode as it has already been declared"); 696 semanticFail("Cannot declare a parameter named '", name.impl(), "' in strict mode"); 697 } 698 if (declarationResult & DeclarationResult::InvalidDuplicateDeclaration) { 699 // It's not always an error to define a duplicate parameter. 700 // It's only an error when there are default parameter values or destructuring parameters. 701 // We note this value now so we can check it later. 702 if (duplicateIdentifier) 703 *duplicateIdentifier = &name; 723 704 } 724 705 } … … 848 829 innerPattern = parseDestructuringPattern(context, kind, exportType, duplicateIdentifier, hasDestructuringPattern, bindingContext, depth + 1); 849 830 else 850 innerPattern = createBindingPattern(context, kind, exportType, *propertyName, depth + 1,identifierToken, bindingContext, duplicateIdentifier);831 innerPattern = createBindingPattern(context, kind, exportType, *propertyName, identifierToken, bindingContext, duplicateIdentifier); 851 832 } else { 852 833 JSTokenType tokenType = m_token.m_type; … … 904 885 } 905 886 failIfTrue(match(LET) && (kind == DestructureToLet || kind == DestructureToConst), "Can't use 'let' as an identifier name for a LexicalDeclaration"); 906 pattern = createBindingPattern(context, kind, exportType, *m_token.m_data.ident, depth,m_token, bindingContext, duplicateIdentifier);887 pattern = createBindingPattern(context, kind, exportType, *m_token.m_data.ident, m_token, bindingContext, duplicateIdentifier); 907 888 next(); 908 889 break;
Note:
See TracChangeset
for help on using the changeset viewer.