Index: src/preparser.h |
diff --git a/src/preparser.h b/src/preparser.h |
index d890ae5c216d7b497d0f3801288bd2fe7c4123fb..0f274dc17e0da2522240abb730e9dd9afffa1a6e 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_do_expression_parsing_(false) {} |
#define ALLOW_ACCESSORS(name) \ |
bool allow_##name() const { return allow_##name##_; } \ |
@@ -136,8 +138,16 @@ class ParserBase : public Traits { |
ALLOW_ACCESSORS(harmony_new_target); |
ALLOW_ACCESSORS(strong_mode); |
ALLOW_ACCESSORS(legacy_const); |
+ ALLOW_ACCESSORS(do_expression_parsing); |
#undef ALLOW_ACCESSORS |
+ INLINE(bool CheckStackOverflow()) { |
+ if (stack_overflow_) return true; |
+ if (GetCurrentStackPosition() >= stack_limit_) return false; |
+ stack_overflow_ = true; |
+ return true; |
+ } |
+ |
protected: |
enum AllowRestrictedIdentifiers { |
kAllowRestrictedIdentifiers, |
@@ -841,6 +851,7 @@ class ParserBase : public Traits { |
bool allow_harmony_new_target_; |
bool allow_strong_mode_; |
bool allow_legacy_const_; |
+ bool allow_do_expression_parsing_; |
}; |
@@ -1655,6 +1666,8 @@ class PreParserTraits { |
PreParserExpression expression, const Scanner::Location& params_loc, |
Scanner::Location* duplicate_loc, bool* ok); |
+ V8_INLINE PreParserExpression ParseDoExpression(bool* ok); |
+ |
void ReindexLiterals(const PreParserFormalParameters& paramaters) {} |
struct TemplateLiteralState {}; |
@@ -1814,6 +1827,7 @@ class PreParser : public ParserBase<PreParserTraits> { |
Statement ParseFunctionDeclaration(bool* ok); |
Statement ParseClassDeclaration(bool* ok); |
Statement ParseBlock(bool* ok); |
+ Expression ParseDoExpression(bool* ok); |
rossberg
2015/10/13 10:44:32
Nit: group this with the Expression parsing functi
caitp (gmail)
2015/10/13 15:05:59
Done.
|
Statement ParseVariableStatement(VariableDeclarationContext var_context, |
bool* ok); |
Statement ParseVariableDeclarations(VariableDeclarationContext var_context, |
@@ -1902,6 +1916,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 +2241,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 +2422,13 @@ ParserBase<Traits>::ParsePrimaryExpression(ExpressionClassifier* classifier, |
result = this->ParseV8Intrinsic(CHECK_OK); |
break; |
} |
+ |
+ case Token::DO: |
+ if (token == Token::DO && allow_do_expression_parsing()) { |
+ BindingPatternUnexpectedToken(classifier); |
+ result = Traits::ParseDoExpression(CHECK_OK); |
+ break; |
+ } |
// If we're not allowing special syntax we fall-through to the |
// default case. |