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

Unified Diff: src/preparser.h

Issue 197353003: Move ParseYieldExpression to ParserBase. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 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/parser.cc ('k') | src/preparser.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/preparser.h
diff --git a/src/preparser.h b/src/preparser.h
index b77bc7a22251a6e0b8866670b26ed4133253be20..7de3805156576ff282254faf2d072ff5ce0b5da9 100644
--- a/src/preparser.h
+++ b/src/preparser.h
@@ -345,6 +345,7 @@ class ParserBase : public Traits {
typename Traits::Type::ExpressionList ParseArguments(bool* ok);
typename Traits::Type::Expression ParseAssignmentExpression(bool accept_IN,
bool* ok);
+ typename Traits::Type::Expression ParseYieldExpression(bool* ok);
// Used to detect duplicates in object literals. Each of the values
// kGetterProperty, kSetterProperty and kValueProperty represents
@@ -535,6 +536,9 @@ class PreParserExpression {
void* AsCall() const { return NULL; }
void* AsCallNew() const { return NULL; }
+ // More dummy implementations of things PreParser doesn't need to track:
+ void set_index(int index) {} // For YieldExpressions
+
private:
// First two/three bits are used as flags.
// Bit 0 and 1 represent identifiers or strings literals, and are
@@ -661,6 +665,17 @@ class PreParserFactory {
int pos) {
return PreParserExpression::Default();
}
+
+ PreParserExpression NewVariableProxy(void* generator_variable) {
+ return PreParserExpression::Default();
+ }
+
+ PreParserExpression NewYield(PreParserExpression generator_object,
+ PreParserExpression expression,
+ Yield::Kind yield_kind,
+ int pos) {
+ return PreParserExpression::Default();
+ }
};
@@ -682,6 +697,7 @@ class PreParserTraits {
// Return types for traversing functions.
typedef PreParserIdentifier Identifier;
typedef PreParserExpression Expression;
+ typedef PreParserExpression YieldExpression;
typedef PreParserExpression FunctionLiteral;
typedef PreParserExpression ObjectLiteralProperty;
typedef PreParserExpression Literal;
@@ -828,7 +844,6 @@ class PreParserTraits {
int function_token_position,
FunctionLiteral::FunctionType type,
bool* ok);
- PreParserExpression ParseYieldExpression(bool* ok);
PreParserExpression ParseConditionalExpression(bool accept_IN, bool* ok);
private:
@@ -994,7 +1009,6 @@ class PreParser : public ParserBase<PreParserTraits> {
Statement ParseThrowStatement(bool* ok);
Statement ParseTryStatement(bool* ok);
Statement ParseDebuggerStatement(bool* ok);
- Expression ParseYieldExpression(bool* ok);
Expression ParseConditionalExpression(bool accept_IN, bool* ok);
Expression ParseBinaryExpression(int prec, bool accept_IN, bool* ok);
Expression ParseUnaryExpression(bool* ok);
@@ -1616,6 +1630,28 @@ typename Traits::Type::Expression ParserBase<Traits>::ParseAssignmentExpression(
return factory()->NewAssignment(op, expression, right, pos);
}
+template <class Traits>
+typename Traits::Type::Expression ParserBase<Traits>::ParseYieldExpression(
+ bool* ok) {
+ // YieldExpression ::
+ // 'yield' '*'? AssignmentExpression
+ int pos = peek_position();
+ Expect(Token::YIELD, CHECK_OK);
+ Yield::Kind kind =
+ Check(Token::MUL) ? Yield::DELEGATING : Yield::SUSPEND;
+ typename Traits::Type::Expression generator_object =
+ factory()->NewVariableProxy(function_state_->generator_object_variable());
+ typename Traits::Type::Expression expression =
+ ParseAssignmentExpression(false, CHECK_OK);
+ typename Traits::Type::YieldExpression yield =
+ factory()->NewYield(generator_object, expression, kind, pos);
+ if (kind == Yield::DELEGATING) {
+ yield->set_index(function_state_->NextHandlerIndex());
+ }
+ return yield;
+}
+
+
#undef CHECK_OK
#undef CHECK_OK_CUSTOM
« no previous file with comments | « src/parser.cc ('k') | src/preparser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698