OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 dart._js_helper; | 5 library dart._js_helper; |
6 | 6 |
7 import 'dart:collection'; | 7 import 'dart:collection'; |
8 | 8 |
9 import 'dart:_foreign_helper' show | 9 import 'dart:_foreign_helper' show |
10 JS, | 10 JS, |
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
587 int index = 0; | 587 int index = 0; |
588 int length = getLength(keyValuePairs); | 588 int length = getLength(keyValuePairs); |
589 while (index < length) { | 589 while (index < length) { |
590 var key = getIndex(keyValuePairs, index++); | 590 var key = getIndex(keyValuePairs, index++); |
591 var value = getIndex(keyValuePairs, index++); | 591 var value = getIndex(keyValuePairs, index++); |
592 result[key] = value; | 592 result[key] = value; |
593 } | 593 } |
594 return result; | 594 return result; |
595 } | 595 } |
596 | 596 |
597 /** | |
598 * Called by generated code to convert a Dart closure to a JS | |
599 * closure when the Dart closure is passed to the DOM. | |
600 */ | |
601 convertDartClosureToJS(closure, int arity) { | |
602 // TODO(vsm): Dart2JS wraps closures to: | |
603 // (a) adjust the calling convention, and | |
604 // (b) record the source isolate | |
605 // Do we need either? | |
606 // See: https://github.com/dart-lang/dev_compiler/issues/164 | |
607 return closure; | |
608 } | |
609 | |
610 bool jsHasOwnProperty(var jsObject, String property) { | 597 bool jsHasOwnProperty(var jsObject, String property) { |
611 return JS('bool', r'#.hasOwnProperty(#)', jsObject, property); | 598 return JS('bool', r'#.hasOwnProperty(#)', jsObject, property); |
612 } | 599 } |
613 | 600 |
614 jsPropertyAccess(var jsObject, String property) { | 601 jsPropertyAccess(var jsObject, String property) { |
615 return JS('var', r'#[#]', jsObject, property); | 602 return JS('var', r'#[#]', jsObject, property); |
616 } | 603 } |
617 | 604 |
618 /** | 605 /** |
619 * Called at the end of unaborted switch cases to get the singleton | 606 * Called at the end of unaborted switch cases to get the singleton |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
769 int random64() { | 756 int random64() { |
770 // TODO(lrn): Use a secure random source. | 757 // TODO(lrn): Use a secure random source. |
771 int int32a = JS("int", "(Math.random() * 0x100000000) >>> 0"); | 758 int int32a = JS("int", "(Math.random() * 0x100000000) >>> 0"); |
772 int int32b = JS("int", "(Math.random() * 0x100000000) >>> 0"); | 759 int int32b = JS("int", "(Math.random() * 0x100000000) >>> 0"); |
773 return int32a + int32b * 0x100000000; | 760 return int32a + int32b * 0x100000000; |
774 } | 761 } |
775 | 762 |
776 String jsonEncodeNative(String string) { | 763 String jsonEncodeNative(String string) { |
777 return JS("String", "JSON.stringify(#)", string); | 764 return JS("String", "JSON.stringify(#)", string); |
778 } | 765 } |
OLD | NEW |