Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(239)

Side by Side Diff: dart/frog/leg/lib/core.dart

Issue 9420001: Various mocks and tweaks to reduce cancels in Leg. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | dart/frog/leg/lib/coreimpl.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #library('core'); 5 #library('core');
6 6
7 #import('coreimpl.dart'); 7 #import('coreimpl.dart');
8 8
9 #import('js_helper.dart'); // TODO(ahe): remove this import. 9 #import('js_helper.dart'); // TODO(ahe): remove this import.
10 10
(...skipping 20 matching lines...) Expand all
31 #source('../../../corelib/src/pattern.dart'); 31 #source('../../../corelib/src/pattern.dart');
32 #source('../../../corelib/src/promise.dart'); 32 #source('../../../corelib/src/promise.dart');
33 #source('../../../corelib/src/queue.dart'); 33 #source('../../../corelib/src/queue.dart');
34 #source('../../../corelib/src/regexp.dart'); 34 #source('../../../corelib/src/regexp.dart');
35 #source('../../../corelib/src/set.dart'); 35 #source('../../../corelib/src/set.dart');
36 // #source('../../../corelib/src/stopwatch.dart'); 36 // #source('../../../corelib/src/stopwatch.dart');
37 #source('../../../corelib/src/string.dart'); 37 #source('../../../corelib/src/string.dart');
38 #source('../../../corelib/src/string_buffer.dart'); 38 #source('../../../corelib/src/string_buffer.dart');
39 #source('../../../corelib/src/strings.dart'); 39 #source('../../../corelib/src/strings.dart');
40 #source('../../../corelib/src/time_zone.dart'); 40 #source('../../../corelib/src/time_zone.dart');
41 #source('mock.dart');
41 42
42 void print(var obj) => Primitives.printString(obj.toString()); 43 void print(var obj) => Primitives.printString(obj.toString());
43 44
44 class Object { 45 class Object {
45 String toString() => Primitives.objectToString(this); 46 String toString() => Primitives.objectToString(this);
46 47
47 void noSuchMethod(String name, List args) { 48 void noSuchMethod(String name, List args) {
48 throw new NoSuchMethodException(this, name, args); 49 throw new NoSuchMethodException(this, name, args);
49 } 50 }
50 } 51 }
51
52 class NoSuchMethodException {
53 Object receiver;
54 String name;
55 List args;
56 NoSuchMethodException(Object this.receiver, String this.name, List this.args);
57 String toString() {
58 return "NoSuchMethodException - receiver: '$receiver'" +
59 "function name: '$name' arguments: [$args]";
60 }
61 }
62
63 class List<T> implements Iterable<T> {
64 factory List([int length]) => Primitives.newList(length);
65 }
66
67 interface Exception {}
68
69 class Stopwatch {
70 double startMs;
71 double elapsedMs;
72
73 Stopwatch() {
74 elapsedMs = 0.0;
75 }
76
77 void start() {
78 if (startMs == null) {
79 startMs = Primitives.dateNow();
80 }
81 }
82
83 void stop() {
84 if (startMs == null) return;
85 elapsedMs += Primitives.dateNow() - startMs;
86 startMs = null;
87 }
88
89 void reset() {
90 elapsedMs = 0.0;
91 if (startMs == null) return;
92 startMs = Primitives.dateNow();
93 }
94
95 int elapsed() {
96 return elapsedInMs();
97 }
98
99 int elapsedInUs() {
100 return elapsedInMs() * 1000;
101 }
102
103 int elapsedInMs() {
104 if (startMs == null) {
105 return Primitives.mathFloor(elapsedMs);
106 } else {
107 return Primitives.mathFloor(elapsedMs + (Primitives.dateNow() - startMs));
108 }
109 }
110
111 int frequency() {
112 return 1000;
113 }
114 }
OLDNEW
« no previous file with comments | « no previous file | dart/frog/leg/lib/coreimpl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698