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

Side by Side Diff: src/parser.cc

Issue 1074009: Mark all loop conditions. (Closed)
Patch Set: Negate test to match previous (and correct) behavior. Created 10 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
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 2626 matching lines...) Expand 10 before | Expand all | Expand 10 after
2638 Statement* body = ParseStatement(NULL, CHECK_OK); 2638 Statement* body = ParseStatement(NULL, CHECK_OK);
2639 Expect(Token::WHILE, CHECK_OK); 2639 Expect(Token::WHILE, CHECK_OK);
2640 Expect(Token::LPAREN, CHECK_OK); 2640 Expect(Token::LPAREN, CHECK_OK);
2641 2641
2642 if (loop != NULL) { 2642 if (loop != NULL) {
2643 int position = scanner().location().beg_pos; 2643 int position = scanner().location().beg_pos;
2644 loop->set_condition_position(position); 2644 loop->set_condition_position(position);
2645 } 2645 }
2646 2646
2647 Expression* cond = ParseExpression(true, CHECK_OK); 2647 Expression* cond = ParseExpression(true, CHECK_OK);
2648 if (cond != NULL) cond->set_is_loop_condition(true);
2648 Expect(Token::RPAREN, CHECK_OK); 2649 Expect(Token::RPAREN, CHECK_OK);
2649 2650
2650 // Allow do-statements to be terminated with and without 2651 // Allow do-statements to be terminated with and without
2651 // semi-colons. This allows code such as 'do;while(0)return' to 2652 // semi-colons. This allows code such as 'do;while(0)return' to
2652 // parse, which would not be the case if we had used the 2653 // parse, which would not be the case if we had used the
2653 // ExpectSemicolon() functionality here. 2654 // ExpectSemicolon() functionality here.
2654 if (peek() == Token::SEMICOLON) Consume(Token::SEMICOLON); 2655 if (peek() == Token::SEMICOLON) Consume(Token::SEMICOLON);
2655 2656
2656 if (loop != NULL) loop->Initialize(cond, body); 2657 if (loop != NULL) loop->Initialize(cond, body);
2657 2658
2658 seen_loop_stmt_ = true; 2659 seen_loop_stmt_ = true;
2659 2660
2660 return loop; 2661 return loop;
2661 } 2662 }
2662 2663
2663 2664
2664 WhileStatement* Parser::ParseWhileStatement(ZoneStringList* labels, bool* ok) { 2665 WhileStatement* Parser::ParseWhileStatement(ZoneStringList* labels, bool* ok) {
2665 // WhileStatement :: 2666 // WhileStatement ::
2666 // 'while' '(' Expression ')' Statement 2667 // 'while' '(' Expression ')' Statement
2667 2668
2668 WhileStatement* loop = NEW(WhileStatement(labels)); 2669 WhileStatement* loop = NEW(WhileStatement(labels));
2669 Target target(this, loop); 2670 Target target(this, loop);
2670 2671
2671 Expect(Token::WHILE, CHECK_OK); 2672 Expect(Token::WHILE, CHECK_OK);
2672 Expect(Token::LPAREN, CHECK_OK); 2673 Expect(Token::LPAREN, CHECK_OK);
2673 Expression* cond = ParseExpression(true, CHECK_OK); 2674 Expression* cond = ParseExpression(true, CHECK_OK);
2675 if (cond != NULL) cond->set_is_loop_condition(true);
2674 Expect(Token::RPAREN, CHECK_OK); 2676 Expect(Token::RPAREN, CHECK_OK);
2675 Statement* body = ParseStatement(NULL, CHECK_OK); 2677 Statement* body = ParseStatement(NULL, CHECK_OK);
2676 2678
2677 if (loop != NULL) loop->Initialize(cond, body); 2679 if (loop != NULL) loop->Initialize(cond, body);
2678 2680
2679 seen_loop_stmt_ = true; 2681 seen_loop_stmt_ = true;
2680 2682
2681 return loop; 2683 return loop;
2682 } 2684 }
2683 2685
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
2757 // Standard 'for' loop 2759 // Standard 'for' loop
2758 ForStatement* loop = NEW(ForStatement(labels)); 2760 ForStatement* loop = NEW(ForStatement(labels));
2759 Target target(this, loop); 2761 Target target(this, loop);
2760 2762
2761 // Parsed initializer at this point. 2763 // Parsed initializer at this point.
2762 Expect(Token::SEMICOLON, CHECK_OK); 2764 Expect(Token::SEMICOLON, CHECK_OK);
2763 2765
2764 Expression* cond = NULL; 2766 Expression* cond = NULL;
2765 if (peek() != Token::SEMICOLON) { 2767 if (peek() != Token::SEMICOLON) {
2766 cond = ParseExpression(true, CHECK_OK); 2768 cond = ParseExpression(true, CHECK_OK);
2767 if (cond && cond->AsCompareOperation()) { 2769 if (cond != NULL) cond->set_is_loop_condition(true);
2768 cond->AsCompareOperation()->set_is_for_loop_condition();
2769 }
2770 } 2770 }
2771 Expect(Token::SEMICOLON, CHECK_OK); 2771 Expect(Token::SEMICOLON, CHECK_OK);
2772 2772
2773 Statement* next = NULL; 2773 Statement* next = NULL;
2774 if (peek() != Token::RPAREN) { 2774 if (peek() != Token::RPAREN) {
2775 Expression* exp = ParseExpression(true, CHECK_OK); 2775 Expression* exp = ParseExpression(true, CHECK_OK);
2776 next = NEW(ExpressionStatement(exp)); 2776 next = NEW(ExpressionStatement(exp));
2777 } 2777 }
2778 Expect(Token::RPAREN, CHECK_OK); 2778 Expect(Token::RPAREN, CHECK_OK);
2779 2779
(...skipping 2393 matching lines...) Expand 10 before | Expand all | Expand 10 after
5173 parser.ParseLazy(script_source, name, 5173 parser.ParseLazy(script_source, name,
5174 start_position, end_position, is_expression); 5174 start_position, end_position, is_expression);
5175 return result; 5175 return result;
5176 } 5176 }
5177 5177
5178 5178
5179 #undef NEW 5179 #undef NEW
5180 5180
5181 5181
5182 } } // namespace v8::internal 5182 } } // namespace v8::internal
OLDNEW
« src/ia32/codegen-ia32.cc ('K') | « src/ia32/codegen-ia32.cc ('k') | src/x64/codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698