summaryrefslogtreecommitdiff
path: root/deps/v8/src/preparser.cc
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src/preparser.cc')
-rw-r--r--deps/v8/src/preparser.cc62
1 files changed, 38 insertions, 24 deletions
diff --git a/deps/v8/src/preparser.cc b/deps/v8/src/preparser.cc
index 154a9ae527..5a6a094f6a 100644
--- a/deps/v8/src/preparser.cc
+++ b/deps/v8/src/preparser.cc
@@ -21,24 +21,16 @@ namespace v8 {
namespace internal {
void PreParserTraits::ReportMessageAt(Scanner::Location location,
- const char* message,
- const char* arg,
- bool is_reference_error) {
- ReportMessageAt(location.beg_pos,
- location.end_pos,
- message,
- arg,
- is_reference_error);
+ const char* message, const char* arg,
+ ParseErrorType error_type) {
+ ReportMessageAt(location.beg_pos, location.end_pos, message, arg, error_type);
}
-void PreParserTraits::ReportMessageAt(int start_pos,
- int end_pos,
- const char* message,
- const char* arg,
- bool is_reference_error) {
- pre_parser_->log_->LogMessage(start_pos, end_pos, message, arg,
- is_reference_error);
+void PreParserTraits::ReportMessageAt(int start_pos, int end_pos,
+ const char* message, const char* arg,
+ ParseErrorType error_type) {
+ pre_parser_->log_->LogMessage(start_pos, end_pos, message, arg, error_type);
}
@@ -182,7 +174,6 @@ PreParser::Statement PreParser::ParseStatementListItem(bool* ok) {
case Token::CONST:
return ParseVariableStatement(kStatementListItem, ok);
case Token::LET:
- DCHECK(allow_harmony_scoping());
if (is_strict(language_mode())) {
return ParseVariableStatement(kStatementListItem, ok);
}
@@ -202,8 +193,19 @@ void PreParser::ParseStatementList(int end_token, bool* ok) {
if (directive_prologue && peek() != Token::STRING) {
directive_prologue = false;
}
+ Token::Value token = peek();
+ Scanner::Location old_super_loc = function_state_->super_call_location();
Statement statement = ParseStatementListItem(ok);
if (!*ok) return;
+ Scanner::Location super_loc = function_state_->super_call_location();
+ if (is_strong(language_mode()) &&
+ i::IsConstructor(function_state_->kind()) &&
+ !old_super_loc.IsValid() && super_loc.IsValid() &&
+ token != Token::SUPER) {
+ ReportMessageAt(super_loc, "strong_super_call_nested");
+ *ok = false;
+ return;
+ }
if (directive_prologue) {
if (statement.IsUseStrictLiteral()) {
scope_->SetLanguageMode(
@@ -391,7 +393,7 @@ PreParser::Statement PreParser::ParseBlock(bool* ok) {
//
Expect(Token::LBRACE, CHECK_OK);
while (peek() != Token::RBRACE) {
- if (allow_harmony_scoping() && is_strict(language_mode())) {
+ if (is_strict(language_mode())) {
ParseStatementListItem(CHECK_OK);
} else {
ParseStatement(CHECK_OK);
@@ -464,12 +466,6 @@ PreParser::Statement PreParser::ParseVariableDeclarations(
Consume(Token::CONST);
if (is_strict(language_mode())) {
DCHECK(var_context != kStatement);
- if (!allow_harmony_scoping()) {
- Scanner::Location location = scanner()->peek_location();
- ReportMessageAt(location, "strict_const");
- *ok = false;
- return Statement::Default();
- }
is_strict_const = true;
require_initializer = var_context != kForStatement;
}
@@ -617,6 +613,7 @@ PreParser::Statement PreParser::ParseReturnStatement(bool* ok) {
// reporting any errors on it, because of the way errors are
// reported (underlining).
Expect(Token::RETURN, CHECK_OK);
+ function_state_->set_return_location(scanner()->location());
// An ECMAScript program is considered syntactically incorrect if it
// contains a return statement that is not within the body of a
@@ -628,6 +625,14 @@ PreParser::Statement PreParser::ParseReturnStatement(bool* ok) {
tok != Token::SEMICOLON &&
tok != Token::RBRACE &&
tok != Token::EOS) {
+ if (is_strong(language_mode()) &&
+ i::IsConstructor(function_state_->kind())) {
+ int pos = peek_position();
+ ReportMessageAt(Scanner::Location(pos, pos + 1),
+ "strong_constructor_return_value");
+ *ok = false;
+ return Statement::Default();
+ }
ParseExpression(true, CHECK_OK);
}
ExpectSemicolon(CHECK_OK);
@@ -678,7 +683,7 @@ PreParser::Statement PreParser::ParseSwitchStatement(bool* ok) {
while (token != Token::CASE &&
token != Token::DEFAULT &&
token != Token::RBRACE) {
- ParseStatement(CHECK_OK);
+ ParseStatementListItem(CHECK_OK);
token = peek();
}
}
@@ -953,6 +958,15 @@ PreParser::Expression PreParser::ParseFunctionLiteral(
CheckStrictOctalLiteral(start_position, end_position, CHECK_OK);
}
+ if (is_strong(language_mode()) && IsSubclassConstructor(kind)) {
+ if (!function_state.super_call_location().IsValid()) {
+ ReportMessageAt(function_name_location, "strong_super_call_missing",
+ kReferenceError);
+ *ok = false;
+ return Expression::Default();
+ }
+ }
+
return Expression::Default();
}