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

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

Issue 9359039: Source in most stuff. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: rebased 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 | « dart/frog/leg/frog_leg.dart ('k') | 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
11 #source('../../../corelib/src/bool.dart');
12 #source('../../../corelib/src/collection.dart');
13 #source('../../../corelib/src/comparable.dart');
14 #source('../../../corelib/src/date.dart');
15 #source('../../../corelib/src/double.dart');
16 #source('../../../corelib/src/duration.dart');
17 // #source('../../../corelib/src/exceptions.dart');
18 // #source('../../../corelib/src/expect.dart');
19 #source('../../../corelib/src/function.dart');
20 #source('../../../corelib/src/future.dart');
21 #source('../../../corelib/src/hashable.dart');
22 #source('../../../corelib/src/int.dart');
23 #source('../../../corelib/src/isolate.dart');
24 #source('../../../corelib/src/iterable.dart');
25 #source('../../../corelib/src/iterator.dart');
26 // #source('../../../corelib/src/list.dart');
27 #source('../../../corelib/src/map.dart');
28 #source('../../../corelib/src/math.dart');
29 #source('../../../corelib/src/num.dart');
30 #source('../../../corelib/src/options.dart');
31 #source('../../../corelib/src/pattern.dart');
32 #source('../../../corelib/src/promise.dart');
33 #source('../../../corelib/src/queue.dart');
34 #source('../../../corelib/src/regexp.dart');
35 #source('../../../corelib/src/set.dart');
36 // #source('../../../corelib/src/stopwatch.dart');
37 #source('../../../corelib/src/string.dart');
38 #source('../../../corelib/src/string_buffer.dart');
39 #source('../../../corelib/src/strings.dart');
40 #source('../../../corelib/src/time_zone.dart');
41
11 void print(var obj) { 42 void print(var obj) {
12 obj = obj.toString(); 43 obj = obj.toString();
13 var hasConsole = JS("bool", @"typeof console == 'object'"); 44 var hasConsole = JS("bool", @"typeof console == 'object'");
14 if (hasConsole) { 45 if (hasConsole) {
15 JS("void", @"console.log($0)", obj); 46 JS("void", @"console.log($0)", obj);
16 } else { 47 } else {
17 JS("void", @"write($0)", obj); 48 JS("void", @"write($0)", obj);
18 JS("void", @"write('\n')"); 49 JS("void", @"write('\n')");
19 } 50 }
20 } 51 }
21 52
22 /* Include when interfaces are implemented
23 interface Iterable<T> {
24 Iterator<T> iterator();
25 }
26
27 interface Iterator<T> {
28 bool hasNext();
29 T next();
30 }
31 */
32 class int {}
33 class double {}
34 class String {}
35 class bool {}
36 class num {}
37 class Object { 53 class Object {
38 String toString() { 54 String toString() {
39 String name = JS('String', @'this.constructor.name'); 55 String name = JS('String', @'this.constructor.name');
40 if (name === null) { 56 if (name === null) {
41 name = JS('String', @'$0.match(/^\s*function\s*(\S*)\s*\(/)[1]', 57 name = JS('String', @'$0.match(/^\s*function\s*(\S*)\s*\(/)[1]',
42 JS('String', @'this.constructor.toString()')); 58 JS('String', @'this.constructor.toString()'));
43 } 59 }
44 return "Instance of '$name'"; 60 return "Instance of '$name'";
45 } 61 }
46 62
47 void noSuchMethod(String name, List args) { 63 void noSuchMethod(String name, List args) {
48 throw new NoSuchMethodException(this, name, args); 64 throw new NoSuchMethodException(this, name, args);
49 } 65 }
50 } 66 }
51 67
52 class NoSuchMethodException { 68 class NoSuchMethodException {
53 Object receiver; 69 Object receiver;
54 String name; 70 String name;
55 List args; 71 List args;
56 NoSuchMethodException(Object this.receiver, String this.name, List this.args); 72 NoSuchMethodException(Object this.receiver, String this.name, List this.args);
57 String toString() { 73 String toString() {
58 return "NoSuchMethodException - receiver: '$receiver'" + 74 return "NoSuchMethodException - receiver: '$receiver'" +
59 "function name: '$name' arguments: [$args]"; 75 "function name: '$name' arguments: [$args]";
60 } 76 }
61 } 77 }
62 78
63 class List<T> /* implements Iterable<T> */ { 79 class List<T> implements Iterable<T> {
64 80
65 factory List([int length]) { 81 factory List([int length]) {
66 if (length == null) return JS("Object", @"new Array()"); 82 if (length == null) return JS("Object", @"new Array()");
67 if (!(length is int)) throw "Invalid argument"; 83 if (!(length is int)) throw "Invalid argument";
68 if (length < 0) throw "Negative size"; 84 if (length < 0) throw "Negative size";
69 return JS("Object", @"new Array($0)", length); 85 return JS("Object", @"new Array($0)", length);
70 } 86 }
71 } 87 }
72 88
73 class ListIterator<T> /* implements Iterator<T> */ { 89 class ListIterator<T> implements Iterator<T> {
74 int i; 90 int i;
75 List<T> list; 91 List<T> list;
76 ListIterator(List<T> this.list) : i = 0; 92 ListIterator(List<T> this.list) : i = 0;
77 bool hasNext() => i < JS("int", @"$0.length", list); 93 bool hasNext() => i < JS("int", @"$0.length", list);
78 T next() { 94 T next() {
79 var value = JS("Object", @"$0[$1]", list, i); 95 var value = JS("Object", @"$0[$1]", list, i);
80 i += 1; 96 i += 1;
81 return value; 97 return value;
82 } 98 }
83 } 99 }
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 } else { 179 } else {
164 return 180 return
165 JS("num", @"Math.floor($0 + (Date.now() - $1))", elapsedMs, startMs); 181 JS("num", @"Math.floor($0 + (Date.now() - $1))", elapsedMs, startMs);
166 } 182 }
167 } 183 }
168 184
169 int frequency() { 185 int frequency() {
170 return 1000; 186 return 1000;
171 } 187 }
172 } 188 }
OLDNEW
« no previous file with comments | « dart/frog/leg/frog_leg.dart ('k') | dart/frog/leg/lib/coreimpl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698