Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(836)

Unified Diff: src/parsing/parser-base.h

Issue 1678303002: [es7] implement exponentiation operator proposal (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/parsing/parser.cc ('k') | src/parsing/preparser.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parsing/parser-base.h
diff --git a/src/parsing/parser-base.h b/src/parsing/parser-base.h
index dc67e536c8e0eb76f9921bd712fa9fbc0ddb0e58..9c3d92c7d1c9f7f53c68bc0217c114c098668e06 100644
--- a/src/parsing/parser-base.h
+++ b/src/parsing/parser-base.h
@@ -121,6 +121,12 @@ class ParserBase : public Traits {
bool allow_##name() const { return allow_##name##_; } \
void set_allow_##name(bool allow) { allow_##name##_ = allow; }
+#define SCANNER_ACCESSORS(name) \
+ bool allow_##name() const { return scanner_->allow_##name(); } \
+ void set_allow_##name(bool allow) { \
+ return scanner_->set_allow_##name(allow); \
+ }
+
ALLOW_ACCESSORS(lazy);
ALLOW_ACCESSORS(natives);
ALLOW_ACCESSORS(harmony_sloppy);
@@ -131,6 +137,7 @@ class ParserBase : public Traits {
ALLOW_ACCESSORS(harmony_do_expressions);
ALLOW_ACCESSORS(harmony_function_name);
ALLOW_ACCESSORS(harmony_function_sent);
+ SCANNER_ACCESSORS(harmony_exponentiation_operator);
#undef ALLOW_ACCESSORS
nickie 2016/03/21 08:51:49 Shouldn't there be an #undef SCANNER_ACCESSORS her
caitp (gmail) 2016/03/21 10:44:17 Yes, there should! I'm surprised this doesn't trig
caitp (gmail) 2016/03/21 10:50:03 well, I guess I used a different name in scanner.h
uintptr_t stack_limit() const { return stack_limit_; }
@@ -2010,6 +2017,11 @@ ParserBase<Traits>::ParseAssignmentExpression(bool accept_IN,
Traits::SetFunctionNameFromIdentifierRef(right, expression);
}
+ if (op == Token::ASSIGN_EXP) {
+ DCHECK(!is_destructuring_assignment);
+ return Traits::RewriteAssignExponentiation(expression, right, pos);
+ }
+
ExpressionT result = factory()->NewAssignment(op, expression, right, pos);
if (is_destructuring_assignment) {
@@ -2119,8 +2131,11 @@ ParserBase<Traits>::ParseBinaryExpression(int prec, bool accept_IN,
ArrowFormalParametersUnexpectedToken(classifier);
Token::Value op = Next();
int pos = position();
+
+ const bool is_right_associative = op == Token::EXP;
+ const int next_prec = is_right_associative ? prec1 : prec1 + 1;
ExpressionT y =
- ParseBinaryExpression(prec1 + 1, accept_IN, classifier, CHECK_OK);
+ ParseBinaryExpression(next_prec, accept_IN, classifier, CHECK_OK);
Traits::RewriteNonPattern(classifier, CHECK_OK);
if (this->ShortcutNumericLiteralBinaryExpression(&x, y, op, pos,
@@ -2148,6 +2163,9 @@ ParserBase<Traits>::ParseBinaryExpression(int prec, bool accept_IN,
x = factory()->NewUnaryOperation(Token::NOT, x, pos);
}
}
+
+ } else if (op == Token::EXP) {
+ x = Traits::RewriteExponentiation(x, y, pos);
} else {
// We have a "normal" binary operation.
x = factory()->NewBinaryOperation(op, x, y, pos);
@@ -2193,6 +2211,12 @@ ParserBase<Traits>::ParseUnaryExpression(ExpressionClassifier* classifier,
}
}
+ if (peek() == Token::EXP) {
+ ReportUnexpectedToken(Next());
+ *ok = false;
+ return this->EmptyExpression();
+ }
+
// Allow Traits do rewrite the expression.
return this->BuildUnaryExpression(expression, op, pos, factory());
} else if (Token::IsCountOp(op)) {
« no previous file with comments | « src/parsing/parser.cc ('k') | src/parsing/preparser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698