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

Side by Side Diff: src/rewriter.cc

Issue 9969146: Fix rewriter to not treat throw as an expression. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 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 | « no previous file | test/mjsunit/regress/regress-2054.js » ('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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 // a variable declaration with initialization expression is 'undefined' 104 // a variable declaration with initialization expression is 'undefined'
105 // with some JS VMs: For instance, using smjs, print(eval('var x = 7')) 105 // with some JS VMs: For instance, using smjs, print(eval('var x = 7'))
106 // returns 'undefined'. To obtain the same behavior with v8, we need 106 // returns 'undefined'. To obtain the same behavior with v8, we need
107 // to prevent rewriting in that case. 107 // to prevent rewriting in that case.
108 if (!node->is_initializer_block()) Process(node->statements()); 108 if (!node->is_initializer_block()) Process(node->statements());
109 } 109 }
110 110
111 111
112 void Processor::VisitExpressionStatement(ExpressionStatement* node) { 112 void Processor::VisitExpressionStatement(ExpressionStatement* node) {
113 // Rewrite : <x>; -> .result = <x>; 113 // Rewrite : <x>; -> .result = <x>;
114 if (!is_set_) { 114 if (!is_set_ && !node->expression()->IsThrow()) {
115 node->set_expression(SetResult(node->expression())); 115 node->set_expression(SetResult(node->expression()));
116 if (!in_try_) is_set_ = true; 116 if (!in_try_) is_set_ = true;
117 } 117 }
118 } 118 }
119 119
120 120
121 void Processor::VisitIfStatement(IfStatement* node) { 121 void Processor::VisitIfStatement(IfStatement* node) {
122 // Rewrite both then and else parts (reversed). 122 // Rewrite both then and else parts (reversed).
123 bool save = is_set_; 123 bool save = is_set_;
124 Visit(node->else_statement()); 124 Visit(node->else_statement());
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 result_statement->set_statement_pos(position); 264 result_statement->set_statement_pos(position);
265 body->Add(result_statement); 265 body->Add(result_statement);
266 } 266 }
267 } 267 }
268 268
269 return true; 269 return true;
270 } 270 }
271 271
272 272
273 } } // namespace v8::internal 273 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-2054.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698