OLD | NEW |
(Empty) | |
| 1 dart_library.library('dart/_utils', null, /* Imports */[ |
| 2 ], /* Lazy imports */[ |
| 3 ], function(exports, dart) { |
| 4 'use strict'; |
| 5 let defineProperty = Object.defineProperty; |
| 6 let getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; |
| 7 let getOwnPropertyNames = Object.getOwnPropertyNames; |
| 8 let getOwnPropertySymbols = Object.getOwnPropertySymbols; |
| 9 let hasOwnProperty = Object.prototype.hasOwnProperty; |
| 10 let StrongModeError = (function() { |
| 11 function StrongModeError(message) { |
| 12 Error.call(this); |
| 13 this.message = message; |
| 14 } |
| 15 ; |
| 16 Object.setPrototypeOf(StrongModeError.prototype, Error.prototype); |
| 17 return StrongModeError; |
| 18 })(); |
| 19 function throwStrongModeError(message) { |
| 20 throw new StrongModeError(message); |
| 21 } |
| 22 function throwInternalError(message) { |
| 23 throw Error(message); |
| 24 } |
| 25 function assert_(condition) { |
| 26 if (!condition) |
| 27 throwInternalError("The compiler is broken: failed assert"); |
| 28 } |
| 29 function getOwnNamesAndSymbols(obj) { |
| 30 return getOwnPropertyNames(obj).concat(getOwnPropertySymbols(obj)); |
| 31 } |
| 32 function safeGetOwnProperty(obj, name) { |
| 33 let desc = getOwnPropertyDescriptor(obj, name); |
| 34 if (desc) |
| 35 return desc.value; |
| 36 } |
| 37 function defineLazyProperty(to, name, desc) { |
| 38 let init = desc.get; |
| 39 let value = null; |
| 40 function lazySetter(x) { |
| 41 init = null; |
| 42 value = x; |
| 43 } |
| 44 function circularInitError() { |
| 45 throwInternalError('circular initialization for field ' + name); |
| 46 } |
| 47 function lazyGetter() { |
| 48 if (init == null) |
| 49 return value; |
| 50 let f = init; |
| 51 init = circularInitError; |
| 52 lazySetter(f()); |
| 53 return value; |
| 54 } |
| 55 desc.get = lazyGetter; |
| 56 desc.configurable = true; |
| 57 if (desc.set) |
| 58 desc.set = lazySetter; |
| 59 return defineProperty(to, name, desc); |
| 60 } |
| 61 function defineLazy(to, from) { |
| 62 for (let name of getOwnNamesAndSymbols(from)) { |
| 63 defineLazyProperty(to, name, getOwnPropertyDescriptor(from, name)); |
| 64 } |
| 65 } |
| 66 function defineMemoizedGetter(obj, name, getter) { |
| 67 return defineLazyProperty(obj, name, {get: getter}); |
| 68 } |
| 69 function copyTheseProperties(to, from, names) { |
| 70 for (let name of names) { |
| 71 defineProperty(to, name, getOwnPropertyDescriptor(from, name)); |
| 72 } |
| 73 return to; |
| 74 } |
| 75 function copyProperties(to, from) { |
| 76 return copyTheseProperties(to, from, getOwnNamesAndSymbols(from)); |
| 77 } |
| 78 function export_(to, from, show, hide) { |
| 79 if (show == void 0) { |
| 80 show = getOwnNamesAndSymbols(from); |
| 81 } |
| 82 if (hide != void 0) { |
| 83 var hideMap = new Set(hide); |
| 84 show = show.filter(k => !hideMap.has(k)); |
| 85 } |
| 86 return copyTheseProperties(to, from, show); |
| 87 } |
| 88 // Exports: |
| 89 exports.defineProperty = defineProperty; |
| 90 exports.getOwnPropertyDescriptor = getOwnPropertyDescriptor; |
| 91 exports.getOwnPropertyNames = getOwnPropertyNames; |
| 92 exports.getOwnPropertySymbols = getOwnPropertySymbols; |
| 93 exports.hasOwnProperty = hasOwnProperty; |
| 94 exports.StrongModeError = StrongModeError; |
| 95 exports.throwStrongModeError = throwStrongModeError; |
| 96 exports.throwInternalError = throwInternalError; |
| 97 exports.assert_ = assert_; |
| 98 exports.getOwnNamesAndSymbols = getOwnNamesAndSymbols; |
| 99 exports.safeGetOwnProperty = safeGetOwnProperty; |
| 100 exports.defineLazyProperty = defineLazyProperty; |
| 101 exports.defineLazy = defineLazy; |
| 102 exports.defineMemoizedGetter = defineMemoizedGetter; |
| 103 exports.copyTheseProperties = copyTheseProperties; |
| 104 exports.copyProperties = copyProperties; |
| 105 exports.export_ = export_; |
| 106 }); |
OLD | NEW |