| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 <cmath> | 5 #include <cmath> |
| 6 | 6 |
| 7 #include "src/allocation.h" | 7 #include "src/allocation.h" |
| 8 #include "src/base/logging.h" | 8 #include "src/base/logging.h" |
| 9 #include "src/conversions-inl.h" | 9 #include "src/conversions-inl.h" |
| 10 #include "src/conversions.h" | 10 #include "src/conversions.h" |
| (...skipping 905 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 916 Scanner::Location eval_args_error_loc = Scanner::Location::invalid(); | 916 Scanner::Location eval_args_error_loc = Scanner::Location::invalid(); |
| 917 Scanner::Location dupe_error_loc = Scanner::Location::invalid(); | 917 Scanner::Location dupe_error_loc = Scanner::Location::invalid(); |
| 918 Scanner::Location reserved_error_loc = Scanner::Location::invalid(); | 918 Scanner::Location reserved_error_loc = Scanner::Location::invalid(); |
| 919 | 919 |
| 920 bool is_rest = false; | 920 bool is_rest = false; |
| 921 bool done = arity_restriction == FunctionLiteral::GETTER_ARITY || | 921 bool done = arity_restriction == FunctionLiteral::GETTER_ARITY || |
| 922 (peek() == Token::RPAREN && | 922 (peek() == Token::RPAREN && |
| 923 arity_restriction != FunctionLiteral::SETTER_ARITY); | 923 arity_restriction != FunctionLiteral::SETTER_ARITY); |
| 924 while (!done) { | 924 while (!done) { |
| 925 bool is_strict_reserved = false; | 925 bool is_strict_reserved = false; |
| 926 int rest_pos; |
| 926 is_rest = peek() == Token::ELLIPSIS && allow_harmony_rest_params(); | 927 is_rest = peek() == Token::ELLIPSIS && allow_harmony_rest_params(); |
| 927 if (is_rest) { | 928 if (is_rest) { |
| 928 Consume(Token::ELLIPSIS); | 929 Consume(Token::ELLIPSIS); |
| 930 rest_pos = position(); |
| 929 } | 931 } |
| 930 | 932 |
| 931 Identifier param_name = | 933 Identifier param_name = |
| 932 ParseIdentifierOrStrictReservedWord(&is_strict_reserved, CHECK_OK); | 934 ParseIdentifierOrStrictReservedWord(&is_strict_reserved, CHECK_OK); |
| 933 if (!eval_args_error_loc.IsValid() && param_name.IsEvalOrArguments()) { | 935 if (!eval_args_error_loc.IsValid() && param_name.IsEvalOrArguments()) { |
| 934 eval_args_error_loc = scanner()->location(); | 936 eval_args_error_loc = scanner()->location(); |
| 935 } | 937 } |
| 936 if (!reserved_error_loc.IsValid() && is_strict_reserved) { | 938 if (!reserved_error_loc.IsValid() && is_strict_reserved) { |
| 937 reserved_error_loc = scanner()->location(); | 939 reserved_error_loc = scanner()->location(); |
| 938 } | 940 } |
| 939 | 941 |
| 940 int prev_value = scanner()->FindSymbol(&duplicate_finder, 1); | 942 int prev_value = scanner()->FindSymbol(&duplicate_finder, 1); |
| 941 | 943 |
| 942 if (!dupe_error_loc.IsValid() && prev_value != 0) { | 944 if (!dupe_error_loc.IsValid() && prev_value != 0) { |
| 943 dupe_error_loc = scanner()->location(); | 945 dupe_error_loc = scanner()->location(); |
| 944 } | 946 } |
| 945 | 947 |
| 948 if (peek() == Token::ASSIGN) { |
| 949 Consume(Token::ASSIGN); |
| 950 static const bool accept_IN = true; |
| 951 ExpressionT defaultValue = ParseAssignmentExpression(accept_IN, CHECK_OK); |
| 952 if (is_rest) { |
| 953 ReportMessageAt(Scanner::Location(rest_pos, scanner()->location().end_po
s), "rest_param_default"); |
| 954 *ok = false; |
| 955 return Expression::Default(); |
| 956 } |
| 957 // Default value is not needed in pre-parser. |
| 958 USE(defaultValue); |
| 959 } |
| 960 |
| 946 if (arity_restriction == FunctionLiteral::SETTER_ARITY) break; | 961 if (arity_restriction == FunctionLiteral::SETTER_ARITY) break; |
| 947 done = (peek() == Token::RPAREN); | 962 done = (peek() == Token::RPAREN); |
| 948 if (!done) { | 963 if (!done) { |
| 949 if (is_rest) { | 964 if (is_rest) { |
| 950 ReportMessageAt(scanner()->peek_location(), "param_after_rest"); | 965 ReportMessageAt(scanner()->peek_location(), "param_after_rest"); |
| 951 *ok = false; | 966 *ok = false; |
| 952 return Expression::Default(); | 967 return Expression::Default(); |
| 953 } | 968 } |
| 954 Expect(Token::COMMA, CHECK_OK); | 969 Expect(Token::COMMA, CHECK_OK); |
| 955 } | 970 } |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1074 | 1089 |
| 1075 DCHECK(!spread_pos.IsValid()); | 1090 DCHECK(!spread_pos.IsValid()); |
| 1076 | 1091 |
| 1077 return Expression::Default(); | 1092 return Expression::Default(); |
| 1078 } | 1093 } |
| 1079 | 1094 |
| 1080 #undef CHECK_OK | 1095 #undef CHECK_OK |
| 1081 | 1096 |
| 1082 | 1097 |
| 1083 } } // v8::internal | 1098 } } // v8::internal |
| OLD | NEW |