Revision: 19921
Author: [email protected]
Date: Fri Mar 14 09:51:22 2014 UTC
Log: Move ParseYieldExpression to ParserBase.
[email protected]
BUG=v8:3126
LOG=N
Review URL: https://codereview.chromium.org/197353003
http://code.google.com/p/v8/source/detail?r=19921
Modified:
/branches/bleeding_edge/src/parser.cc
/branches/bleeding_edge/src/parser.h
/branches/bleeding_edge/src/preparser.cc
/branches/bleeding_edge/src/preparser.h
=======================================
--- /branches/bleeding_edge/src/parser.cc Fri Mar 14 09:43:04 2014 UTC
+++ /branches/bleeding_edge/src/parser.cc Fri Mar 14 09:51:22 2014 UTC
@@ -636,11 +636,6 @@
name_is_strict_reserved,
is_generator,
function_token_position, type, ok);
}
-
-
-Expression* ParserTraits::ParseYieldExpression(bool* ok) {
- return parser_->ParseYieldExpression(ok);
-}
Expression* ParserTraits::ParseConditionalExpression(bool accept_IN, bool*
ok) {
@@ -2933,24 +2928,6 @@
return loop;
}
}
-
-
-Expression* Parser::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;
- Expression* generator_object = factory()->NewVariableProxy(
- function_state_->generator_object_variable());
- Expression* expression = ParseAssignmentExpression(false, CHECK_OK);
- Yield* yield = factory()->NewYield(generator_object, expression, kind,
pos);
- if (kind == Yield::DELEGATING) {
- yield->set_index(function_state_->NextHandlerIndex());
- }
- return yield;
-}
// Precedence = 3
=======================================
--- /branches/bleeding_edge/src/parser.h Fri Mar 14 09:43:04 2014 UTC
+++ /branches/bleeding_edge/src/parser.h Fri Mar 14 09:51:22 2014 UTC
@@ -420,6 +420,7 @@
// Return types for traversing functions.
typedef Handle<String> Identifier;
typedef v8::internal::Expression* Expression;
+ typedef Yield* YieldExpression;
typedef v8::internal::FunctionLiteral* FunctionLiteral;
typedef v8::internal::Literal* Literal;
typedef ObjectLiteral::Property* ObjectLiteralProperty;
@@ -556,7 +557,6 @@
int function_token_position,
FunctionLiteral::FunctionType type,
bool* ok);
- Expression* ParseYieldExpression(bool* ok);
Expression* ParseConditionalExpression(bool accept_IN, bool* ok);
private:
@@ -700,7 +700,6 @@
// Support for hamony block scoped bindings.
Block* ParseScopedBlock(ZoneStringList* labels, 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);
=======================================
--- /branches/bleeding_edge/src/preparser.cc Fri Mar 14 09:43:04 2014 UTC
+++ /branches/bleeding_edge/src/preparser.cc Fri Mar 14 09:51:22 2014 UTC
@@ -140,11 +140,6 @@
name, function_name_location, name_is_strict_reserved, is_generator,
function_token_position, type, ok);
}
-
-
-PreParserExpression PreParserTraits::ParseYieldExpression(bool* ok) {
- return pre_parser_->ParseYieldExpression(ok);
-}
PreParserExpression PreParserTraits::ParseConditionalExpression(bool
accept_IN,
@@ -842,19 +837,6 @@
((void)0
#define DUMMY ) // to make indentation work
#undef DUMMY
-
-
-// Precedence = 3
-PreParser::Expression PreParser::ParseYieldExpression(bool* ok) {
- // YieldExpression ::
- // 'yield' '*'? AssignmentExpression
- Consume(Token::YIELD);
- Check(Token::MUL);
-
- ParseAssignmentExpression(false, CHECK_OK);
-
- return Expression::Default();
-}
// Precedence = 3
=======================================
--- /branches/bleeding_edge/src/preparser.h Fri Mar 14 09:43:04 2014 UTC
+++ /branches/bleeding_edge/src/preparser.h Fri Mar 14 09:51:22 2014 UTC
@@ -384,6 +384,7 @@
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
@@ -573,6 +574,9 @@
// doesn't do function name inferring.
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.
@@ -700,6 +704,17 @@
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();
+ }
};
@@ -722,6 +737,7 @@
// Return types for traversing functions.
typedef PreParserIdentifier Identifier;
typedef PreParserExpression Expression;
+ typedef PreParserExpression YieldExpression;
typedef PreParserExpression FunctionLiteral;
typedef PreParserExpression ObjectLiteralProperty;
typedef PreParserExpression Literal;
@@ -871,7 +887,6 @@
int function_token_position,
FunctionLiteral::FunctionType type,
bool* ok);
- PreParserExpression ParseYieldExpression(bool* ok);
PreParserExpression ParseConditionalExpression(bool accept_IN, bool* ok);
private:
@@ -1037,7 +1052,6 @@
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);
@@ -1652,6 +1666,28 @@
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
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.