Commit 982b46ae authored by rossberg's avatar rossberg Committed by Commit bot

[strong] Make strong 'this' optional for experimentation

R=arv@chromium.org, conradw@chromium.org
BUG=v8:3956
LOG=N

Review URL: https://codereview.chromium.org/1180943007

Cr-Commit-Position: refs/heads/master@{#29026}
parent d06591a2
...@@ -174,6 +174,7 @@ DEFINE_IMPLICATION(use_strong, use_strict) ...@@ -174,6 +174,7 @@ DEFINE_IMPLICATION(use_strong, use_strict)
DEFINE_BOOL(strong_mode, false, "experimental strong language mode") DEFINE_BOOL(strong_mode, false, "experimental strong language mode")
DEFINE_IMPLICATION(use_strong, strong_mode) DEFINE_IMPLICATION(use_strong, strong_mode)
DEFINE_BOOL(strong_this, true, "don't allow 'this' to escape from constructors")
DEFINE_BOOL(es_staging, false, "enable all completed harmony features") DEFINE_BOOL(es_staging, false, "enable all completed harmony features")
DEFINE_BOOL(harmony, false, "enable all completed harmony features") DEFINE_BOOL(harmony, false, "enable all completed harmony features")
......
...@@ -2562,6 +2562,8 @@ Statement* Parser::ParseExpressionOrLabelledStatement( ...@@ -2562,6 +2562,8 @@ Statement* Parser::ParseExpressionOrLabelledStatement(
return nullptr; return nullptr;
case Token::THIS: case Token::THIS:
if (!FLAG_strong_this) break;
// Fall through.
case Token::SUPER: case Token::SUPER:
if (is_strong(language_mode()) && if (is_strong(language_mode()) &&
i::IsConstructor(function_state_->kind())) { i::IsConstructor(function_state_->kind())) {
......
...@@ -599,6 +599,8 @@ PreParser::Statement PreParser::ParseExpressionOrLabelledStatement(bool* ok) { ...@@ -599,6 +599,8 @@ PreParser::Statement PreParser::ParseExpressionOrLabelledStatement(bool* ok) {
return Statement::Default(); return Statement::Default();
case Token::THIS: case Token::THIS:
if (!FLAG_strong_this) break;
// Fall through.
case Token::SUPER: case Token::SUPER:
if (is_strong(language_mode()) && if (is_strong(language_mode()) &&
i::IsConstructor(function_state_->kind())) { i::IsConstructor(function_state_->kind())) {
......
...@@ -2064,7 +2064,7 @@ ParserBase<Traits>::ParsePrimaryExpression(ExpressionClassifier* classifier, ...@@ -2064,7 +2064,7 @@ ParserBase<Traits>::ParsePrimaryExpression(ExpressionClassifier* classifier,
case Token::THIS: { case Token::THIS: {
BindingPatternUnexpectedToken(classifier); BindingPatternUnexpectedToken(classifier);
Consume(Token::THIS); Consume(Token::THIS);
if (is_strong(language_mode())) { if (FLAG_strong_this && is_strong(language_mode())) {
// Constructors' usages of 'this' in strong mode are parsed separately. // Constructors' usages of 'this' in strong mode are parsed separately.
// TODO(rossberg): this does not work with arrow functions yet. // TODO(rossberg): this does not work with arrow functions yet.
if (i::IsConstructor(function_state_->kind())) { if (i::IsConstructor(function_state_->kind())) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment