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 void print(var obj) { | 5 void print(var obj) { |
| 6 // TODO(ngeoffray): enable when the parser accepts it. | 6 // TODO(ngeoffray): enable when the parser accepts it. |
| 7 // obj = obj.toString(); | 7 // obj = obj.toString(); |
| 8 var hasConsole = JS("bool", @"typeof console == 'object'"); | 8 var hasConsole = JS("bool", @"typeof console == 'object'"); |
| 9 if (hasConsole) { | 9 if (hasConsole) { |
| 10 JS("void", @"console.log($0)", obj); | 10 JS("void", @"console.log($0)", obj); |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 113 JS("bool", @"typeof $0 === 'number'", a) || | 113 JS("bool", @"typeof $0 === 'number'", a) || |
| 114 JS("bool", @"typeof $0 === 'boolean'", a) || | 114 JS("bool", @"typeof $0 === 'boolean'", a) || |
| 115 JS("bool", @"typeof $0 === 'string'", a)) { | 115 JS("bool", @"typeof $0 === 'string'", a)) { |
| 116 return JS("bool", @"$0 === $1", a, b); | 116 return JS("bool", @"$0 === $1", a, b); |
| 117 } | 117 } |
| 118 // TODO(kasperl): This is not the right implementation if the a has | 118 // TODO(kasperl): This is not the right implementation if the a has |
| 119 // a user-defined == operator. | 119 // a user-defined == operator. |
| 120 return JS("bool", @"$0 === $1", a, b); | 120 return JS("bool", @"$0 === $1", a, b); |
| 121 } | 121 } |
| 122 | 122 |
| 123 eqq(var a, var b) { | |
|
ngeoffray
2012/01/06 08:10:20
Why this method if HIdentity always ends up being
| |
| 124 return JS("bool", @"$0 === $1", a, b); | |
| 125 } | |
| 126 | |
| 123 gt(var a, var b) { | 127 gt(var a, var b) { |
| 124 if (checkNumbers(a, b, "num> expects a number as second operand.")) { | 128 if (checkNumbers(a, b, "num> expects a number as second operand.")) { |
| 125 return JS("bool", @"$0 > $1", a, b); | 129 return JS("bool", @"$0 > $1", a, b); |
| 126 } | 130 } |
| 127 throw "Unimplemented user-defined binary >."; | 131 throw "Unimplemented user-defined binary >."; |
| 128 } | 132 } |
| 129 | 133 |
| 130 ge(var a, var b) { | 134 ge(var a, var b) { |
| 131 if (checkNumbers(a, b, "num>= expects a number as second operand.")) { | 135 if (checkNumbers(a, b, "num>= expects a number as second operand.")) { |
| 132 return JS("bool", @"$0 >= $1", a, b); | 136 return JS("bool", @"$0 >= $1", a, b); |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 328 } else { | 332 } else { |
| 329 return | 333 return |
| 330 JS("num", @"Math.floor($0 + (Date.now() - $1))", elapsedMs, startMs); | 334 JS("num", @"Math.floor($0 + (Date.now() - $1))", elapsedMs, startMs); |
| 331 } | 335 } |
| 332 } | 336 } |
| 333 | 337 |
| 334 int frequency() { | 338 int frequency() { |
| 335 return 1000; | 339 return 1000; |
| 336 } | 340 } |
| 337 } | 341 } |
| OLD | NEW |