| OLD | NEW |
| (Empty) | |
| 1 // Expectation for test: |
| 2 // foo(x, list) { |
| 3 // var sum = 0; |
| 4 // for (int k = 0; k < 10; k++) { |
| 5 // // Everything can be hoisted out up to the index access which is |
| 6 // // blocked by the bounds check. |
| 7 // var a = x.left.left; |
| 8 // var b = x.left.right; |
| 9 // var c = x.right.left; |
| 10 // var d = x.right.right; |
| 11 // var i = a.value + c.value; |
| 12 // var j = b.value + d.value; |
| 13 // var z = list[i * j] + i; |
| 14 // sum += z; |
| 15 // } |
| 16 // return sum; |
| 17 // } |
| 18 // // Use a different class for each level in the tree, so type inference |
| 19 // // is not confused. |
| 20 // class Root { |
| 21 // Branch left, right; |
| 22 // Root(this.left, this.right); |
| 23 // } |
| 24 // class Branch { |
| 25 // Leaf left, right; |
| 26 // Branch(this.left, this.right); |
| 27 // } |
| 28 // class Leaf { |
| 29 // int value; |
| 30 // Leaf(this.value); |
| 31 // } |
| 32 // main() { |
| 33 // var x1 = new Leaf(1); |
| 34 // var x2 = new Leaf(10); |
| 35 // var x3 = new Leaf(20); |
| 36 // var x4 = new Leaf(-10); |
| 37 // var y1 = new Branch(x1, x2); |
| 38 // var y2 = new Branch(x3, x4); |
| 39 // var z = new Root(y1, y2); |
| 40 // print(foo(z, [1,2,3,4,5,6,7,8,9,10])); |
| 41 // } |
| 42 |
| 43 function() { |
| 44 var v0 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], i = 1 + 20, v1 = i * (10 + -10), sum
= 0, k = 0, line; |
| 45 for (; k < 10; sum += i + v0[v1], ++k) |
| 46 if (v1 < 0 || v1 >= 10) |
| 47 return H.ioore(v0, v1); |
| 48 line = sum === 0 ? 1 / sum < 0 ? "-0.0" : "" + sum : "" + sum; |
| 49 if (typeof dartPrint == "function") |
| 50 dartPrint(line); |
| 51 else if (typeof console == "object" && typeof console.log != "undefined") |
| 52 console.log(line); |
| 53 else if (!(typeof window == "object")) { |
| 54 if (!(typeof print == "function")) |
| 55 throw "Unable to print message: " + String(line); |
| 56 print(line); |
| 57 } |
| 58 } |
| OLD | NEW |