OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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._utils; | 5 library dart._utils; |
6 | 6 |
7 import 'dart:_foreign_helper' show JS; | 7 import 'dart:_foreign_helper' show JS; |
8 | 8 |
9 /// This library defines a set of general javascript utilities for us | 9 /// This library defines a set of general javascript utilities for us |
10 /// by the Dart runtime. | 10 /// by the Dart runtime. |
11 // TODO(ochafik): Rewrite some of these in Dart when possible. | 11 // TODO(ochafik): Rewrite some of these in Dart when possible. |
12 | 12 |
13 // TODO(ochafik): Make these final + special-case them in js_codegen to fix | 13 final defineProperty = JS('', 'Object.defineProperty'); |
14 // Analyzer errors. | 14 final getOwnPropertyDescriptor = JS('', 'Object.getOwnPropertyDescriptor'); |
15 const defineProperty = JS('', 'Object.defineProperty'); | 15 final getOwnPropertyNames = JS('', 'Object.getOwnPropertyNames'); |
16 const getOwnPropertyDescriptor = JS('', 'Object.getOwnPropertyDescriptor'); | 16 final getOwnPropertySymbols = JS('', 'Object.getOwnPropertySymbols'); |
17 const getOwnPropertyNames = JS('', 'Object.getOwnPropertyNames'); | |
18 const getOwnPropertySymbols = JS('', 'Object.getOwnPropertySymbols'); | |
19 | 17 |
20 const hasOwnProperty = JS('', 'Object.prototype.hasOwnProperty'); | 18 final hasOwnProperty = JS('', 'Object.prototype.hasOwnProperty'); |
21 | 19 |
22 // TODO(ochafik): Add ES6 class syntax support to JS intrinsics to avoid this. | 20 // TODO(ochafik): Add ES6 class syntax support to JS intrinsics to avoid this. |
23 const StrongModeError = JS('', '''(function() { | 21 final StrongModeError = JS('', '''(function() { |
24 function StrongModeError(message) { | 22 function StrongModeError(message) { |
25 Error.call(this); | 23 Error.call(this); |
26 this.message = message; | 24 this.message = message; |
27 }; | 25 }; |
28 Object.setPrototypeOf(StrongModeError.prototype, Error.prototype); | 26 Object.setPrototypeOf(StrongModeError.prototype, Error.prototype); |
29 return StrongModeError; | 27 return StrongModeError; |
30 })()'''); | 28 })()'''); |
31 | 29 |
32 /// This error indicates a strong mode specific failure. | 30 /// This error indicates a strong mode specific failure. |
33 void throwStrongModeError(String message) => JS('', '''((message) => { | 31 void throwStrongModeError(String message) => JS('', '''((message) => { |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 export_(to, from, show, hide) => JS('', '''((to, from, show, hide) => { | 117 export_(to, from, show, hide) => JS('', '''((to, from, show, hide) => { |
120 if (show == void 0 || show.length == 0) { | 118 if (show == void 0 || show.length == 0) { |
121 show = getOwnNamesAndSymbols(from); | 119 show = getOwnNamesAndSymbols(from); |
122 } | 120 } |
123 if (hide != void 0) { | 121 if (hide != void 0) { |
124 var hideMap = new Set(hide); | 122 var hideMap = new Set(hide); |
125 show = show.filter((k) => !hideMap.has(k)); | 123 show = show.filter((k) => !hideMap.has(k)); |
126 } | 124 } |
127 return copyTheseProperties(to, from, show); | 125 return copyTheseProperties(to, from, show); |
128 })(#, #, #, #)''', to, from, show, hide); | 126 })(#, #, #, #)''', to, from, show, hide); |
OLD | NEW |