Chromium Code Reviews| 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 922 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 933 if (is_lazily_parsed) { | 933 if (is_lazily_parsed) { |
| 934 ParseLazyFunctionLiteralBody(CHECK_OK); | 934 ParseLazyFunctionLiteralBody(CHECK_OK); |
| 935 } else { | 935 } else { |
| 936 ParseSourceElements(Token::RBRACE, ok); | 936 ParseSourceElements(Token::RBRACE, ok); |
| 937 } | 937 } |
| 938 Expect(Token::RBRACE, CHECK_OK); | 938 Expect(Token::RBRACE, CHECK_OK); |
| 939 | 939 |
| 940 // Validate strict mode. We can do this only after parsing the function, | 940 // Validate strict mode. We can do this only after parsing the function, |
| 941 // since the function can declare itself strict. | 941 // since the function can declare itself strict. |
| 942 // Concise methods use StrictFormalParameters. | 942 // Concise methods use StrictFormalParameters. |
| 943 if (is_strict(language_mode()) || IsConciseMethod(kind) || is_rest) { | 943 bool check_params = |
| 944 if (function_name.IsEvalOrArguments()) { | 944 is_strict(language_mode()) || IsConciseMethod(kind) || is_rest; |
| 945 ReportMessageAt(function_name_location, "strict_eval_arguments"); | 945 if (check_params) { |
| 946 *ok = false; | 946 bool check_name = is_strict(language_mode()) && !IsConciseMethod(kind) && |
| 947 return Expression::Default(); | 947 !IsAccessorFunction(kind); |
| 948 if (!check_name) { | |
| 949 CheckStrictFunctionParameters(eval_args_error_loc, dupe_error_loc, | |
|
arv (Not doing code reviews)
2015/02/06 00:03:55
Another option might be to pass in language_mode()
adamk
2015/02/06 00:23:58
Yeah, I think that's a better move than having to
| |
| 950 reserved_error_loc, CHECK_OK); | |
| 951 } else { | |
| 952 CheckStrictFunctionNameAndParameters( | |
| 953 function_name, name_is_strict_reserved, function_name_location, | |
| 954 eval_args_error_loc, dupe_error_loc, reserved_error_loc, CHECK_OK); | |
| 948 } | 955 } |
| 949 if (name_is_strict_reserved) { | 956 } |
| 950 ReportMessageAt(function_name_location, "unexpected_strict_reserved"); | |
| 951 *ok = false; | |
| 952 return Expression::Default(); | |
| 953 } | |
| 954 if (eval_args_error_loc.IsValid()) { | |
| 955 ReportMessageAt(eval_args_error_loc, "strict_eval_arguments"); | |
| 956 *ok = false; | |
| 957 return Expression::Default(); | |
| 958 } | |
| 959 if (dupe_error_loc.IsValid()) { | |
| 960 ReportMessageAt(dupe_error_loc, "strict_param_dupe"); | |
| 961 *ok = false; | |
| 962 return Expression::Default(); | |
| 963 } | |
| 964 if (reserved_error_loc.IsValid()) { | |
| 965 ReportMessageAt(reserved_error_loc, "unexpected_strict_reserved"); | |
| 966 *ok = false; | |
| 967 return Expression::Default(); | |
| 968 } | |
| 969 | 957 |
| 958 if (is_strict(language_mode())) { | |
| 970 int end_position = scanner()->location().end_pos; | 959 int end_position = scanner()->location().end_pos; |
| 971 CheckStrictOctalLiteral(start_position, end_position, CHECK_OK); | 960 CheckStrictOctalLiteral(start_position, end_position, CHECK_OK); |
| 972 } | 961 } |
| 973 | 962 |
| 974 return Expression::Default(); | 963 return Expression::Default(); |
| 975 } | 964 } |
| 976 | 965 |
| 977 | 966 |
| 978 void PreParser::ParseLazyFunctionLiteralBody(bool* ok) { | 967 void PreParser::ParseLazyFunctionLiteralBody(bool* ok) { |
| 979 int body_start = position(); | 968 int body_start = position(); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1047 ParseIdentifier(kAllowEvalOrArguments, CHECK_OK); | 1036 ParseIdentifier(kAllowEvalOrArguments, CHECK_OK); |
| 1048 ParseArguments(ok); | 1037 ParseArguments(ok); |
| 1049 | 1038 |
| 1050 return Expression::Default(); | 1039 return Expression::Default(); |
| 1051 } | 1040 } |
| 1052 | 1041 |
| 1053 #undef CHECK_OK | 1042 #undef CHECK_OK |
| 1054 | 1043 |
| 1055 | 1044 |
| 1056 } } // v8::internal | 1045 } } // v8::internal |
| OLD | NEW |