| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 // Mocks of things that Leg cannot read directly. | 5 // Mocks of things that Leg cannot read directly. |
| 6 | 6 |
| 7 // TODO(ahe): Remove this file. | 7 // TODO(ahe): Remove this file. |
| 8 | 8 |
| 9 class AssertionError {} | 9 class AssertionError {} |
| 10 class TypeError extends AssertionError {} | 10 class TypeError extends AssertionError {} |
| 11 class FallThroughError {} | 11 class FallThroughError {} |
| 12 | 12 |
| 13 // TODO(ahe): VM specfic exception? | 13 // TODO(ahe): VM specfic exception? |
| 14 class InternalError {} | 14 class InternalError {} |
| 15 | 15 |
| 16 // TODO(ahe): VM specfic exception? | 16 // TODO(ahe): VM specfic exception? |
| 17 class StaticResolutionException implements Exception {} | 17 class StaticResolutionException implements Exception {} |
| 18 | 18 |
| 19 class List<E> implements Iterable<E> { | 19 class List<E> implements Iterable<E> { |
| 20 factory List([int length]) => Primitives.newList(length); | 20 factory List([int length]) => Primitives.newList(length); |
| 21 factory List.from(Iterable<E> other) { | 21 factory List.from(Iterable<E> other) { |
| 22 throw 'List.from is not implemented'; | 22 throw 'List.from is not implemented'; |
| 23 } | 23 } |
| 24 } | 24 } |
| 25 | 25 |
| 26 class Stopwatch { | |
| 27 double startMs; | |
| 28 double elapsedMs; | |
| 29 | |
| 30 Stopwatch() { | |
| 31 elapsedMs = 0.0; | |
| 32 } | |
| 33 | |
| 34 void start() { | |
| 35 if (startMs == null) { | |
| 36 startMs = Primitives.dateNow(); | |
| 37 } | |
| 38 } | |
| 39 | |
| 40 void stop() { | |
| 41 if (startMs == null) return; | |
| 42 elapsedMs += Primitives.dateNow() - startMs; | |
| 43 startMs = null; | |
| 44 } | |
| 45 | |
| 46 void reset() { | |
| 47 elapsedMs = 0.0; | |
| 48 if (startMs == null) return; | |
| 49 startMs = Primitives.dateNow(); | |
| 50 } | |
| 51 | |
| 52 int elapsed() { | |
| 53 return elapsedInMs(); | |
| 54 } | |
| 55 | |
| 56 int elapsedInUs() { | |
| 57 return elapsedInMs() * 1000; | |
| 58 } | |
| 59 | |
| 60 int elapsedInMs() { | |
| 61 if (startMs == null) { | |
| 62 return Primitives.mathFloor(elapsedMs); | |
| 63 } else { | |
| 64 return Primitives.mathFloor(elapsedMs + (Primitives.dateNow() - startMs)); | |
| 65 } | |
| 66 } | |
| 67 | |
| 68 int frequency() { | |
| 69 return 1000; | |
| 70 } | |
| 71 } | |
| 72 | |
| 73 void assert(condition) {} | 26 void assert(condition) {} |
| OLD | NEW |