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

Side by Side Diff: src/parser.cc

Issue 148233011: Unify (Pre)Parser::ParseTryStatement. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: test for success 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 | « no previous file | src/preparser.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 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 2468 matching lines...) Expand 10 before | Expand all | Expand 10 after
2479 if (tok == Token::CATCH) { 2479 if (tok == Token::CATCH) {
2480 Consume(Token::CATCH); 2480 Consume(Token::CATCH);
2481 2481
2482 Expect(Token::LPAREN, CHECK_OK); 2482 Expect(Token::LPAREN, CHECK_OK);
2483 catch_scope = NewScope(top_scope_, CATCH_SCOPE); 2483 catch_scope = NewScope(top_scope_, CATCH_SCOPE);
2484 catch_scope->set_start_position(scanner().location().beg_pos); 2484 catch_scope->set_start_position(scanner().location().beg_pos);
2485 name = ParseIdentifier(kDontAllowEvalOrArguments, CHECK_OK); 2485 name = ParseIdentifier(kDontAllowEvalOrArguments, CHECK_OK);
2486 2486
2487 Expect(Token::RPAREN, CHECK_OK); 2487 Expect(Token::RPAREN, CHECK_OK);
2488 2488
2489 if (peek() == Token::LBRACE) { 2489 Target target(&this->target_stack_, &catch_collector);
2490 Target target(&this->target_stack_, &catch_collector); 2490 VariableMode mode = is_extended_mode() ? LET : VAR;
2491 VariableMode mode = is_extended_mode() ? LET : VAR; 2491 catch_variable =
2492 catch_variable = 2492 catch_scope->DeclareLocal(name, mode, kCreatedInitialized);
2493 catch_scope->DeclareLocal(name, mode, kCreatedInitialized);
2494 2493
2495 BlockState block_state(this, catch_scope); 2494 BlockState block_state(this, catch_scope);
2496 catch_block = ParseBlock(NULL, CHECK_OK); 2495 catch_block = ParseBlock(NULL, CHECK_OK);
2497 } else { 2496
2498 Expect(Token::LBRACE, CHECK_OK);
2499 }
2500 catch_scope->set_end_position(scanner().location().end_pos); 2497 catch_scope->set_end_position(scanner().location().end_pos);
2501 tok = peek(); 2498 tok = peek();
2502 } 2499 }
2503 2500
2504 Block* finally_block = NULL; 2501 Block* finally_block = NULL;
2505 if (tok == Token::FINALLY || catch_block == NULL) { 2502 ASSERT(tok == Token::FINALLY || catch_block != NULL);
2503 if (tok == Token::FINALLY) {
2506 Consume(Token::FINALLY); 2504 Consume(Token::FINALLY);
2507 finally_block = ParseBlock(NULL, CHECK_OK); 2505 finally_block = ParseBlock(NULL, CHECK_OK);
2508 } 2506 }
2509 2507
2510 // Simplify the AST nodes by converting: 2508 // Simplify the AST nodes by converting:
2511 // 'try B0 catch B1 finally B2' 2509 // 'try B0 catch B1 finally B2'
2512 // to: 2510 // to:
2513 // 'try { try B0 catch B1 } finally B2' 2511 // 'try { try B0 catch B1 } finally B2'
2514 2512
2515 if (catch_block != NULL && finally_block != NULL) { 2513 if (catch_block != NULL && finally_block != NULL) {
(...skipping 3178 matching lines...) Expand 10 before | Expand all | Expand 10 after
5694 ASSERT(info()->isolate()->has_pending_exception()); 5692 ASSERT(info()->isolate()->has_pending_exception());
5695 } else { 5693 } else {
5696 result = ParseProgram(); 5694 result = ParseProgram();
5697 } 5695 }
5698 } 5696 }
5699 info()->SetFunction(result); 5697 info()->SetFunction(result);
5700 return (result != NULL); 5698 return (result != NULL);
5701 } 5699 }
5702 5700
5703 } } // namespace v8::internal 5701 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/preparser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698