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 part of tree_ir.optimization; | 5 part of tree_ir.optimization; |
6 | 6 |
7 /** | 7 /** |
8 * Performs the following transformations on the tree: | 8 * Performs the following transformations on the tree: |
9 * - Assignment propagation | 9 * - Assignment propagation |
10 * - If-to-conditional conversion | 10 * - If-to-conditional conversion |
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 // the expression statement. If they can occur here they should be | 400 // the expression statement. If they can occur here they should be |
401 // handled well. | 401 // handled well. |
402 List<Assign> savedEnvironment = environment; | 402 List<Assign> savedEnvironment = environment; |
403 environment = <Assign>[]; | 403 environment = <Assign>[]; |
404 node.next = visitStatement(node.next); | 404 node.next = visitStatement(node.next); |
405 assert(environment.isEmpty); | 405 assert(environment.isEmpty); |
406 environment = savedEnvironment; | 406 environment = savedEnvironment; |
407 return node; | 407 return node; |
408 } | 408 } |
409 | 409 |
| 410 Statement visitSetField(SetField node) { |
| 411 node.next = visitStatement(node.next); |
| 412 node.object = visitExpression(node.object); |
| 413 node.value = visitExpression(node.value); |
| 414 return node; |
| 415 } |
| 416 |
| 417 Expression visitGetField(GetField node) { |
| 418 node.object = visitExpression(node.object); |
| 419 return node; |
| 420 } |
| 421 |
| 422 Expression visitCreateBox(CreateBox node) { |
| 423 return node; |
| 424 } |
| 425 |
| 426 Expression visitCreateClosureClass(CreateClosureClass node) { |
| 427 for (int i = node.arguments.length - 1; i >= 0; --i) { |
| 428 node.arguments[i] = visitExpression(node.arguments[i]); |
| 429 } |
| 430 return node; |
| 431 } |
| 432 |
410 /// If [s] and [t] are similar statements we extract their subexpressions | 433 /// If [s] and [t] are similar statements we extract their subexpressions |
411 /// and returns a new statement of the same type using expressions combined | 434 /// and returns a new statement of the same type using expressions combined |
412 /// with the [combine] callback. For example: | 435 /// with the [combine] callback. For example: |
413 /// | 436 /// |
414 /// combineStatements(Return E1, Return E2) = Return combine(E1, E2) | 437 /// combineStatements(Return E1, Return E2) = Return combine(E1, E2) |
415 /// | 438 /// |
416 /// If [combine] returns E1 then the unified statement is equivalent to [s], | 439 /// If [combine] returns E1 then the unified statement is equivalent to [s], |
417 /// and if [combine] returns E2 the unified statement is equivalence to [t]. | 440 /// and if [combine] returns E2 the unified statement is equivalence to [t]. |
418 /// | 441 /// |
419 /// It is guaranteed that no side effects occur between the beginning of the | 442 /// It is guaranteed that no side effects occur between the beginning of the |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
566 } | 589 } |
567 | 590 |
568 Expression makeCondition(Expression e, bool polarity) { | 591 Expression makeCondition(Expression e, bool polarity) { |
569 return polarity ? e : new Not(e); | 592 return polarity ? e : new Not(e); |
570 } | 593 } |
571 | 594 |
572 Statement getBranch(If node, bool polarity) { | 595 Statement getBranch(If node, bool polarity) { |
573 return polarity ? node.thenStatement : node.elseStatement; | 596 return polarity ? node.thenStatement : node.elseStatement; |
574 } | 597 } |
575 } | 598 } |
OLD | NEW |