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