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

Side by Side Diff: src/parser.cc

Issue 6691058: Restart AST node numbering when we enter a function. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 8 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/ia32/full-codegen-ia32.cc ('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 2010 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
11 // with the distribution. 11 // with the distribution.
(...skipping 3526 matching lines...) Expand 10 before | Expand all | Expand 10 after
3538 LexicalScope lexical_scope(this, scope, isolate()); 3538 LexicalScope lexical_scope(this, scope, isolate());
3539 top_scope_->SetScopeName(name); 3539 top_scope_->SetScopeName(name);
3540 3540
3541 // FormalParameterList :: 3541 // FormalParameterList ::
3542 // '(' (Identifier)*[','] ')' 3542 // '(' (Identifier)*[','] ')'
3543 Expect(Token::LPAREN, CHECK_OK); 3543 Expect(Token::LPAREN, CHECK_OK);
3544 int start_pos = scanner().location().beg_pos; 3544 int start_pos = scanner().location().beg_pos;
3545 Scanner::Location name_loc = Scanner::NoLocation(); 3545 Scanner::Location name_loc = Scanner::NoLocation();
3546 Scanner::Location dupe_loc = Scanner::NoLocation(); 3546 Scanner::Location dupe_loc = Scanner::NoLocation();
3547 Scanner::Location reserved_loc = Scanner::NoLocation(); 3547 Scanner::Location reserved_loc = Scanner::NoLocation();
3548 Isolate* isolate = Isolate::Current();
Kevin Millikin (Chromium) 2011/04/05 15:56:11 You should probably call (the parser's) isolate()
3549 unsigned old_ast_node_id = isolate->ast_node_id();
3550 isolate->set_ast_node_id(1);
3548 3551
3549 bool done = (peek() == Token::RPAREN); 3552 bool done = (peek() == Token::RPAREN);
3550 while (!done) { 3553 while (!done) {
3551 bool is_reserved = false; 3554 bool is_reserved = false;
3552 Handle<String> param_name = 3555 Handle<String> param_name =
3553 ParseIdentifierOrReservedWord(&is_reserved, CHECK_OK); 3556 ParseIdentifierOrReservedWord(&is_reserved, CHECK_OK);
3554 3557
3555 // Store locations for possible future error reports. 3558 // Store locations for possible future error reports.
3556 if (!name_loc.IsValid() && IsEvalOrArguments(param_name)) { 3559 if (!name_loc.IsValid() && IsEvalOrArguments(param_name)) {
3557 name_loc = scanner().location(); 3560 name_loc = scanner().location();
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
3614 if (is_lazily_compiled && pre_data() != NULL) { 3617 if (is_lazily_compiled && pre_data() != NULL) {
3615 FunctionEntry entry = pre_data()->GetFunctionEntry(function_block_pos); 3618 FunctionEntry entry = pre_data()->GetFunctionEntry(function_block_pos);
3616 if (!entry.is_valid()) { 3619 if (!entry.is_valid()) {
3617 ReportInvalidPreparseData(name, CHECK_OK); 3620 ReportInvalidPreparseData(name, CHECK_OK);
3618 } 3621 }
3619 end_pos = entry.end_pos(); 3622 end_pos = entry.end_pos();
3620 if (end_pos <= function_block_pos) { 3623 if (end_pos <= function_block_pos) {
3621 // End position greater than end of stream is safe, and hard to check. 3624 // End position greater than end of stream is safe, and hard to check.
3622 ReportInvalidPreparseData(name, CHECK_OK); 3625 ReportInvalidPreparseData(name, CHECK_OK);
3623 } 3626 }
3624 isolate()->counters()->total_preparse_skipped()->Increment( 3627 isolate->counters()->total_preparse_skipped()->Increment(
3625 end_pos - function_block_pos); 3628 end_pos - function_block_pos);
3626 // Seek to position just before terminal '}'. 3629 // Seek to position just before terminal '}'.
3627 scanner().SeekForward(end_pos - 1); 3630 scanner().SeekForward(end_pos - 1);
3628 materialized_literal_count = entry.literal_count(); 3631 materialized_literal_count = entry.literal_count();
3629 expected_property_count = entry.property_count(); 3632 expected_property_count = entry.property_count();
3630 only_simple_this_property_assignments = false; 3633 only_simple_this_property_assignments = false;
3631 this_property_assignments = isolate()->factory()->empty_fixed_array(); 3634 this_property_assignments = isolate->factory()->empty_fixed_array();
3632 Expect(Token::RBRACE, CHECK_OK); 3635 Expect(Token::RBRACE, CHECK_OK);
3633 } else { 3636 } else {
3634 ParseSourceElements(body, Token::RBRACE, CHECK_OK); 3637 ParseSourceElements(body, Token::RBRACE, CHECK_OK);
3635 3638
3636 materialized_literal_count = lexical_scope.materialized_literal_count(); 3639 materialized_literal_count = lexical_scope.materialized_literal_count();
3637 expected_property_count = lexical_scope.expected_property_count(); 3640 expected_property_count = lexical_scope.expected_property_count();
3638 only_simple_this_property_assignments = 3641 only_simple_this_property_assignments =
3639 lexical_scope.only_simple_this_property_assignments(); 3642 lexical_scope.only_simple_this_property_assignments();
3640 this_property_assignments = lexical_scope.this_property_assignments(); 3643 this_property_assignments = lexical_scope.this_property_assignments();
3641 3644
3642 Expect(Token::RBRACE, CHECK_OK); 3645 Expect(Token::RBRACE, CHECK_OK);
3643 end_pos = scanner().location().end_pos; 3646 end_pos = scanner().location().end_pos;
3644 } 3647 }
3648 isolate->set_ast_node_id(old_ast_node_id);
3645 3649
3646 // Validate strict mode. 3650 // Validate strict mode.
3647 if (top_scope_->is_strict_mode()) { 3651 if (top_scope_->is_strict_mode()) {
3648 if (IsEvalOrArguments(name)) { 3652 if (IsEvalOrArguments(name)) {
3649 int position = function_token_position != RelocInfo::kNoPosition 3653 int position = function_token_position != RelocInfo::kNoPosition
3650 ? function_token_position 3654 ? function_token_position
3651 : (start_pos > 0 ? start_pos - 1 : start_pos); 3655 : (start_pos > 0 ? start_pos - 1 : start_pos);
3652 Scanner::Location location = Scanner::Location(position, start_pos); 3656 Scanner::Location location = Scanner::Location(position, start_pos);
3653 ReportMessageAt(location, 3657 ReportMessageAt(location,
3654 "strict_function_name", Vector<const char*>::empty()); 3658 "strict_function_name", Vector<const char*>::empty());
3655 *ok = false; 3659 *ok = false; return NULL;
3656 return NULL;
3657 } 3660 }
3658 if (name_loc.IsValid()) { 3661 if (name_loc.IsValid()) {
3659 ReportMessageAt(name_loc, "strict_param_name", 3662 ReportMessageAt(name_loc, "strict_param_name",
3660 Vector<const char*>::empty()); 3663 Vector<const char*>::empty());
3661 *ok = false; 3664 *ok = false;
3662 return NULL; 3665 return NULL;
3663 } 3666 }
3664 if (dupe_loc.IsValid()) { 3667 if (dupe_loc.IsValid()) {
3665 ReportMessageAt(dupe_loc, "strict_param_dupe", 3668 ReportMessageAt(dupe_loc, "strict_param_dupe",
3666 Vector<const char*>::empty()); 3669 Vector<const char*>::empty());
(...skipping 1492 matching lines...) Expand 10 before | Expand all | Expand 10 after
5159 info->is_global(), 5162 info->is_global(),
5160 info->StrictMode()); 5163 info->StrictMode());
5161 } 5164 }
5162 } 5165 }
5163 5166
5164 info->SetFunction(result); 5167 info->SetFunction(result);
5165 return (result != NULL); 5168 return (result != NULL);
5166 } 5169 }
5167 5170
5168 } } // namespace v8::internal 5171 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ia32/full-codegen-ia32.cc ('k') | src/prettyprinter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698