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

Side by Side Diff: src/preparser.h

Issue 348893007: Allow yield expressions without a RHS. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_PREPARSER_H 5 #ifndef V8_PREPARSER_H
6 #define V8_PREPARSER_H 6 #define V8_PREPARSER_H
7 7
8 #include "src/v8.h" 8 #include "src/v8.h"
9 9
10 #include "src/func-name-inferrer.h" 10 #include "src/func-name-inferrer.h"
(...skipping 1774 matching lines...) Expand 10 before | Expand all | Expand 10 after
1785 fni_->Leave(); 1785 fni_->Leave();
1786 } 1786 }
1787 1787
1788 return factory()->NewAssignment(op, expression, right, pos); 1788 return factory()->NewAssignment(op, expression, right, pos);
1789 } 1789 }
1790 1790
1791 template <class Traits> 1791 template <class Traits>
1792 typename ParserBase<Traits>::ExpressionT 1792 typename ParserBase<Traits>::ExpressionT
1793 ParserBase<Traits>::ParseYieldExpression(bool* ok) { 1793 ParserBase<Traits>::ParseYieldExpression(bool* ok) {
1794 // YieldExpression :: 1794 // YieldExpression ::
1795 // 'yield' '*'? AssignmentExpression 1795 // 'yield' ([no line terminator] '*'? AssignmentExpression)?
1796 int pos = peek_position(); 1796 int pos = peek_position();
1797 Expect(Token::YIELD, CHECK_OK); 1797 Expect(Token::YIELD, CHECK_OK);
1798 Yield::Kind kind =
1799 Check(Token::MUL) ? Yield::DELEGATING : Yield::SUSPEND;
1800 ExpressionT generator_object = 1798 ExpressionT generator_object =
1801 factory()->NewVariableProxy(function_state_->generator_object_variable()); 1799 factory()->NewVariableProxy(function_state_->generator_object_variable());
1802 ExpressionT expression = 1800 ExpressionT expression = Traits::EmptyExpression();
1803 ParseAssignmentExpression(false, CHECK_OK); 1801 Yield::Kind kind = Yield::SUSPEND;
1802 if (!scanner()->HasAnyLineTerminatorBeforeNext()) {
1803 if (Check(Token::MUL)) kind = Yield::DELEGATING;
1804 switch (peek()) {
1805 case Token::EOS:
1806 case Token::SEMICOLON:
1807 case Token::RBRACE:
1808 case Token::RBRACK:
1809 case Token::RPAREN:
1810 case Token::COLON:
1811 case Token::COMMA:
1812 break;
1813 default:
1814 expression = ParseAssignmentExpression(false, CHECK_OK);
1815 break;
1816 }
1817 }
1804 typename Traits::Type::YieldExpression yield = 1818 typename Traits::Type::YieldExpression yield =
1805 factory()->NewYield(generator_object, expression, kind, pos); 1819 factory()->NewYield(generator_object, expression, kind, pos);
1806 if (kind == Yield::DELEGATING) { 1820 if (kind == Yield::DELEGATING) {
1807 yield->set_index(function_state_->NextHandlerIndex()); 1821 yield->set_index(function_state_->NextHandlerIndex());
1808 } 1822 }
1809 return yield; 1823 return yield;
1810 } 1824 }
1811 1825
1812 1826
1813 // Precedence = 3 1827 // Precedence = 3
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
2206 parser()->ReportMessage("accessor_get_set"); 2220 parser()->ReportMessage("accessor_get_set");
2207 } 2221 }
2208 *ok = false; 2222 *ok = false;
2209 } 2223 }
2210 } 2224 }
2211 2225
2212 2226
2213 } } // v8::internal 2227 } } // v8::internal
2214 2228
2215 #endif // V8_PREPARSER_H 2229 #endif // V8_PREPARSER_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698