Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 // Adds Dart-methods to the prototype of the JS Boolean function. | 5 // Adds Dart-methods to the prototype of the JS Boolean function. |
| 6 // TODO(floitsch): the following comment needs to be updated once we compile | 6 // TODO(floitsch): the following comment needs to be updated once we compile |
| 7 // boolean checks with '=== true'. | 7 // boolean checks with '=== true'. |
| 8 // WARNING: 'this' inside this class is always treated as 'true'. | 8 // WARNING: 'this' inside this class is always treated as 'true'. |
| 9 // That is if (this) ... will always pick the 'then' branch. | 9 // That is if (this) ... will always pick the 'then' branch. |
| 10 // The reason is that, once compiled to JS, 'this' is represented by a | 10 // The reason is that, once compiled to JS, 'this' is represented by a |
| 11 // JS Boolean object. However "if (new Boolean(false)) .." picks the then | 11 // JS Boolean object. However "if (new Boolean(false)) .." picks the then |
| 12 // branch. | 12 // branch. |
| 13 class BoolImplementation implements bool native "Boolean" { | 13 class BoolImplementation implements bool native "Boolean" { |
| 14 bool operator ==(other) native; | 14 bool operator ==(other) native; |
| 15 | 15 |
| 16 // TODO(floitsch): we should intercept toString for primitives, to avoid | 16 // TODO(floitsch): we should intercept toString for primitives, to avoid |
| 17 // creating a wrapper object. | 17 // creating a wrapper object. |
| 18 String toString() native; | 18 String toString() native; |
| 19 | |
| 20 BoolImplementation toBool() native; | |
| 21 | |
| 22 get dynamic() { return toBool(); } | |
|
floitsch
2011/10/14 20:20:44
good catch.
| |
| 19 } | 23 } |
| OLD | NEW |