Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 import "package:expect/expect.dart"; | |
| 6 | |
| 7 class Foo { | |
| 8 var field = 0; | |
| 9 } | |
| 10 | |
| 11 bar(x,y) { | |
| 12 return x * 100 + y; | |
| 13 } | |
| 14 | |
| 15 foo(z) { | |
| 16 var x = 0, y = x; | |
| 17 if (z > 0) { | |
| 18 x = 10; | |
| 19 } | |
| 20 if (z > 10) { | |
| 21 y = 20; | |
| 22 } | |
| 23 return bar(x,y); | |
|
asgerf
2014/06/03 14:37:17
Without register allocation, this reference to 'y'
sigurdm
2014/06/04 07:51:57
This could maybe be a comment in the code for late
| |
| 24 } | |
| 25 | |
| 26 baz(z) { | |
| 27 var f = new Foo() | |
| 28 ..field = 10 | |
| 29 ..field = z; | |
| 30 return f; | |
| 31 } | |
| 32 | |
| 33 main() { | |
| 34 Expect.equals(0, foo(0)); | |
| 35 Expect.equals(1000, foo(5)); | |
| 36 Expect.equals(1020, foo(15)); | |
| 37 | |
| 38 Expect.equals(20, baz(20).field); | |
| 39 Expect.equals(30, baz(30).field); | |
| 40 } | |
| OLD | NEW |