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

Side by Side Diff: src/parser.cc

Issue 5626: Get rid of the local variable we use to keep the state... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 12 years, 2 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/codegen-ia32.cc ('k') | src/usage-analyzer.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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 1580 matching lines...) Expand 10 before | Expand all | Expand 10 after
1591 1591
1592 // Create body block. 1592 // Create body block.
1593 Block* body = NEW(Block(NULL, 1, false)); 1593 Block* body = NEW(Block(NULL, 1, false));
1594 body->AddStatement(stat); 1594 body->AddStatement(stat);
1595 1595
1596 // Create exit block. 1596 // Create exit block.
1597 Block* exit = NEW(Block(NULL, 1, false)); 1597 Block* exit = NEW(Block(NULL, 1, false));
1598 exit->AddStatement(NEW(WithExitStatement())); 1598 exit->AddStatement(NEW(WithExitStatement()));
1599 1599
1600 // Return a try-finally statement. 1600 // Return a try-finally statement.
1601 TryFinally* wrapper = NEW(TryFinally(body, NULL, exit)); 1601 TryFinally* wrapper = NEW(TryFinally(body, exit));
1602 wrapper->set_escaping_labels(collector.labels()); 1602 wrapper->set_escaping_labels(collector.labels());
1603 result->AddStatement(wrapper); 1603 result->AddStatement(wrapper);
1604 return result; 1604 return result;
1605 } else { 1605 } else {
1606 return NULL; 1606 return NULL;
1607 } 1607 }
1608 } 1608 }
1609 1609
1610 1610
1611 Statement* Parser::ParseWithStatement(ZoneStringList* labels, bool* ok) { 1611 Statement* Parser::ParseWithStatement(ZoneStringList* labels, bool* ok) {
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
1786 { Target target(this, &catch_collector); 1786 { Target target(this, &catch_collector);
1787 catch_block = WithHelper(obj, NULL, CHECK_OK); 1787 catch_block = WithHelper(obj, NULL, CHECK_OK);
1788 } 1788 }
1789 } else { 1789 } else {
1790 Expect(Token::LBRACE, CHECK_OK); 1790 Expect(Token::LBRACE, CHECK_OK);
1791 } 1791 }
1792 1792
1793 tok = peek(); 1793 tok = peek();
1794 } 1794 }
1795 1795
1796 VariableProxy* finally_var = NULL;
1797 if (tok == Token::FINALLY || !has_catch) { 1796 if (tok == Token::FINALLY || !has_catch) {
1798 Consume(Token::FINALLY); 1797 Consume(Token::FINALLY);
1799 // Declare a variable for holding the finally state while 1798 // Declare a variable for holding the finally state while
1800 // executing the finally block. 1799 // executing the finally block.
1801 finally_var = top_scope_->NewTemporary(Factory::finally_state_symbol());
1802 finally_block = ParseBlock(NULL, CHECK_OK); 1800 finally_block = ParseBlock(NULL, CHECK_OK);
1803 } 1801 }
1804 1802
1805 // Simplify the AST nodes by converting: 1803 // Simplify the AST nodes by converting:
1806 // 'try { } catch { } finally { }' 1804 // 'try { } catch { } finally { }'
1807 // to: 1805 // to:
1808 // 'try { try { } catch { } } finally { }' 1806 // 'try { try { } catch { } } finally { }'
1809 1807
1810 if (!is_pre_parsing_ && catch_block != NULL && finally_block != NULL) { 1808 if (!is_pre_parsing_ && catch_block != NULL && finally_block != NULL) {
1811 TryCatch* statement = NEW(TryCatch(try_block, catch_var, catch_block)); 1809 TryCatch* statement = NEW(TryCatch(try_block, catch_var, catch_block));
1812 statement->set_escaping_labels(collector.labels()); 1810 statement->set_escaping_labels(collector.labels());
1813 try_block = NEW(Block(NULL, 1, false)); 1811 try_block = NEW(Block(NULL, 1, false));
1814 try_block->AddStatement(statement); 1812 try_block->AddStatement(statement);
1815 catch_block = NULL; 1813 catch_block = NULL;
1816 } 1814 }
1817 1815
1818 TryStatement* result = NULL; 1816 TryStatement* result = NULL;
1819 if (!is_pre_parsing_) { 1817 if (!is_pre_parsing_) {
1820 if (catch_block != NULL) { 1818 if (catch_block != NULL) {
1821 ASSERT(finally_block == NULL); 1819 ASSERT(finally_block == NULL);
1822 result = NEW(TryCatch(try_block, catch_var, catch_block)); 1820 result = NEW(TryCatch(try_block, catch_var, catch_block));
1823 result->set_escaping_labels(collector.labels()); 1821 result->set_escaping_labels(collector.labels());
1824 } else { 1822 } else {
1825 ASSERT(finally_block != NULL); 1823 ASSERT(finally_block != NULL);
1826 result = NEW(TryFinally(try_block, finally_var, finally_block)); 1824 result = NEW(TryFinally(try_block, finally_block));
1827 // Add the labels of the try block and the catch block. 1825 // Add the labels of the try block and the catch block.
1828 for (int i = 0; i < collector.labels()->length(); i++) { 1826 for (int i = 0; i < collector.labels()->length(); i++) {
1829 catch_collector.labels()->Add(collector.labels()->at(i)); 1827 catch_collector.labels()->Add(collector.labels()->at(i));
1830 } 1828 }
1831 result->set_escaping_labels(catch_collector.labels()); 1829 result->set_escaping_labels(catch_collector.labels());
1832 } 1830 }
1833 } 1831 }
1834 1832
1835 return result; 1833 return result;
1836 } 1834 }
(...skipping 1419 matching lines...) Expand 10 before | Expand all | Expand 10 after
3256 start_position, 3254 start_position,
3257 is_expression); 3255 is_expression);
3258 return result; 3256 return result;
3259 } 3257 }
3260 3258
3261 3259
3262 #undef NEW 3260 #undef NEW
3263 3261
3264 3262
3265 } } // namespace v8::internal 3263 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/codegen-ia32.cc ('k') | src/usage-analyzer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698