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

Side by Side Diff: src/parsing/parser-base.h

Issue 1634403002: Add ES2015 Function.name support to pattern and default parameter initializers (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 10 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 #ifndef V8_PARSING_PARSER_BASE_H 5 #ifndef V8_PARSING_PARSER_BASE_H
6 #define V8_PARSING_PARSER_BASE_H 6 #define V8_PARSING_PARSER_BASE_H
7 7
8 #include "src/ast/scopes.h" 8 #include "src/ast/scopes.h"
9 #include "src/bailout-reason.h" 9 #include "src/bailout-reason.h"
10 #include "src/hashmap.h" 10 #include "src/hashmap.h"
(...skipping 1659 matching lines...) Expand 10 before | Expand all | Expand 10 after
1670 true, &rhs_classifier, CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); 1670 true, &rhs_classifier, CHECK_OK_CUSTOM(EmptyObjectLiteralProperty));
1671 rhs = Traits::RewriteNonPattern( 1671 rhs = Traits::RewriteNonPattern(
1672 rhs, &rhs_classifier, CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); 1672 rhs, &rhs_classifier, CHECK_OK_CUSTOM(EmptyObjectLiteralProperty));
1673 classifier->Accumulate(rhs_classifier, 1673 classifier->Accumulate(rhs_classifier,
1674 ExpressionClassifier::ExpressionProductions); 1674 ExpressionClassifier::ExpressionProductions);
1675 value = factory()->NewAssignment(Token::ASSIGN, lhs, rhs, 1675 value = factory()->NewAssignment(Token::ASSIGN, lhs, rhs,
1676 RelocInfo::kNoPosition); 1676 RelocInfo::kNoPosition);
1677 classifier->RecordCoverInitializedNameError( 1677 classifier->RecordCoverInitializedNameError(
1678 Scanner::Location(next_beg_pos, scanner()->location().end_pos), 1678 Scanner::Location(next_beg_pos, scanner()->location().end_pos),
1679 MessageTemplate::kInvalidCoverInitializedName); 1679 MessageTemplate::kInvalidCoverInitializedName);
1680
1681 if (allow_harmony_function_name()) {
1682 Traits::SetFunctionNameFromIdentifierRef(rhs, lhs);
1683 }
1680 } else { 1684 } else {
1681 value = lhs; 1685 value = lhs;
1682 } 1686 }
1683 1687
1684 return factory()->NewObjectLiteralProperty( 1688 return factory()->NewObjectLiteralProperty(
1685 name_expression, value, ObjectLiteralProperty::COMPUTED, false, 1689 name_expression, value, ObjectLiteralProperty::COMPUTED, false,
1686 false); 1690 false);
1687 } 1691 }
1688 } 1692 }
1689 1693
(...skipping 1185 matching lines...) Expand 10 before | Expand all | Expand 10 after
2875 ExpressionT initializer = Traits::EmptyExpression(); 2879 ExpressionT initializer = Traits::EmptyExpression();
2876 if (!is_rest && allow_harmony_default_parameters() && Check(Token::ASSIGN)) { 2880 if (!is_rest && allow_harmony_default_parameters() && Check(Token::ASSIGN)) {
2877 ExpressionClassifier init_classifier; 2881 ExpressionClassifier init_classifier;
2878 initializer = ParseAssignmentExpression(true, &init_classifier, ok); 2882 initializer = ParseAssignmentExpression(true, &init_classifier, ok);
2879 if (!*ok) return; 2883 if (!*ok) return;
2880 initializer = Traits::RewriteNonPattern(initializer, &init_classifier, ok); 2884 initializer = Traits::RewriteNonPattern(initializer, &init_classifier, ok);
2881 ValidateFormalParameterInitializer(&init_classifier, ok); 2885 ValidateFormalParameterInitializer(&init_classifier, ok);
2882 if (!*ok) return; 2886 if (!*ok) return;
2883 parameters->is_simple = false; 2887 parameters->is_simple = false;
2884 classifier->RecordNonSimpleParameter(); 2888 classifier->RecordNonSimpleParameter();
2889
2890 if (allow_harmony_function_name()) {
2891 Traits::SetFunctionNameFromIdentifierRef(initializer, pattern);
2892 }
2885 } 2893 }
2886 2894
2887 Traits::AddFormalParameter(parameters, pattern, initializer, 2895 Traits::AddFormalParameter(parameters, pattern, initializer,
2888 scanner()->location().end_pos, is_rest); 2896 scanner()->location().end_pos, is_rest);
2889 } 2897 }
2890 2898
2891 2899
2892 template <class Traits> 2900 template <class Traits>
2893 void ParserBase<Traits>::ParseFormalParameterList( 2901 void ParserBase<Traits>::ParseFormalParameterList(
2894 FormalParametersT* parameters, ExpressionClassifier* classifier, bool* ok) { 2902 FormalParametersT* parameters, ExpressionClassifier* classifier, bool* ok) {
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
3338 return; 3346 return;
3339 } 3347 }
3340 has_seen_constructor_ = true; 3348 has_seen_constructor_ = true;
3341 return; 3349 return;
3342 } 3350 }
3343 } 3351 }
3344 } // namespace internal 3352 } // namespace internal
3345 } // namespace v8 3353 } // namespace v8
3346 3354
3347 #endif // V8_PARSING_PARSER_BASE_H 3355 #endif // V8_PARSING_PARSER_BASE_H
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/harmony/function-name.js » ('j') | test/mjsunit/harmony/function-name.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698