OLD | NEW |
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 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/api.h" | 7 #include "src/api.h" |
8 #include "src/ast.h" | 8 #include "src/ast.h" |
9 #include "src/bailout-reason.h" | 9 #include "src/bailout-reason.h" |
10 #include "src/base/platform/platform.h" | 10 #include "src/base/platform/platform.h" |
(...skipping 1174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1185 TargetScope scope(&this->target_stack_); | 1185 TargetScope scope(&this->target_stack_); |
1186 | 1186 |
1187 DCHECK(body != NULL); | 1187 DCHECK(body != NULL); |
1188 bool directive_prologue = true; // Parsing directive prologue. | 1188 bool directive_prologue = true; // Parsing directive prologue. |
1189 | 1189 |
1190 while (peek() != end_token) { | 1190 while (peek() != end_token) { |
1191 if (directive_prologue && peek() != Token::STRING) { | 1191 if (directive_prologue && peek() != Token::STRING) { |
1192 directive_prologue = false; | 1192 directive_prologue = false; |
1193 } | 1193 } |
1194 | 1194 |
| 1195 Token::Value token = peek(); |
1195 Scanner::Location token_loc = scanner()->peek_location(); | 1196 Scanner::Location token_loc = scanner()->peek_location(); |
| 1197 Scanner::Location old_super_loc = function_state_->super_call_location(); |
1196 Statement* stat = ParseStatementListItem(CHECK_OK); | 1198 Statement* stat = ParseStatementListItem(CHECK_OK); |
| 1199 Scanner::Location super_loc = function_state_->super_call_location(); |
| 1200 |
| 1201 if (is_strong(language_mode()) && |
| 1202 i::IsConstructor(function_state_->kind()) && |
| 1203 !old_super_loc.IsValid() && super_loc.IsValid() && |
| 1204 token != Token::SUPER) { |
| 1205 // TODO(rossberg): This is more permissive than spec'ed, it allows e.g. |
| 1206 // super(), 1; |
| 1207 // super() + ""; |
| 1208 // super() = 0; |
| 1209 // That should still be safe, though, thanks to left-to-right evaluation. |
| 1210 // The proper check would be difficult to implement in the preparser. |
| 1211 ReportMessageAt(super_loc, "strong_super_call_nested"); |
| 1212 *ok = false; |
| 1213 return NULL; |
| 1214 } |
| 1215 |
1197 if (stat == NULL || stat->IsEmpty()) { | 1216 if (stat == NULL || stat->IsEmpty()) { |
1198 directive_prologue = false; // End of directive prologue. | 1217 directive_prologue = false; // End of directive prologue. |
1199 continue; | 1218 continue; |
1200 } | 1219 } |
1201 | 1220 |
1202 if (directive_prologue) { | 1221 if (directive_prologue) { |
1203 // A shot at a directive. | 1222 // A shot at a directive. |
1204 ExpressionStatement* e_stat; | 1223 ExpressionStatement* e_stat; |
1205 Literal* literal; | 1224 Literal* literal; |
1206 // Still processing directive prologue? | 1225 // Still processing directive prologue? |
(...skipping 2702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3909 eval_args_error_loc, dupe_error_loc, | 3928 eval_args_error_loc, dupe_error_loc, |
3910 reserved_error_loc, CHECK_OK); | 3929 reserved_error_loc, CHECK_OK); |
3911 | 3930 |
3912 if (is_strict(language_mode())) { | 3931 if (is_strict(language_mode())) { |
3913 CheckStrictOctalLiteral(scope->start_position(), scope->end_position(), | 3932 CheckStrictOctalLiteral(scope->start_position(), scope->end_position(), |
3914 CHECK_OK); | 3933 CHECK_OK); |
3915 } | 3934 } |
3916 if (is_strict(language_mode())) { | 3935 if (is_strict(language_mode())) { |
3917 CheckConflictingVarDeclarations(scope, CHECK_OK); | 3936 CheckConflictingVarDeclarations(scope, CHECK_OK); |
3918 } | 3937 } |
| 3938 if (is_strong(language_mode()) && IsSubclassConstructor(kind)) { |
| 3939 if (!function_state.super_call_location().IsValid()) { |
| 3940 ReportMessageAt(function_name_location, "strong_super_call_missing", |
| 3941 kReferenceError); |
| 3942 *ok = false; |
| 3943 return nullptr; |
| 3944 } |
| 3945 } |
3919 } | 3946 } |
3920 | 3947 |
3921 FunctionLiteral* function_literal = factory()->NewFunctionLiteral( | 3948 FunctionLiteral* function_literal = factory()->NewFunctionLiteral( |
3922 function_name, ast_value_factory(), scope, body, | 3949 function_name, ast_value_factory(), scope, body, |
3923 materialized_literal_count, expected_property_count, handler_count, | 3950 materialized_literal_count, expected_property_count, handler_count, |
3924 num_parameters, duplicate_parameters, function_type, | 3951 num_parameters, duplicate_parameters, function_type, |
3925 FunctionLiteral::kIsFunction, parenthesized, kind, pos); | 3952 FunctionLiteral::kIsFunction, parenthesized, kind, pos); |
3926 function_literal->set_function_token_position(function_token_pos); | 3953 function_literal->set_function_token_position(function_token_pos); |
3927 | 3954 |
3928 if (scope->has_rest_parameter()) { | 3955 if (scope->has_rest_parameter()) { |
(...skipping 1579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5508 } else { | 5535 } else { |
5509 const uc16* data = reinterpret_cast<const uc16*>(raw_string->raw_data()); | 5536 const uc16* data = reinterpret_cast<const uc16*>(raw_string->raw_data()); |
5510 running_hash = StringHasher::ComputeRunningHash(running_hash, data, | 5537 running_hash = StringHasher::ComputeRunningHash(running_hash, data, |
5511 raw_string->length()); | 5538 raw_string->length()); |
5512 } | 5539 } |
5513 } | 5540 } |
5514 | 5541 |
5515 return running_hash; | 5542 return running_hash; |
5516 } | 5543 } |
5517 } } // namespace v8::internal | 5544 } } // namespace v8::internal |
OLD | NEW |