OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/ast_transformer.h" | 5 #include "vm/ast_transformer.h" |
6 | 6 |
7 #include "vm/object_store.h" | 7 #include "vm/object_store.h" |
8 #include "vm/parser.h" | 8 #include "vm/parser.h" |
9 #include "vm/thread.h" | 9 #include "vm/thread.h" |
10 | 10 |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 preamble_->Add(new (Z) IfNode( | 226 preamble_->Add(new (Z) IfNode( |
227 token_pos, new (Z) ComparisonNode( | 227 token_pos, new (Z) ComparisonNode( |
228 token_pos, Token::kNE, load_error_param, | 228 token_pos, Token::kNE, load_error_param, |
229 new (Z) LiteralNode(token_pos, Object::null_instance())), | 229 new (Z) LiteralNode(token_pos, Object::null_instance())), |
230 error_ne_null_branch, NULL)); | 230 error_ne_null_branch, NULL)); |
231 | 231 |
232 result_ = MakeName(new (Z) LoadLocalNode(token_pos, result_param)); | 232 result_ = MakeName(new (Z) LoadLocalNode(token_pos, result_param)); |
233 } | 233 } |
234 | 234 |
235 | 235 |
236 // Transforms boolean expressions into a sequence of evaluatons that only lazily | 236 // Transforms boolean expressions into a sequence of evaluations that only |
237 // evaluate subexpressions. | 237 // lazily evaluate subexpressions. |
238 // | 238 // |
239 // Example: | 239 // Example: |
240 // | 240 // |
241 // (a || b) only evaluates b if a is false | 241 // (a || b) only evaluates b if a is false |
242 // | 242 // |
243 // Transformation (roughly): | 243 // Transformation (roughly): |
244 // | 244 // |
245 // t_1 = a; | 245 // t_1 = a; |
246 // if (!t_1) { | 246 // if (!t_1) { |
247 // t_2 = b; | 247 // t_2 = b; |
(...skipping 26 matching lines...) Expand all Loading... |
274 | 274 |
275 LocalScope* AwaitTransformer::ChainNewScope(LocalScope* parent) { | 275 LocalScope* AwaitTransformer::ChainNewScope(LocalScope* parent) { |
276 return new (Z) | 276 return new (Z) |
277 LocalScope(parent, parent->function_level(), parent->loop_level()); | 277 LocalScope(parent, parent->function_level(), parent->loop_level()); |
278 } | 278 } |
279 | 279 |
280 | 280 |
281 void AwaitTransformer::VisitBinaryOpNode(BinaryOpNode* node) { | 281 void AwaitTransformer::VisitBinaryOpNode(BinaryOpNode* node) { |
282 AstNode* new_left = Transform(node->left()); | 282 AstNode* new_left = Transform(node->left()); |
283 AstNode* new_right = NULL; | 283 AstNode* new_right = NULL; |
284 // Preserve lazy evaluaton. | 284 // Preserve lazy evaluation. |
285 if ((node->kind() == Token::kAND) || (node->kind() == Token::kOR)) { | 285 if ((node->kind() == Token::kAND) || (node->kind() == Token::kOR)) { |
286 new_right = LazyTransform(node->kind(), new_left, node->right()); | 286 new_right = LazyTransform(node->kind(), new_left, node->right()); |
287 } else { | 287 } else { |
288 new_right = Transform(node->right()); | 288 new_right = Transform(node->right()); |
289 } | 289 } |
290 result_ = MakeName(new (Z) BinaryOpNode(node->token_pos(), node->kind(), | 290 result_ = MakeName(new (Z) BinaryOpNode(node->token_pos(), node->kind(), |
291 new_left, new_right)); | 291 new_left, new_right)); |
292 } | 292 } |
293 | 293 |
294 | 294 |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
521 } | 521 } |
522 | 522 |
523 | 523 |
524 void AwaitTransformer::VisitThrowNode(ThrowNode* node) { | 524 void AwaitTransformer::VisitThrowNode(ThrowNode* node) { |
525 AstNode* new_exception = Transform(node->exception()); | 525 AstNode* new_exception = Transform(node->exception()); |
526 result_ = MakeName( | 526 result_ = MakeName( |
527 new (Z) ThrowNode(node->token_pos(), new_exception, node->stacktrace())); | 527 new (Z) ThrowNode(node->token_pos(), new_exception, node->stacktrace())); |
528 } | 528 } |
529 | 529 |
530 } // namespace dart | 530 } // namespace dart |
OLD | NEW |