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

Side by Side Diff: src/preparser.cc

Issue 196933005: Move ParseBinaryExpression 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/preparser.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 bool is_generator, 135 bool is_generator,
136 int function_token_position, 136 int function_token_position,
137 FunctionLiteral::FunctionType type, 137 FunctionLiteral::FunctionType type,
138 bool* ok) { 138 bool* ok) {
139 return pre_parser_->ParseFunctionLiteral( 139 return pre_parser_->ParseFunctionLiteral(
140 name, function_name_location, name_is_strict_reserved, is_generator, 140 name, function_name_location, name_is_strict_reserved, is_generator,
141 function_token_position, type, ok); 141 function_token_position, type, ok);
142 } 142 }
143 143
144 144
145 PreParserExpression PreParserTraits::ParseBinaryExpression(int prec, 145 PreParserExpression PreParserTraits::ParseUnaryExpression(bool* ok) {
146 bool accept_IN, 146 return pre_parser_->ParseUnaryExpression(ok);
147 bool* ok) {
148 return pre_parser_->ParseBinaryExpression(prec, accept_IN, ok);
149 } 147 }
150 148
151 149
152 PreParser::PreParseResult PreParser::PreParseLazyFunction( 150 PreParser::PreParseResult PreParser::PreParseLazyFunction(
153 StrictMode strict_mode, bool is_generator, ParserRecorder* log) { 151 StrictMode strict_mode, bool is_generator, ParserRecorder* log) {
154 log_ = log; 152 log_ = log;
155 // Lazy functions always have trivial outer scopes (no with/catch scopes). 153 // Lazy functions always have trivial outer scopes (no with/catch scopes).
156 PreParserScope top_scope(scope_, GLOBAL_SCOPE); 154 PreParserScope top_scope(scope_, GLOBAL_SCOPE);
157 FunctionState top_state(&function_state_, &scope_, &top_scope); 155 FunctionState top_state(&function_state_, &scope_, &top_scope);
158 scope_->SetStrictMode(strict_mode); 156 scope_->SetStrictMode(strict_mode);
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after
833 831
834 832
835 #undef CHECK_OK 833 #undef CHECK_OK
836 #define CHECK_OK ok); \ 834 #define CHECK_OK ok); \
837 if (!*ok) return Expression::Default(); \ 835 if (!*ok) return Expression::Default(); \
838 ((void)0 836 ((void)0
839 #define DUMMY ) // to make indentation work 837 #define DUMMY ) // to make indentation work
840 #undef DUMMY 838 #undef DUMMY
841 839
842 840
843 // Precedence >= 4
844 PreParser::Expression PreParser::ParseBinaryExpression(int prec,
845 bool accept_IN,
846 bool* ok) {
847 Expression result = ParseUnaryExpression(CHECK_OK);
848 for (int prec1 = Precedence(peek(), accept_IN); prec1 >= prec; prec1--) {
849 // prec1 >= 4
850 while (Precedence(peek(), accept_IN) == prec1) {
851 Next();
852 ParseBinaryExpression(prec1 + 1, accept_IN, CHECK_OK);
853 result = Expression::Default();
854 }
855 }
856 return result;
857 }
858
859
860 PreParser::Expression PreParser::ParseUnaryExpression(bool* ok) { 841 PreParser::Expression PreParser::ParseUnaryExpression(bool* ok) {
861 // UnaryExpression :: 842 // UnaryExpression ::
862 // PostfixExpression 843 // PostfixExpression
863 // 'delete' UnaryExpression 844 // 'delete' UnaryExpression
864 // 'void' UnaryExpression 845 // 'void' UnaryExpression
865 // 'typeof' UnaryExpression 846 // 'typeof' UnaryExpression
866 // '++' UnaryExpression 847 // '++' UnaryExpression
867 // '--' UnaryExpression 848 // '--' UnaryExpression
868 // '+' UnaryExpression 849 // '+' UnaryExpression
869 // '-' UnaryExpression 850 // '-' UnaryExpression
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
1201 int identifier_pos = position(); 1182 int identifier_pos = position();
1202 if (scanner()->is_literal_one_byte()) { 1183 if (scanner()->is_literal_one_byte()) {
1203 log_->LogAsciiSymbol(identifier_pos, scanner()->literal_one_byte_string()); 1184 log_->LogAsciiSymbol(identifier_pos, scanner()->literal_one_byte_string());
1204 } else { 1185 } else {
1205 log_->LogUtf16Symbol(identifier_pos, scanner()->literal_utf16_string()); 1186 log_->LogUtf16Symbol(identifier_pos, scanner()->literal_utf16_string());
1206 } 1187 }
1207 } 1188 }
1208 1189
1209 1190
1210 } } // v8::internal 1191 } } // v8::internal
OLDNEW
« no previous file with comments | « src/preparser.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698