| 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 919 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 930 parenthesized_function_ = false; | 930 parenthesized_function_ = false; |
| 931 | 931 |
| 932 Expect(Token::LBRACE, CHECK_OK); | 932 Expect(Token::LBRACE, CHECK_OK); |
| 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 name and parameter names. We can do this only after parsing the |
| 941 // since the function can declare itself strict. | 941 // function, since the function can declare itself strict. |
| 942 // Concise methods use StrictFormalParameters. | 942 CheckFunctionName(language_mode(), kind, function_name, |
| 943 if (is_strict(language_mode()) || IsConciseMethod(kind) || is_rest) { | 943 name_is_strict_reserved, function_name_location, CHECK_OK); |
| 944 if (function_name.IsEvalOrArguments()) { | 944 const bool use_strict_params = is_rest || IsConciseMethod(kind); |
| 945 ReportMessageAt(function_name_location, "strict_eval_arguments"); | 945 CheckFunctionParameterNames(language_mode(), use_strict_params, |
| 946 *ok = false; | 946 eval_args_error_loc, dupe_error_loc, |
| 947 return Expression::Default(); | 947 reserved_error_loc, CHECK_OK); |
| 948 } | |
| 949 if (name_is_strict_reserved) { | |
| 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 | 948 |
| 949 if (is_strict(language_mode())) { |
| 970 int end_position = scanner()->location().end_pos; | 950 int end_position = scanner()->location().end_pos; |
| 971 CheckStrictOctalLiteral(start_position, end_position, CHECK_OK); | 951 CheckStrictOctalLiteral(start_position, end_position, CHECK_OK); |
| 972 } | 952 } |
| 973 | 953 |
| 974 return Expression::Default(); | 954 return Expression::Default(); |
| 975 } | 955 } |
| 976 | 956 |
| 977 | 957 |
| 978 void PreParser::ParseLazyFunctionLiteralBody(bool* ok) { | 958 void PreParser::ParseLazyFunctionLiteralBody(bool* ok) { |
| 979 int body_start = position(); | 959 int body_start = position(); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1047 ParseIdentifier(kAllowEvalOrArguments, CHECK_OK); | 1027 ParseIdentifier(kAllowEvalOrArguments, CHECK_OK); |
| 1048 ParseArguments(ok); | 1028 ParseArguments(ok); |
| 1049 | 1029 |
| 1050 return Expression::Default(); | 1030 return Expression::Default(); |
| 1051 } | 1031 } |
| 1052 | 1032 |
| 1053 #undef CHECK_OK | 1033 #undef CHECK_OK |
| 1054 | 1034 |
| 1055 | 1035 |
| 1056 } } // v8::internal | 1036 } } // v8::internal |
| OLD | NEW |