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

Side by Side Diff: src/parser.cc

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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/parser.h ('k') | src/preparser.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 bool is_generator, 631 bool is_generator,
632 int function_token_position, 632 int function_token_position,
633 FunctionLiteral::FunctionType type, 633 FunctionLiteral::FunctionType type,
634 bool* ok) { 634 bool* ok) {
635 return parser_->ParseFunctionLiteral(name, function_name_location, 635 return parser_->ParseFunctionLiteral(name, function_name_location,
636 name_is_strict_reserved, is_generator, 636 name_is_strict_reserved, is_generator,
637 function_token_position, type, ok); 637 function_token_position, type, ok);
638 } 638 }
639 639
640 640
641 Expression* ParserTraits::ParseYieldExpression(bool* ok) {
642 return parser_->ParseYieldExpression(ok);
643 }
644
645
646 Expression* ParserTraits::ParseConditionalExpression(bool accept_IN, bool* ok) { 641 Expression* ParserTraits::ParseConditionalExpression(bool accept_IN, bool* ok) {
647 return parser_->ParseConditionalExpression(accept_IN, ok); 642 return parser_->ParseConditionalExpression(accept_IN, ok);
648 } 643 }
649 644
650 645
651 Parser::Parser(CompilationInfo* info) 646 Parser::Parser(CompilationInfo* info)
652 : ParserBase<ParserTraits>(&scanner_, 647 : ParserBase<ParserTraits>(&scanner_,
653 info->isolate()->stack_guard()->real_climit(), 648 info->isolate()->stack_guard()->real_climit(),
654 info->extension(), 649 info->extension(),
655 info->zone(), 650 info->zone(),
(...skipping 2272 matching lines...) Expand 10 before | Expand all | Expand 10 after
2928 result->set_scope(for_scope); 2923 result->set_scope(for_scope);
2929 loop->Initialize(NULL, cond, next, body); 2924 loop->Initialize(NULL, cond, next, body);
2930 return result; 2925 return result;
2931 } else { 2926 } else {
2932 loop->Initialize(init, cond, next, body); 2927 loop->Initialize(init, cond, next, body);
2933 return loop; 2928 return loop;
2934 } 2929 }
2935 } 2930 }
2936 2931
2937 2932
2938 Expression* Parser::ParseYieldExpression(bool* ok) {
2939 // YieldExpression ::
2940 // 'yield' '*'? AssignmentExpression
2941 int pos = peek_position();
2942 Expect(Token::YIELD, CHECK_OK);
2943 Yield::Kind kind =
2944 Check(Token::MUL) ? Yield::DELEGATING : Yield::SUSPEND;
2945 Expression* generator_object = factory()->NewVariableProxy(
2946 function_state_->generator_object_variable());
2947 Expression* expression = ParseAssignmentExpression(false, CHECK_OK);
2948 Yield* yield = factory()->NewYield(generator_object, expression, kind, pos);
2949 if (kind == Yield::DELEGATING) {
2950 yield->set_index(function_state_->NextHandlerIndex());
2951 }
2952 return yield;
2953 }
2954
2955
2956 // Precedence = 3 2933 // Precedence = 3
2957 Expression* Parser::ParseConditionalExpression(bool accept_IN, bool* ok) { 2934 Expression* Parser::ParseConditionalExpression(bool accept_IN, bool* ok) {
2958 // ConditionalExpression :: 2935 // ConditionalExpression ::
2959 // LogicalOrExpression 2936 // LogicalOrExpression
2960 // LogicalOrExpression '?' AssignmentExpression ':' AssignmentExpression 2937 // LogicalOrExpression '?' AssignmentExpression ':' AssignmentExpression
2961 2938
2962 int pos = peek_position(); 2939 int pos = peek_position();
2963 // We start using the binary expression parser for prec >= 4 only! 2940 // We start using the binary expression parser for prec >= 4 only!
2964 Expression* expression = ParseBinaryExpression(4, accept_IN, CHECK_OK); 2941 Expression* expression = ParseBinaryExpression(4, accept_IN, CHECK_OK);
2965 if (peek() != Token::CONDITIONAL) return expression; 2942 if (peek() != Token::CONDITIONAL) return expression;
(...skipping 2156 matching lines...) Expand 10 before | Expand all | Expand 10 after
5122 ASSERT(info()->isolate()->has_pending_exception()); 5099 ASSERT(info()->isolate()->has_pending_exception());
5123 } else { 5100 } else {
5124 result = ParseProgram(); 5101 result = ParseProgram();
5125 } 5102 }
5126 } 5103 }
5127 info()->SetFunction(result); 5104 info()->SetFunction(result);
5128 return (result != NULL); 5105 return (result != NULL);
5129 } 5106 }
5130 5107
5131 } } // namespace v8::internal 5108 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/parser.h ('k') | src/preparser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698