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

Side by Side Diff: src/preparser.cc

Issue 430503007: Rename ASSERT* to DCHECK*. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: REBASE and fixes Created 6 years, 4 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') | src/prettyprinter.cc » ('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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 #include <cmath> 5 #include <cmath>
6 6
7 #include "include/v8stdint.h" 7 #include "include/v8stdint.h"
8 8
9 #include "src/allocation.h" 9 #include "src/allocation.h"
10 #include "src/base/logging.h" 10 #include "src/base/logging.h"
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 log_ = log; 110 log_ = log;
111 // Lazy functions always have trivial outer scopes (no with/catch scopes). 111 // Lazy functions always have trivial outer scopes (no with/catch scopes).
112 PreParserScope top_scope(scope_, GLOBAL_SCOPE); 112 PreParserScope top_scope(scope_, GLOBAL_SCOPE);
113 FunctionState top_state(&function_state_, &scope_, &top_scope, NULL, 113 FunctionState top_state(&function_state_, &scope_, &top_scope, NULL,
114 this->ast_value_factory()); 114 this->ast_value_factory());
115 scope_->SetStrictMode(strict_mode); 115 scope_->SetStrictMode(strict_mode);
116 PreParserScope function_scope(scope_, FUNCTION_SCOPE); 116 PreParserScope function_scope(scope_, FUNCTION_SCOPE);
117 FunctionState function_state(&function_state_, &scope_, &function_scope, NULL, 117 FunctionState function_state(&function_state_, &scope_, &function_scope, NULL,
118 this->ast_value_factory()); 118 this->ast_value_factory());
119 function_state.set_is_generator(is_generator); 119 function_state.set_is_generator(is_generator);
120 ASSERT_EQ(Token::LBRACE, scanner()->current_token()); 120 DCHECK_EQ(Token::LBRACE, scanner()->current_token());
121 bool ok = true; 121 bool ok = true;
122 int start_position = peek_position(); 122 int start_position = peek_position();
123 ParseLazyFunctionLiteralBody(&ok); 123 ParseLazyFunctionLiteralBody(&ok);
124 if (stack_overflow()) return kPreParseStackOverflow; 124 if (stack_overflow()) return kPreParseStackOverflow;
125 if (!ok) { 125 if (!ok) {
126 ReportUnexpectedToken(scanner()->current_token()); 126 ReportUnexpectedToken(scanner()->current_token());
127 } else { 127 } else {
128 ASSERT_EQ(Token::RBRACE, scanner()->peek()); 128 DCHECK_EQ(Token::RBRACE, scanner()->peek());
129 if (scope_->strict_mode() == STRICT) { 129 if (scope_->strict_mode() == STRICT) {
130 int end_pos = scanner()->location().end_pos; 130 int end_pos = scanner()->location().end_pos;
131 CheckOctalLiteral(start_position, end_pos, &ok); 131 CheckOctalLiteral(start_position, end_pos, &ok);
132 } 132 }
133 } 133 }
134 return kPreParseSuccess; 134 return kPreParseSuccess;
135 } 135 }
136 136
137 137
138 // Preparsing checks a JavaScript program and emits preparse-data that helps 138 // Preparsing checks a JavaScript program and emits preparse-data that helps
(...skipping 28 matching lines...) Expand all
167 // LetDeclaration 167 // LetDeclaration
168 // ConstDeclaration 168 // ConstDeclaration
169 // GeneratorDeclaration 169 // GeneratorDeclaration
170 170
171 switch (peek()) { 171 switch (peek()) {
172 case Token::FUNCTION: 172 case Token::FUNCTION:
173 return ParseFunctionDeclaration(ok); 173 return ParseFunctionDeclaration(ok);
174 case Token::CONST: 174 case Token::CONST:
175 return ParseVariableStatement(kSourceElement, ok); 175 return ParseVariableStatement(kSourceElement, ok);
176 case Token::LET: 176 case Token::LET:
177 ASSERT(allow_harmony_scoping()); 177 DCHECK(allow_harmony_scoping());
178 if (strict_mode() == STRICT) { 178 if (strict_mode() == STRICT) {
179 return ParseVariableStatement(kSourceElement, ok); 179 return ParseVariableStatement(kSourceElement, ok);
180 } 180 }
181 // Fall through. 181 // Fall through.
182 default: 182 default:
183 return ParseStatement(ok); 183 return ParseStatement(ok);
184 } 184 }
185 } 185 }
186 186
187 187
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 } 299 }
300 300
301 case Token::DEBUGGER: 301 case Token::DEBUGGER:
302 return ParseDebuggerStatement(ok); 302 return ParseDebuggerStatement(ok);
303 303
304 case Token::VAR: 304 case Token::VAR:
305 case Token::CONST: 305 case Token::CONST:
306 return ParseVariableStatement(kStatement, ok); 306 return ParseVariableStatement(kStatement, ok);
307 307
308 case Token::LET: 308 case Token::LET:
309 ASSERT(allow_harmony_scoping()); 309 DCHECK(allow_harmony_scoping());
310 if (strict_mode() == STRICT) { 310 if (strict_mode() == STRICT) {
311 return ParseVariableStatement(kStatement, ok); 311 return ParseVariableStatement(kStatement, ok);
312 } 312 }
313 // Fall through. 313 // Fall through.
314 default: 314 default:
315 return ParseExpressionOrLabelledStatement(ok); 315 return ParseExpressionOrLabelledStatement(ok);
316 } 316 }
317 } 317 }
318 318
319 319
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 // Identifier ':' Statement 469 // Identifier ':' Statement
470 470
471 bool starts_with_identifier = peek_any_identifier(); 471 bool starts_with_identifier = peek_any_identifier();
472 Expression expr = ParseExpression(true, CHECK_OK); 472 Expression expr = ParseExpression(true, CHECK_OK);
473 // Even if the expression starts with an identifier, it is not necessarily an 473 // Even if the expression starts with an identifier, it is not necessarily an
474 // identifier. For example, "foo + bar" starts with an identifier but is not 474 // identifier. For example, "foo + bar" starts with an identifier but is not
475 // an identifier. 475 // an identifier.
476 if (starts_with_identifier && expr.IsIdentifier() && peek() == Token::COLON) { 476 if (starts_with_identifier && expr.IsIdentifier() && peek() == Token::COLON) {
477 // Expression is a single identifier, and not, e.g., a parenthesized 477 // Expression is a single identifier, and not, e.g., a parenthesized
478 // identifier. 478 // identifier.
479 ASSERT(!expr.AsIdentifier().IsFutureReserved()); 479 DCHECK(!expr.AsIdentifier().IsFutureReserved());
480 ASSERT(strict_mode() == SLOPPY || 480 DCHECK(strict_mode() == SLOPPY ||
481 (!expr.AsIdentifier().IsFutureStrictReserved() && 481 (!expr.AsIdentifier().IsFutureStrictReserved() &&
482 !expr.AsIdentifier().IsYield())); 482 !expr.AsIdentifier().IsYield()));
483 Consume(Token::COLON); 483 Consume(Token::COLON);
484 return ParseStatement(ok); 484 return ParseStatement(ok);
485 // Preparsing is disabled for extensions (because the extension details 485 // Preparsing is disabled for extensions (because the extension details
486 // aren't passed to lazily compiled functions), so we don't 486 // aren't passed to lazily compiled functions), so we don't
487 // accept "native function" in the preparser. 487 // accept "native function" in the preparser.
488 } 488 }
489 // Parsed expression statement. 489 // Parsed expression statement.
490 ExpectSemicolon(CHECK_OK); 490 ExpectSemicolon(CHECK_OK);
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
900 return Expression::Default(); 900 return Expression::Default();
901 } 901 }
902 902
903 903
904 void PreParser::ParseLazyFunctionLiteralBody(bool* ok) { 904 void PreParser::ParseLazyFunctionLiteralBody(bool* ok) {
905 int body_start = position(); 905 int body_start = position();
906 ParseSourceElements(Token::RBRACE, ok); 906 ParseSourceElements(Token::RBRACE, ok);
907 if (!*ok) return; 907 if (!*ok) return;
908 908
909 // Position right after terminal '}'. 909 // Position right after terminal '}'.
910 ASSERT_EQ(Token::RBRACE, scanner()->peek()); 910 DCHECK_EQ(Token::RBRACE, scanner()->peek());
911 int body_end = scanner()->peek_location().end_pos; 911 int body_end = scanner()->peek_location().end_pos;
912 log_->LogFunction(body_start, body_end, 912 log_->LogFunction(body_start, body_end,
913 function_state_->materialized_literal_count(), 913 function_state_->materialized_literal_count(),
914 function_state_->expected_property_count(), 914 function_state_->expected_property_count(),
915 strict_mode()); 915 strict_mode());
916 } 916 }
917 917
918 918
919 PreParser::Expression PreParser::ParseV8Intrinsic(bool* ok) { 919 PreParser::Expression PreParser::ParseV8Intrinsic(bool* ok) {
920 // CallRuntime :: 920 // CallRuntime ::
921 // '%' Identifier Arguments 921 // '%' Identifier Arguments
922 Expect(Token::MOD, CHECK_OK); 922 Expect(Token::MOD, CHECK_OK);
923 if (!allow_natives_syntax()) { 923 if (!allow_natives_syntax()) {
924 *ok = false; 924 *ok = false;
925 return Expression::Default(); 925 return Expression::Default();
926 } 926 }
927 // Allow "eval" or "arguments" for backward compatibility. 927 // Allow "eval" or "arguments" for backward compatibility.
928 ParseIdentifier(kAllowEvalOrArguments, CHECK_OK); 928 ParseIdentifier(kAllowEvalOrArguments, CHECK_OK);
929 ParseArguments(ok); 929 ParseArguments(ok);
930 930
931 return Expression::Default(); 931 return Expression::Default();
932 } 932 }
933 933
934 #undef CHECK_OK 934 #undef CHECK_OK
935 935
936 936
937 } } // v8::internal 937 } } // v8::internal
OLDNEW
« no previous file with comments | « src/preparser.h ('k') | src/prettyprinter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698