Index: lib/runtime/dart/_utils.js |
diff --git a/lib/runtime/dart/_utils.js b/lib/runtime/dart/_utils.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..5dea60c4f41ec6055fdc31a7d4e73f565919d0f4 |
--- /dev/null |
+++ b/lib/runtime/dart/_utils.js |
@@ -0,0 +1,106 @@ |
+dart_library.library('dart/_utils', null, /* Imports */[ |
+], /* Lazy imports */[ |
+], function(exports, dart) { |
+ 'use strict'; |
+ let defineProperty = Object.defineProperty; |
+ let getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; |
+ let getOwnPropertyNames = Object.getOwnPropertyNames; |
+ let getOwnPropertySymbols = Object.getOwnPropertySymbols; |
+ let hasOwnProperty = Object.prototype.hasOwnProperty; |
+ let StrongModeError = (function() { |
+ function StrongModeError(message) { |
+ Error.call(this); |
+ this.message = message; |
+ } |
+ ; |
+ Object.setPrototypeOf(StrongModeError.prototype, Error.prototype); |
+ return StrongModeError; |
+ })(); |
+ function throwStrongModeError(message) { |
+ throw new StrongModeError(message); |
+ } |
+ function throwInternalError(message) { |
+ throw Error(message); |
+ } |
+ function assert_(condition) { |
+ if (!condition) |
+ throwInternalError("The compiler is broken: failed assert"); |
+ } |
+ function getOwnNamesAndSymbols(obj) { |
+ return getOwnPropertyNames(obj).concat(getOwnPropertySymbols(obj)); |
+ } |
+ function safeGetOwnProperty(obj, name) { |
+ let desc = getOwnPropertyDescriptor(obj, name); |
+ if (desc) |
+ return desc.value; |
+ } |
+ function defineLazyProperty(to, name, desc) { |
+ let init = desc.get; |
+ let value = null; |
+ function lazySetter(x) { |
+ init = null; |
+ value = x; |
+ } |
+ function circularInitError() { |
+ throwInternalError('circular initialization for field ' + name); |
+ } |
+ function lazyGetter() { |
+ if (init == null) |
+ return value; |
+ let f = init; |
+ init = circularInitError; |
+ lazySetter(f()); |
+ return value; |
+ } |
+ desc.get = lazyGetter; |
+ desc.configurable = true; |
+ if (desc.set) |
+ desc.set = lazySetter; |
+ return defineProperty(to, name, desc); |
+ } |
+ function defineLazy(to, from) { |
+ for (let name of getOwnNamesAndSymbols(from)) { |
+ defineLazyProperty(to, name, getOwnPropertyDescriptor(from, name)); |
+ } |
+ } |
+ function defineMemoizedGetter(obj, name, getter) { |
+ return defineLazyProperty(obj, name, {get: getter}); |
+ } |
+ function copyTheseProperties(to, from, names) { |
+ for (let name of names) { |
+ defineProperty(to, name, getOwnPropertyDescriptor(from, name)); |
+ } |
+ return to; |
+ } |
+ function copyProperties(to, from) { |
+ return copyTheseProperties(to, from, getOwnNamesAndSymbols(from)); |
+ } |
+ function export_(to, from, show, hide) { |
+ if (show == void 0) { |
+ show = getOwnNamesAndSymbols(from); |
+ } |
+ if (hide != void 0) { |
+ var hideMap = new Set(hide); |
+ show = show.filter(k => !hideMap.has(k)); |
+ } |
+ return copyTheseProperties(to, from, show); |
+ } |
+ // Exports: |
+ exports.defineProperty = defineProperty; |
+ exports.getOwnPropertyDescriptor = getOwnPropertyDescriptor; |
+ exports.getOwnPropertyNames = getOwnPropertyNames; |
+ exports.getOwnPropertySymbols = getOwnPropertySymbols; |
+ exports.hasOwnProperty = hasOwnProperty; |
+ exports.StrongModeError = StrongModeError; |
+ exports.throwStrongModeError = throwStrongModeError; |
+ exports.throwInternalError = throwInternalError; |
+ exports.assert_ = assert_; |
+ exports.getOwnNamesAndSymbols = getOwnNamesAndSymbols; |
+ exports.safeGetOwnProperty = safeGetOwnProperty; |
+ exports.defineLazyProperty = defineLazyProperty; |
+ exports.defineLazy = defineLazy; |
+ exports.defineMemoizedGetter = defineMemoizedGetter; |
+ exports.copyTheseProperties = copyTheseProperties; |
+ exports.copyProperties = copyProperties; |
+ exports.export_ = export_; |
+}); |