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

Side by Side Diff: src/parser.cc

Issue 12613007: Harden Function()'s parsing of function literals. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments by Andreas Rossberg. Created 7 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/compiler.cc ('k') | src/runtime.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 638 matching lines...) Expand 10 before | Expand all | Expand 10 after
649 int beg_loc = scanner().location().beg_pos; 649 int beg_loc = scanner().location().beg_pos;
650 ParseSourceElements(body, Token::EOS, info->is_eval(), true, &ok); 650 ParseSourceElements(body, Token::EOS, info->is_eval(), true, &ok);
651 if (ok && !top_scope_->is_classic_mode()) { 651 if (ok && !top_scope_->is_classic_mode()) {
652 CheckOctalLiteral(beg_loc, scanner().location().end_pos, &ok); 652 CheckOctalLiteral(beg_loc, scanner().location().end_pos, &ok);
653 } 653 }
654 654
655 if (ok && is_extended_mode()) { 655 if (ok && is_extended_mode()) {
656 CheckConflictingVarDeclarations(top_scope_, &ok); 656 CheckConflictingVarDeclarations(top_scope_, &ok);
657 } 657 }
658 658
659 if (ok && info->parse_restriction() == ONLY_SINGLE_FUNCTION_LITERAL) {
660 if (body->length() != 1 ||
661 !body->at(0)->IsExpressionStatement() ||
662 !body->at(0)->AsExpressionStatement()->
663 expression()->IsFunctionLiteral()) {
664 ReportMessage("unable_to_parse", Vector<const char*>::empty());
665 ok = false;
666 }
667 }
668
659 if (ok) { 669 if (ok) {
660 result = factory()->NewFunctionLiteral( 670 result = factory()->NewFunctionLiteral(
661 no_name, 671 no_name,
662 top_scope_, 672 top_scope_,
663 body, 673 body,
664 function_state.materialized_literal_count(), 674 function_state.materialized_literal_count(),
665 function_state.expected_property_count(), 675 function_state.expected_property_count(),
666 function_state.handler_count(), 676 function_state.handler_count(),
667 function_state.only_simple_this_property_assignments(), 677 function_state.only_simple_this_property_assignments(),
668 function_state.this_property_assignments(), 678 function_state.this_property_assignments(),
(...skipping 5263 matching lines...) Expand 10 before | Expand all | Expand 10 after
5932 ASSERT(info->isolate()->has_pending_exception()); 5942 ASSERT(info->isolate()->has_pending_exception());
5933 } else { 5943 } else {
5934 result = parser.ParseProgram(); 5944 result = parser.ParseProgram();
5935 } 5945 }
5936 } 5946 }
5937 info->SetFunction(result); 5947 info->SetFunction(result);
5938 return (result != NULL); 5948 return (result != NULL);
5939 } 5949 }
5940 5950
5941 } } // namespace v8::internal 5951 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/compiler.cc ('k') | src/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698