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

Side by Side Diff: src/parser.cc

Issue 140183005: Unify function name validation in Parser and PreParser. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: rebased Created 6 years, 10 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 3370 matching lines...) Expand 10 before | Expand all | Expand 10 after
3381 3381
3382 Expression* Parser::ParseMemberWithNewPrefixesExpression(PositionStack* stack, 3382 Expression* Parser::ParseMemberWithNewPrefixesExpression(PositionStack* stack,
3383 bool* ok) { 3383 bool* ok) {
3384 // MemberExpression :: 3384 // MemberExpression ::
3385 // (PrimaryExpression | FunctionLiteral) 3385 // (PrimaryExpression | FunctionLiteral)
3386 // ('[' Expression ']' | '.' Identifier | Arguments)* 3386 // ('[' Expression ']' | '.' Identifier | Arguments)*
3387 3387
3388 // Parse the initial primary or function expression. 3388 // Parse the initial primary or function expression.
3389 Expression* result = NULL; 3389 Expression* result = NULL;
3390 if (peek() == Token::FUNCTION) { 3390 if (peek() == Token::FUNCTION) {
3391 Expect(Token::FUNCTION, CHECK_OK); 3391 Consume(Token::FUNCTION);
3392 int function_token_position = position(); 3392 int function_token_position = position();
3393 bool is_generator = allow_generators() && Check(Token::MUL); 3393 bool is_generator = allow_generators() && Check(Token::MUL);
3394 Handle<String> name; 3394 Handle<String> name;
3395 bool is_strict_reserved_name = false; 3395 bool is_strict_reserved_name = false;
3396 Scanner::Location function_name_location = Scanner::Location::invalid(); 3396 Scanner::Location function_name_location = Scanner::Location::invalid();
3397 if (peek_any_identifier()) { 3397 if (peek_any_identifier()) {
3398 name = ParseIdentifierOrStrictReservedWord(&is_strict_reserved_name, 3398 name = ParseIdentifierOrStrictReservedWord(&is_strict_reserved_name,
3399 CHECK_OK); 3399 CHECK_OK);
3400 function_name_location = scanner().location(); 3400 function_name_location = scanner().location();
3401 } 3401 }
(...skipping 856 matching lines...) Expand 10 before | Expand all | Expand 10 after
4258 4258
4259 // Validate strict mode. 4259 // Validate strict mode.
4260 if (!top_scope_->is_classic_mode()) { 4260 if (!top_scope_->is_classic_mode()) {
4261 if (IsEvalOrArguments(function_name)) { 4261 if (IsEvalOrArguments(function_name)) {
4262 ReportMessageAt(function_name_location, 4262 ReportMessageAt(function_name_location,
4263 "strict_eval_arguments", 4263 "strict_eval_arguments",
4264 Vector<const char*>::empty()); 4264 Vector<const char*>::empty());
4265 *ok = false; 4265 *ok = false;
4266 return NULL; 4266 return NULL;
4267 } 4267 }
4268 if (name_is_strict_reserved) {
4269 ReportMessageAt(function_name_location, "unexpected_strict_reserved",
4270 Vector<const char*>::empty());
4271 *ok = false;
4272 return NULL;
4273 }
4268 if (name_loc.IsValid()) { 4274 if (name_loc.IsValid()) {
4269 ReportMessageAt(name_loc, "strict_eval_arguments", 4275 ReportMessageAt(name_loc, "strict_eval_arguments",
4270 Vector<const char*>::empty()); 4276 Vector<const char*>::empty());
4271 *ok = false; 4277 *ok = false;
4272 return NULL; 4278 return NULL;
4273 } 4279 }
4274 if (dupe_loc.IsValid()) { 4280 if (dupe_loc.IsValid()) {
4275 ReportMessageAt(dupe_loc, "strict_param_dupe", 4281 ReportMessageAt(dupe_loc, "strict_param_dupe",
4276 Vector<const char*>::empty()); 4282 Vector<const char*>::empty());
4277 *ok = false; 4283 *ok = false;
4278 return NULL; 4284 return NULL;
4279 }
4280 if (name_is_strict_reserved) {
4281 ReportMessageAt(function_name_location, "unexpected_strict_reserved",
4282 Vector<const char*>::empty());
4283 *ok = false;
4284 return NULL;
4285 } 4285 }
4286 if (reserved_loc.IsValid()) { 4286 if (reserved_loc.IsValid()) {
4287 ReportMessageAt(reserved_loc, "unexpected_strict_reserved", 4287 ReportMessageAt(reserved_loc, "unexpected_strict_reserved",
4288 Vector<const char*>::empty()); 4288 Vector<const char*>::empty());
4289 *ok = false; 4289 *ok = false;
4290 return NULL; 4290 return NULL;
4291 } 4291 }
4292 CheckOctalLiteral(scope->start_position(), 4292 CheckOctalLiteral(scope->start_position(),
4293 scope->end_position(), 4293 scope->end_position(),
4294 CHECK_OK); 4294 CHECK_OK);
(...skipping 1394 matching lines...) Expand 10 before | Expand all | Expand 10 after
5689 ASSERT(info()->isolate()->has_pending_exception()); 5689 ASSERT(info()->isolate()->has_pending_exception());
5690 } else { 5690 } else {
5691 result = ParseProgram(); 5691 result = ParseProgram();
5692 } 5692 }
5693 } 5693 }
5694 info()->SetFunction(result); 5694 info()->SetFunction(result);
5695 return (result != NULL); 5695 return (result != NULL);
5696 } 5696 }
5697 5697
5698 } } // namespace v8::internal 5698 } } // 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