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

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

Issue 9027002: Support factory methods. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years 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
OLDNEW
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(@"typeof console == 'object'"); 8 var hasConsole = JS(@"typeof console == 'object'");
9 if (hasConsole) { 9 if (hasConsole) {
10 JS(@"console.log($0)", obj); 10 JS(@"console.log($0)", obj);
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 return JS(@"$0.length", receiver); 238 return JS(@"$0.length", receiver);
239 } 239 }
240 throw "Unimplemented user-defined length."; 240 throw "Unimplemented user-defined length.";
241 } 241 }
242 242
243 class int {} 243 class int {}
244 class double {} 244 class double {}
245 class String {} 245 class String {}
246 class bool {} 246 class bool {}
247 class Object {} 247 class Object {}
248 class List<T> {} 248 class List<T> {
249 factory List(int n) {
250 return JS(@"new Array($0)", n);
kasperl 2011/12/22 11:34:42 Should we be checking that i is an int here (at le
ngeoffray 2011/12/22 13:07:02 Done.
251 }
252 }
249 253
250 class Stopwatch { 254 class Stopwatch {
251 double startMs; 255 double startMs;
252 double elapsedMs; 256 double elapsedMs;
253 257
254 Stopwatch() { 258 Stopwatch() {
255 elapsedMs = 0.0; 259 elapsedMs = 0.0;
256 } 260 }
257 261
258 void start() { 262 void start() {
(...skipping 27 matching lines...) Expand all
286 return JS(@"Math.floor($0)", elapsedMs); 290 return JS(@"Math.floor($0)", elapsedMs);
287 } else { 291 } else {
288 return JS(@"Math.floor($0 + (Date.now() - $1))", elapsedMs, startMs); 292 return JS(@"Math.floor($0 + (Date.now() - $1))", elapsedMs, startMs);
289 } 293 }
290 } 294 }
291 295
292 int frequency() { 296 int frequency() {
293 return 1000; 297 return 1000;
294 } 298 }
295 } 299 }
OLDNEW
« no previous file with comments | « frog/leg/emitter.dart ('k') | frog/leg/namer.dart » ('j') | frog/leg/resolver.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698