Chromium Code Reviews| Index: src/preparser.h |
| diff --git a/src/preparser.h b/src/preparser.h |
| index d890ae5c216d7b497d0f3801288bd2fe7c4123fb..2608628b747e0feeccdcfa1c5def4ea23d2a5cca 100644 |
| --- a/src/preparser.h |
| +++ b/src/preparser.h |
| @@ -88,6 +88,7 @@ class ParserBase : public Traits { |
| typedef typename Traits::Type::FunctionLiteral FunctionLiteralT; |
| typedef typename Traits::Type::Literal LiteralT; |
| typedef typename Traits::Type::ObjectLiteralProperty ObjectLiteralPropertyT; |
| + typedef typename Traits::Type::StatementList StatementListT; |
| ParserBase(Zone* zone, Scanner* scanner, uintptr_t stack_limit, |
| v8::Extension* extension, AstValueFactory* ast_value_factory, |
| @@ -117,7 +118,8 @@ class ParserBase : public Traits { |
| allow_harmony_spread_arrays_(false), |
| allow_harmony_new_target_(false), |
| allow_strong_mode_(false), |
| - allow_legacy_const_(true) {} |
| + allow_legacy_const_(true), |
| + allow_harmony_do_expressions_(false) {} |
| #define ALLOW_ACCESSORS(name) \ |
| bool allow_##name() const { return allow_##name##_; } \ |
| @@ -136,8 +138,18 @@ class ParserBase : public Traits { |
| ALLOW_ACCESSORS(harmony_new_target); |
| ALLOW_ACCESSORS(strong_mode); |
| ALLOW_ACCESSORS(legacy_const); |
| + ALLOW_ACCESSORS(harmony_do_expressions); |
| #undef ALLOW_ACCESSORS |
| + INLINE(bool CheckStackOverflow()) { |
|
adamk
2015/10/15 10:59:33
I don't think you need this anymore.
|
| + if (stack_overflow_) return true; |
| + if (GetCurrentStackPosition() >= stack_limit_) return false; |
| + stack_overflow_ = true; |
| + return true; |
| + } |
| + |
| + uintptr_t stack_limit() const { return stack_limit_; } |
| + |
| protected: |
| enum AllowRestrictedIdentifiers { |
| kAllowRestrictedIdentifiers, |
| @@ -841,6 +853,7 @@ class ParserBase : public Traits { |
| bool allow_harmony_new_target_; |
| bool allow_strong_mode_; |
| bool allow_legacy_const_; |
| + bool allow_harmony_do_expressions_; |
| }; |
| @@ -1697,6 +1710,7 @@ class PreParserTraits { |
| // Temporary glue; these functions will move to ParserBase. |
| PreParserExpression ParseV8Intrinsic(bool* ok); |
| + V8_INLINE PreParserExpression ParseDoExpression(bool* ok); |
| PreParserExpression ParseFunctionLiteral( |
| PreParserIdentifier name, Scanner::Location function_name_location, |
| FunctionNameValidity function_name_validity, FunctionKind kind, |
| @@ -1837,6 +1851,7 @@ class PreParser : public ParserBase<PreParserTraits> { |
| Expression ParseConditionalExpression(bool accept_IN, bool* ok); |
| Expression ParseObjectLiteral(bool* ok); |
| Expression ParseV8Intrinsic(bool* ok); |
| + Expression ParseDoExpression(bool* ok); |
| V8_INLINE void SkipLazyFunctionBody(int* materialized_literal_count, |
| int* expected_property_count, bool* ok); |
| @@ -1902,6 +1917,11 @@ void PreParserTraits::ParseArrowFunctionFormalParameterList( |
| } |
| +PreParserExpression PreParserTraits::ParseDoExpression(bool* ok) { |
| + return pre_parser_->ParseDoExpression(ok); |
| +} |
| + |
| + |
| PreParserStatementList PreParser::ParseEagerFunctionBody( |
| PreParserIdentifier function_name, int pos, |
| const PreParserFormalParameters& parameters, FunctionKind kind, |
| @@ -2222,6 +2242,7 @@ ParserBase<Traits>::ParsePrimaryExpression(ExpressionClassifier* classifier, |
| // ClassLiteral |
| // '(' Expression ')' |
| // TemplateLiteral |
| + // do Block |
| int beg_pos = scanner()->peek_location().beg_pos; |
| int end_pos = scanner()->peek_location().end_pos; |
| @@ -2402,6 +2423,13 @@ ParserBase<Traits>::ParsePrimaryExpression(ExpressionClassifier* classifier, |
| result = this->ParseV8Intrinsic(CHECK_OK); |
| break; |
| } |
| + |
| + case Token::DO: |
| + if (token == Token::DO && allow_harmony_do_expressions()) { |
|
adamk
2015/10/15 10:59:33
Didn't we just switch on |token|?
caitp (gmail)
2015/10/15 11:24:17
It can fall through from the above, unfortunately
adamk
2015/10/15 12:01:25
What if you restructured the cases to have returns
caitp (gmail)
2015/10/15 12:34:07
I think doing that will add a lot of unrelated noi
adamk
2015/10/15 12:42:27
If you want to wait on it, please add a TODO.
|
| + BindingPatternUnexpectedToken(classifier); |
| + result = Traits::ParseDoExpression(CHECK_OK); |
| + break; |
| + } |
| // If we're not allowing special syntax we fall-through to the |
| // default case. |