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/preparser.h

Issue 1083623002: Refactor formal parameter error locations into a class (Closed) Base URL: https://chromium.googlesource.com/v8/v8@master
Patch Set: Created 5 years, 8 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 | « src/parser.cc ('k') | src/preparser.cc » ('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 #ifndef V8_PREPARSER_H 5 #ifndef V8_PREPARSER_H
6 #define V8_PREPARSER_H 6 #define V8_PREPARSER_H
7 7
8 #include "src/v8.h" 8 #include "src/v8.h"
9 9
10 #include "src/bailout-reason.h" 10 #include "src/bailout-reason.h"
11 #include "src/func-name-inferrer.h" 11 #include "src/func-name-inferrer.h"
12 #include "src/hashmap.h" 12 #include "src/hashmap.h"
13 #include "src/scanner.h" 13 #include "src/scanner.h"
14 #include "src/scopes.h" 14 #include "src/scopes.h"
15 #include "src/token.h" 15 #include "src/token.h"
16 16
17 namespace v8 { 17 namespace v8 {
18 namespace internal { 18 namespace internal {
19 19
20
21 // When parsing the formal parameters of a function, we usually don't yet know
22 // if the function will be strict, so we cannot yet produce errors for
23 // parameter names or duplicates. Instead, we remember the locations of these
24 // errors if they occur and produce the errors later.
25 class FormalParameterErrorLocations BASE_EMBEDDED {
rossberg 2015/04/13 09:12:16 Could this be a local (protected?) class of PrePar
26 public:
27 FormalParameterErrorLocations()
28 : eval_or_arguments_(Scanner::Location::invalid()),
29 undefined_(Scanner::Location::invalid()),
30 duplicate_(Scanner::Location::invalid()),
31 reserved_(Scanner::Location::invalid()) {}
32
33 Scanner::Location eval_or_arguments_;
arv (Not doing code reviews) 2015/04/13 14:24:17 Nit: public fields should not end with underscore.
34 Scanner::Location undefined_;
35 Scanner::Location duplicate_;
36 Scanner::Location reserved_;
37 };
38
39
20 // Common base class shared between parser and pre-parser. Traits encapsulate 40 // Common base class shared between parser and pre-parser. Traits encapsulate
21 // the differences between Parser and PreParser: 41 // the differences between Parser and PreParser:
22 42
23 // - Return types: For example, Parser functions return Expression* and 43 // - Return types: For example, Parser functions return Expression* and
24 // PreParser functions return PreParserExpression. 44 // PreParser functions return PreParserExpression.
25 45
26 // - Creating parse tree nodes: Parser generates an AST during the recursive 46 // - Creating parse tree nodes: Parser generates an AST during the recursive
27 // descent. PreParser doesn't create a tree. Instead, it passes around minimal 47 // descent. PreParser doesn't create a tree. Instead, it passes around minimal
28 // data objects (PreParserExpression, PreParserIdentifier etc.) which contain 48 // data objects (PreParserExpression, PreParserIdentifier etc.) which contain
29 // just enough data for the upper layer functions. PreParserFactory is 49 // just enough data for the upper layer functions. PreParserFactory is
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 Traits::ReportMessageAt(function_name_loc, "strong_undefined"); 512 Traits::ReportMessageAt(function_name_loc, "strong_undefined");
493 *ok = false; 513 *ok = false;
494 return; 514 return;
495 } 515 }
496 } 516 }
497 517
498 // Checking the parameter names of a function literal. This has to be done 518 // Checking the parameter names of a function literal. This has to be done
499 // after parsing the function, since the function can declare itself strict. 519 // after parsing the function, since the function can declare itself strict.
500 void CheckFunctionParameterNames(LanguageMode language_mode, 520 void CheckFunctionParameterNames(LanguageMode language_mode,
501 bool strict_params, 521 bool strict_params,
502 const Scanner::Location& eval_args_loc, 522 const FormalParameterErrorLocations& locs,
503 const Scanner::Location& undefined_loc,
504 const Scanner::Location& dupe_loc,
505 const Scanner::Location& reserved_loc,
506 bool* ok) { 523 bool* ok) {
507 if (is_sloppy(language_mode) && !strict_params) return; 524 if (is_sloppy(language_mode) && !strict_params) return;
508 if (is_strict(language_mode) && eval_args_loc.IsValid()) { 525 if (is_strict(language_mode) && locs.eval_or_arguments_.IsValid()) {
509 Traits::ReportMessageAt(eval_args_loc, "strict_eval_arguments"); 526 Traits::ReportMessageAt(locs.eval_or_arguments_, "strict_eval_arguments");
510 *ok = false; 527 *ok = false;
511 return; 528 return;
512 } 529 }
513 if (is_strong(language_mode) && undefined_loc.IsValid()) { 530 if (is_strong(language_mode) && locs.undefined_.IsValid()) {
514 Traits::ReportMessageAt(undefined_loc, "strong_undefined"); 531 Traits::ReportMessageAt(locs.undefined_, "strong_undefined");
515 *ok = false; 532 *ok = false;
516 return; 533 return;
517 } 534 }
518 // TODO(arv): When we add support for destructuring in setters we also need 535 // TODO(arv): When we add support for destructuring in setters we also need
519 // to check for duplicate names. 536 // to check for duplicate names.
520 if (dupe_loc.IsValid()) { 537 if (locs.duplicate_.IsValid()) {
521 Traits::ReportMessageAt(dupe_loc, "strict_param_dupe"); 538 Traits::ReportMessageAt(locs.duplicate_, "strict_param_dupe");
522 *ok = false; 539 *ok = false;
523 return; 540 return;
524 } 541 }
525 if (reserved_loc.IsValid()) { 542 if (locs.reserved_.IsValid()) {
526 Traits::ReportMessageAt(reserved_loc, "unexpected_strict_reserved"); 543 Traits::ReportMessageAt(locs.reserved_, "unexpected_strict_reserved");
527 *ok = false; 544 *ok = false;
528 return; 545 return;
529 } 546 }
530 } 547 }
531 548
532 // Determine precedence of given token. 549 // Determine precedence of given token.
533 static int Precedence(Token::Value token, bool accept_IN) { 550 static int Precedence(Token::Value token, bool accept_IN) {
534 if (token == Token::IN && !accept_IN) 551 if (token == Token::IN && !accept_IN)
535 return 0; // 0 precedence will terminate binary expression parsing 552 return 0; // 0 precedence will terminate binary expression parsing
536 return Token::Precedence(token); 553 return Token::Precedence(token);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 ExpressionT ParseMemberExpression(bool* ok); 621 ExpressionT ParseMemberExpression(bool* ok);
605 ExpressionT ParseMemberExpressionContinuation(ExpressionT expression, 622 ExpressionT ParseMemberExpressionContinuation(ExpressionT expression,
606 bool* ok); 623 bool* ok);
607 ExpressionT ParseArrowFunctionLiteral(int start_pos, ExpressionT params_ast, 624 ExpressionT ParseArrowFunctionLiteral(int start_pos, ExpressionT params_ast,
608 bool* ok); 625 bool* ok);
609 ExpressionT ParseTemplateLiteral(ExpressionT tag, int start, bool* ok); 626 ExpressionT ParseTemplateLiteral(ExpressionT tag, int start, bool* ok);
610 void AddTemplateExpression(ExpressionT); 627 void AddTemplateExpression(ExpressionT);
611 ExpressionT ParseSuperExpression(bool is_new, bool* ok); 628 ExpressionT ParseSuperExpression(bool is_new, bool* ok);
612 629
613 FormalParameterT ParseFormalParameter(DuplicateFinder* duplicate_finder, 630 FormalParameterT ParseFormalParameter(DuplicateFinder* duplicate_finder,
614 Scanner::Location* eval_args_error_loc, 631 FormalParameterErrorLocations* locs,
615 Scanner::Location* undefined_error_loc,
616 Scanner::Location* dupe_error_loc,
617 Scanner::Location* reserved_error_loc,
618 bool* ok); 632 bool* ok);
619 FormalParameterListT ParseFormalParameterList( 633 FormalParameterListT ParseFormalParameterList(
620 Scanner::Location* eval_args_error_loc, 634 FormalParameterErrorLocations* locs, bool* is_rest, bool* ok);
621 Scanner::Location* undefined_error_loc, Scanner::Location* dupe_error_loc,
622 Scanner::Location* reserved_error_loc, bool* is_rest, bool* ok);
623 void CheckArityRestrictions( 635 void CheckArityRestrictions(
624 int param_count, FunctionLiteral::ArityRestriction arity_restriction, 636 int param_count, FunctionLiteral::ArityRestriction arity_restriction,
625 int formals_start_pos, int formals_end_pos, bool* ok); 637 int formals_start_pos, int formals_end_pos, bool* ok);
626 638
627 // Checks if the expression is a valid reference expression (e.g., on the 639 // Checks if the expression is a valid reference expression (e.g., on the
628 // left-hand side of assignments). Although ruled out by ECMA as early errors, 640 // left-hand side of assignments). Although ruled out by ECMA as early errors,
629 // we allow calls for web compatibility and rewrite them to a runtime throw. 641 // we allow calls for web compatibility and rewrite them to a runtime throw.
630 ExpressionT CheckAndRewriteReferenceExpression( 642 ExpressionT CheckAndRewriteReferenceExpression(
631 ExpressionT expression, 643 ExpressionT expression,
632 Scanner::Location location, const char* message, bool* ok); 644 Scanner::Location location, const char* message, bool* ok);
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
922 934
923 bool IsCall() const { 935 bool IsCall() const {
924 return TypeField::decode(code_) == kExpression && 936 return TypeField::decode(code_) == kExpression &&
925 ExpressionTypeField::decode(code_) == kCallExpression; 937 ExpressionTypeField::decode(code_) == kCallExpression;
926 } 938 }
927 939
928 bool IsValidReferenceExpression() const { 940 bool IsValidReferenceExpression() const {
929 return IsIdentifier() || IsProperty(); 941 return IsIdentifier() || IsProperty();
930 } 942 }
931 943
932 bool IsValidArrowParamList(Scanner::Location* undefined_loc) const { 944 bool IsValidArrowParamList(FormalParameterErrorLocations* locs) const {
933 ValidArrowParam valid = ValidateArrowParams(); 945 ValidArrowParam valid = ValidateArrowParams();
934 if (ParenthesizationField::decode(code_) == kMultiParenthesizedExpression) { 946 if (ParenthesizationField::decode(code_) == kMultiParenthesizedExpression) {
935 return false; 947 return false;
936 } 948 }
937 if (valid == kValidArrowParam) { 949 if (valid == kValidArrowParam) {
938 return true; 950 return true;
939 } else if (valid == kInvalidStrongArrowParam) { 951 } else if (valid == kInvalidStrongArrowParam) {
940 // Return true for now regardless of strong mode for compatibility with 952 // Return true for now regardless of strong mode for compatibility with
941 // parser. 953 // parser.
942 *undefined_loc = Scanner::Location(); 954 locs->undefined_ = Scanner::Location();
943 return true; 955 return true;
944 } else { 956 } else {
945 return false; 957 return false;
946 } 958 }
947 } 959 }
948 960
949 // At the moment PreParser doesn't track these expression types. 961 // At the moment PreParser doesn't track these expression types.
950 bool IsFunctionLiteral() const { return false; } 962 bool IsFunctionLiteral() const { return false; }
951 bool IsCallNew() const { return false; } 963 bool IsCallNew() const { return false; }
952 964
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after
1537 int* expected_property_count, bool* ok) { 1549 int* expected_property_count, bool* ok) {
1538 UNREACHABLE(); 1550 UNREACHABLE();
1539 } 1551 }
1540 1552
1541 V8_INLINE PreParserStatementList 1553 V8_INLINE PreParserStatementList
1542 ParseEagerFunctionBody(PreParserIdentifier function_name, int pos, 1554 ParseEagerFunctionBody(PreParserIdentifier function_name, int pos,
1543 Variable* fvar, Token::Value fvar_init_op, 1555 Variable* fvar, Token::Value fvar_init_op,
1544 FunctionKind kind, bool* ok); 1556 FunctionKind kind, bool* ok);
1545 1557
1546 // Utility functions 1558 // Utility functions
1547 int DeclareArrowParametersFromExpression(PreParserExpression expression, 1559 V8_INLINE int DeclareArrowParametersFromExpression(
1548 Scope* scope, 1560 PreParserExpression expression, Scope* scope,
1549 Scanner::Location* undefined_loc, 1561 FormalParameterErrorLocations* locs, bool* ok) {
1550 Scanner::Location* dupe_loc, 1562 // TODO(wingo): Detect duplicated identifiers in paramlists. Detect eval or
1551 bool* ok) { 1563 // arguments. Detect reserved words.
1552 // TODO(aperez): Detect duplicated identifiers in paramlists. 1564 *ok = expression.IsValidArrowParamList(locs);
1553 *ok = expression.IsValidArrowParamList(undefined_loc);
1554 return 0; 1565 return 0;
1555 } 1566 }
1556 1567
1557 struct TemplateLiteralState {}; 1568 struct TemplateLiteralState {};
1558 1569
1559 TemplateLiteralState OpenTemplateLiteral(int pos) { 1570 TemplateLiteralState OpenTemplateLiteral(int pos) {
1560 return TemplateLiteralState(); 1571 return TemplateLiteralState();
1561 } 1572 }
1562 void AddTemplateSpan(TemplateLiteralState*, bool) {} 1573 void AddTemplateSpan(TemplateLiteralState*, bool) {}
1563 void AddTemplateExpression(TemplateLiteralState*, PreParserExpression) {} 1574 void AddTemplateExpression(TemplateLiteralState*, PreParserExpression) {}
(...skipping 1484 matching lines...) Expand 10 before | Expand all | Expand 10 after
3048 } 3059 }
3049 } 3060 }
3050 DCHECK(false); 3061 DCHECK(false);
3051 return this->EmptyExpression(); 3062 return this->EmptyExpression();
3052 } 3063 }
3053 3064
3054 3065
3055 template <class Traits> 3066 template <class Traits>
3056 typename ParserBase<Traits>::FormalParameterT 3067 typename ParserBase<Traits>::FormalParameterT
3057 ParserBase<Traits>::ParseFormalParameter(DuplicateFinder* duplicate_finder, 3068 ParserBase<Traits>::ParseFormalParameter(DuplicateFinder* duplicate_finder,
3058 Scanner::Location* eval_args_error_loc, 3069 FormalParameterErrorLocations* locs,
3059 Scanner::Location* undefined_error_loc,
3060 Scanner::Location* dupe_error_loc,
3061 Scanner::Location* reserved_error_loc,
3062 bool* ok) { 3070 bool* ok) {
3063 // FormalParameter[Yield,GeneratorParameter] : 3071 // FormalParameter[Yield,GeneratorParameter] :
3064 // BindingElement[?Yield, ?GeneratorParameter] 3072 // BindingElement[?Yield, ?GeneratorParameter]
3065 bool is_strict_reserved; 3073 bool is_strict_reserved;
3066 IdentifierT name = 3074 IdentifierT name =
3067 ParseIdentifierOrStrictReservedWord(&is_strict_reserved, ok); 3075 ParseIdentifierOrStrictReservedWord(&is_strict_reserved, ok);
3068 if (!*ok) return this->EmptyFormalParameter(); 3076 if (!*ok) return this->EmptyFormalParameter();
3069 3077
3070 // Store locations for possible future error reports. 3078 // Store locations for possible future error reports.
3071 if (!eval_args_error_loc->IsValid() && this->IsEvalOrArguments(name)) { 3079 if (!locs->eval_or_arguments_.IsValid() && this->IsEvalOrArguments(name)) {
3072 *eval_args_error_loc = scanner()->location(); 3080 locs->eval_or_arguments_ = scanner()->location();
3073 } 3081 }
3074 if (!undefined_error_loc->IsValid() && this->IsUndefined(name)) { 3082 if (!locs->undefined_.IsValid() && this->IsUndefined(name)) {
3075 *undefined_error_loc = scanner()->location(); 3083 locs->undefined_ = scanner()->location();
3076 } 3084 }
3077 if (!reserved_error_loc->IsValid() && is_strict_reserved) { 3085 if (!locs->reserved_.IsValid() && is_strict_reserved) {
3078 *reserved_error_loc = scanner()->location(); 3086 locs->reserved_ = scanner()->location();
3079 } 3087 }
3080 if (!dupe_error_loc->IsValid()) { 3088 if (!locs->duplicate_.IsValid()) {
3081 int prev_value = scanner()->FindSymbol(duplicate_finder, 1); 3089 int prev_value = scanner()->FindSymbol(duplicate_finder, 1);
3082 if (prev_value != 0) *dupe_error_loc = scanner()->location(); 3090 if (prev_value != 0) locs->duplicate_ = scanner()->location();
3083 } 3091 }
3084 3092
3085 return name; 3093 return name;
3086 } 3094 }
3087 3095
3088 3096
3089 template <class Traits> 3097 template <class Traits>
3090 typename ParserBase<Traits>::FormalParameterListT 3098 typename ParserBase<Traits>::FormalParameterListT
3091 ParserBase<Traits>::ParseFormalParameterList( 3099 ParserBase<Traits>::ParseFormalParameterList(
3092 Scanner::Location* eval_args_error_loc, 3100 FormalParameterErrorLocations* locs, bool* is_rest, bool* ok) {
3093 Scanner::Location* undefined_error_loc, Scanner::Location* dupe_error_loc,
3094 Scanner::Location* reserved_error_loc, bool* is_rest, bool* ok) {
3095 // FormalParameters[Yield,GeneratorParameter] : 3101 // FormalParameters[Yield,GeneratorParameter] :
3096 // [empty] 3102 // [empty]
3097 // FormalParameterList[?Yield, ?GeneratorParameter] 3103 // FormalParameterList[?Yield, ?GeneratorParameter]
3098 // 3104 //
3099 // FormalParameterList[Yield,GeneratorParameter] : 3105 // FormalParameterList[Yield,GeneratorParameter] :
3100 // FunctionRestParameter[?Yield] 3106 // FunctionRestParameter[?Yield]
3101 // FormalsList[?Yield, ?GeneratorParameter] 3107 // FormalsList[?Yield, ?GeneratorParameter]
3102 // FormalsList[?Yield, ?GeneratorParameter] , FunctionRestParameter[?Yield] 3108 // FormalsList[?Yield, ?GeneratorParameter] , FunctionRestParameter[?Yield]
3103 // 3109 //
3104 // FormalsList[Yield,GeneratorParameter] : 3110 // FormalsList[Yield,GeneratorParameter] :
3105 // FormalParameter[?Yield, ?GeneratorParameter] 3111 // FormalParameter[?Yield, ?GeneratorParameter]
3106 // FormalsList[?Yield, ?GeneratorParameter] , 3112 // FormalsList[?Yield, ?GeneratorParameter] ,
3107 // FormalParameter[?Yield,?GeneratorParameter] 3113 // FormalParameter[?Yield,?GeneratorParameter]
3108 3114
3109 FormalParameterListT result = this->NewFormalParameterList(4, zone_); 3115 FormalParameterListT result = this->NewFormalParameterList(4, zone_);
3110 DuplicateFinder duplicate_finder(scanner()->unicode_cache()); 3116 DuplicateFinder duplicate_finder(scanner()->unicode_cache());
3111 3117
3112 if (peek() != Token::RPAREN) { 3118 if (peek() != Token::RPAREN) {
3113 do { 3119 do {
3114 *is_rest = allow_harmony_rest_params() && Check(Token::ELLIPSIS); 3120 *is_rest = allow_harmony_rest_params() && Check(Token::ELLIPSIS);
3115 FormalParameterT param = ParseFormalParameter( 3121 FormalParameterT param =
3116 &duplicate_finder, eval_args_error_loc, undefined_error_loc, 3122 ParseFormalParameter(&duplicate_finder, locs, ok);
3117 dupe_error_loc, reserved_error_loc, ok);
3118 if (!*ok) return this->NullFormalParameterList(); 3123 if (!*ok) return this->NullFormalParameterList();
3119 result->Add(param, zone()); 3124 result->Add(param, zone());
3120 if (result->length() > Code::kMaxArguments) { 3125 if (result->length() > Code::kMaxArguments) {
3121 ReportMessage("too_many_parameters"); 3126 ReportMessage("too_many_parameters");
3122 *ok = false; 3127 *ok = false;
3123 return this->NullFormalParameterList(); 3128 return this->NullFormalParameterList();
3124 } 3129 }
3125 } while (!*is_rest && Check(Token::COMMA)); 3130 } while (!*is_rest && Check(Token::COMMA));
3126 } 3131 }
3127 3132
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
3178 int num_parameters = -1; 3183 int num_parameters = -1;
3179 int materialized_literal_count = -1; 3184 int materialized_literal_count = -1;
3180 int expected_property_count = -1; 3185 int expected_property_count = -1;
3181 int handler_count = 0; 3186 int handler_count = 0;
3182 Scanner::Location super_loc; 3187 Scanner::Location super_loc;
3183 3188
3184 { 3189 {
3185 typename Traits::Type::Factory function_factory(ast_value_factory()); 3190 typename Traits::Type::Factory function_factory(ast_value_factory());
3186 FunctionState function_state(&function_state_, &scope_, scope, 3191 FunctionState function_state(&function_state_, &scope_, scope,
3187 kArrowFunction, &function_factory); 3192 kArrowFunction, &function_factory);
3188 Scanner::Location undefined_loc = Scanner::Location::invalid(); 3193 FormalParameterErrorLocations error_locs;
3189 Scanner::Location dupe_loc = Scanner::Location::invalid();
3190 // TODO(arv): Pass in eval_args_loc and reserved_loc here.
3191 num_parameters = Traits::DeclareArrowParametersFromExpression( 3194 num_parameters = Traits::DeclareArrowParametersFromExpression(
3192 params_ast, scope_, &undefined_loc, &dupe_loc, ok); 3195 params_ast, scope_, &error_locs, ok);
3193 if (!*ok) { 3196 if (!*ok) {
3194 ReportMessageAt( 3197 ReportMessageAt(
3195 Scanner::Location(start_pos, scanner()->location().beg_pos), 3198 Scanner::Location(start_pos, scanner()->location().beg_pos),
3196 "malformed_arrow_function_parameter_list"); 3199 "malformed_arrow_function_parameter_list");
3197 return this->EmptyExpression(); 3200 return this->EmptyExpression();
3198 } 3201 }
3199 3202
3200 if (undefined_loc.IsValid()) { 3203 if (error_locs.undefined_.IsValid()) {
3201 // Workaround for preparser not keeping track of positions. 3204 // Workaround for preparser not keeping track of positions.
3202 undefined_loc = Scanner::Location(start_pos, 3205 error_locs.undefined_ =
3203 scanner()->location().end_pos); 3206 Scanner::Location(start_pos, scanner()->location().end_pos);
3204 } 3207 }
3205 if (num_parameters > Code::kMaxArguments) { 3208 if (num_parameters > Code::kMaxArguments) {
3206 ReportMessageAt(Scanner::Location(params_ast->position(), position()), 3209 ReportMessageAt(Scanner::Location(params_ast->position(), position()),
3207 "too_many_parameters"); 3210 "too_many_parameters");
3208 *ok = false; 3211 *ok = false;
3209 return this->EmptyExpression(); 3212 return this->EmptyExpression();
3210 } 3213 }
3211 3214
3212 Expect(Token::ARROW, CHECK_OK); 3215 Expect(Token::ARROW, CHECK_OK);
3213 3216
(...skipping 25 matching lines...) Expand all
3239 body->Add(factory()->NewReturnStatement(expression, pos), zone()); 3242 body->Add(factory()->NewReturnStatement(expression, pos), zone());
3240 materialized_literal_count = function_state.materialized_literal_count(); 3243 materialized_literal_count = function_state.materialized_literal_count();
3241 expected_property_count = function_state.expected_property_count(); 3244 expected_property_count = function_state.expected_property_count();
3242 handler_count = function_state.handler_count(); 3245 handler_count = function_state.handler_count();
3243 } 3246 }
3244 super_loc = function_state.super_call_location(); 3247 super_loc = function_state.super_call_location();
3245 3248
3246 scope->set_start_position(start_pos); 3249 scope->set_start_position(start_pos);
3247 scope->set_end_position(scanner()->location().end_pos); 3250 scope->set_end_position(scanner()->location().end_pos);
3248 3251
3249 // Arrow function *parameter lists* are always checked as in strict mode. 3252 // Arrow function formal parameters are parsed as StrictFormalParameterList,
3250 // TODO(arv): eval_args_loc and reserved_loc needs to be set by 3253 // which is not the same as "parameters of a strict function"; it only means
3251 // DeclareArrowParametersFromExpression. 3254 // that duplicates are not allowed. Of course, the arrow function may
3252 Scanner::Location eval_args_loc = Scanner::Location::invalid(); 3255 // itself be strict as well.
3253 Scanner::Location reserved_loc = Scanner::Location::invalid();
3254 const bool use_strict_params = true; 3256 const bool use_strict_params = true;
3255 this->CheckFunctionParameterNames(language_mode(), use_strict_params, 3257 this->CheckFunctionParameterNames(language_mode(), use_strict_params,
3256 eval_args_loc, undefined_loc, dupe_loc, 3258 error_locs, CHECK_OK);
3257 reserved_loc, CHECK_OK);
3258 3259
3259 // Validate strict mode. 3260 // Validate strict mode.
3260 if (is_strict(language_mode())) { 3261 if (is_strict(language_mode())) {
3261 CheckStrictOctalLiteral(start_pos, scanner()->location().end_pos, 3262 CheckStrictOctalLiteral(start_pos, scanner()->location().end_pos,
3262 CHECK_OK); 3263 CHECK_OK);
3263 this->CheckConflictingVarDeclarations(scope, CHECK_OK); 3264 this->CheckConflictingVarDeclarations(scope, CHECK_OK);
3264 } 3265 }
3265 } 3266 }
3266 3267
3267 FunctionLiteralT function_literal = factory()->NewFunctionLiteral( 3268 FunctionLiteralT function_literal = factory()->NewFunctionLiteral(
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
3460 *ok = false; 3461 *ok = false;
3461 return; 3462 return;
3462 } 3463 }
3463 has_seen_constructor_ = true; 3464 has_seen_constructor_ = true;
3464 return; 3465 return;
3465 } 3466 }
3466 } 3467 }
3467 } } // v8::internal 3468 } } // v8::internal
3468 3469
3469 #endif // V8_PREPARSER_H 3470 #endif // V8_PREPARSER_H
OLDNEW
« no previous file with comments | « src/parser.cc ('k') | src/preparser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698