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 library _js_helper; | 5 library _js_helper; |
6 | 6 |
7 import 'dart:collection'; | 7 import 'dart:collection'; |
8 | 8 |
9 part 'constant_map.dart'; | 9 part 'constant_map.dart'; |
10 part 'native_helper.dart'; | 10 part 'native_helper.dart'; |
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
528 if ((length is !int) || (length < 0)) { | 528 if ((length is !int) || (length < 0)) { |
529 throw new ArgumentError(length); | 529 throw new ArgumentError(length); |
530 } | 530 } |
531 var result = JS('=List', r'new Array(#)', length); | 531 var result = JS('=List', r'new Array(#)', length); |
532 JS('void', r'#.fixed$length = #', result, true); | 532 JS('void', r'#.fixed$length = #', result, true); |
533 return result; | 533 return result; |
534 } | 534 } |
535 | 535 |
536 static num dateNow() => JS('num', r'Date.now()'); | 536 static num dateNow() => JS('num', r'Date.now()'); |
537 | 537 |
538 static num numMicroseconds() { | |
539 if (JS('bool', 'typeof window != "undefined" && window !== null')) { | |
540 var performance = JS('var', 'window.performance'); | |
541 if (performance != null && | |
542 JS('bool', 'typeof #.webkitNow == "function"', performance)) { | |
543 return (1000 * JS('num', '#.webkitNow()', performance)).floor(); | |
Emily Fortuna
2012/11/26 23:31:31
This is the line that's different. The key thing I
| |
544 } | |
545 } | |
546 return 1000 * dateNow(); | |
547 } | |
548 | |
538 // This is to avoid stack overflows due to very large argument arrays in | 549 // This is to avoid stack overflows due to very large argument arrays in |
539 // apply(). It fixes http://dartbug.com/6919 | 550 // apply(). It fixes http://dartbug.com/6919 |
540 static String _fromCharCodeApply(List<int> array) { | 551 static String _fromCharCodeApply(List<int> array) { |
541 String result = ""; | 552 String result = ""; |
542 const kMaxApply = 500; | 553 const kMaxApply = 500; |
543 int end = array.length; | 554 int end = array.length; |
544 for (var i = 0; i < end; i += kMaxApply) { | 555 for (var i = 0; i < end; i += kMaxApply) { |
545 var subarray; | 556 var subarray; |
546 if (end <= kMaxApply) { | 557 if (end <= kMaxApply) { |
547 subarray = array; | 558 subarray = array; |
(...skipping 1044 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1592 var argument = typeInfo[i]; | 1603 var argument = typeInfo[i]; |
1593 if (argument == null) { | 1604 if (argument == null) { |
1594 argument = 'dynamic'; | 1605 argument = 'dynamic'; |
1595 } | 1606 } |
1596 arguments.add(argument); | 1607 arguments.add(argument); |
1597 } | 1608 } |
1598 return '$className<$arguments>'; | 1609 return '$className<$arguments>'; |
1599 } | 1610 } |
1600 | 1611 |
1601 createRuntimeType(String name) => new TypeImpl(name); | 1612 createRuntimeType(String name) => new TypeImpl(name); |
OLD | NEW |