| OLD | NEW |
| (Empty) |
| 1 var _js_helper; | |
| 2 (function(exports) { | |
| 3 'use strict'; | |
| 4 class _Patch extends dart.Object { | |
| 5 _Patch() { | |
| 6 } | |
| 7 } | |
| 8 let patch = new _Patch(); | |
| 9 class InternalMap extends dart.Object { | |
| 10 } | |
| 11 // Function requiresPreamble: () → dynamic | |
| 12 function requiresPreamble() { | |
| 13 } | |
| 14 // Function isJsIndexable: (dynamic, dynamic) → bool | |
| 15 function isJsIndexable(object, record) { | |
| 16 if (record !== null) { | |
| 17 let result = _interceptors.dispatchRecordIndexability(record); | |
| 18 if (result !== null) | |
| 19 return dart.as(result, core.bool); | |
| 20 } | |
| 21 return dart.is(object, JavaScriptIndexingBehavior); | |
| 22 } | |
| 23 // Function S: (dynamic) → String | |
| 24 function S(value) { | |
| 25 if (typeof value == string) | |
| 26 return dart.as(value, core.String); | |
| 27 if (dart.is(value, core.num)) { | |
| 28 if (!dart.equals(value, 0)) { | |
| 29 return "" + value; | |
| 30 } | |
| 31 } else if (true === value) { | |
| 32 return 'true'; | |
| 33 } else if (false === value) { | |
| 34 return 'false'; | |
| 35 } else if (value === null) { | |
| 36 return 'null'; | |
| 37 } | |
| 38 let res = dart.dinvoke(value, 'toString'); | |
| 39 if (!(typeof res == string)) | |
| 40 throw new core.ArgumentError(value); | |
| 41 return dart.as(res, core.String); | |
| 42 } | |
| 43 // Function createInvocationMirror: (String, dynamic, dynamic, dynamic, dynami
c) → dynamic | |
| 44 function createInvocationMirror(name, internalName, kind, arguments, argumentN
ames) { | |
| 45 return new JSInvocationMirror(name, dart.as(internalName, core.String), dart
.as(kind, core.int), dart.as(arguments, core.List), dart.as(argumentNames, core.
List)); | |
| 46 } | |
| 47 // Function createUnmangledInvocationMirror: (Symbol, dynamic, dynamic, dynami
c, dynamic) → dynamic | |
| 48 function createUnmangledInvocationMirror(symbol, internalName, kind, arguments
, argumentNames) { | |
| 49 return new JSInvocationMirror(symbol, dart.as(internalName, core.String), da
rt.as(kind, core.int), dart.as(arguments, core.List), dart.as(argumentNames, cor
e.List)); | |
| 50 } | |
| 51 // Function throwInvalidReflectionError: (String) → void | |
| 52 function throwInvalidReflectionError(memberName) { | |
| 53 throw new core.UnsupportedError(`Can't use '${memberName}' in reflection ` +
"because it is not included in a @MirrorsUsed annotation."); | |
| 54 } | |
| 55 // Function traceHelper: (String) → void | |
| 56 function traceHelper(method) { | |
| 57 if (!this.cache) { | |
| 58 this.cache = Object.create(null); | |
| 59 } | |
| 60 if (!this.cache[method]) { | |
| 61 console.log(method); | |
| 62 this.cache[method] = true; | |
| 63 } | |
| 64 } | |
| 65 class JSInvocationMirror extends dart.Object { | |
| 66 JSInvocationMirror(_memberName, _internalName, _kind, _arguments, _namedArgu
mentNames) { | |
| 67 this._memberName = _memberName; | |
| 68 this._internalName = _internalName; | |
| 69 this._kind = _kind; | |
| 70 this._arguments = _arguments; | |
| 71 this._namedArgumentNames = _namedArgumentNames; | |
| 72 this._namedIndices = null; | |
| 73 } | |
| 74 get memberName() { | |
| 75 if (dart.is(this._memberName, core.Symbol)) | |
| 76 return dart.as(this._memberName, core.Symbol); | |
| 77 let name = dart.as(this._memberName, core.String); | |
| 78 let unmangledName = _js_names.mangledNames.get(name); | |
| 79 if (unmangledName !== null) { | |
| 80 name = unmangledName.split(':').get(0); | |
| 81 } else { | |
| 82 if (_js_names.mangledNames.get(this._internalName) === null) { | |
| 83 core.print(`Warning: '${name}' is used reflectively but not in Mirrors
Used. ` + "This will break minified code."); | |
| 84 } | |
| 85 } | |
| 86 this._memberName = new _internal.Symbol.unvalidated(name); | |
| 87 return dart.as(this._memberName, core.Symbol); | |
| 88 } | |
| 89 get isMethod() { | |
| 90 return this._kind === METHOD; | |
| 91 } | |
| 92 get isGetter() { | |
| 93 return this._kind === GETTER; | |
| 94 } | |
| 95 get isSetter() { | |
| 96 return this._kind === SETTER; | |
| 97 } | |
| 98 get isAccessor() { | |
| 99 return this._kind !== METHOD; | |
| 100 } | |
| 101 get positionalArguments() { | |
| 102 if (this.isGetter) | |
| 103 return /* Unimplemented const */new List.from([]); | |
| 104 let argumentCount = this._arguments.length - this._namedArgumentNames.leng
th; | |
| 105 if (argumentCount === 0) | |
| 106 return /* Unimplemented const */new List.from([]); | |
| 107 let list = new List.from([]); | |
| 108 for (let index = 0; index < argumentCount; index++) { | |
| 109 list.add(this._arguments.get(index)); | |
| 110 } | |
| 111 return dart.as(makeLiteralListConst(list), core.List); | |
| 112 } | |
| 113 get namedArguments() { | |
| 114 if (this.isAccessor) | |
| 115 return dart.map(); | |
| 116 let namedArgumentCount = this._namedArgumentNames.length; | |
| 117 let namedArgumentsStartIndex = this._arguments.length - namedArgumentCount
; | |
| 118 if (namedArgumentCount === 0) | |
| 119 return dart.map(); | |
| 120 let map = new core.Map(); | |
| 121 for (let i = 0; i < namedArgumentCount; i++) { | |
| 122 map.set(new _internal.Symbol.unvalidated(dart.as(this._namedArgumentName
s.get(i), core.String)), this._arguments.get(namedArgumentsStartIndex + i)); | |
| 123 } | |
| 124 return map; | |
| 125 } | |
| 126 _getCachedInvocation(object) { | |
| 127 let interceptor = _interceptors.getInterceptor(object); | |
| 128 let receiver = object; | |
| 129 let name = this._internalName; | |
| 130 let arguments = this._arguments; | |
| 131 let interceptedNames = _foreign_helper.JS_EMBEDDED_GLOBAL('', dart.as(_js_
embedded_names.INTERCEPTED_NAMES, core.String)); | |
| 132 let isIntercepted = Object.prototype.hasOwnProperty.call(interceptedNames,
name); | |
| 133 if (isIntercepted) { | |
| 134 receiver = interceptor; | |
| 135 if (object === interceptor) { | |
| 136 interceptor = null; | |
| 137 } | |
| 138 } else { | |
| 139 interceptor = null; | |
| 140 } | |
| 141 let isCatchAll = false; | |
| 142 let method = receiver[name]; | |
| 143 if (typeof method != "function") { | |
| 144 let baseName = _internal.Symbol.getName(dart.as(this.memberName, _intern
al.Symbol)); | |
| 145 method = receiver[baseName + "*"]; | |
| 146 if (method === null) { | |
| 147 interceptor = _interceptors.getInterceptor(object); | |
| 148 method = interceptor[baseName + "*"]; | |
| 149 if (method !== null) { | |
| 150 isIntercepted = true; | |
| 151 receiver = interceptor; | |
| 152 } else { | |
| 153 interceptor = null; | |
| 154 } | |
| 155 } | |
| 156 isCatchAll = true; | |
| 157 } | |
| 158 if (typeof method == "function") { | |
| 159 if (isCatchAll) { | |
| 160 return new CachedCatchAllInvocation(name, method, isIntercepted, dart.
as(interceptor, _interceptors.Interceptor)); | |
| 161 } else { | |
| 162 return new CachedInvocation(name, method, isIntercepted, dart.as(inter
ceptor, _interceptors.Interceptor)); | |
| 163 } | |
| 164 } else { | |
| 165 return new CachedNoSuchMethodInvocation(interceptor); | |
| 166 } | |
| 167 } | |
| 168 static invokeFromMirror(invocation, victim) { | |
| 169 let cached = invocation._getCachedInvocation(victim); | |
| 170 if (dart.dload(cached, 'isNoSuchMethod')) { | |
| 171 return dart.dinvoke(cached, 'invokeOn', victim, invocation); | |
| 172 } else { | |
| 173 return dart.dinvoke(cached, 'invokeOn', victim, invocation._arguments); | |
| 174 } | |
| 175 } | |
| 176 static getCachedInvocation(invocation, victim) { | |
| 177 return invocation._getCachedInvocation(victim); | |
| 178 } | |
| 179 } | |
| 180 JSInvocationMirror.METHOD = 0; | |
| 181 JSInvocationMirror.GETTER = 1; | |
| 182 JSInvocationMirror.SETTER = 2; | |
| 183 class CachedInvocation extends dart.Object { | |
| 184 CachedInvocation(mangledName, jsFunction, isIntercepted, cachedInterceptor)
{ | |
| 185 this.mangledName = mangledName; | |
| 186 this.jsFunction = jsFunction; | |
| 187 this.isIntercepted = isIntercepted; | |
| 188 this.cachedInterceptor = cachedInterceptor; | |
| 189 } | |
| 190 get isNoSuchMethod() { | |
| 191 return false; | |
| 192 } | |
| 193 get isGetterStub() { | |
| 194 return !!this.jsFunction.$getterStub; | |
| 195 } | |
| 196 invokeOn(victim, arguments) { | |
| 197 let receiver = victim; | |
| 198 if (!dart.notNull(this.isIntercepted)) { | |
| 199 if (!dart.is(arguments, _interceptors.JSArray)) | |
| 200 arguments = new core.List.from(arguments); | |
| 201 } else { | |
| 202 arguments = new List.from([victim]); | |
| 203 arguments.addAll(arguments); | |
| 204 if (this.cachedInterceptor !== null) | |
| 205 receiver = this.cachedInterceptor; | |
| 206 } | |
| 207 return this.jsFunction.apply(receiver, arguments); | |
| 208 } | |
| 209 } | |
| 210 class CachedCatchAllInvocation extends CachedInvocation { | |
| 211 CachedCatchAllInvocation(name, jsFunction, isIntercepted, cachedInterceptor)
{ | |
| 212 this.info = new ReflectionInfo(jsFunction); | |
| 213 super.CachedInvocation(name, jsFunction, isIntercepted, cachedInterceptor)
; | |
| 214 } | |
| 215 get isGetterStub() { | |
| 216 return false; | |
| 217 } | |
| 218 invokeOn(victim, arguments) { | |
| 219 let receiver = victim; | |
| 220 let providedArgumentCount = null; | |
| 221 let fullParameterCount = this.info.requiredParameterCount + this.info.opti
onalParameterCount; | |
| 222 if (!dart.notNull(this.isIntercepted)) { | |
| 223 if (dart.is(arguments, _interceptors.JSArray)) { | |
| 224 providedArgumentCount = arguments.length; | |
| 225 if (providedArgumentCount < fullParameterCount) { | |
| 226 arguments = new core.List.from(arguments); | |
| 227 } | |
| 228 } else { | |
| 229 arguments = new core.List.from(arguments); | |
| 230 providedArgumentCount = arguments.length; | |
| 231 } | |
| 232 } else { | |
| 233 arguments = new List.from([victim]); | |
| 234 arguments.addAll(arguments); | |
| 235 if (this.cachedInterceptor !== null) | |
| 236 receiver = this.cachedInterceptor; | |
| 237 providedArgumentCount = arguments.length - 1; | |
| 238 } | |
| 239 if (dart.notNull(this.info.areOptionalParametersNamed) && dart.notNull(pro
videdArgumentCount > this.info.requiredParameterCount)) { | |
| 240 throw new UnimplementedNoSuchMethodError(`Invocation of unstubbed method
'${this.info.reflectionName}'` + ` with ${arguments.length} arguments.`); | |
| 241 } else if (providedArgumentCount < this.info.requiredParameterCount) { | |
| 242 throw new UnimplementedNoSuchMethodError(`Invocation of unstubbed method
'${this.info.reflectionName}'` + ` with ${providedArgumentCount} arguments (too
few).`); | |
| 243 } else if (providedArgumentCount > fullParameterCount) { | |
| 244 throw new UnimplementedNoSuchMethodError(`Invocation of unstubbed method
'${this.info.reflectionName}'` + ` with ${providedArgumentCount} arguments (too
many).`); | |
| 245 } | |
| 246 for (let i = providedArgumentCount; i < fullParameterCount; i++) { | |
| 247 arguments.add(getMetadata(this.info.defaultValue(i))); | |
| 248 } | |
| 249 return this.jsFunction.apply(receiver, arguments); | |
| 250 } | |
| 251 } | |
| 252 class CachedNoSuchMethodInvocation extends dart.Object { | |
| 253 CachedNoSuchMethodInvocation(interceptor) { | |
| 254 this.interceptor = interceptor; | |
| 255 } | |
| 256 get isNoSuchMethod() { | |
| 257 return true; | |
| 258 } | |
| 259 get isGetterStub() { | |
| 260 return false; | |
| 261 } | |
| 262 invokeOn(victim, invocation) { | |
| 263 let receiver = this.interceptor === null ? victim : this.interceptor; | |
| 264 return dart.dinvoke(receiver, 'noSuchMethod', invocation); | |
| 265 } | |
| 266 } | |
| 267 class ReflectionInfo extends dart.Object { | |
| 268 ReflectionInfo$internal(jsFunction, data, isAccessor, requiredParameterCount
, optionalParameterCount, areOptionalParametersNamed, functionType) { | |
| 269 this.jsFunction = jsFunction; | |
| 270 this.data = data; | |
| 271 this.isAccessor = isAccessor; | |
| 272 this.requiredParameterCount = requiredParameterCount; | |
| 273 this.optionalParameterCount = optionalParameterCount; | |
| 274 this.areOptionalParametersNamed = areOptionalParametersNamed; | |
| 275 this.functionType = functionType; | |
| 276 this.cachedSortedIndices = null; | |
| 277 } | |
| 278 ReflectionInfo(jsFunction) { | |
| 279 let data = dart.as(jsFunction.$reflectionInfo, core.List); | |
| 280 if (data === null) | |
| 281 return null; | |
| 282 data = _interceptors.JSArray.markFixedList(data); | |
| 283 let requiredParametersInfo = data[REQUIRED_PARAMETERS_INFO]; | |
| 284 let requiredParameterCount = requiredParametersInfo >> 1; | |
| 285 let isAccessor = (requiredParametersInfo & 1) === 1; | |
| 286 let optionalParametersInfo = data[OPTIONAL_PARAMETERS_INFO]; | |
| 287 let optionalParameterCount = optionalParametersInfo >> 1; | |
| 288 let areOptionalParametersNamed = (optionalParametersInfo & 1) === 1; | |
| 289 let functionType = data[FUNCTION_TYPE_INDEX]; | |
| 290 return new ReflectionInfo.internal(jsFunction, data, isAccessor, requiredP
arameterCount, optionalParameterCount, areOptionalParametersNamed, functionType)
; | |
| 291 } | |
| 292 parameterName(parameter) { | |
| 293 let metadataIndex = null; | |
| 294 if (_foreign_helper.JS_GET_FLAG('MUST_RETAIN_METADATA')) { | |
| 295 metadataIndex = this.data[2 * parameter + this.optionalParameterCount +
FIRST_DEFAULT_ARGUMENT]; | |
| 296 } else { | |
| 297 metadataIndex = this.data[parameter + this.optionalParameterCount + FIRS
T_DEFAULT_ARGUMENT]; | |
| 298 } | |
| 299 let metadata = _foreign_helper.JS_EMBEDDED_GLOBAL('', dart.as(_js_embedded
_names.METADATA, core.String)); | |
| 300 return metadata[metadataIndex]; | |
| 301 } | |
| 302 parameterMetadataAnnotations(parameter) { | |
| 303 if (!dart.notNull(_foreign_helper.JS_GET_FLAG('MUST_RETAIN_METADATA'))) { | |
| 304 throw new core.StateError('metadata has not been preserved'); | |
| 305 } else { | |
| 306 return dart.as(this.data[2 * parameter + this.optionalParameterCount + F
IRST_DEFAULT_ARGUMENT + 1], core.List$(core.int)); | |
| 307 } | |
| 308 } | |
| 309 defaultValue(parameter) { | |
| 310 if (parameter < this.requiredParameterCount) | |
| 311 return dart.as(null, core.int); | |
| 312 return this.data[FIRST_DEFAULT_ARGUMENT + parameter - this.requiredParamet
erCount]; | |
| 313 } | |
| 314 defaultValueInOrder(parameter) { | |
| 315 if (parameter < this.requiredParameterCount) | |
| 316 return dart.as(null, core.int); | |
| 317 if (dart.notNull(!dart.notNull(this.areOptionalParametersNamed)) || dart.n
otNull(this.optionalParameterCount === 1)) { | |
| 318 return this.defaultValue(parameter); | |
| 319 } | |
| 320 let index = this.sortedIndex(parameter - this.requiredParameterCount); | |
| 321 return this.defaultValue(index); | |
| 322 } | |
| 323 parameterNameInOrder(parameter) { | |
| 324 if (parameter < this.requiredParameterCount) | |
| 325 return null; | |
| 326 if (dart.notNull(!dart.notNull(this.areOptionalParametersNamed)) || dart.n
otNull(this.optionalParameterCount === 1)) { | |
| 327 return this.parameterName(parameter); | |
| 328 } | |
| 329 let index = this.sortedIndex(parameter - this.requiredParameterCount); | |
| 330 return this.parameterName(index); | |
| 331 } | |
| 332 sortedIndex(unsortedIndex) { | |
| 333 if (this.cachedSortedIndices === null) { | |
| 334 this.cachedSortedIndices = new core.List(this.optionalParameterCount); | |
| 335 let positions = dart.map(); | |
| 336 for (let i = 0; i < this.optionalParameterCount; i++) { | |
| 337 let index = this.requiredParameterCount + i; | |
| 338 positions.set(this.parameterName(index), index); | |
| 339 } | |
| 340 let index = 0; | |
| 341 ((_) => { | |
| 342 _.sort(); | |
| 343 return _; | |
| 344 }).bind(this)(positions.keys.toList()).forEach(((name) => { | |
| 345 this.cachedSortedIndices.set(index++, positions.get(name)); | |
| 346 }).bind(this)); | |
| 347 } | |
| 348 return dart.as(this.cachedSortedIndices.get(unsortedIndex), core.int); | |
| 349 } | |
| 350 computeFunctionRti(jsConstructor) { | |
| 351 if (typeof this.functionType == "number") { | |
| 352 return getMetadata(dart.as(this.functionType, core.int)); | |
| 353 } else if (typeof this.functionType == "function") { | |
| 354 let fakeInstance = new jsConstructor(); | |
| 355 setRuntimeTypeInfo(fakeInstance, fakeInstance["<>"]); | |
| 356 return this.functionType.apply({$receiver: fakeInstance}); | |
| 357 } else { | |
| 358 throw new RuntimeError('Unexpected function type'); | |
| 359 } | |
| 360 } | |
| 361 get reflectionName() { | |
| 362 return this.jsFunction.$reflectionName; | |
| 363 } | |
| 364 } | |
| 365 dart.defineNamedConstructor(ReflectionInfo, 'internal'); | |
| 366 ReflectionInfo.REQUIRED_PARAMETERS_INFO = 0; | |
| 367 ReflectionInfo.OPTIONAL_PARAMETERS_INFO = 1; | |
| 368 ReflectionInfo.FUNCTION_TYPE_INDEX = 2; | |
| 369 ReflectionInfo.FIRST_DEFAULT_ARGUMENT = 3; | |
| 370 // Function getMetadata: (int) → dynamic | |
| 371 function getMetadata(index) { | |
| 372 let metadata = _foreign_helper.JS_EMBEDDED_GLOBAL('', dart.as(_js_embedded_n
ames.METADATA, core.String)); | |
| 373 return metadata[index]; | |
| 374 } | |
| 375 class Primitives extends dart.Object { | |
| 376 static initializeStatics(id) { | |
| 377 mirrorFunctionCacheName = `_${id}`; | |
| 378 mirrorInvokeCacheName = `_${id}`; | |
| 379 } | |
| 380 static objectHashCode(object) { | |
| 381 let hash = dart.as(object.$identityHash, core.int); | |
| 382 if (hash === null) { | |
| 383 hash = Math.random() * 0x3fffffff | 0; | |
| 384 object.$identityHash = hash; | |
| 385 } | |
| 386 return hash; | |
| 387 } | |
| 388 static _throwFormatException(string) { | |
| 389 throw new core.FormatException(string); | |
| 390 } | |
| 391 static parseInt(source, radix, handleError) { | |
| 392 if (handleError === null) | |
| 393 handleError = dart.as(_throwFormatException, dart.throw_("Unimplemented
type (String) → int")); | |
| 394 checkString(source); | |
| 395 let match = /^\s*[+-]?((0x[a-f0-9]+)|(\d+)|([a-z0-9]+))\s*$/i.exec(source)
; | |
| 396 let digitsIndex = 1; | |
| 397 let hexIndex = 2; | |
| 398 let decimalIndex = 3; | |
| 399 let nonDecimalHexIndex = 4; | |
| 400 if (radix === null) { | |
| 401 radix = 10; | |
| 402 if (match !== null) { | |
| 403 if (dart.dindex(match, hexIndex) !== null) { | |
| 404 return dart.notNull(parseInt(source, 16)); | |
| 405 } | |
| 406 if (dart.dindex(match, decimalIndex) !== null) { | |
| 407 return dart.notNull(parseInt(source, 10)); | |
| 408 } | |
| 409 return handleError(source); | |
| 410 } | |
| 411 } else { | |
| 412 if (!(typeof radix == number)) | |
| 413 throw new core.ArgumentError("Radix is not an integer"); | |
| 414 if (dart.notNull(radix < 2) || dart.notNull(radix > 36)) { | |
| 415 throw new core.RangeError(`Radix ${radix} not in range 2..36`); | |
| 416 } | |
| 417 if (match !== null) { | |
| 418 if (dart.notNull(radix === 10) && dart.notNull(dart.dindex(match, deci
malIndex) !== null)) { | |
| 419 return dart.notNull(parseInt(source, 10)); | |
| 420 } | |
| 421 if (dart.notNull(radix < 10) || dart.notNull(dart.dindex(match, decima
lIndex) === null)) { | |
| 422 let maxCharCode = null; | |
| 423 if (radix <= 10) { | |
| 424 maxCharCode = 48 + radix - 1; | |
| 425 } else { | |
| 426 maxCharCode = 97 + radix - 10 - 1; | |
| 427 } | |
| 428 let digitsPart = dart.as(dart.dindex(match, digitsIndex), core.Strin
g); | |
| 429 for (let i = 0; i < digitsPart.length; i++) { | |
| 430 let characterCode = digitsPart.codeUnitAt(0) | 32; | |
| 431 if (digitsPart.codeUnitAt(i) > maxCharCode) { | |
| 432 return handleError(source); | |
| 433 } | |
| 434 } | |
| 435 } | |
| 436 } | |
| 437 } | |
| 438 if (match === null) | |
| 439 return handleError(source); | |
| 440 return dart.notNull(parseInt(source, radix)); | |
| 441 } | |
| 442 static parseDouble(source, handleError) { | |
| 443 checkString(source); | |
| 444 if (handleError === null) | |
| 445 handleError = dart.as(_throwFormatException, dart.throw_("Unimplemented
type (String) → double")); | |
| 446 if (!dart.notNull(/^\s*[+-]?(?:Infinity|NaN|(?:\.\d+|\d+(?:\.\d*)?)(?:[eE]
[+-]?\d+)?)\s*$/.test(source))) { | |
| 447 return handleError(source); | |
| 448 } | |
| 449 let result = parseFloat(source); | |
| 450 if (result.isNaN) { | |
| 451 let trimmed = source.trim(); | |
| 452 if (dart.notNull(dart.notNull(dart.equals(trimmed, 'NaN')) || dart.notNu
ll(dart.equals(trimmed, '+NaN'))) || dart.notNull(dart.equals(trimmed, '-NaN')))
{ | |
| 453 return dart.notNull(result); | |
| 454 } | |
| 455 return handleError(source); | |
| 456 } | |
| 457 return dart.notNull(result); | |
| 458 } | |
| 459 static formatType(className, typeArguments) { | |
| 460 return _js_names.unmangleAllIdentifiersIfPreservedAnyways(`${className}${j
oinArguments(typeArguments, 0)}`); | |
| 461 } | |
| 462 static objectTypeName(object) { | |
| 463 let name = constructorNameFallback(_interceptors.getInterceptor(object)); | |
| 464 if (dart.equals(name, 'Object')) { | |
| 465 let decompiled = String(object.constructor).match(/^\s*function\s*(\S*)\
s*\(/)[1]; | |
| 466 if (typeof decompiled == string) | |
| 467 if (/^\w+$/.test(decompiled)) | |
| 468 name = dart.as(decompiled, core.String); | |
| 469 } | |
| 470 if (dart.notNull(name.length > 1) && dart.notNull(core.identical(name.code
UnitAt(0), DOLLAR_CHAR_VALUE))) { | |
| 471 name = name.substring(1); | |
| 472 } | |
| 473 return formatType(name, dart.as(getRuntimeTypeInfo(object), core.List)); | |
| 474 } | |
| 475 static objectToString(object) { | |
| 476 let name = objectTypeName(object); | |
| 477 return `Instance of '${name}'`; | |
| 478 } | |
| 479 static dateNow() { | |
| 480 return Date.now(); | |
| 481 } | |
| 482 static initTicker() { | |
| 483 if (timerFrequency !== null) | |
| 484 return; | |
| 485 timerFrequency = 1000; | |
| 486 timerTicks = dateNow; | |
| 487 if (typeof window == "undefined") | |
| 488 return; | |
| 489 let window = window; | |
| 490 if (window === null) | |
| 491 return; | |
| 492 let performance = window.performance; | |
| 493 if (performance === null) | |
| 494 return; | |
| 495 if (typeof performance.now != "function") | |
| 496 return; | |
| 497 timerFrequency = 1000000; | |
| 498 timerTicks = (() => (1000 * dart.notNull(performance.now())).floor()).bind
(this); | |
| 499 } | |
| 500 static get isD8() { | |
| 501 return typeof version == "function" && typeof os == "object" && "system" i
n os; | |
| 502 } | |
| 503 static get isJsshell() { | |
| 504 return typeof version == "function" && typeof system == "function"; | |
| 505 } | |
| 506 static currentUri() { | |
| 507 requiresPreamble(); | |
| 508 if (!!self.location) { | |
| 509 return self.location.href; | |
| 510 } | |
| 511 return null; | |
| 512 } | |
| 513 static _fromCharCodeApply(array) { | |
| 514 let result = ""; | |
| 515 let kMaxApply = 500; | |
| 516 let end = array.length; | |
| 517 for (let i = 0; i < end; i = kMaxApply) { | |
| 518 let subarray = null; | |
| 519 if (end <= kMaxApply) { | |
| 520 subarray = array; | |
| 521 } else { | |
| 522 subarray = array.slice(i, i + kMaxApply < end ? i + kMaxApply : end); | |
| 523 } | |
| 524 result = result + String.fromCharCode.apply(null, subarray); | |
| 525 } | |
| 526 return result; | |
| 527 } | |
| 528 static stringFromCodePoints(codePoints) { | |
| 529 let a = new List.from([]); | |
| 530 for (let i of codePoints) { | |
| 531 if (!(typeof i == number)) | |
| 532 throw new core.ArgumentError(i); | |
| 533 if (dart.dbinary(i, '<=', 65535)) { | |
| 534 a.add(dart.as(i, core.int)); | |
| 535 } else if (dart.dbinary(i, '<=', 1114111)) { | |
| 536 a.add(dart.notNull(55296['+'](dart.dbinary(dart.dbinary(dart.dbinary(i
, '-', 65536), '>>', 10), '&', 1023)))); | |
| 537 a.add(dart.notNull(56320['+'](dart.dbinary(i, '&', 1023)))); | |
| 538 } else { | |
| 539 throw new core.ArgumentError(i); | |
| 540 } | |
| 541 } | |
| 542 return _fromCharCodeApply(a); | |
| 543 } | |
| 544 static stringFromCharCodes(charCodes) { | |
| 545 for (let i of charCodes) { | |
| 546 if (!(typeof i == number)) | |
| 547 throw new core.ArgumentError(i); | |
| 548 if (dart.dbinary(i, '<', 0)) | |
| 549 throw new core.ArgumentError(i); | |
| 550 if (dart.dbinary(i, '>', 65535)) | |
| 551 return stringFromCodePoints(charCodes); | |
| 552 } | |
| 553 return _fromCharCodeApply(dart.as(charCodes, core.List$(core.int))); | |
| 554 } | |
| 555 static stringFromCharCode(charCode) { | |
| 556 if (0['<='](charCode)) { | |
| 557 if (dart.dbinary(charCode, '<=', 65535)) { | |
| 558 return String.fromCharCode(charCode); | |
| 559 } | |
| 560 if (dart.dbinary(charCode, '<=', 1114111)) { | |
| 561 let bits = dart.dbinary(charCode, '-', 65536); | |
| 562 let low = 56320['|'](dart.dbinary(bits, '&', 1023)); | |
| 563 let high = 55296['|'](dart.dbinary(bits, '>>', 10)); | |
| 564 return String.fromCharCode(high, low); | |
| 565 } | |
| 566 } | |
| 567 throw new core.RangeError.range(dart.as(charCode, core.num), 0, 1114111); | |
| 568 } | |
| 569 static stringConcatUnchecked(string1, string2) { | |
| 570 return _foreign_helper.JS_STRING_CONCAT(string1, string2); | |
| 571 } | |
| 572 static flattenString(str) { | |
| 573 return str.charCodeAt(0) == 0 ? str : str; | |
| 574 } | |
| 575 static getTimeZoneName(receiver) { | |
| 576 let d = lazyAsJsDate(receiver); | |
| 577 let match = dart.as(/\((.*)\)/.exec(d.toString()), core.List); | |
| 578 if (match !== null) | |
| 579 return dart.as(match.get(1), core.String); | |
| 580 match = dart.as(/^[A-Z,a-z]{3}\s[A-Z,a-z]{3}\s\d+\s\d{2}:\d{2}:\d{2}\s([A-
Z]{3,5})\s\d{4}$/.exec(d.toString()), core.List); | |
| 581 if (match !== null) | |
| 582 return dart.as(match.get(1), core.String); | |
| 583 match = dart.as(/(?:GMT|UTC)[+-]\d{4}/.exec(d.toString()), core.List); | |
| 584 if (match !== null) | |
| 585 return dart.as(match.get(0), core.String); | |
| 586 return ""; | |
| 587 } | |
| 588 static getTimeZoneOffsetInMinutes(receiver) { | |
| 589 return -lazyAsJsDate(receiver).getTimezoneOffset(); | |
| 590 } | |
| 591 static valueFromDecomposedDate(years, month, day, hours, minutes, seconds, m
illiseconds, isUtc) { | |
| 592 let MAX_MILLISECONDS_SINCE_EPOCH = 8640000000000000; | |
| 593 checkInt(years); | |
| 594 checkInt(month); | |
| 595 checkInt(day); | |
| 596 checkInt(hours); | |
| 597 checkInt(minutes); | |
| 598 checkInt(seconds); | |
| 599 checkInt(milliseconds); | |
| 600 checkBool(isUtc); | |
| 601 let jsMonth = dart.dbinary(month, '-', 1); | |
| 602 let value = null; | |
| 603 if (isUtc) { | |
| 604 value = Date.UTC(years, jsMonth, day, hours, minutes, seconds, milliseco
nds); | |
| 605 } else { | |
| 606 value = new Date(years, jsMonth, day, hours, minutes, seconds, milliseco
nds).valueOf(); | |
| 607 } | |
| 608 if (core.bool['||'](dart.dbinary(dart.dload(value, 'isNaN'), '||', dart.db
inary(value, '<', -MAX_MILLISECONDS_SINCE_EPOCH)), dart.dbinary(value, '>', MAX_
MILLISECONDS_SINCE_EPOCH))) { | |
| 609 return null; | |
| 610 } | |
| 611 if (dart.dbinary(dart.dbinary(years, '<=', 0), '||', dart.dbinary(years, '
<', 100))) | |
| 612 return patchUpY2K(value, years, isUtc); | |
| 613 return value; | |
| 614 } | |
| 615 static patchUpY2K(value, years, isUtc) { | |
| 616 let date = new Date(value); | |
| 617 if (isUtc) { | |
| 618 date.setUTCFullYear(years); | |
| 619 } else { | |
| 620 date.setFullYear(years); | |
| 621 } | |
| 622 return date.valueOf(); | |
| 623 } | |
| 624 static lazyAsJsDate(receiver) { | |
| 625 if (receiver.date === void 0) { | |
| 626 receiver.date = new Date(dart.dload(receiver, 'millisecondsSinceEpoch'))
; | |
| 627 } | |
| 628 return receiver.date; | |
| 629 } | |
| 630 static getYear(receiver) { | |
| 631 return dart.dload(receiver, 'isUtc') ? lazyAsJsDate(receiver).getUTCFullYe
ar() + 0 : lazyAsJsDate(receiver).getFullYear() + 0; | |
| 632 } | |
| 633 static getMonth(receiver) { | |
| 634 return dart.dload(receiver, 'isUtc') ? lazyAsJsDate(receiver).getUTCMonth(
) + 1 : lazyAsJsDate(receiver).getMonth() + 1; | |
| 635 } | |
| 636 static getDay(receiver) { | |
| 637 return dart.dload(receiver, 'isUtc') ? lazyAsJsDate(receiver).getUTCDate()
+ 0 : lazyAsJsDate(receiver).getDate() + 0; | |
| 638 } | |
| 639 static getHours(receiver) { | |
| 640 return dart.dload(receiver, 'isUtc') ? lazyAsJsDate(receiver).getUTCHours(
) + 0 : lazyAsJsDate(receiver).getHours() + 0; | |
| 641 } | |
| 642 static getMinutes(receiver) { | |
| 643 return dart.dload(receiver, 'isUtc') ? lazyAsJsDate(receiver).getUTCMinute
s() + 0 : lazyAsJsDate(receiver).getMinutes() + 0; | |
| 644 } | |
| 645 static getSeconds(receiver) { | |
| 646 return dart.dload(receiver, 'isUtc') ? lazyAsJsDate(receiver).getUTCSecond
s() + 0 : lazyAsJsDate(receiver).getSeconds() + 0; | |
| 647 } | |
| 648 static getMilliseconds(receiver) { | |
| 649 return dart.dload(receiver, 'isUtc') ? lazyAsJsDate(receiver).getUTCMillis
econds() + 0 : lazyAsJsDate(receiver).getMilliseconds() + 0; | |
| 650 } | |
| 651 static getWeekday(receiver) { | |
| 652 let weekday = dart.dload(receiver, 'isUtc') ? lazyAsJsDate(receiver).getUT
CDay() + 0 : lazyAsJsDate(receiver).getDay() + 0; | |
| 653 return (weekday + 6) % 7 + 1; | |
| 654 } | |
| 655 static valueFromDateString(str) { | |
| 656 if (!(typeof str == string)) | |
| 657 throw new core.ArgumentError(str); | |
| 658 let value = Date.parse(str); | |
| 659 if (value.isNaN) | |
| 660 throw new core.ArgumentError(str); | |
| 661 return value; | |
| 662 } | |
| 663 static getProperty(object, key) { | |
| 664 if (dart.notNull(dart.notNull(dart.notNull(object === null) || dart.notNul
l(typeof object == boolean)) || dart.notNull(dart.is(object, core.num))) || dart
.notNull(typeof object == string)) { | |
| 665 throw new core.ArgumentError(object); | |
| 666 } | |
| 667 return object[key]; | |
| 668 } | |
| 669 static setProperty(object, key, value) { | |
| 670 if (dart.notNull(dart.notNull(dart.notNull(object === null) || dart.notNul
l(typeof object == boolean)) || dart.notNull(dart.is(object, core.num))) || dart
.notNull(typeof object == string)) { | |
| 671 throw new core.ArgumentError(object); | |
| 672 } | |
| 673 object[key] = value; | |
| 674 } | |
| 675 static functionNoSuchMethod(function, positionalArguments, namedArguments) { | |
| 676 let argumentCount = 0; | |
| 677 let arguments = new List.from([]); | |
| 678 let namedArgumentList = new List.from([]); | |
| 679 if (positionalArguments !== null) { | |
| 680 argumentCount = positionalArguments.length; | |
| 681 arguments.addAll(positionalArguments); | |
| 682 } | |
| 683 let names = ''; | |
| 684 if (dart.notNull(namedArguments !== null) && dart.notNull(!dart.notNull(na
medArguments.isEmpty))) { | |
| 685 namedArguments.forEach(((name, argument) => { | |
| 686 names = `${names}$${name}`; | |
| 687 namedArgumentList.add(name); | |
| 688 arguments.add(argument); | |
| 689 argumentCount++; | |
| 690 }).bind(this)); | |
| 691 } | |
| 692 let selectorName = `${_foreign_helper.JS_GET_NAME("CALL_PREFIX")}$${argume
ntCount}${names}`; | |
| 693 return dart.dinvoke(function, 'noSuchMethod', createUnmangledInvocationMir
ror(dart.throw_("Unimplemented SymbolLiteral: #call"), selectorName, JSInvocatio
nMirror.METHOD, arguments, namedArgumentList)); | |
| 694 } | |
| 695 static applyFunction(function, positionalArguments, namedArguments) { | |
| 696 return namedArguments === null ? applyFunctionWithPositionalArguments(func
tion, positionalArguments) : applyFunctionWithNamedArguments(function, positiona
lArguments, namedArguments); | |
| 697 } | |
| 698 static applyFunctionWithPositionalArguments(function, positionalArguments) { | |
| 699 let argumentCount = 0; | |
| 700 let arguments = null; | |
| 701 if (positionalArguments !== null) { | |
| 702 if (positionalArguments instanceof Array) { | |
| 703 arguments = positionalArguments; | |
| 704 } else { | |
| 705 arguments = new core.List.from(positionalArguments); | |
| 706 } | |
| 707 argumentCount = arguments.length; | |
| 708 } else { | |
| 709 arguments = new List.from([]); | |
| 710 } | |
| 711 let selectorName = `${_foreign_helper.JS_GET_NAME("CALL_PREFIX")}$${argume
ntCount}`; | |
| 712 let jsFunction = function[selectorName]; | |
| 713 if (jsFunction === null) { | |
| 714 return functionNoSuchMethod(function, positionalArguments, null); | |
| 715 } | |
| 716 return jsFunction.apply(function, arguments); | |
| 717 } | |
| 718 static applyFunctionWithNamedArguments(function, positionalArguments, namedA
rguments) { | |
| 719 if (namedArguments.isEmpty) { | |
| 720 return applyFunctionWithPositionalArguments(function, positionalArgument
s); | |
| 721 } | |
| 722 let interceptor = _interceptors.getInterceptor(function); | |
| 723 let jsFunction = interceptor["call*"]; | |
| 724 if (jsFunction === null) { | |
| 725 return functionNoSuchMethod(function, positionalArguments, namedArgument
s); | |
| 726 } | |
| 727 let info = new ReflectionInfo(jsFunction); | |
| 728 if (dart.notNull(info === null) || dart.notNull(!dart.notNull(info.areOpti
onalParametersNamed))) { | |
| 729 return functionNoSuchMethod(function, positionalArguments, namedArgument
s); | |
| 730 } | |
| 731 if (positionalArguments !== null) { | |
| 732 positionalArguments = new core.List.from(positionalArguments); | |
| 733 } else { | |
| 734 positionalArguments = new List.from([]); | |
| 735 } | |
| 736 if (info.requiredParameterCount !== positionalArguments.length) { | |
| 737 return functionNoSuchMethod(function, positionalArguments, namedArgument
s); | |
| 738 } | |
| 739 let defaultArguments = new core.Map(); | |
| 740 for (let i = 0; i < info.optionalParameterCount; i++) { | |
| 741 let index = i + info.requiredParameterCount; | |
| 742 let parameterName = info.parameterNameInOrder(index); | |
| 743 let value = info.defaultValueInOrder(index); | |
| 744 let defaultValue = getMetadata(value); | |
| 745 defaultArguments.set(parameterName, defaultValue); | |
| 746 } | |
| 747 let bad = false; | |
| 748 namedArguments.forEach(((parameter, value) => { | |
| 749 if (defaultArguments.containsKey(parameter)) { | |
| 750 defaultArguments.set(parameter, value); | |
| 751 } else { | |
| 752 bad = true; | |
| 753 } | |
| 754 }).bind(this)); | |
| 755 if (bad) { | |
| 756 return functionNoSuchMethod(function, positionalArguments, namedArgument
s); | |
| 757 } | |
| 758 positionalArguments.addAll(defaultArguments.values); | |
| 759 return jsFunction.apply(function, positionalArguments); | |
| 760 } | |
| 761 static _mangledNameMatchesType(mangledName, type) { | |
| 762 return mangledName == type._typeName; | |
| 763 } | |
| 764 static identicalImplementation(a, b) { | |
| 765 return a == null ? b == null : a === b; | |
| 766 } | |
| 767 static extractStackTrace(error) { | |
| 768 return getTraceFromException(error.$thrownJsError); | |
| 769 } | |
| 770 } | |
| 771 Primitives.mirrorFunctionCacheName = '$cachedFunction'; | |
| 772 Primitives.mirrorInvokeCacheName = '$cachedInvocation'; | |
| 773 Primitives.DOLLAR_CHAR_VALUE = 36; | |
| 774 Primitives.timerFrequency = null; | |
| 775 Primitives.timerTicks = null; | |
| 776 class JsCache extends dart.Object { | |
| 777 static allocate() { | |
| 778 let result = Object.create(null); | |
| 779 result.x = 0; | |
| 780 delete result.x; | |
| 781 return result; | |
| 782 } | |
| 783 static fetch(cache, key) { | |
| 784 return cache[key]; | |
| 785 } | |
| 786 static update(cache, key, value) { | |
| 787 cache[key] = value; | |
| 788 } | |
| 789 } | |
| 790 // Function iae: (dynamic) → dynamic | |
| 791 function iae(argument) { | |
| 792 throw new core.ArgumentError(argument); | |
| 793 } | |
| 794 // Function ioore: (dynamic, dynamic) → dynamic | |
| 795 function ioore(receiver, index) { | |
| 796 if (receiver === null) | |
| 797 dart.dload(receiver, 'length'); | |
| 798 if (!(typeof index == number)) | |
| 799 iae(index); | |
| 800 throw new core.RangeError.value(dart.as(index, core.num)); | |
| 801 } | |
| 802 // Function stringLastIndexOfUnchecked: (dynamic, dynamic, dynamic) → dynamic | |
| 803 function stringLastIndexOfUnchecked(receiver, element, start) { | |
| 804 return receiver.lastIndexOf(element, start); | |
| 805 } | |
| 806 // Function checkNull: (dynamic) → dynamic | |
| 807 function checkNull(object) { | |
| 808 if (object === null) | |
| 809 throw new core.ArgumentError(null); | |
| 810 return object; | |
| 811 } | |
| 812 // Function checkNum: (dynamic) → dynamic | |
| 813 function checkNum(value) { | |
| 814 if (!dart.is(value, core.num)) { | |
| 815 throw new core.ArgumentError(value); | |
| 816 } | |
| 817 return value; | |
| 818 } | |
| 819 // Function checkInt: (dynamic) → dynamic | |
| 820 function checkInt(value) { | |
| 821 if (!(typeof value == number)) { | |
| 822 throw new core.ArgumentError(value); | |
| 823 } | |
| 824 return value; | |
| 825 } | |
| 826 // Function checkBool: (dynamic) → dynamic | |
| 827 function checkBool(value) { | |
| 828 if (!(typeof value == boolean)) { | |
| 829 throw new core.ArgumentError(value); | |
| 830 } | |
| 831 return value; | |
| 832 } | |
| 833 // Function checkString: (dynamic) → dynamic | |
| 834 function checkString(value) { | |
| 835 if (!(typeof value == string)) { | |
| 836 throw new core.ArgumentError(value); | |
| 837 } | |
| 838 return value; | |
| 839 } | |
| 840 // Function wrapException: (dynamic) → dynamic | |
| 841 function wrapException(ex) { | |
| 842 if (ex === null) | |
| 843 ex = new core.NullThrownError(); | |
| 844 let wrapper = new Error(); | |
| 845 wrapper.dartException = ex; | |
| 846 if ("defineProperty" in Object) { | |
| 847 Object.defineProperty(wrapper, "message", {get: _foreign_helper.DART_CLOSU
RE_TO_JS(toStringWrapper)}); | |
| 848 wrapper.name = ""; | |
| 849 } else { | |
| 850 wrapper.toString = _foreign_helper.DART_CLOSURE_TO_JS(toStringWrapper); | |
| 851 } | |
| 852 return wrapper; | |
| 853 } | |
| 854 // Function toStringWrapper: () → dynamic | |
| 855 function toStringWrapper() { | |
| 856 return dart.dinvoke(this.dartException, 'toString'); | |
| 857 } | |
| 858 // Function throwExpression: (dynamic) → dynamic | |
| 859 function throwExpression(ex) { | |
| 860 throw wrapException(ex); | |
| 861 } | |
| 862 // Function makeLiteralListConst: (dynamic) → dynamic | |
| 863 function makeLiteralListConst(list) { | |
| 864 list.immutable$list = true; | |
| 865 list.fixed$length = true; | |
| 866 return list; | |
| 867 } | |
| 868 // Function throwRuntimeError: (dynamic) → dynamic | |
| 869 function throwRuntimeError(message) { | |
| 870 throw new RuntimeError(message); | |
| 871 } | |
| 872 // Function throwAbstractClassInstantiationError: (dynamic) → dynamic | |
| 873 function throwAbstractClassInstantiationError(className) { | |
| 874 throw new core.AbstractClassInstantiationError(dart.as(className, core.Strin
g)); | |
| 875 } | |
| 876 class TypeErrorDecoder extends dart.Object { | |
| 877 TypeErrorDecoder(_arguments, _argumentsExpr, _expr, _method, _receiver, _pat
tern) { | |
| 878 this._arguments = _arguments; | |
| 879 this._argumentsExpr = _argumentsExpr; | |
| 880 this._expr = _expr; | |
| 881 this._method = _method; | |
| 882 this._receiver = _receiver; | |
| 883 this._pattern = _pattern; | |
| 884 } | |
| 885 matchTypeError(message) { | |
| 886 let match = new RegExp(this._pattern).exec(message); | |
| 887 if (match === null) | |
| 888 return null; | |
| 889 let result = Object.create(null); | |
| 890 if (this._arguments !== -1) { | |
| 891 result.arguments = match[this._arguments + 1]; | |
| 892 } | |
| 893 if (this._argumentsExpr !== -1) { | |
| 894 result.argumentsExpr = match[this._argumentsExpr + 1]; | |
| 895 } | |
| 896 if (this._expr !== -1) { | |
| 897 result.expr = match[this._expr + 1]; | |
| 898 } | |
| 899 if (this._method !== -1) { | |
| 900 result.method = match[this._method + 1]; | |
| 901 } | |
| 902 if (this._receiver !== -1) { | |
| 903 result.receiver = match[this._receiver + 1]; | |
| 904 } | |
| 905 return result; | |
| 906 } | |
| 907 static buildJavaScriptObject() { | |
| 908 return { | |
| 909 toString: function() { | |
| 910 return "$receiver$"; | |
| 911 } | |
| 912 }; | |
| 913 } | |
| 914 static buildJavaScriptObjectWithNonClosure() { | |
| 915 return { | |
| 916 $method$: null, | |
| 917 toString: function() { | |
| 918 return "$receiver$"; | |
| 919 } | |
| 920 }; | |
| 921 } | |
| 922 static extractPattern(message) { | |
| 923 message = message.replace(String({}), '$receiver$'); | |
| 924 message = message.replace(new RegExp(ESCAPE_REGEXP, 'g'), '\\$&'); | |
| 925 let match = dart.as(message.match(/\\\$[a-zA-Z]+\\\$/g), core.List$(core.S
tring)); | |
| 926 if (match === null) | |
| 927 match = dart.as(new List.from([]), core.List$(core.String)); | |
| 928 let arguments = match.indexOf('\\$arguments\\$'); | |
| 929 let argumentsExpr = match.indexOf('\\$argumentsExpr\\$'); | |
| 930 let expr = match.indexOf('\\$expr\\$'); | |
| 931 let method = match.indexOf('\\$method\\$'); | |
| 932 let receiver = match.indexOf('\\$receiver\\$'); | |
| 933 let pattern = message.replace('\\$arguments\\$', '((?:x|[^x])*)').replace(
'\\$argumentsExpr\\$', '((?:x|[^x])*)').replace('\\$expr\\$', '((?:x|[^x])*)').r
eplace('\\$method\\$', '((?:x|[^x])*)').replace('\\$receiver\\$', '((?:x|[^x])*)
'); | |
| 934 return new TypeErrorDecoder(arguments, argumentsExpr, expr, method, receiv
er, pattern); | |
| 935 } | |
| 936 static provokeCallErrorOn(expression) { | |
| 937 let function = function($expr$) { | |
| 938 var $argumentsExpr$ = '$arguments$'; | |
| 939 try { | |
| 940 $expr$.$method$($argumentsExpr$); | |
| 941 } catch (e) { | |
| 942 return e.message; | |
| 943 } | |
| 944 | |
| 945 }; | |
| 946 return function(expression); | |
| 947 } | |
| 948 static provokeCallErrorOnNull() { | |
| 949 let function = function() { | |
| 950 var $argumentsExpr$ = '$arguments$'; | |
| 951 try { | |
| 952 null.$method$($argumentsExpr$); | |
| 953 } catch (e) { | |
| 954 return e.message; | |
| 955 } | |
| 956 | |
| 957 }; | |
| 958 return function(); | |
| 959 } | |
| 960 static provokeCallErrorOnUndefined() { | |
| 961 let function = function() { | |
| 962 var $argumentsExpr$ = '$arguments$'; | |
| 963 try { | |
| 964 (void 0).$method$($argumentsExpr$); | |
| 965 } catch (e) { | |
| 966 return e.message; | |
| 967 } | |
| 968 | |
| 969 }; | |
| 970 return function(); | |
| 971 } | |
| 972 static provokePropertyErrorOn(expression) { | |
| 973 let function = function($expr$) { | |
| 974 try { | |
| 975 $expr$.$method$; | |
| 976 } catch (e) { | |
| 977 return e.message; | |
| 978 } | |
| 979 | |
| 980 }; | |
| 981 return function(expression); | |
| 982 } | |
| 983 static provokePropertyErrorOnNull() { | |
| 984 let function = function() { | |
| 985 try { | |
| 986 null.$method$; | |
| 987 } catch (e) { | |
| 988 return e.message; | |
| 989 } | |
| 990 | |
| 991 }; | |
| 992 return function(); | |
| 993 } | |
| 994 static provokePropertyErrorOnUndefined() { | |
| 995 let function = function() { | |
| 996 try { | |
| 997 (void 0).$method$; | |
| 998 } catch (e) { | |
| 999 return e.message; | |
| 1000 } | |
| 1001 | |
| 1002 }; | |
| 1003 return function(); | |
| 1004 } | |
| 1005 } | |
| 1006 dart.defineLazyProperties(TypeErrorDecoder, { | |
| 1007 get noSuchMethodPattern() { | |
| 1008 return dart.as(extractPattern(provokeCallErrorOn(buildJavaScriptObject()))
, TypeErrorDecoder); | |
| 1009 }, | |
| 1010 get notClosurePattern() { | |
| 1011 return dart.as(extractPattern(provokeCallErrorOn(buildJavaScriptObjectWith
NonClosure())), TypeErrorDecoder); | |
| 1012 }, | |
| 1013 get nullCallPattern() { | |
| 1014 return dart.as(extractPattern(provokeCallErrorOn(null)), TypeErrorDecoder)
; | |
| 1015 }, | |
| 1016 get nullLiteralCallPattern() { | |
| 1017 return dart.as(extractPattern(provokeCallErrorOnNull()), TypeErrorDecoder)
; | |
| 1018 }, | |
| 1019 get undefinedCallPattern() { | |
| 1020 return dart.as(extractPattern(provokeCallErrorOn(void 0)), TypeErrorDecode
r); | |
| 1021 }, | |
| 1022 get undefinedLiteralCallPattern() { | |
| 1023 return dart.as(extractPattern(provokeCallErrorOnUndefined()), TypeErrorDec
oder); | |
| 1024 }, | |
| 1025 get nullPropertyPattern() { | |
| 1026 return dart.as(extractPattern(provokePropertyErrorOn(null)), TypeErrorDeco
der); | |
| 1027 }, | |
| 1028 get nullLiteralPropertyPattern() { | |
| 1029 return dart.as(extractPattern(provokePropertyErrorOnNull()), TypeErrorDeco
der); | |
| 1030 }, | |
| 1031 get undefinedPropertyPattern() { | |
| 1032 return dart.as(extractPattern(provokePropertyErrorOn(void 0)), TypeErrorDe
coder); | |
| 1033 }, | |
| 1034 get undefinedLiteralPropertyPattern() { | |
| 1035 return dart.as(extractPattern(provokePropertyErrorOnUndefined()), TypeErro
rDecoder); | |
| 1036 } | |
| 1037 }); | |
| 1038 class NullError extends core.Error { | |
| 1039 NullError(_message, match) { | |
| 1040 this._message = _message; | |
| 1041 this._method = dart.as(match === null ? null : match.method, core.String); | |
| 1042 super.Error(); | |
| 1043 } | |
| 1044 toString() { | |
| 1045 if (this._method === null) | |
| 1046 return `NullError: ${this._message}`; | |
| 1047 return `NullError: Cannot call "${this._method}" on null`; | |
| 1048 } | |
| 1049 } | |
| 1050 class JsNoSuchMethodError extends core.Error { | |
| 1051 JsNoSuchMethodError(_message, match) { | |
| 1052 this._message = _message; | |
| 1053 this._method = dart.as(match === null ? null : match.method, core.String); | |
| 1054 this._receiver = dart.as(match === null ? null : match.receiver, core.Stri
ng); | |
| 1055 super.Error(); | |
| 1056 } | |
| 1057 toString() { | |
| 1058 if (this._method === null) | |
| 1059 return `NoSuchMethodError: ${this._message}`; | |
| 1060 if (this._receiver === null) { | |
| 1061 return `NoSuchMethodError: Cannot call "${this._method}" (${this._messag
e})`; | |
| 1062 } | |
| 1063 return `NoSuchMethodError: Cannot call "${this._method}" on "${this._recei
ver}" ` + `(${this._message})`; | |
| 1064 } | |
| 1065 } | |
| 1066 class UnknownJsTypeError extends core.Error { | |
| 1067 UnknownJsTypeError(_message) { | |
| 1068 this._message = _message; | |
| 1069 super.Error(); | |
| 1070 } | |
| 1071 toString() { | |
| 1072 return this._message.isEmpty ? 'Error' : `Error: ${this._message}`; | |
| 1073 } | |
| 1074 } | |
| 1075 // Function unwrapException: (dynamic) → dynamic | |
| 1076 function unwrapException(ex) { | |
| 1077 // Function saveStackTrace: (dynamic) → dynamic | |
| 1078 function saveStackTrace(error) { | |
| 1079 if (dart.is(error, core.Error)) { | |
| 1080 let thrownStackTrace = error.$thrownJsError; | |
| 1081 if (thrownStackTrace === null) { | |
| 1082 error.$thrownJsError = ex; | |
| 1083 } | |
| 1084 } | |
| 1085 return error; | |
| 1086 } | |
| 1087 if (ex === null) | |
| 1088 return null; | |
| 1089 if (typeof ex !== "object") | |
| 1090 return ex; | |
| 1091 if ("dartException" in ex) { | |
| 1092 return saveStackTrace(ex.dartException); | |
| 1093 } else if (!dart.notNull("message" in ex)) { | |
| 1094 return ex; | |
| 1095 } | |
| 1096 let message = ex.message; | |
| 1097 if (dart.notNull("number" in ex) && dart.notNull(typeof ex.number == "number
")) { | |
| 1098 let number = ex.number; | |
| 1099 let ieErrorCode = number & 65535; | |
| 1100 let ieFacilityNumber = number >> 16 & 8191; | |
| 1101 if (ieFacilityNumber === 10) { | |
| 1102 switch (ieErrorCode) { | |
| 1103 case 438: | |
| 1104 return saveStackTrace(new JsNoSuchMethodError(`${message} (Error ${i
eErrorCode})`, null)); | |
| 1105 case 445: | |
| 1106 case 5007: | |
| 1107 return saveStackTrace(new NullError(`${message} (Error ${ieErrorCode
})`, null)); | |
| 1108 } | |
| 1109 } | |
| 1110 } | |
| 1111 if (ex instanceof TypeError) { | |
| 1112 let match = null; | |
| 1113 let nsme = TypeErrorDecoder.noSuchMethodPattern; | |
| 1114 let notClosure = TypeErrorDecoder.notClosurePattern; | |
| 1115 let nullCall = TypeErrorDecoder.nullCallPattern; | |
| 1116 let nullLiteralCall = TypeErrorDecoder.nullLiteralCallPattern; | |
| 1117 let undefCall = TypeErrorDecoder.undefinedCallPattern; | |
| 1118 let undefLiteralCall = TypeErrorDecoder.undefinedLiteralCallPattern; | |
| 1119 let nullProperty = TypeErrorDecoder.nullPropertyPattern; | |
| 1120 let nullLiteralProperty = TypeErrorDecoder.nullLiteralPropertyPattern; | |
| 1121 let undefProperty = TypeErrorDecoder.undefinedPropertyPattern; | |
| 1122 let undefLiteralProperty = TypeErrorDecoder.undefinedLiteralPropertyPatter
n; | |
| 1123 if ((match = dart.dinvoke(nsme, 'matchTypeError', message)) !== null) { | |
| 1124 return saveStackTrace(new JsNoSuchMethodError(dart.as(message, core.Stri
ng), match)); | |
| 1125 } else if ((match = dart.dinvoke(notClosure, 'matchTypeError', message)) !
== null) { | |
| 1126 match.method = "call"; | |
| 1127 return saveStackTrace(new JsNoSuchMethodError(dart.as(message, core.Stri
ng), match)); | |
| 1128 } else if (dart.notNull(dart.notNull(dart.notNull(dart.notNull(dart.notNul
l(dart.notNull(dart.notNull((match = dart.dinvoke(nullCall, 'matchTypeError', me
ssage)) !== null) || dart.notNull((match = dart.dinvoke(nullLiteralCall, 'matchT
ypeError', message)) !== null)) || dart.notNull((match = dart.dinvoke(undefCall,
'matchTypeError', message)) !== null)) || dart.notNull((match = dart.dinvoke(un
defLiteralCall, 'matchTypeError', message)) !== null)) || dart.notNull((match =
dart.dinvoke(nullProperty, 'matchTypeError', message)) !== null)) || dart.notNul
l((match = dart.dinvoke(nullLiteralCall, 'matchTypeError', message)) !== null))
|| dart.notNull((match = dart.dinvoke(undefProperty, 'matchTypeError', message))
!== null)) || dart.notNull((match = dart.dinvoke(undefLiteralProperty, 'matchTy
peError', message)) !== null)) { | |
| 1129 return saveStackTrace(new NullError(dart.as(message, core.String), match
)); | |
| 1130 } | |
| 1131 return saveStackTrace(new UnknownJsTypeError(dart.as(typeof message == str
ing ? message : '', core.String))); | |
| 1132 } | |
| 1133 if (ex instanceof RangeError) { | |
| 1134 if (dart.notNull(typeof message == string) && dart.notNull(contains(dart.a
s(message, core.String), 'call stack'))) { | |
| 1135 return new core.StackOverflowError(); | |
| 1136 } | |
| 1137 return saveStackTrace(new core.ArgumentError()); | |
| 1138 } | |
| 1139 if (typeof InternalError == "function" && ex instanceof InternalError) { | |
| 1140 if (dart.notNull(typeof message == string) && dart.notNull(dart.equals(mes
sage, 'too much recursion'))) { | |
| 1141 return new core.StackOverflowError(); | |
| 1142 } | |
| 1143 } | |
| 1144 return ex; | |
| 1145 } | |
| 1146 // Function getTraceFromException: (dynamic) → StackTrace | |
| 1147 function getTraceFromException(exception) { | |
| 1148 return new _StackTrace(exception); | |
| 1149 } | |
| 1150 class _StackTrace extends dart.Object { | |
| 1151 _StackTrace(_exception) { | |
| 1152 this._exception = _exception; | |
| 1153 this._trace = null; | |
| 1154 } | |
| 1155 toString() { | |
| 1156 if (this._trace !== null) | |
| 1157 return this._trace; | |
| 1158 let trace = null; | |
| 1159 if (typeof this._exception === "object") { | |
| 1160 trace = dart.as(this._exception.stack, core.String); | |
| 1161 } | |
| 1162 return this._trace = trace === null ? '' : trace; | |
| 1163 } | |
| 1164 } | |
| 1165 // Function objectHashCode: (dynamic) → int | |
| 1166 function objectHashCode(object) { | |
| 1167 if (dart.notNull(object === null) || dart.notNull(typeof object != 'object')
) { | |
| 1168 return dart.as(dart.dload(object, 'hashCode'), core.int); | |
| 1169 } else { | |
| 1170 return Primitives.objectHashCode(object); | |
| 1171 } | |
| 1172 } | |
| 1173 // Function fillLiteralMap: (dynamic, Map<dynamic, dynamic>) → dynamic | |
| 1174 function fillLiteralMap(keyValuePairs, result) { | |
| 1175 let index = 0; | |
| 1176 let length = getLength(keyValuePairs); | |
| 1177 while (index < length) { | |
| 1178 let key = getIndex(keyValuePairs, index++); | |
| 1179 let value = getIndex(keyValuePairs, index++); | |
| 1180 result.set(key, value); | |
| 1181 } | |
| 1182 return result; | |
| 1183 } | |
| 1184 // Function invokeClosure: (Function, dynamic, int, dynamic, dynamic, dynamic,
dynamic) → dynamic | |
| 1185 function invokeClosure(closure, isolate, numberOfArguments, arg1, arg2, arg3,
arg4) { | |
| 1186 if (numberOfArguments === 0) { | |
| 1187 return _foreign_helper.JS_CALL_IN_ISOLATE(isolate, () => dart.dinvokef(clo
sure)); | |
| 1188 } else if (numberOfArguments === 1) { | |
| 1189 return _foreign_helper.JS_CALL_IN_ISOLATE(isolate, () => dart.dinvokef(clo
sure, arg1)); | |
| 1190 } else if (numberOfArguments === 2) { | |
| 1191 return _foreign_helper.JS_CALL_IN_ISOLATE(isolate, () => dart.dinvokef(clo
sure, arg1, arg2)); | |
| 1192 } else if (numberOfArguments === 3) { | |
| 1193 return _foreign_helper.JS_CALL_IN_ISOLATE(isolate, () => dart.dinvokef(clo
sure, arg1, arg2, arg3)); | |
| 1194 } else if (numberOfArguments === 4) { | |
| 1195 return _foreign_helper.JS_CALL_IN_ISOLATE(isolate, () => dart.dinvokef(clo
sure, arg1, arg2, arg3, arg4)); | |
| 1196 } else { | |
| 1197 throw new core.Exception('Unsupported number of arguments for wrapped clos
ure'); | |
| 1198 } | |
| 1199 } | |
| 1200 // Function convertDartClosureToJS: (dynamic, int) → dynamic | |
| 1201 function convertDartClosureToJS(closure, arity) { | |
| 1202 if (closure === null) | |
| 1203 return null; | |
| 1204 let function = closure.$identity; | |
| 1205 if (!!function) | |
| 1206 return function; | |
| 1207 function = function(closure, arity, context, invoke) { | |
| 1208 return function(a1, a2, a3, a4) { | |
| 1209 return invoke(closure, context, arity, a1, a2, a3, a4); | |
| 1210 }; | |
| 1211 }(closure, arity, _foreign_helper.JS_CURRENT_ISOLATE_CONTEXT(), _foreign_hel
per.DART_CLOSURE_TO_JS(invokeClosure)); | |
| 1212 closure.$identity = function; | |
| 1213 return function; | |
| 1214 } | |
| 1215 class Closure extends dart.Object { | |
| 1216 Closure() { | |
| 1217 } | |
| 1218 static fromTearOff(receiver, functions, reflectionInfo, isStatic, jsArgument
s, propertyName) { | |
| 1219 _foreign_helper.JS_EFFECT(() => { | |
| 1220 BoundClosure.receiverOf(dart.as(void 0, BoundClosure)); | |
| 1221 BoundClosure.selfOf(dart.as(void 0, BoundClosure)); | |
| 1222 }); | |
| 1223 let function = functions[0]; | |
| 1224 let name = dart.as(function.$stubName, core.String); | |
| 1225 let callName = dart.as(function.$callName, core.String); | |
| 1226 function.$reflectionInfo = reflectionInfo; | |
| 1227 let info = new ReflectionInfo(function); | |
| 1228 let functionType = info.functionType; | |
| 1229 let prototype = isStatic ? Object.create(new TearOffClosure().constructor.
prototype) : Object.create(new BoundClosure(null, null, null, null).constructor.
prototype); | |
| 1230 prototype.$initialize = prototype.constructor; | |
| 1231 let constructor = isStatic ? function() { | |
| 1232 this.$initialize(); | |
| 1233 } : isCsp ? function(a, b, c, d) { | |
| 1234 this.$initialize(a, b, c, d); | |
| 1235 } : new Function("a", "b", "c", "d", "this.$initialize(a,b,c,d);" + functi
onCounter++); | |
| 1236 prototype.constructor = constructor; | |
| 1237 constructor.prototype = prototype; | |
| 1238 let trampoline = function; | |
| 1239 let isIntercepted = false; | |
| 1240 if (!dart.notNull(isStatic)) { | |
| 1241 if (jsArguments.length == 1) { | |
| 1242 isIntercepted = true; | |
| 1243 } | |
| 1244 trampoline = forwardCallTo(receiver, function, isIntercepted); | |
| 1245 trampoline.$reflectionInfo = reflectionInfo; | |
| 1246 } else { | |
| 1247 prototype.$name = propertyName; | |
| 1248 } | |
| 1249 let signatureFunction = null; | |
| 1250 if (typeof functionType == "number") { | |
| 1251 let metadata = _foreign_helper.JS_EMBEDDED_GLOBAL('', dart.as(_js_embedd
ed_names.METADATA, core.String)); | |
| 1252 signatureFunction = function(s) { | |
| 1253 return function() { | |
| 1254 return metadata[s]; | |
| 1255 }; | |
| 1256 }(functionType); | |
| 1257 } else if (dart.notNull(!dart.notNull(isStatic)) && dart.notNull(typeof fu
nctionType == "function")) { | |
| 1258 let getReceiver = isIntercepted ? _foreign_helper.RAW_DART_FUNCTION_REF(
BoundClosure.receiverOf) : _foreign_helper.RAW_DART_FUNCTION_REF(BoundClosure.se
lfOf); | |
| 1259 signatureFunction = function(f, r) { | |
| 1260 return function() { | |
| 1261 return f.apply({$receiver: r(this)}, arguments); | |
| 1262 }; | |
| 1263 }(functionType, getReceiver); | |
| 1264 } else { | |
| 1265 throw 'Error in reflectionInfo.'; | |
| 1266 } | |
| 1267 prototype[_foreign_helper.JS_SIGNATURE_NAME()] = signatureFunction; | |
| 1268 prototype[callName] = trampoline; | |
| 1269 for (let i = 1; i < functions.length; i++) { | |
| 1270 let stub = functions.get(i); | |
| 1271 let stubCallName = stub.$callName; | |
| 1272 if (stubCallName !== null) { | |
| 1273 prototype[stubCallName] = isStatic ? stub : forwardCallTo(receiver, st
ub, isIntercepted); | |
| 1274 } | |
| 1275 } | |
| 1276 prototype["call*"] = trampoline; | |
| 1277 return constructor; | |
| 1278 } | |
| 1279 static cspForwardCall(arity, isSuperCall, stubName, function) { | |
| 1280 let getSelf = _foreign_helper.RAW_DART_FUNCTION_REF(BoundClosure.selfOf); | |
| 1281 if (isSuperCall) | |
| 1282 arity = -1; | |
| 1283 switch (arity) { | |
| 1284 case 0: | |
| 1285 return function(n, S) { | |
| 1286 return function() { | |
| 1287 return S(this)[n](); | |
| 1288 }; | |
| 1289 }(stubName, getSelf); | |
| 1290 case 1: | |
| 1291 return function(n, S) { | |
| 1292 return function(a) { | |
| 1293 return S(this)[n](a); | |
| 1294 }; | |
| 1295 }(stubName, getSelf); | |
| 1296 case 2: | |
| 1297 return function(n, S) { | |
| 1298 return function(a, b) { | |
| 1299 return S(this)[n](a, b); | |
| 1300 }; | |
| 1301 }(stubName, getSelf); | |
| 1302 case 3: | |
| 1303 return function(n, S) { | |
| 1304 return function(a, b, c) { | |
| 1305 return S(this)[n](a, b, c); | |
| 1306 }; | |
| 1307 }(stubName, getSelf); | |
| 1308 case 4: | |
| 1309 return function(n, S) { | |
| 1310 return function(a, b, c, d) { | |
| 1311 return S(this)[n](a, b, c, d); | |
| 1312 }; | |
| 1313 }(stubName, getSelf); | |
| 1314 case 5: | |
| 1315 return function(n, S) { | |
| 1316 return function(a, b, c, d, e) { | |
| 1317 return S(this)[n](a, b, c, d, e); | |
| 1318 }; | |
| 1319 }(stubName, getSelf); | |
| 1320 default: | |
| 1321 return function(f, s) { | |
| 1322 return function() { | |
| 1323 return f.apply(s(this), arguments); | |
| 1324 }; | |
| 1325 }(function, getSelf); | |
| 1326 } | |
| 1327 } | |
| 1328 static get isCsp() { | |
| 1329 return typeof dart_precompiled == "function"; | |
| 1330 } | |
| 1331 static forwardCallTo(receiver, function, isIntercepted) { | |
| 1332 if (isIntercepted) | |
| 1333 return forwardInterceptedCallTo(receiver, function); | |
| 1334 let stubName = dart.as(function.$stubName, core.String); | |
| 1335 let arity = function.length; | |
| 1336 let lookedUpFunction = receiver[stubName]; | |
| 1337 let isSuperCall = !dart.notNull(core.identical(function, lookedUpFunction)
); | |
| 1338 if (dart.notNull(dart.notNull(isCsp) || dart.notNull(isSuperCall)) || dart
.notNull(arity >= 27)) { | |
| 1339 return cspForwardCall(arity, isSuperCall, stubName, function); | |
| 1340 } | |
| 1341 if (arity === 0) { | |
| 1342 return new Function('return function(){' + `return this.${BoundClosure.s
elfFieldName()}.${stubName}();` + `${functionCounter++}` + '}')(); | |
| 1343 } | |
| 1344 dart.assert(dart.notNull(1 <= arity) && dart.notNull(arity < 27)); | |
| 1345 let arguments = "abcdefghijklmnopqrstuvwxyz".split("").splice(0, arity).jo
in(","); | |
| 1346 return new Function(`return function(${arguments}){` + `return this.${Boun
dClosure.selfFieldName()}.${stubName}(${arguments});` + `${functionCounter++}` +
'}')(); | |
| 1347 } | |
| 1348 static cspForwardInterceptedCall(arity, isSuperCall, name, function) { | |
| 1349 let getSelf = _foreign_helper.RAW_DART_FUNCTION_REF(BoundClosure.selfOf); | |
| 1350 let getReceiver = _foreign_helper.RAW_DART_FUNCTION_REF(BoundClosure.recei
verOf); | |
| 1351 if (isSuperCall) | |
| 1352 arity = -1; | |
| 1353 switch (arity) { | |
| 1354 case 0: | |
| 1355 throw new RuntimeError('Intercepted function with no arguments.'); | |
| 1356 case 1: | |
| 1357 return function(n, s, r) { | |
| 1358 return function() { | |
| 1359 return s(this)[n](r(this)); | |
| 1360 }; | |
| 1361 }(name, getSelf, getReceiver); | |
| 1362 case 2: | |
| 1363 return function(n, s, r) { | |
| 1364 return function(a) { | |
| 1365 return s(this)[n](r(this), a); | |
| 1366 }; | |
| 1367 }(name, getSelf, getReceiver); | |
| 1368 case 3: | |
| 1369 return function(n, s, r) { | |
| 1370 return function(a, b) { | |
| 1371 return s(this)[n](r(this), a, b); | |
| 1372 }; | |
| 1373 }(name, getSelf, getReceiver); | |
| 1374 case 4: | |
| 1375 return function(n, s, r) { | |
| 1376 return function(a, b, c) { | |
| 1377 return s(this)[n](r(this), a, b, c); | |
| 1378 }; | |
| 1379 }(name, getSelf, getReceiver); | |
| 1380 case 5: | |
| 1381 return function(n, s, r) { | |
| 1382 return function(a, b, c, d) { | |
| 1383 return s(this)[n](r(this), a, b, c, d); | |
| 1384 }; | |
| 1385 }(name, getSelf, getReceiver); | |
| 1386 case 6: | |
| 1387 return function(n, s, r) { | |
| 1388 return function(a, b, c, d, e) { | |
| 1389 return s(this)[n](r(this), a, b, c, d, e); | |
| 1390 }; | |
| 1391 }(name, getSelf, getReceiver); | |
| 1392 default: | |
| 1393 return function(f, s, r, a) { | |
| 1394 return function() { | |
| 1395 a = [r(this)]; | |
| 1396 Array.prototype.push.apply(a, arguments); | |
| 1397 return f.apply(s(this), a); | |
| 1398 }; | |
| 1399 }(function, getSelf, getReceiver); | |
| 1400 } | |
| 1401 } | |
| 1402 static forwardInterceptedCallTo(receiver, function) { | |
| 1403 let selfField = BoundClosure.selfFieldName(); | |
| 1404 let receiverField = BoundClosure.receiverFieldName(); | |
| 1405 let stubName = dart.as(function.$stubName, core.String); | |
| 1406 let arity = function.length; | |
| 1407 let isCsp = typeof dart_precompiled == "function"; | |
| 1408 let lookedUpFunction = receiver[stubName]; | |
| 1409 let isSuperCall = !dart.notNull(core.identical(function, lookedUpFunction)
); | |
| 1410 if (dart.notNull(dart.notNull(isCsp) || dart.notNull(isSuperCall)) || dart
.notNull(arity >= 28)) { | |
| 1411 return cspForwardInterceptedCall(arity, isSuperCall, stubName, function)
; | |
| 1412 } | |
| 1413 if (arity === 1) { | |
| 1414 return new Function('return function(){' + `return this.${selfField}.${s
tubName}(this.${receiverField});` + `${functionCounter++}` + '}')(); | |
| 1415 } | |
| 1416 dart.assert(dart.notNull(1 < arity) && dart.notNull(arity < 28)); | |
| 1417 let arguments = "abcdefghijklmnopqrstuvwxyz".split("").splice(0, arity - 1
).join(","); | |
| 1418 return new Function(`return function(${arguments}){` + `return this.${self
Field}.${stubName}(this.${receiverField}, ${arguments});` + `${functionCounter++
}` + '}')(); | |
| 1419 } | |
| 1420 toString() { | |
| 1421 return "Closure"; | |
| 1422 } | |
| 1423 } | |
| 1424 Closure.FUNCTION_INDEX = 0; | |
| 1425 Closure.NAME_INDEX = 1; | |
| 1426 Closure.CALL_NAME_INDEX = 2; | |
| 1427 Closure.REQUIRED_PARAMETER_INDEX = 3; | |
| 1428 Closure.OPTIONAL_PARAMETER_INDEX = 4; | |
| 1429 Closure.DEFAULT_ARGUMENTS_INDEX = 5; | |
| 1430 Closure.functionCounter = 0; | |
| 1431 // Function closureFromTearOff: (dynamic, dynamic, dynamic, dynamic, dynamic,
dynamic) → dynamic | |
| 1432 function closureFromTearOff(receiver, functions, reflectionInfo, isStatic, jsA
rguments, name) { | |
| 1433 return Closure.fromTearOff(receiver, _interceptors.JSArray.markFixedList(dar
t.as(functions, core.List)), _interceptors.JSArray.markFixedList(dart.as(reflect
ionInfo, core.List)), !!isStatic, jsArguments, name); | |
| 1434 } | |
| 1435 class TearOffClosure extends Closure { | |
| 1436 } | |
| 1437 class BoundClosure extends TearOffClosure { | |
| 1438 BoundClosure(_self, _target, _receiver, _name) { | |
| 1439 this._self = _self; | |
| 1440 this._target = _target; | |
| 1441 this._receiver = _receiver; | |
| 1442 this._name = _name; | |
| 1443 super.TearOffClosure(); | |
| 1444 } | |
| 1445 ['=='](other) { | |
| 1446 if (core.identical(this, other)) | |
| 1447 return true; | |
| 1448 if (!dart.is(other, BoundClosure)) | |
| 1449 return false; | |
| 1450 return this._self === dart.dload(other, '_self') && this._target === dart.
dload(other, '_target') && this._receiver === dart.dload(other, '_receiver'); | |
| 1451 } | |
| 1452 get hashCode() { | |
| 1453 let receiverHashCode = null; | |
| 1454 if (this._receiver === null) { | |
| 1455 receiverHashCode = Primitives.objectHashCode(this._self); | |
| 1456 } else if (!dart.equals(typeof this._receiver, 'object')) { | |
| 1457 receiverHashCode = dart.as(dart.dload(this._receiver, 'hashCode'), core.
int); | |
| 1458 } else { | |
| 1459 receiverHashCode = Primitives.objectHashCode(this._receiver); | |
| 1460 } | |
| 1461 return receiverHashCode ^ Primitives.objectHashCode(this._target); | |
| 1462 } | |
| 1463 static selfOf(closure) { | |
| 1464 return closure._self; | |
| 1465 } | |
| 1466 static targetOf(closure) { | |
| 1467 return closure._target; | |
| 1468 } | |
| 1469 static receiverOf(closure) { | |
| 1470 return closure._receiver; | |
| 1471 } | |
| 1472 static nameOf(closure) { | |
| 1473 return closure._name; | |
| 1474 } | |
| 1475 static selfFieldName() { | |
| 1476 if (selfFieldNameCache === null) { | |
| 1477 selfFieldNameCache = computeFieldNamed('self'); | |
| 1478 } | |
| 1479 return selfFieldNameCache; | |
| 1480 } | |
| 1481 static receiverFieldName() { | |
| 1482 if (receiverFieldNameCache === null) { | |
| 1483 receiverFieldNameCache = computeFieldNamed('receiver'); | |
| 1484 } | |
| 1485 return receiverFieldNameCache; | |
| 1486 } | |
| 1487 static computeFieldNamed(fieldName) { | |
| 1488 let template = new BoundClosure('self', 'target', 'receiver', 'name'); | |
| 1489 let names = _interceptors.JSArray.markFixedList(dart.as(Object.getOwnPrope
rtyNames(template), core.List)); | |
| 1490 for (let i = 0; i < names.length; i++) { | |
| 1491 let name = names.get(i); | |
| 1492 if (template[name] === fieldName) { | |
| 1493 return name; | |
| 1494 } | |
| 1495 } | |
| 1496 } | |
| 1497 } | |
| 1498 BoundClosure.selfFieldNameCache = null; | |
| 1499 BoundClosure.receiverFieldNameCache = null; | |
| 1500 // Function jsHasOwnProperty: (dynamic, String) → bool | |
| 1501 function jsHasOwnProperty(jsObject, property) { | |
| 1502 return jsObject.hasOwnProperty(property); | |
| 1503 } | |
| 1504 // Function jsPropertyAccess: (dynamic, String) → dynamic | |
| 1505 function jsPropertyAccess(jsObject, property) { | |
| 1506 return jsObject[property]; | |
| 1507 } | |
| 1508 // Function getFallThroughError: () → dynamic | |
| 1509 function getFallThroughError() { | |
| 1510 return new FallThroughErrorImplementation(); | |
| 1511 } | |
| 1512 class Creates extends dart.Object { | |
| 1513 Creates(types) { | |
| 1514 this.types = types; | |
| 1515 } | |
| 1516 } | |
| 1517 class Returns extends dart.Object { | |
| 1518 Returns(types) { | |
| 1519 this.types = types; | |
| 1520 } | |
| 1521 } | |
| 1522 class JSName extends dart.Object { | |
| 1523 JSName(name) { | |
| 1524 this.name = name; | |
| 1525 } | |
| 1526 } | |
| 1527 // Function boolConversionCheck: (dynamic) → dynamic | |
| 1528 function boolConversionCheck(value) { | |
| 1529 if (typeof value == boolean) | |
| 1530 return value; | |
| 1531 boolTypeCheck(value); | |
| 1532 dart.assert(value !== null); | |
| 1533 return false; | |
| 1534 } | |
| 1535 // Function stringTypeCheck: (dynamic) → dynamic | |
| 1536 function stringTypeCheck(value) { | |
| 1537 if (value === null) | |
| 1538 return value; | |
| 1539 if (typeof value == string) | |
| 1540 return value; | |
| 1541 throw new TypeErrorImplementation(value, 'String'); | |
| 1542 } | |
| 1543 // Function stringTypeCast: (dynamic) → dynamic | |
| 1544 function stringTypeCast(value) { | |
| 1545 if (dart.notNull(typeof value == string) || dart.notNull(value === null)) | |
| 1546 return value; | |
| 1547 throw new CastErrorImplementation(Primitives.objectTypeName(value), 'String'
); | |
| 1548 } | |
| 1549 // Function doubleTypeCheck: (dynamic) → dynamic | |
| 1550 function doubleTypeCheck(value) { | |
| 1551 if (value === null) | |
| 1552 return value; | |
| 1553 if (typeof value == number) | |
| 1554 return value; | |
| 1555 throw new TypeErrorImplementation(value, 'double'); | |
| 1556 } | |
| 1557 // Function doubleTypeCast: (dynamic) → dynamic | |
| 1558 function doubleTypeCast(value) { | |
| 1559 if (dart.notNull(typeof value == number) || dart.notNull(value === null)) | |
| 1560 return value; | |
| 1561 throw new CastErrorImplementation(Primitives.objectTypeName(value), 'double'
); | |
| 1562 } | |
| 1563 // Function numTypeCheck: (dynamic) → dynamic | |
| 1564 function numTypeCheck(value) { | |
| 1565 if (value === null) | |
| 1566 return value; | |
| 1567 if (dart.is(value, core.num)) | |
| 1568 return value; | |
| 1569 throw new TypeErrorImplementation(value, 'num'); | |
| 1570 } | |
| 1571 // Function numTypeCast: (dynamic) → dynamic | |
| 1572 function numTypeCast(value) { | |
| 1573 if (dart.notNull(dart.is(value, core.num)) || dart.notNull(value === null)) | |
| 1574 return value; | |
| 1575 throw new CastErrorImplementation(Primitives.objectTypeName(value), 'num'); | |
| 1576 } | |
| 1577 // Function boolTypeCheck: (dynamic) → dynamic | |
| 1578 function boolTypeCheck(value) { | |
| 1579 if (value === null) | |
| 1580 return value; | |
| 1581 if (typeof value == boolean) | |
| 1582 return value; | |
| 1583 throw new TypeErrorImplementation(value, 'bool'); | |
| 1584 } | |
| 1585 // Function boolTypeCast: (dynamic) → dynamic | |
| 1586 function boolTypeCast(value) { | |
| 1587 if (dart.notNull(typeof value == boolean) || dart.notNull(value === null)) | |
| 1588 return value; | |
| 1589 throw new CastErrorImplementation(Primitives.objectTypeName(value), 'bool'); | |
| 1590 } | |
| 1591 // Function intTypeCheck: (dynamic) → dynamic | |
| 1592 function intTypeCheck(value) { | |
| 1593 if (value === null) | |
| 1594 return value; | |
| 1595 if (typeof value == number) | |
| 1596 return value; | |
| 1597 throw new TypeErrorImplementation(value, 'int'); | |
| 1598 } | |
| 1599 // Function intTypeCast: (dynamic) → dynamic | |
| 1600 function intTypeCast(value) { | |
| 1601 if (dart.notNull(typeof value == number) || dart.notNull(value === null)) | |
| 1602 return value; | |
| 1603 throw new CastErrorImplementation(Primitives.objectTypeName(value), 'int'); | |
| 1604 } | |
| 1605 // Function propertyTypeError: (dynamic, dynamic) → void | |
| 1606 function propertyTypeError(value, property) { | |
| 1607 let name = dart.as(dart.dinvoke(property, 'substring', 3, dart.dload(propert
y, 'length')), core.String); | |
| 1608 throw new TypeErrorImplementation(value, name); | |
| 1609 } | |
| 1610 // Function propertyTypeCastError: (dynamic, dynamic) → void | |
| 1611 function propertyTypeCastError(value, property) { | |
| 1612 let actualType = Primitives.objectTypeName(value); | |
| 1613 let expectedType = dart.as(dart.dinvoke(property, 'substring', 3, dart.dload
(property, 'length')), core.String); | |
| 1614 throw new CastErrorImplementation(actualType, expectedType); | |
| 1615 } | |
| 1616 // Function propertyTypeCheck: (dynamic, dynamic) → dynamic | |
| 1617 function propertyTypeCheck(value, property) { | |
| 1618 if (value === null) | |
| 1619 return value; | |
| 1620 if (!!value[property]) | |
| 1621 return value; | |
| 1622 propertyTypeError(value, property); | |
| 1623 } | |
| 1624 // Function propertyTypeCast: (dynamic, dynamic) → dynamic | |
| 1625 function propertyTypeCast(value, property) { | |
| 1626 if (dart.notNull(value === null) || dart.notNull(!!value[property])) | |
| 1627 return value; | |
| 1628 propertyTypeCastError(value, property); | |
| 1629 } | |
| 1630 // Function interceptedTypeCheck: (dynamic, dynamic) → dynamic | |
| 1631 function interceptedTypeCheck(value, property) { | |
| 1632 if (value === null) | |
| 1633 return value; | |
| 1634 if (dart.notNull(core.identical(typeof value, 'object')) && dart.notNull(_in
terceptors.getInterceptor(value)[property])) { | |
| 1635 return value; | |
| 1636 } | |
| 1637 propertyTypeError(value, property); | |
| 1638 } | |
| 1639 // Function interceptedTypeCast: (dynamic, dynamic) → dynamic | |
| 1640 function interceptedTypeCast(value, property) { | |
| 1641 if (dart.notNull(value === null) || dart.notNull(dart.notNull(typeof value =
== "object") && dart.notNull(_interceptors.getInterceptor(value)[property]))) { | |
| 1642 return value; | |
| 1643 } | |
| 1644 propertyTypeCastError(value, property); | |
| 1645 } | |
| 1646 // Function numberOrStringSuperTypeCheck: (dynamic, dynamic) → dynamic | |
| 1647 function numberOrStringSuperTypeCheck(value, property) { | |
| 1648 if (value === null) | |
| 1649 return value; | |
| 1650 if (typeof value == string) | |
| 1651 return value; | |
| 1652 if (dart.is(value, core.num)) | |
| 1653 return value; | |
| 1654 if (!!value[property]) | |
| 1655 return value; | |
| 1656 propertyTypeError(value, property); | |
| 1657 } | |
| 1658 // Function numberOrStringSuperTypeCast: (dynamic, dynamic) → dynamic | |
| 1659 function numberOrStringSuperTypeCast(value, property) { | |
| 1660 if (typeof value == string) | |
| 1661 return value; | |
| 1662 if (dart.is(value, core.num)) | |
| 1663 return value; | |
| 1664 return propertyTypeCast(value, property); | |
| 1665 } | |
| 1666 // Function numberOrStringSuperNativeTypeCheck: (dynamic, dynamic) → dynamic | |
| 1667 function numberOrStringSuperNativeTypeCheck(value, property) { | |
| 1668 if (value === null) | |
| 1669 return value; | |
| 1670 if (typeof value == string) | |
| 1671 return value; | |
| 1672 if (dart.is(value, core.num)) | |
| 1673 return value; | |
| 1674 if (_interceptors.getInterceptor(value)[property]) | |
| 1675 return value; | |
| 1676 propertyTypeError(value, property); | |
| 1677 } | |
| 1678 // Function numberOrStringSuperNativeTypeCast: (dynamic, dynamic) → dynamic | |
| 1679 function numberOrStringSuperNativeTypeCast(value, property) { | |
| 1680 if (value === null) | |
| 1681 return value; | |
| 1682 if (typeof value == string) | |
| 1683 return value; | |
| 1684 if (dart.is(value, core.num)) | |
| 1685 return value; | |
| 1686 if (_interceptors.getInterceptor(value)[property]) | |
| 1687 return value; | |
| 1688 propertyTypeCastError(value, property); | |
| 1689 } | |
| 1690 // Function stringSuperTypeCheck: (dynamic, dynamic) → dynamic | |
| 1691 function stringSuperTypeCheck(value, property) { | |
| 1692 if (value === null) | |
| 1693 return value; | |
| 1694 if (typeof value == string) | |
| 1695 return value; | |
| 1696 if (!!value[property]) | |
| 1697 return value; | |
| 1698 propertyTypeError(value, property); | |
| 1699 } | |
| 1700 // Function stringSuperTypeCast: (dynamic, dynamic) → dynamic | |
| 1701 function stringSuperTypeCast(value, property) { | |
| 1702 if (typeof value == string) | |
| 1703 return value; | |
| 1704 return propertyTypeCast(value, property); | |
| 1705 } | |
| 1706 // Function stringSuperNativeTypeCheck: (dynamic, dynamic) → dynamic | |
| 1707 function stringSuperNativeTypeCheck(value, property) { | |
| 1708 if (value === null) | |
| 1709 return value; | |
| 1710 if (typeof value == string) | |
| 1711 return value; | |
| 1712 if (_interceptors.getInterceptor(value)[property]) | |
| 1713 return value; | |
| 1714 propertyTypeError(value, property); | |
| 1715 } | |
| 1716 // Function stringSuperNativeTypeCast: (dynamic, dynamic) → dynamic | |
| 1717 function stringSuperNativeTypeCast(value, property) { | |
| 1718 if (dart.notNull(typeof value == string) || dart.notNull(value === null)) | |
| 1719 return value; | |
| 1720 if (_interceptors.getInterceptor(value)[property]) | |
| 1721 return value; | |
| 1722 propertyTypeCastError(value, property); | |
| 1723 } | |
| 1724 // Function listTypeCheck: (dynamic) → dynamic | |
| 1725 function listTypeCheck(value) { | |
| 1726 if (value === null) | |
| 1727 return value; | |
| 1728 if (dart.is(value, core.List)) | |
| 1729 return value; | |
| 1730 throw new TypeErrorImplementation(value, 'List'); | |
| 1731 } | |
| 1732 // Function listTypeCast: (dynamic) → dynamic | |
| 1733 function listTypeCast(value) { | |
| 1734 if (dart.notNull(dart.is(value, core.List)) || dart.notNull(value === null)) | |
| 1735 return value; | |
| 1736 throw new CastErrorImplementation(Primitives.objectTypeName(value), 'List'); | |
| 1737 } | |
| 1738 // Function listSuperTypeCheck: (dynamic, dynamic) → dynamic | |
| 1739 function listSuperTypeCheck(value, property) { | |
| 1740 if (value === null) | |
| 1741 return value; | |
| 1742 if (dart.is(value, core.List)) | |
| 1743 return value; | |
| 1744 if (!!value[property]) | |
| 1745 return value; | |
| 1746 propertyTypeError(value, property); | |
| 1747 } | |
| 1748 // Function listSuperTypeCast: (dynamic, dynamic) → dynamic | |
| 1749 function listSuperTypeCast(value, property) { | |
| 1750 if (dart.is(value, core.List)) | |
| 1751 return value; | |
| 1752 return propertyTypeCast(value, property); | |
| 1753 } | |
| 1754 // Function listSuperNativeTypeCheck: (dynamic, dynamic) → dynamic | |
| 1755 function listSuperNativeTypeCheck(value, property) { | |
| 1756 if (value === null) | |
| 1757 return value; | |
| 1758 if (dart.is(value, core.List)) | |
| 1759 return value; | |
| 1760 if (_interceptors.getInterceptor(value)[property]) | |
| 1761 return value; | |
| 1762 propertyTypeError(value, property); | |
| 1763 } | |
| 1764 // Function listSuperNativeTypeCast: (dynamic, dynamic) → dynamic | |
| 1765 function listSuperNativeTypeCast(value, property) { | |
| 1766 if (dart.notNull(dart.is(value, core.List)) || dart.notNull(value === null)) | |
| 1767 return value; | |
| 1768 if (_interceptors.getInterceptor(value)[property]) | |
| 1769 return value; | |
| 1770 propertyTypeCastError(value, property); | |
| 1771 } | |
| 1772 // Function voidTypeCheck: (dynamic) → dynamic | |
| 1773 function voidTypeCheck(value) { | |
| 1774 if (value === null) | |
| 1775 return value; | |
| 1776 throw new TypeErrorImplementation(value, 'void'); | |
| 1777 } | |
| 1778 // Function checkMalformedType: (dynamic, dynamic) → dynamic | |
| 1779 function checkMalformedType(value, message) { | |
| 1780 if (value === null) | |
| 1781 return value; | |
| 1782 throw new TypeErrorImplementation.fromMessage(dart.as(message, core.String))
; | |
| 1783 } | |
| 1784 // Function checkDeferredIsLoaded: (String, String) → void | |
| 1785 function checkDeferredIsLoaded(loadId, uri) { | |
| 1786 if (!dart.notNull(exports._loadedLibraries.contains(loadId))) { | |
| 1787 throw new DeferredNotLoadedError(uri); | |
| 1788 } | |
| 1789 } | |
| 1790 class JavaScriptIndexingBehavior extends _interceptors.JSMutableIndexable { | |
| 1791 } | |
| 1792 class TypeErrorImplementation extends core.Error { | |
| 1793 TypeErrorImplementation(value, type) { | |
| 1794 this.message = `type '${Primitives.objectTypeName(value)}' is not a subtyp
e ` + `of type '${type}'`; | |
| 1795 super.Error(); | |
| 1796 } | |
| 1797 TypeErrorImplementation$fromMessage(message) { | |
| 1798 this.message = message; | |
| 1799 super.Error(); | |
| 1800 } | |
| 1801 toString() { | |
| 1802 return this.message; | |
| 1803 } | |
| 1804 } | |
| 1805 dart.defineNamedConstructor(TypeErrorImplementation, 'fromMessage'); | |
| 1806 class CastErrorImplementation extends core.Error { | |
| 1807 CastErrorImplementation(actualType, expectedType) { | |
| 1808 this.message = `CastError: Casting value of type ${actualType} to` + ` inc
ompatible type ${expectedType}`; | |
| 1809 super.Error(); | |
| 1810 } | |
| 1811 toString() { | |
| 1812 return this.message; | |
| 1813 } | |
| 1814 } | |
| 1815 class FallThroughErrorImplementation extends core.FallThroughError { | |
| 1816 FallThroughErrorImplementation() { | |
| 1817 super.FallThroughError(); | |
| 1818 } | |
| 1819 toString() { | |
| 1820 return "Switch case fall-through."; | |
| 1821 } | |
| 1822 } | |
| 1823 // Function assertHelper: (dynamic) → void | |
| 1824 function assertHelper(condition) { | |
| 1825 if (!(typeof condition == boolean)) { | |
| 1826 if (dart.is(condition, core.Function)) | |
| 1827 condition = dart.dinvokef(condition); | |
| 1828 if (!(typeof condition == boolean)) { | |
| 1829 throw new TypeErrorImplementation(condition, 'bool'); | |
| 1830 } | |
| 1831 } | |
| 1832 if (true !== condition) | |
| 1833 throw new core.AssertionError(); | |
| 1834 } | |
| 1835 // Function throwNoSuchMethod: (dynamic, dynamic, dynamic, dynamic) → void | |
| 1836 function throwNoSuchMethod(obj, name, arguments, expectedArgumentNames) { | |
| 1837 let memberName = new _internal.Symbol.unvalidated(dart.as(name, core.String)
); | |
| 1838 throw new core.NoSuchMethodError(obj, memberName, dart.as(arguments, core.Li
st), new core.Map(), dart.as(expectedArgumentNames, core.List)); | |
| 1839 } | |
| 1840 // Function throwCyclicInit: (String) → void | |
| 1841 function throwCyclicInit(staticName) { | |
| 1842 throw new core.CyclicInitializationError(`Cyclic initialization for static $
{staticName}`); | |
| 1843 } | |
| 1844 class RuntimeError extends core.Error { | |
| 1845 RuntimeError(message) { | |
| 1846 this.message = message; | |
| 1847 super.Error(); | |
| 1848 } | |
| 1849 toString() { | |
| 1850 return `RuntimeError: ${this.message}`; | |
| 1851 } | |
| 1852 } | |
| 1853 class DeferredNotLoadedError extends core.Error { | |
| 1854 DeferredNotLoadedError(libraryName) { | |
| 1855 this.libraryName = libraryName; | |
| 1856 super.Error(); | |
| 1857 } | |
| 1858 toString() { | |
| 1859 return `Deferred library ${this.libraryName} was not loaded.`; | |
| 1860 } | |
| 1861 } | |
| 1862 class RuntimeType extends dart.Object { | |
| 1863 RuntimeType() { | |
| 1864 } | |
| 1865 } | |
| 1866 class RuntimeFunctionType extends RuntimeType { | |
| 1867 RuntimeFunctionType(returnType, parameterTypes, optionalParameterTypes, name
dParameters) { | |
| 1868 this.returnType = returnType; | |
| 1869 this.parameterTypes = parameterTypes; | |
| 1870 this.optionalParameterTypes = optionalParameterTypes; | |
| 1871 this.namedParameters = namedParameters; | |
| 1872 super.RuntimeType(); | |
| 1873 } | |
| 1874 get isVoid() { | |
| 1875 return dart.is(this.returnType, VoidRuntimeType); | |
| 1876 } | |
| 1877 _isTest(expression) { | |
| 1878 let functionTypeObject = this._extractFunctionTypeObjectFrom(expression); | |
| 1879 return functionTypeObject === null ? false : isFunctionSubtype(functionTyp
eObject, this.toRti()); | |
| 1880 } | |
| 1881 _asCheck(expression) { | |
| 1882 return this._check(expression, true); | |
| 1883 } | |
| 1884 _assertCheck(expression) { | |
| 1885 if (inAssert) | |
| 1886 return null; | |
| 1887 inAssert = true; | |
| 1888 try { | |
| 1889 return this._check(expression, false); | |
| 1890 } finally { | |
| 1891 inAssert = false; | |
| 1892 } | |
| 1893 } | |
| 1894 _check(expression, isCast) { | |
| 1895 if (expression === null) | |
| 1896 return null; | |
| 1897 if (this._isTest(expression)) | |
| 1898 return expression; | |
| 1899 let self = new FunctionTypeInfoDecoderRing(this.toRti()).toString(); | |
| 1900 if (isCast) { | |
| 1901 let functionTypeObject = this._extractFunctionTypeObjectFrom(expression)
; | |
| 1902 let pretty = null; | |
| 1903 if (functionTypeObject !== null) { | |
| 1904 pretty = new FunctionTypeInfoDecoderRing(functionTypeObject).toString(
); | |
| 1905 } else { | |
| 1906 pretty = Primitives.objectTypeName(expression); | |
| 1907 } | |
| 1908 throw new CastErrorImplementation(pretty, self); | |
| 1909 } else { | |
| 1910 throw new TypeErrorImplementation(expression, self); | |
| 1911 } | |
| 1912 } | |
| 1913 _extractFunctionTypeObjectFrom(o) { | |
| 1914 let interceptor = _interceptors.getInterceptor(o); | |
| 1915 return _foreign_helper.JS_SIGNATURE_NAME() in interceptor ? interceptor[_f
oreign_helper.JS_SIGNATURE_NAME()]() : null; | |
| 1916 } | |
| 1917 toRti() { | |
| 1918 let result = {[_foreign_helper.JS_FUNCTION_TYPE_TAG()]: "dynafunc"}; | |
| 1919 if (this.isVoid) { | |
| 1920 result[_foreign_helper.JS_FUNCTION_TYPE_VOID_RETURN_TAG()] = true; | |
| 1921 } else { | |
| 1922 if (!dart.is(this.returnType, DynamicRuntimeType)) { | |
| 1923 result[_foreign_helper.JS_FUNCTION_TYPE_RETURN_TYPE_TAG()] = this.retu
rnType.toRti(); | |
| 1924 } | |
| 1925 } | |
| 1926 if (dart.notNull(this.parameterTypes !== null) && dart.notNull(!dart.notNu
ll(this.parameterTypes.isEmpty))) { | |
| 1927 result[_foreign_helper.JS_FUNCTION_TYPE_REQUIRED_PARAMETERS_TAG()] = lis
tToRti(this.parameterTypes); | |
| 1928 } | |
| 1929 if (dart.notNull(this.optionalParameterTypes !== null) && dart.notNull(!da
rt.notNull(this.optionalParameterTypes.isEmpty))) { | |
| 1930 result[_foreign_helper.JS_FUNCTION_TYPE_OPTIONAL_PARAMETERS_TAG()] = lis
tToRti(this.optionalParameterTypes); | |
| 1931 } | |
| 1932 if (this.namedParameters !== null) { | |
| 1933 let namedRti = Object.create(null); | |
| 1934 let keys = _js_names.extractKeys(this.namedParameters); | |
| 1935 for (let i = 0; i < keys.length; i++) { | |
| 1936 let name = keys.get(i); | |
| 1937 let rti = dart.dinvoke(this.namedParameters[name], 'toRti'); | |
| 1938 namedRti[name] = rti; | |
| 1939 } | |
| 1940 result[_foreign_helper.JS_FUNCTION_TYPE_NAMED_PARAMETERS_TAG()] = namedR
ti; | |
| 1941 } | |
| 1942 return result; | |
| 1943 } | |
| 1944 static listToRti(list) { | |
| 1945 list = list; | |
| 1946 let result = []; | |
| 1947 for (let i = 0; i['<'](dart.dload(list, 'length')); i++) { | |
| 1948 result.push(dart.dinvoke(dart.dindex(list, i), 'toRti')); | |
| 1949 } | |
| 1950 return result; | |
| 1951 } | |
| 1952 toString() { | |
| 1953 let result = '('; | |
| 1954 let needsComma = false; | |
| 1955 if (this.parameterTypes !== null) { | |
| 1956 for (let i = 0; i < this.parameterTypes.length; i++) { | |
| 1957 let type = this.parameterTypes.get(i); | |
| 1958 if (needsComma) | |
| 1959 result = ', '; | |
| 1960 result = `${type}`; | |
| 1961 needsComma = true; | |
| 1962 } | |
| 1963 } | |
| 1964 if (dart.notNull(this.optionalParameterTypes !== null) && dart.notNull(!da
rt.notNull(this.optionalParameterTypes.isEmpty))) { | |
| 1965 if (needsComma) | |
| 1966 result = ', '; | |
| 1967 needsComma = false; | |
| 1968 result = '['; | |
| 1969 for (let i = 0; i < this.optionalParameterTypes.length; i++) { | |
| 1970 let type = this.optionalParameterTypes.get(i); | |
| 1971 if (needsComma) | |
| 1972 result = ', '; | |
| 1973 result = `${type}`; | |
| 1974 needsComma = true; | |
| 1975 } | |
| 1976 result = ']'; | |
| 1977 } else if (this.namedParameters !== null) { | |
| 1978 if (needsComma) | |
| 1979 result = ', '; | |
| 1980 needsComma = false; | |
| 1981 result = '{'; | |
| 1982 let keys = _js_names.extractKeys(this.namedParameters); | |
| 1983 for (let i = 0; i < keys.length; i++) { | |
| 1984 let name = keys.get(i); | |
| 1985 if (needsComma) | |
| 1986 result = ', '; | |
| 1987 let rti = dart.dinvoke(this.namedParameters[name], 'toRti'); | |
| 1988 result = `${rti} ${name}`; | |
| 1989 needsComma = true; | |
| 1990 } | |
| 1991 result = '}'; | |
| 1992 } | |
| 1993 result = `) -> ${this.returnType}`; | |
| 1994 return result; | |
| 1995 } | |
| 1996 } | |
| 1997 RuntimeFunctionType.inAssert = false; | |
| 1998 // Function buildFunctionType: (dynamic, dynamic, dynamic) → RuntimeFunctionTy
pe | |
| 1999 function buildFunctionType(returnType, parameterTypes, optionalParameterTypes)
{ | |
| 2000 return new RuntimeFunctionType(dart.as(returnType, RuntimeType), dart.as(par
ameterTypes, core.List$(RuntimeType)), dart.as(optionalParameterTypes, core.List
$(RuntimeType)), null); | |
| 2001 } | |
| 2002 // Function buildNamedFunctionType: (dynamic, dynamic, dynamic) → RuntimeFunct
ionType | |
| 2003 function buildNamedFunctionType(returnType, parameterTypes, namedParameters) { | |
| 2004 return new RuntimeFunctionType(dart.as(returnType, RuntimeType), dart.as(par
ameterTypes, core.List$(RuntimeType)), null, namedParameters); | |
| 2005 } | |
| 2006 // Function buildInterfaceType: (dynamic, dynamic) → RuntimeType | |
| 2007 function buildInterfaceType(rti, typeArguments) { | |
| 2008 let name = dart.as(rti.name, core.String); | |
| 2009 if (core.bool['||'](typeArguments === null, dart.dload(typeArguments, 'isEmp
ty'))) { | |
| 2010 return new RuntimeTypePlain(name); | |
| 2011 } | |
| 2012 return new RuntimeTypeGeneric(name, dart.as(typeArguments, core.List$(Runtim
eType)), null); | |
| 2013 } | |
| 2014 class DynamicRuntimeType extends RuntimeType { | |
| 2015 DynamicRuntimeType() { | |
| 2016 super.RuntimeType(); | |
| 2017 } | |
| 2018 toString() { | |
| 2019 return 'dynamic'; | |
| 2020 } | |
| 2021 toRti() { | |
| 2022 return null; | |
| 2023 } | |
| 2024 } | |
| 2025 // Function getDynamicRuntimeType: () → RuntimeType | |
| 2026 function getDynamicRuntimeType() { | |
| 2027 return new DynamicRuntimeType(); | |
| 2028 } | |
| 2029 class VoidRuntimeType extends RuntimeType { | |
| 2030 VoidRuntimeType() { | |
| 2031 super.RuntimeType(); | |
| 2032 } | |
| 2033 toString() { | |
| 2034 return 'void'; | |
| 2035 } | |
| 2036 toRti() { | |
| 2037 return dart.throw_('internal error'); | |
| 2038 } | |
| 2039 } | |
| 2040 // Function getVoidRuntimeType: () → RuntimeType | |
| 2041 function getVoidRuntimeType() { | |
| 2042 return new VoidRuntimeType(); | |
| 2043 } | |
| 2044 // Function functionTypeTestMetaHelper: () → dynamic | |
| 2045 function functionTypeTestMetaHelper() { | |
| 2046 let dyn = x; | |
| 2047 let dyn2 = x; | |
| 2048 let fixedListOrNull = dart.as(x, core.List); | |
| 2049 let fixedListOrNull2 = dart.as(x, core.List); | |
| 2050 let fixedList = dart.as(x, core.List); | |
| 2051 let jsObject = x; | |
| 2052 buildFunctionType(dyn, fixedListOrNull, fixedListOrNull2); | |
| 2053 buildNamedFunctionType(dyn, fixedList, jsObject); | |
| 2054 buildInterfaceType(dyn, fixedListOrNull); | |
| 2055 getDynamicRuntimeType(); | |
| 2056 getVoidRuntimeType(); | |
| 2057 convertRtiToRuntimeType(dyn); | |
| 2058 dart.dinvoke(dyn, '_isTest', dyn2); | |
| 2059 dart.dinvoke(dyn, '_asCheck', dyn2); | |
| 2060 dart.dinvoke(dyn, '_assertCheck', dyn2); | |
| 2061 } | |
| 2062 // Function convertRtiToRuntimeType: (dynamic) → RuntimeType | |
| 2063 function convertRtiToRuntimeType(rti) { | |
| 2064 if (rti === null) { | |
| 2065 return getDynamicRuntimeType(); | |
| 2066 } else if (typeof rti == "function") { | |
| 2067 return new RuntimeTypePlain(rti.name); | |
| 2068 } else if (rti.constructor == Array) { | |
| 2069 let list = dart.as(rti, core.List); | |
| 2070 let name = list.get(0).name; | |
| 2071 let arguments = new List.from([]); | |
| 2072 for (let i = 1; i < list.length; i++) { | |
| 2073 arguments.add(convertRtiToRuntimeType(list.get(i))); | |
| 2074 } | |
| 2075 return new RuntimeTypeGeneric(name, dart.as(arguments, core.List$(RuntimeT
ype)), rti); | |
| 2076 } else if ("func" in rti) { | |
| 2077 return new FunctionTypeInfoDecoderRing(rti).toRuntimeType(); | |
| 2078 } else { | |
| 2079 throw new RuntimeError("Cannot convert " + `'${JSON.stringify(rti)}' to Ru
ntimeType.`); | |
| 2080 } | |
| 2081 } | |
| 2082 class RuntimeTypePlain extends RuntimeType { | |
| 2083 RuntimeTypePlain(name) { | |
| 2084 this.name = name; | |
| 2085 super.RuntimeType(); | |
| 2086 } | |
| 2087 toRti() { | |
| 2088 let allClasses = _foreign_helper.JS_EMBEDDED_GLOBAL('', dart.as(_js_embedd
ed_names.ALL_CLASSES, core.String)); | |
| 2089 let rti = allClasses[this.name]; | |
| 2090 if (rti === null) | |
| 2091 throw `no type for '${this.name}'`; | |
| 2092 return rti; | |
| 2093 } | |
| 2094 toString() { | |
| 2095 return this.name; | |
| 2096 } | |
| 2097 } | |
| 2098 class RuntimeTypeGeneric extends RuntimeType { | |
| 2099 RuntimeTypeGeneric(name, arguments, rti) { | |
| 2100 this.name = name; | |
| 2101 this.arguments = arguments; | |
| 2102 this.rti = rti; | |
| 2103 super.RuntimeType(); | |
| 2104 } | |
| 2105 toRti() { | |
| 2106 if (this.rti !== null) | |
| 2107 return this.rti; | |
| 2108 let allClasses = _foreign_helper.JS_EMBEDDED_GLOBAL('', dart.as(_js_embedd
ed_names.ALL_CLASSES, core.String)); | |
| 2109 let result = [allClasses[this.name]]; | |
| 2110 if (dart.dindex(result, 0) === null) { | |
| 2111 throw `no type for '${this.name}<...>'`; | |
| 2112 } | |
| 2113 for (let argument of this.arguments) { | |
| 2114 result.push(argument.toRti()); | |
| 2115 } | |
| 2116 return this.rti = result; | |
| 2117 } | |
| 2118 toString() { | |
| 2119 return `${this.name}<${this.arguments.join(", ")}>`; | |
| 2120 } | |
| 2121 } | |
| 2122 class FunctionTypeInfoDecoderRing extends dart.Object { | |
| 2123 FunctionTypeInfoDecoderRing(_typeData) { | |
| 2124 this._typeData = _typeData; | |
| 2125 this._cachedToString = null; | |
| 2126 } | |
| 2127 get _hasReturnType() { | |
| 2128 return "ret" in this._typeData; | |
| 2129 } | |
| 2130 get _returnType() { | |
| 2131 return this._typeData.ret; | |
| 2132 } | |
| 2133 get _isVoid() { | |
| 2134 return !!this._typeData["void"]; | |
| 2135 } | |
| 2136 get _hasArguments() { | |
| 2137 return "args" in this._typeData; | |
| 2138 } | |
| 2139 get _arguments() { | |
| 2140 return dart.as(this._typeData.args, core.List); | |
| 2141 } | |
| 2142 get _hasOptionalArguments() { | |
| 2143 return "opt" in this._typeData; | |
| 2144 } | |
| 2145 get _optionalArguments() { | |
| 2146 return dart.as(this._typeData.opt, core.List); | |
| 2147 } | |
| 2148 get _hasNamedArguments() { | |
| 2149 return "named" in this._typeData; | |
| 2150 } | |
| 2151 get _namedArguments() { | |
| 2152 return this._typeData.named; | |
| 2153 } | |
| 2154 toRuntimeType() { | |
| 2155 return new DynamicRuntimeType(); | |
| 2156 } | |
| 2157 _convert(type) { | |
| 2158 let result = runtimeTypeToString(type); | |
| 2159 if (result !== null) | |
| 2160 return result; | |
| 2161 if ("func" in type) { | |
| 2162 return new FunctionTypeInfoDecoderRing(type).toString(); | |
| 2163 } else { | |
| 2164 throw 'bad type'; | |
| 2165 } | |
| 2166 } | |
| 2167 toString() { | |
| 2168 if (this._cachedToString !== null) | |
| 2169 return this._cachedToString; | |
| 2170 let s = "("; | |
| 2171 let sep = ''; | |
| 2172 if (this._hasArguments) { | |
| 2173 for (let argument of this._arguments) { | |
| 2174 s = sep; | |
| 2175 s = this._convert(argument); | |
| 2176 sep = ', '; | |
| 2177 } | |
| 2178 } | |
| 2179 if (this._hasOptionalArguments) { | |
| 2180 s = `${sep}[`; | |
| 2181 sep = ''; | |
| 2182 for (let argument of this._optionalArguments) { | |
| 2183 s = sep; | |
| 2184 s = this._convert(argument); | |
| 2185 sep = ', '; | |
| 2186 } | |
| 2187 s = ']'; | |
| 2188 } | |
| 2189 if (this._hasNamedArguments) { | |
| 2190 s = `${sep}{`; | |
| 2191 sep = ''; | |
| 2192 for (let name of _js_names.extractKeys(this._namedArguments)) { | |
| 2193 s = sep; | |
| 2194 s = `${name}: `; | |
| 2195 s = this._convert(this._namedArguments[name]); | |
| 2196 sep = ', '; | |
| 2197 } | |
| 2198 s = '}'; | |
| 2199 } | |
| 2200 s = ') -> '; | |
| 2201 if (this._isVoid) { | |
| 2202 s = 'void'; | |
| 2203 } else if (this._hasReturnType) { | |
| 2204 s = this._convert(this._returnType); | |
| 2205 } else { | |
| 2206 s = 'dynamic'; | |
| 2207 } | |
| 2208 return this._cachedToString = `${s}`; | |
| 2209 } | |
| 2210 } | |
| 2211 class UnimplementedNoSuchMethodError extends core.Error { | |
| 2212 UnimplementedNoSuchMethodError(_message) { | |
| 2213 this._message = _message; | |
| 2214 super.Error(); | |
| 2215 } | |
| 2216 toString() { | |
| 2217 return `Unsupported operation: ${this._message}`; | |
| 2218 } | |
| 2219 } | |
| 2220 // Function random64: () → int | |
| 2221 function random64() { | |
| 2222 let int32a = Math.random() * 0x100000000 >>> 0; | |
| 2223 let int32b = Math.random() * 0x100000000 >>> 0; | |
| 2224 return int32a + int32b * 4294967296; | |
| 2225 } | |
| 2226 // Function jsonEncodeNative: (String) → String | |
| 2227 function jsonEncodeNative(string) { | |
| 2228 return JSON.stringify(string); | |
| 2229 } | |
| 2230 // Function getIsolateAffinityTag: (String) → String | |
| 2231 function getIsolateAffinityTag(name) { | |
| 2232 let isolateTagGetter = _foreign_helper.JS_EMBEDDED_GLOBAL('', dart.as(_js_em
bedded_names.GET_ISOLATE_TAG, core.String)); | |
| 2233 return isolateTagGetter(name); | |
| 2234 } | |
| 2235 // Function _loadLibraryWrapper: (String) → () → Future<Null> | |
| 2236 function _loadLibraryWrapper(loadId) { | |
| 2237 return () => loadDeferredLibrary(loadId); | |
| 2238 } | |
| 2239 dart.defineLazyProperties(exports, { | |
| 2240 get _loadingLibraries() { | |
| 2241 return dart.map(); | |
| 2242 }, | |
| 2243 get _loadedLibraries() { | |
| 2244 return new core.Set(); | |
| 2245 } | |
| 2246 }); | |
| 2247 exports.deferredLoadHook = null; | |
| 2248 // Function loadDeferredLibrary: (String) → Future<Null> | |
| 2249 function loadDeferredLibrary(loadId) { | |
| 2250 let urisMap = _foreign_helper.JS_EMBEDDED_GLOBAL('', dart.as(_js_embedded_na
mes.DEFERRED_LIBRARY_URIS, core.String)); | |
| 2251 let uris = dart.as(urisMap[loadId], core.List$(core.String)); | |
| 2252 let hashesMap = _foreign_helper.JS_EMBEDDED_GLOBAL('', dart.as(_js_embedded_
names.DEFERRED_LIBRARY_HASHES, core.String)); | |
| 2253 let hashes = dart.as(hashesMap[loadId], core.List$(core.String)); | |
| 2254 if (uris === null) | |
| 2255 return dart.as(new async.Future.value(null), async.Future$(core.Null)); | |
| 2256 let indices = dart.as(new core.List.generate(uris.length, (i) => i), core.Li
st$(core.int)); | |
| 2257 let isHunkLoaded = _foreign_helper.JS_EMBEDDED_GLOBAL('', dart.as(_js_embedd
ed_names.IS_HUNK_LOADED, core.String)); | |
| 2258 let isHunkInitialized = _foreign_helper.JS_EMBEDDED_GLOBAL('', dart.as(_js_e
mbedded_names.IS_HUNK_INITIALIZED, core.String)); | |
| 2259 let indicesToLoad = indices.where((i) => !dart.notNull(isHunkLoaded(hashes.g
et(i)))).toList(); | |
| 2260 return dart.as(async.Future.wait(dart.as(indicesToLoad.map((i) => _loadHunk(
uris.get(i))), core.Iterable$(async.Future))).then((_) => { | |
| 2261 let indicesToInitialize = indices.where((i) => !dart.notNull(isHunkInitial
ized(hashes.get(i)))).toList(); | |
| 2262 for (let i of indicesToInitialize) { | |
| 2263 let initializer = _foreign_helper.JS_EMBEDDED_GLOBAL('', dart.as(_js_emb
edded_names.INITIALIZE_LOADED_HUNK, core.String)); | |
| 2264 initializer(hashes.get(i)); | |
| 2265 } | |
| 2266 let updated = exports._loadedLibraries.add(loadId); | |
| 2267 if (dart.notNull(updated) && dart.notNull(exports.deferredLoadHook !== nul
l)) { | |
| 2268 exports.deferredLoadHook(); | |
| 2269 } | |
| 2270 }), async.Future$(core.Null)); | |
| 2271 } | |
| 2272 // Function _loadHunk: (String) → Future<Null> | |
| 2273 function _loadHunk(hunkName) { | |
| 2274 let future = exports._loadingLibraries.get(hunkName); | |
| 2275 if (future !== null) { | |
| 2276 return dart.as(future.then((_) => null), async.Future$(core.Null)); | |
| 2277 } | |
| 2278 let uri = _isolate_helper.IsolateNatives.thisScript; | |
| 2279 let index = uri.lastIndexOf('/'); | |
| 2280 uri = `${uri.substring(0, index + 1)}${hunkName}`; | |
| 2281 if (dart.notNull(Primitives.isJsshell) || dart.notNull(Primitives.isD8)) { | |
| 2282 return exports._loadingLibraries.set(hunkName, new async.Future(() => { | |
| 2283 try { | |
| 2284 new Function(`load("${uri}")`)(); | |
| 2285 } catch (error) { | |
| 2286 let stackTrace = dart.stackTrace(error); | |
| 2287 throw new async.DeferredLoadException(`Loading ${uri} failed.`); | |
| 2288 } | |
| 2289 | |
| 2290 return null; | |
| 2291 })); | |
| 2292 } else if (_isolate_helper.isWorker()) { | |
| 2293 return exports._loadingLibraries.set(hunkName, new async.Future(() => { | |
| 2294 let completer = new async.Completer(); | |
| 2295 _isolate_helper.enterJsAsync(); | |
| 2296 let leavingFuture = dart.as(completer.future.whenComplete(() => { | |
| 2297 _isolate_helper.leaveJsAsync(); | |
| 2298 }), async.Future$(core.Null)); | |
| 2299 let index = uri.lastIndexOf('/'); | |
| 2300 uri = `${uri.substring(0, index + 1)}${hunkName}`; | |
| 2301 let xhr = new XMLHttpRequest(); | |
| 2302 xhr.open("GET", uri); | |
| 2303 xhr.addEventListener("load", convertDartClosureToJS((event) => { | |
| 2304 if (xhr.status !== 200) { | |
| 2305 completer.completeError(new async.DeferredLoadException(`Loading ${u
ri} failed.`)); | |
| 2306 return; | |
| 2307 } | |
| 2308 let code = xhr.responseText; | |
| 2309 try { | |
| 2310 new Function(code)(); | |
| 2311 } catch (error) { | |
| 2312 let stackTrace = dart.stackTrace(error); | |
| 2313 completer.completeError(new async.DeferredLoadException(`Evaluating
${uri} failed.`)); | |
| 2314 return; | |
| 2315 } | |
| 2316 | |
| 2317 completer.complete(null); | |
| 2318 }, 1), false); | |
| 2319 let fail = convertDartClosureToJS((event) => { | |
| 2320 new async.DeferredLoadException(`Loading ${uri} failed.`); | |
| 2321 }, 1); | |
| 2322 xhr.addEventListener("error", fail, false); | |
| 2323 xhr.addEventListener("abort", fail, false); | |
| 2324 xhr.send(); | |
| 2325 return leavingFuture; | |
| 2326 })); | |
| 2327 } | |
| 2328 return exports._loadingLibraries.set(hunkName, new async.Future(() => { | |
| 2329 let completer = new async.Completer(); | |
| 2330 let script = document.createElement("script"); | |
| 2331 script.type = "text/javascript"; | |
| 2332 script.src = uri; | |
| 2333 script.addEventListener("load", convertDartClosureToJS((event) => { | |
| 2334 completer.complete(null); | |
| 2335 }, 1), false); | |
| 2336 script.addEventListener("error", convertDartClosureToJS((event) => { | |
| 2337 completer.completeError(new async.DeferredLoadException(`Loading ${uri}
failed.`)); | |
| 2338 }, 1), false); | |
| 2339 document.body.appendChild(script); | |
| 2340 return completer.future; | |
| 2341 })); | |
| 2342 } | |
| 2343 class MainError extends core.Error { | |
| 2344 MainError(_message) { | |
| 2345 this._message = _message; | |
| 2346 super.Error(); | |
| 2347 } | |
| 2348 toString() { | |
| 2349 return `NoSuchMethodError: ${this._message}`; | |
| 2350 } | |
| 2351 } | |
| 2352 // Function missingMain: () → void | |
| 2353 function missingMain() { | |
| 2354 throw new MainError("No top-level function named 'main'."); | |
| 2355 } | |
| 2356 // Function badMain: () → void | |
| 2357 function badMain() { | |
| 2358 throw new MainError("'main' is not a function."); | |
| 2359 } | |
| 2360 // Function mainHasTooManyParameters: () → void | |
| 2361 function mainHasTooManyParameters() { | |
| 2362 throw new MainError("'main' expects too many parameters."); | |
| 2363 } | |
| 2364 class NoSideEffects extends dart.Object { | |
| 2365 NoSideEffects() { | |
| 2366 } | |
| 2367 } | |
| 2368 class NoThrows extends dart.Object { | |
| 2369 NoThrows() { | |
| 2370 } | |
| 2371 } | |
| 2372 class NoInline extends dart.Object { | |
| 2373 NoInline() { | |
| 2374 } | |
| 2375 } | |
| 2376 class IrRepresentation extends dart.Object { | |
| 2377 IrRepresentation(value) { | |
| 2378 this.value = value; | |
| 2379 } | |
| 2380 } | |
| 2381 class Native extends dart.Object { | |
| 2382 Native(name) { | |
| 2383 this.name = name; | |
| 2384 } | |
| 2385 } | |
| 2386 let ConstantMap$ = dart.generic(function(K, V) { | |
| 2387 class ConstantMap extends dart.Object { | |
| 2388 ConstantMap$_() { | |
| 2389 } | |
| 2390 get isEmpty() { | |
| 2391 return this.length === 0; | |
| 2392 } | |
| 2393 get isNotEmpty() { | |
| 2394 return !dart.notNull(this.isEmpty); | |
| 2395 } | |
| 2396 toString() { | |
| 2397 return collection.Maps.mapToString(this); | |
| 2398 } | |
| 2399 _throwUnmodifiable() { | |
| 2400 throw new core.UnsupportedError("Cannot modify unmodifiable Map"); | |
| 2401 } | |
| 2402 set(key, val) { | |
| 2403 return this._throwUnmodifiable(); | |
| 2404 } | |
| 2405 putIfAbsent(key, ifAbsent) { | |
| 2406 return dart.as(this._throwUnmodifiable(), V); | |
| 2407 } | |
| 2408 remove(key) { | |
| 2409 return dart.as(this._throwUnmodifiable(), V); | |
| 2410 } | |
| 2411 clear() { | |
| 2412 return this._throwUnmodifiable(); | |
| 2413 } | |
| 2414 addAll(other) { | |
| 2415 return this._throwUnmodifiable(); | |
| 2416 } | |
| 2417 } | |
| 2418 dart.defineNamedConstructor(ConstantMap, '_'); | |
| 2419 return ConstantMap; | |
| 2420 }); | |
| 2421 let ConstantMap = ConstantMap$(dynamic, dynamic); | |
| 2422 let ConstantStringMap$ = dart.generic(function(K, V) { | |
| 2423 class ConstantStringMap extends ConstantMap$(K, V) { | |
| 2424 ConstantStringMap$_(length, _jsObject, _keys) { | |
| 2425 this.length = length; | |
| 2426 this._jsObject = _jsObject; | |
| 2427 this._keys = _keys; | |
| 2428 super.ConstantMap$_(); | |
| 2429 } | |
| 2430 containsValue(needle) { | |
| 2431 return this.values.any((value) => dart.equals(value, needle)); | |
| 2432 } | |
| 2433 containsKey(key) { | |
| 2434 if (!(typeof key == string)) | |
| 2435 return false; | |
| 2436 if (dart.equals('__proto__', key)) | |
| 2437 return false; | |
| 2438 return jsHasOwnProperty(this._jsObject, dart.as(key, core.String)); | |
| 2439 } | |
| 2440 get(key) { | |
| 2441 if (!dart.notNull(this.containsKey(key))) | |
| 2442 return dart.as(null, V); | |
| 2443 return dart.as(this._fetch(key), V); | |
| 2444 } | |
| 2445 _fetch(key) { | |
| 2446 return jsPropertyAccess(this._jsObject, dart.as(key, core.String)); | |
| 2447 } | |
| 2448 forEach(f) { | |
| 2449 let keys = this._keys; | |
| 2450 for (let i = 0; i['<'](dart.dload(keys, 'length')); i++) { | |
| 2451 let key = dart.dindex(keys, i); | |
| 2452 f(dart.as(key, K), dart.as(this._fetch(key), V)); | |
| 2453 } | |
| 2454 } | |
| 2455 get keys() { | |
| 2456 return new _ConstantMapKeyIterable(this); | |
| 2457 } | |
| 2458 get values() { | |
| 2459 return new _internal.MappedIterable(this._keys, dart.as(((key) => this._
fetch(key)).bind(this), dart.throw_("Unimplemented type (K) → V"))); | |
| 2460 } | |
| 2461 } | |
| 2462 dart.defineNamedConstructor(ConstantStringMap, '_'); | |
| 2463 return ConstantStringMap; | |
| 2464 }); | |
| 2465 let ConstantStringMap = ConstantStringMap$(dynamic, dynamic); | |
| 2466 let ConstantProtoMap$ = dart.generic(function(K, V) { | |
| 2467 class ConstantProtoMap extends ConstantStringMap$(K, V) { | |
| 2468 ConstantProtoMap$_(length, jsObject, keys, _protoValue) { | |
| 2469 this._protoValue = _protoValue; | |
| 2470 super.ConstantStringMap$_(dart.as(length, core.int), jsObject, dart.as(k
eys, core.List$(K))); | |
| 2471 } | |
| 2472 containsKey(key) { | |
| 2473 if (!(typeof key == string)) | |
| 2474 return false; | |
| 2475 if (dart.equals('__proto__', key)) | |
| 2476 return true; | |
| 2477 return jsHasOwnProperty(this._jsObject, dart.as(key, core.String)); | |
| 2478 } | |
| 2479 _fetch(key) { | |
| 2480 return dart.equals('__proto__', key) ? this._protoValue : jsPropertyAcce
ss(this._jsObject, dart.as(key, core.String)); | |
| 2481 } | |
| 2482 } | |
| 2483 dart.defineNamedConstructor(ConstantProtoMap, '_'); | |
| 2484 return ConstantProtoMap; | |
| 2485 }); | |
| 2486 let ConstantProtoMap = ConstantProtoMap$(dynamic, dynamic); | |
| 2487 let _ConstantMapKeyIterable$ = dart.generic(function(K) { | |
| 2488 class _ConstantMapKeyIterable extends collection.IterableBase$(K) { | |
| 2489 _ConstantMapKeyIterable(_map) { | |
| 2490 this._map = _map; | |
| 2491 super.IterableBase(); | |
| 2492 } | |
| 2493 get iterator() { | |
| 2494 return this._map._keys.iterator; | |
| 2495 } | |
| 2496 get length() { | |
| 2497 return this._map._keys.length; | |
| 2498 } | |
| 2499 } | |
| 2500 return _ConstantMapKeyIterable; | |
| 2501 }); | |
| 2502 let _ConstantMapKeyIterable = _ConstantMapKeyIterable$(dynamic); | |
| 2503 let GeneralConstantMap$ = dart.generic(function(K, V) { | |
| 2504 class GeneralConstantMap extends ConstantMap$(K, V) { | |
| 2505 GeneralConstantMap(_jsData) { | |
| 2506 this._jsData = _jsData; | |
| 2507 super.ConstantMap$_(); | |
| 2508 } | |
| 2509 _getMap() { | |
| 2510 if (!this.$map) { | |
| 2511 let backingMap = new collection.LinkedHashMap(); | |
| 2512 this.$map = fillLiteralMap(this._jsData, backingMap); | |
| 2513 } | |
| 2514 return this.$map; | |
| 2515 } | |
| 2516 containsValue(needle) { | |
| 2517 return this._getMap().containsValue(needle); | |
| 2518 } | |
| 2519 containsKey(key) { | |
| 2520 return this._getMap().containsKey(key); | |
| 2521 } | |
| 2522 get(key) { | |
| 2523 return this._getMap().get(key); | |
| 2524 } | |
| 2525 forEach(f) { | |
| 2526 this._getMap().forEach(f); | |
| 2527 } | |
| 2528 get keys() { | |
| 2529 return this._getMap().keys; | |
| 2530 } | |
| 2531 get values() { | |
| 2532 return this._getMap().values; | |
| 2533 } | |
| 2534 get length() { | |
| 2535 return this._getMap().length; | |
| 2536 } | |
| 2537 } | |
| 2538 return GeneralConstantMap; | |
| 2539 }); | |
| 2540 let GeneralConstantMap = GeneralConstantMap$(dynamic, dynamic); | |
| 2541 // Function contains: (String, String) → bool | |
| 2542 function contains(userAgent, name) { | |
| 2543 return userAgent.indexOf(name) !== -1; | |
| 2544 } | |
| 2545 // Function arrayLength: (List<dynamic>) → int | |
| 2546 function arrayLength(array) { | |
| 2547 return array.length; | |
| 2548 } | |
| 2549 // Function arrayGet: (List<dynamic>, int) → dynamic | |
| 2550 function arrayGet(array, index) { | |
| 2551 return array[index]; | |
| 2552 } | |
| 2553 // Function arraySet: (List<dynamic>, int, dynamic) → void | |
| 2554 function arraySet(array, index, value) { | |
| 2555 array[index] = value; | |
| 2556 } | |
| 2557 // Function propertyGet: (dynamic, String) → dynamic | |
| 2558 function propertyGet(object, property) { | |
| 2559 return object[property]; | |
| 2560 } | |
| 2561 // Function callHasOwnProperty: (dynamic, dynamic, String) → bool | |
| 2562 function callHasOwnProperty(function, object, property) { | |
| 2563 return function.call(object, property); | |
| 2564 } | |
| 2565 // Function propertySet: (dynamic, String, dynamic) → void | |
| 2566 function propertySet(object, property, value) { | |
| 2567 object[property] = value; | |
| 2568 } | |
| 2569 // Function getPropertyFromPrototype: (dynamic, String) → dynamic | |
| 2570 function getPropertyFromPrototype(object, name) { | |
| 2571 return Object.getPrototypeOf(object)[name]; | |
| 2572 } | |
| 2573 exports.getTagFunction = null; | |
| 2574 exports.alternateTagFunction = null; | |
| 2575 exports.prototypeForTagFunction = null; | |
| 2576 // Function toStringForNativeObject: (dynamic) → String | |
| 2577 function toStringForNativeObject(obj) { | |
| 2578 let name = exports.getTagFunction === null ? '<Unknown>' : dart.dinvokef(exp
orts.getTagFunction, obj); | |
| 2579 return `Instance of ${name}`; | |
| 2580 } | |
| 2581 // Function hashCodeForNativeObject: (dynamic) → int | |
| 2582 function hashCodeForNativeObject(object) { | |
| 2583 return Primitives.objectHashCode(object); | |
| 2584 } | |
| 2585 // Function defineProperty: (dynamic, String, dynamic) → void | |
| 2586 function defineProperty(obj, property, value) { | |
| 2587 Object.defineProperty(obj, property, {value: value, enumerable: false, writa
ble: true, configurable: true}); | |
| 2588 } | |
| 2589 // Function isDartObject: (dynamic) → bool | |
| 2590 function isDartObject(obj) { | |
| 2591 return obj instanceof _foreign_helper.JS_DART_OBJECT_CONSTRUCTOR(); | |
| 2592 } | |
| 2593 dart.copyProperties(exports, { | |
| 2594 get interceptorsByTag() { | |
| 2595 return _foreign_helper.JS_EMBEDDED_GLOBAL('=Object', dart.as(_js_embedded_
names.INTERCEPTORS_BY_TAG, core.String)); | |
| 2596 }, | |
| 2597 get leafTags() { | |
| 2598 return _foreign_helper.JS_EMBEDDED_GLOBAL('=Object', dart.as(_js_embedded_
names.LEAF_TAGS, core.String)); | |
| 2599 } | |
| 2600 }); | |
| 2601 // Function findDispatchTagForInterceptorClass: (dynamic) → String | |
| 2602 function findDispatchTagForInterceptorClass(interceptorClassConstructor) { | |
| 2603 return dart.as(interceptorClassConstructor[_js_embedded_names.NATIVE_SUPERCL
ASS_TAG_NAME], core.String); | |
| 2604 } | |
| 2605 exports.dispatchRecordsForInstanceTags = null; | |
| 2606 exports.interceptorsForUncacheableTags = null; | |
| 2607 // Function lookupInterceptor: (String) → dynamic | |
| 2608 function lookupInterceptor(tag) { | |
| 2609 return propertyGet(exports.interceptorsByTag, tag); | |
| 2610 } | |
| 2611 let UNCACHED_MARK = '~'; | |
| 2612 let INSTANCE_CACHED_MARK = '!'; | |
| 2613 let LEAF_MARK = '-'; | |
| 2614 let INTERIOR_MARK = '+'; | |
| 2615 let DISCRIMINATED_MARK = '*'; | |
| 2616 // Function lookupAndCacheInterceptor: (dynamic) → dynamic | |
| 2617 function lookupAndCacheInterceptor(obj) { | |
| 2618 dart.assert(!dart.notNull(isDartObject(obj))); | |
| 2619 let tag = dart.as(dart.dinvokef(exports.getTagFunction, obj), core.String); | |
| 2620 let record = propertyGet(exports.dispatchRecordsForInstanceTags, tag); | |
| 2621 if (record !== null) | |
| 2622 return patchInstance(obj, record); | |
| 2623 let interceptor = propertyGet(exports.interceptorsForUncacheableTags, tag); | |
| 2624 if (interceptor !== null) | |
| 2625 return interceptor; | |
| 2626 let interceptorClass = lookupInterceptor(tag); | |
| 2627 if (interceptorClass === null) { | |
| 2628 tag = dart.as(dart.dinvokef(exports.alternateTagFunction, obj, tag), core.
String); | |
| 2629 if (tag !== null) { | |
| 2630 record = propertyGet(exports.dispatchRecordsForInstanceTags, tag); | |
| 2631 if (record !== null) | |
| 2632 return patchInstance(obj, record); | |
| 2633 interceptor = propertyGet(exports.interceptorsForUncacheableTags, tag); | |
| 2634 if (interceptor !== null) | |
| 2635 return interceptor; | |
| 2636 interceptorClass = lookupInterceptor(tag); | |
| 2637 } | |
| 2638 } | |
| 2639 if (interceptorClass === null) { | |
| 2640 return null; | |
| 2641 } | |
| 2642 interceptor = interceptorClass.prototype; | |
| 2643 let mark = tag[0]; | |
| 2644 if (dart.equals(mark, INSTANCE_CACHED_MARK)) { | |
| 2645 record = makeLeafDispatchRecord(interceptor); | |
| 2646 propertySet(exports.dispatchRecordsForInstanceTags, tag, record); | |
| 2647 return patchInstance(obj, record); | |
| 2648 } | |
| 2649 if (dart.equals(mark, UNCACHED_MARK)) { | |
| 2650 propertySet(exports.interceptorsForUncacheableTags, tag, interceptor); | |
| 2651 return interceptor; | |
| 2652 } | |
| 2653 if (dart.equals(mark, LEAF_MARK)) { | |
| 2654 return patchProto(obj, makeLeafDispatchRecord(interceptor)); | |
| 2655 } | |
| 2656 if (dart.equals(mark, INTERIOR_MARK)) { | |
| 2657 return patchInteriorProto(obj, interceptor); | |
| 2658 } | |
| 2659 if (dart.equals(mark, DISCRIMINATED_MARK)) { | |
| 2660 throw new core.UnimplementedError(tag); | |
| 2661 } | |
| 2662 let isLeaf = exports.leafTags[tag] === true; | |
| 2663 if (isLeaf) { | |
| 2664 return patchProto(obj, makeLeafDispatchRecord(interceptor)); | |
| 2665 } else { | |
| 2666 return patchInteriorProto(obj, interceptor); | |
| 2667 } | |
| 2668 } | |
| 2669 // Function patchInstance: (dynamic, dynamic) → dynamic | |
| 2670 function patchInstance(obj, record) { | |
| 2671 _interceptors.setDispatchProperty(obj, record); | |
| 2672 return _interceptors.dispatchRecordInterceptor(record); | |
| 2673 } | |
| 2674 // Function patchProto: (dynamic, dynamic) → dynamic | |
| 2675 function patchProto(obj, record) { | |
| 2676 _interceptors.setDispatchProperty(Object.getPrototypeOf(obj), record); | |
| 2677 return _interceptors.dispatchRecordInterceptor(record); | |
| 2678 } | |
| 2679 // Function patchInteriorProto: (dynamic, dynamic) → dynamic | |
| 2680 function patchInteriorProto(obj, interceptor) { | |
| 2681 let proto = Object.getPrototypeOf(obj); | |
| 2682 let record = _interceptors.makeDispatchRecord(interceptor, proto, null, null
); | |
| 2683 _interceptors.setDispatchProperty(proto, record); | |
| 2684 return interceptor; | |
| 2685 } | |
| 2686 // Function makeLeafDispatchRecord: (dynamic) → dynamic | |
| 2687 function makeLeafDispatchRecord(interceptor) { | |
| 2688 let fieldName = _foreign_helper.JS_IS_INDEXABLE_FIELD_NAME(); | |
| 2689 let indexability = !!interceptor[fieldName]; | |
| 2690 return _interceptors.makeDispatchRecord(interceptor, false, null, indexabili
ty); | |
| 2691 } | |
| 2692 // Function makeDefaultDispatchRecord: (dynamic, dynamic, dynamic) → dynamic | |
| 2693 function makeDefaultDispatchRecord(tag, interceptorClass, proto) { | |
| 2694 let interceptor = interceptorClass.prototype; | |
| 2695 let isLeaf = exports.leafTags[tag] === true; | |
| 2696 if (isLeaf) { | |
| 2697 return makeLeafDispatchRecord(interceptor); | |
| 2698 } else { | |
| 2699 return _interceptors.makeDispatchRecord(interceptor, proto, null, null); | |
| 2700 } | |
| 2701 } | |
| 2702 // Function setNativeSubclassDispatchRecord: (dynamic, dynamic) → dynamic | |
| 2703 function setNativeSubclassDispatchRecord(proto, interceptor) { | |
| 2704 _interceptors.setDispatchProperty(proto, makeLeafDispatchRecord(interceptor)
); | |
| 2705 } | |
| 2706 // Function constructorNameFallback: (dynamic) → String | |
| 2707 function constructorNameFallback(object) { | |
| 2708 return _constructorNameFallback(object); | |
| 2709 } | |
| 2710 exports.initNativeDispatchFlag = null; | |
| 2711 // Function initNativeDispatch: () → void | |
| 2712 function initNativeDispatch() { | |
| 2713 if (true === exports.initNativeDispatchFlag) | |
| 2714 return; | |
| 2715 exports.initNativeDispatchFlag = true; | |
| 2716 initNativeDispatchContinue(); | |
| 2717 } | |
| 2718 // Function initNativeDispatchContinue: () → void | |
| 2719 function initNativeDispatchContinue() { | |
| 2720 exports.dispatchRecordsForInstanceTags = Object.create(null); | |
| 2721 exports.interceptorsForUncacheableTags = Object.create(null); | |
| 2722 initHooks(); | |
| 2723 let map = exports.interceptorsByTag; | |
| 2724 let tags = Object.getOwnPropertyNames(map); | |
| 2725 if (typeof window != "undefined") { | |
| 2726 let context = window; | |
| 2727 let fun = function() { | |
| 2728 }; | |
| 2729 for (let i = 0; i['<'](dart.dload(tags, 'length')); i++) { | |
| 2730 let tag = dart.dindex(tags, i); | |
| 2731 let proto = dart.dinvokef(exports.prototypeForTagFunction, tag); | |
| 2732 if (proto !== null) { | |
| 2733 let interceptorClass = map[tag]; | |
| 2734 let record = makeDefaultDispatchRecord(tag, interceptorClass, proto); | |
| 2735 if (record !== null) { | |
| 2736 _interceptors.setDispatchProperty(proto, record); | |
| 2737 fun.prototype = proto; | |
| 2738 } | |
| 2739 } | |
| 2740 } | |
| 2741 } | |
| 2742 for (let i = 0; i['<'](dart.dload(tags, 'length')); i++) { | |
| 2743 let tag = tags[i]; | |
| 2744 if (/^[A-Za-z_]/.test(tag)) { | |
| 2745 let interceptorClass = propertyGet(map, tag); | |
| 2746 propertySet(map, dart.as(dart.dbinary(INSTANCE_CACHED_MARK, '+', tag), c
ore.String), interceptorClass); | |
| 2747 propertySet(map, dart.as(dart.dbinary(UNCACHED_MARK, '+', tag), core.Str
ing), interceptorClass); | |
| 2748 propertySet(map, dart.as(dart.dbinary(LEAF_MARK, '+', tag), core.String)
, interceptorClass); | |
| 2749 propertySet(map, dart.as(dart.dbinary(INTERIOR_MARK, '+', tag), core.Str
ing), interceptorClass); | |
| 2750 propertySet(map, dart.as(dart.dbinary(DISCRIMINATED_MARK, '+', tag), cor
e.String), interceptorClass); | |
| 2751 } | |
| 2752 } | |
| 2753 } | |
| 2754 // Function initHooks: () → void | |
| 2755 function initHooks() { | |
| 2756 let hooks = _baseHooks(); | |
| 2757 let _fallbackConstructorHooksTransformer = _fallbackConstructorHooksTransfor
merGenerator(_constructorNameFallback); | |
| 2758 hooks = applyHooksTransformer(_fallbackConstructorHooksTransformer, hooks); | |
| 2759 hooks = applyHooksTransformer(_firefoxHooksTransformer, hooks); | |
| 2760 hooks = applyHooksTransformer(_ieHooksTransformer, hooks); | |
| 2761 hooks = applyHooksTransformer(_operaHooksTransformer, hooks); | |
| 2762 hooks = applyHooksTransformer(_safariHooksTransformer, hooks); | |
| 2763 hooks = applyHooksTransformer(_fixDocumentHooksTransformer, hooks); | |
| 2764 hooks = applyHooksTransformer(_dartExperimentalFixupGetTagHooksTransformer,
hooks); | |
| 2765 if (typeof dartNativeDispatchHooksTransformer != "undefined") { | |
| 2766 let transformers = dartNativeDispatchHooksTransformer; | |
| 2767 if (typeof transformers == "function") { | |
| 2768 transformers = new List.from([transformers]); | |
| 2769 } | |
| 2770 if (transformers.constructor == Array) { | |
| 2771 for (let i = 0; i < transformers.length; i++) { | |
| 2772 let transformer = transformers[i]; | |
| 2773 if (typeof transformer == "function") { | |
| 2774 hooks = applyHooksTransformer(transformer, hooks); | |
| 2775 } | |
| 2776 } | |
| 2777 } | |
| 2778 } | |
| 2779 let getTag = hooks.getTag; | |
| 2780 let getUnknownTag = hooks.getUnknownTag; | |
| 2781 let prototypeForTag = hooks.prototypeForTag; | |
| 2782 exports.getTagFunction = (o) => getTag(o); | |
| 2783 exports.alternateTagFunction = (o, tag) => getUnknownTag(o, tag); | |
| 2784 exports.prototypeForTagFunction = (tag) => prototypeForTag(tag); | |
| 2785 } | |
| 2786 // Function applyHooksTransformer: (dynamic, dynamic) → dynamic | |
| 2787 function applyHooksTransformer(transformer, hooks) { | |
| 2788 let newHooks = transformer(hooks); | |
| 2789 return newHooks || hooks; | |
| 2790 } | |
| 2791 let _baseHooks = new _foreign_helper.JS_CONST('\nfunction() {\n function type
NameInChrome(o) {\n var constructor = o.constructor;\n if (constructor) {\
n var name = constructor.name;\n if (name) return name;\n }\n va
r s = Object.prototype.toString.call(o);\n return s.substring(8, s.length - 1
);\n }\n function getUnknownTag(object, tag) {\n // This code really belong
s in [getUnknownTagGenericBrowser] but having it\n // here allows [getUnknown
Tag] to be tested on d8.\n if (/^HTML[A-Z].*Element$/.test(tag)) {\n //
Check that it is not a simple JavaScript object.\n var name = Object.protot
ype.toString.call(object);\n if (name == "[object Object]") return null;\n
return "HTMLElement";\n }\n }\n function getUnknownTagGenericBrowser(o
bject, tag) {\n if (self.HTMLElement && object instanceof HTMLElement) return
"HTMLElement";\n return getUnknownTag(object, tag);\n }\n function prototy
peForTag(tag) {\n if (typeof window == "undefined") return null;\n if (typ
eof window[tag] == "undefined") return null;\n var constructor = window[tag];
\n if (typeof constructor != "function") return null;\n return constructor
.prototype;\n }\n function discriminator(tag) { return null; }\n\n var isBrow
ser = typeof navigator == "object";\n\n return {\n getTag: typeNameInChrome,
\n getUnknownTag: isBrowser ? getUnknownTagGenericBrowser : getUnknownTag,\n
prototypeForTag: prototypeForTag,\n discriminator: discriminator };\n}'); | |
| 2792 let _constructorNameFallback = new _foreign_helper.JS_CONST('\nfunction getTag
Fallback(o) {\n var constructor = o.constructor;\n if (typeof constructor == "
function") {\n var name = constructor.name;\n // If the name is a non-empt
y string, we use that as the type name of this\n // object. There are variou
s cases where that does not work, so we have to\n // detect them and fall thr
ough to the toString() based implementation.\n\n if (typeof name == "string"
&&\n\n // Sometimes the string is empty. This test also catches minified
\n // shadow dom polyfil wrapper for Window on Firefox where the faked\n
// constructor name does not \'stick\'. The shortest real DOM object\n
// names have three characters (e.g. URL, CSS).\n name.length > 2 &
&\n\n // On Firefox we often get "Object" as the constructor name, even f
or\n // more specialized DOM objects.\n name !== "Object" &&\n\n
// This can happen in Opera.\n name !== "Function.prototype") {\n
return name;\n }\n }\n var s = Object.prototype.toString.call(o);\n re
turn s.substring(8, s.length - 1);\n}'); | |
| 2793 let _fallbackConstructorHooksTransformerGenerator = new _foreign_helper.JS_CON
ST('\nfunction(getTagFallback) {\n return function(hooks) {\n // If we are n
ot in a browser, assume we are in d8.\n // TODO(sra): Recognize jsshell.\n
if (typeof navigator != "object") return hooks;\n\n var ua = navigator.userA
gent;\n // TODO(antonm): remove a reference to DumpRenderTree.\n if (ua.in
dexOf("DumpRenderTree") >= 0) return hooks;\n if (ua.indexOf("Chrome") >= 0)
{\n // Confirm constructor name is usable for dispatch.\n function con
firm(p) {\n return typeof window == "object" && window[p] && window[p].na
me == p;\n }\n if (confirm("Window") && confirm("HTMLElement")) return
hooks;\n }\n\n hooks.getTag = getTagFallback;\n };\n}'); | |
| 2794 let _ieHooksTransformer = new _foreign_helper.JS_CONST('\nfunction(hooks) {\n
var userAgent = typeof navigator == "object" ? navigator.userAgent : "";\n if
(userAgent.indexOf("Trident/") == -1) return hooks;\n\n var getTag = hooks.getT
ag;\n\n var quickMap = {\n "BeforeUnloadEvent": "Event",\n "DataTransfer"
: "Clipboard",\n "HTMLDDElement": "HTMLElement",\n "HTMLDTElement": "HTMLE
lement",\n "HTMLPhraseElement": "HTMLElement",\n "Position": "Geoposition"
\n };\n\n function getTagIE(o) {\n var tag = getTag(o);\n var newTag = q
uickMap[tag];\n if (newTag) return newTag;\n // Patches for types which re
port themselves as Objects.\n if (tag == "Object") {\n if (window.DataVi
ew && (o instanceof window.DataView)) return "DataView";\n }\n return tag;
\n }\n\n function prototypeForTagIE(tag) {\n var constructor = window[tag];
\n if (constructor == null) return null;\n return constructor.prototype;\n
}\n\n hooks.getTag = getTagIE;\n hooks.prototypeForTag = prototypeForTagIE;\
n}'); | |
| 2795 let _fixDocumentHooksTransformer = new _foreign_helper.JS_CONST('\nfunction(ho
oks) {\n var getTag = hooks.getTag;\n var prototypeForTag = hooks.prototypeFor
Tag;\n function getTagFixed(o) {\n var tag = getTag(o);\n if (tag == "Doc
ument") {\n // Some browsers and the polymer polyfill call both HTML and XM
L documents\n // "Document", so we check for the xmlVersion property, which
is the empty\n // string on HTML documents. Since both dart:html classes D
ocument and\n // HtmlDocument share the same type, we must patch the instan
ces and not\n // the prototype.\n if (!!o.xmlVersion) return "!Documen
t";\n return "!HTMLDocument";\n }\n return tag;\n }\n\n function pr
ototypeForTagFixed(tag) {\n if (tag == "Document") return null; // Do not pr
e-patch Document.\n return prototypeForTag(tag);\n }\n\n hooks.getTag = get
TagFixed;\n hooks.prototypeForTag = prototypeForTagFixed;\n}'); | |
| 2796 let _firefoxHooksTransformer = new _foreign_helper.JS_CONST('\nfunction(hooks)
{\n var userAgent = typeof navigator == "object" ? navigator.userAgent : "";\n
if (userAgent.indexOf("Firefox") == -1) return hooks;\n\n var getTag = hooks.
getTag;\n\n var quickMap = {\n "BeforeUnloadEvent": "Event",\n "DataTrans
fer": "Clipboard",\n "GeoGeolocation": "Geolocation",\n "Location": "!Loca
tion", // Fixes issue 18151\n "WorkerMessageEvent": "MessageEve
nt",\n "XMLDocument": "!Document"};\n\n function getTagFirefox(o) {\n var
tag = getTag(o);\n return quickMap[tag] || tag;\n }\n\n hooks.getTag = get
TagFirefox;\n}'); | |
| 2797 let _operaHooksTransformer = new _foreign_helper.JS_CONST('\nfunction(hooks) {
return hooks; }\n'); | |
| 2798 let _safariHooksTransformer = new _foreign_helper.JS_CONST('\nfunction(hooks)
{ return hooks; }\n'); | |
| 2799 let _dartExperimentalFixupGetTagHooksTransformer = new _foreign_helper.JS_CONS
T('\nfunction(hooks) {\n if (typeof dartExperimentalFixupGetTag != "function")
return hooks;\n hooks.getTag = dartExperimentalFixupGetTag(hooks.getTag);\n}'); | |
| 2800 // Function regExpGetNative: (JSSyntaxRegExp) → dynamic | |
| 2801 function regExpGetNative(regexp) { | |
| 2802 return regexp._nativeRegExp; | |
| 2803 } | |
| 2804 // Function regExpGetGlobalNative: (JSSyntaxRegExp) → dynamic | |
| 2805 function regExpGetGlobalNative(regexp) { | |
| 2806 let nativeRegexp = regexp._nativeGlobalVersion; | |
| 2807 nativeRegexp.lastIndex = 0; | |
| 2808 return nativeRegexp; | |
| 2809 } | |
| 2810 // Function regExpCaptureCount: (JSSyntaxRegExp) → int | |
| 2811 function regExpCaptureCount(regexp) { | |
| 2812 let nativeAnchoredRegExp = regexp._nativeAnchoredVersion; | |
| 2813 let match = nativeAnchoredRegExp.exec(''); | |
| 2814 return dart.as(dart.dbinary(dart.dload(match, 'length'), '-', 2), core.int); | |
| 2815 } | |
| 2816 class JSSyntaxRegExp extends dart.Object { | |
| 2817 toString() { | |
| 2818 return `RegExp/${this.pattern}/`; | |
| 2819 } | |
| 2820 JSSyntaxRegExp(source, opt$) { | |
| 2821 let multiLine = opt$.multiLine === void 0 ? false : opt$.multiLine; | |
| 2822 let caseSensitive = opt$.caseSensitive === void 0 ? true : opt$.caseSensit
ive; | |
| 2823 this.pattern = source; | |
| 2824 this._nativeRegExp = makeNative(source, multiLine, caseSensitive, false); | |
| 2825 this._nativeGlobalRegExp = null; | |
| 2826 this._nativeAnchoredRegExp = null; | |
| 2827 } | |
| 2828 get _nativeGlobalVersion() { | |
| 2829 if (this._nativeGlobalRegExp !== null) | |
| 2830 return this._nativeGlobalRegExp; | |
| 2831 return this._nativeGlobalRegExp = makeNative(this.pattern, this._isMultiLi
ne, this._isCaseSensitive, true); | |
| 2832 } | |
| 2833 get _nativeAnchoredVersion() { | |
| 2834 if (this._nativeAnchoredRegExp !== null) | |
| 2835 return this._nativeAnchoredRegExp; | |
| 2836 return this._nativeAnchoredRegExp = makeNative(`${this.pattern}|()`, this.
_isMultiLine, this._isCaseSensitive, true); | |
| 2837 } | |
| 2838 get _isMultiLine() { | |
| 2839 return this._nativeRegExp.multiline; | |
| 2840 } | |
| 2841 get _isCaseSensitive() { | |
| 2842 return !this._nativeRegExp.ignoreCase; | |
| 2843 } | |
| 2844 static makeNative(source, multiLine, caseSensitive, global) { | |
| 2845 checkString(source); | |
| 2846 let m = multiLine ? 'm' : ''; | |
| 2847 let i = caseSensitive ? '' : 'i'; | |
| 2848 let g = global ? 'g' : ''; | |
| 2849 let regexp = function() { | |
| 2850 try { | |
| 2851 return new RegExp(source, m + i + g); | |
| 2852 } catch (e) { | |
| 2853 return e; | |
| 2854 } | |
| 2855 | |
| 2856 }(); | |
| 2857 if (regexp instanceof RegExp) | |
| 2858 return regexp; | |
| 2859 let errorMessage = String(regexp); | |
| 2860 throw new core.FormatException(`Illegal RegExp pattern: ${source}, ${error
Message}`); | |
| 2861 } | |
| 2862 firstMatch(string) { | |
| 2863 let m = dart.as(this._nativeRegExp.exec(checkString(string)), core.List$(c
ore.String)); | |
| 2864 if (m === null) | |
| 2865 return null; | |
| 2866 return new _MatchImplementation(this, m); | |
| 2867 } | |
| 2868 hasMatch(string) { | |
| 2869 return this._nativeRegExp.test(checkString(string)); | |
| 2870 } | |
| 2871 stringMatch(string) { | |
| 2872 let match = this.firstMatch(string); | |
| 2873 if (match !== null) | |
| 2874 return match.group(0); | |
| 2875 return null; | |
| 2876 } | |
| 2877 allMatches(string, start) { | |
| 2878 if (start === void 0) | |
| 2879 start = 0; | |
| 2880 checkString(string); | |
| 2881 checkInt(start); | |
| 2882 if (dart.notNull(start < 0) || dart.notNull(start > string.length)) { | |
| 2883 throw new core.RangeError.range(start, 0, string.length); | |
| 2884 } | |
| 2885 return new _AllMatchesIterable(this, string, start); | |
| 2886 } | |
| 2887 _execGlobal(string, start) { | |
| 2888 let regexp = this._nativeGlobalVersion; | |
| 2889 regexp.lastIndex = start; | |
| 2890 let match = dart.as(regexp.exec(string), core.List); | |
| 2891 if (match === null) | |
| 2892 return null; | |
| 2893 return new _MatchImplementation(this, dart.as(match, core.List$(core.Strin
g))); | |
| 2894 } | |
| 2895 _execAnchored(string, start) { | |
| 2896 let regexp = this._nativeAnchoredVersion; | |
| 2897 regexp.lastIndex = start; | |
| 2898 let match = dart.as(regexp.exec(string), core.List); | |
| 2899 if (match === null) | |
| 2900 return null; | |
| 2901 if (match.get(match.length - 1) !== null) | |
| 2902 return null; | |
| 2903 match.length = 1; | |
| 2904 return new _MatchImplementation(this, dart.as(match, core.List$(core.Strin
g))); | |
| 2905 } | |
| 2906 matchAsPrefix(string, start) { | |
| 2907 if (start === void 0) | |
| 2908 start = 0; | |
| 2909 if (dart.notNull(start < 0) || dart.notNull(start > string.length)) { | |
| 2910 throw new core.RangeError.range(start, 0, string.length); | |
| 2911 } | |
| 2912 return this._execAnchored(string, start); | |
| 2913 } | |
| 2914 get isMultiLine() { | |
| 2915 return this._isMultiLine; | |
| 2916 } | |
| 2917 get isCaseSensitive() { | |
| 2918 return this._isCaseSensitive; | |
| 2919 } | |
| 2920 } | |
| 2921 class _MatchImplementation extends dart.Object { | |
| 2922 _MatchImplementation(pattern, _match) { | |
| 2923 this.pattern = pattern; | |
| 2924 this._match = _match; | |
| 2925 dart.assert(typeof this._match.input == string); | |
| 2926 dart.assert(typeof this._match.index == number); | |
| 2927 } | |
| 2928 get input() { | |
| 2929 return this._match.input; | |
| 2930 } | |
| 2931 get start() { | |
| 2932 return this._match.index; | |
| 2933 } | |
| 2934 get end() { | |
| 2935 return this.start + this._match.get(0).length; | |
| 2936 } | |
| 2937 group(index) { | |
| 2938 return this._match.get(index); | |
| 2939 } | |
| 2940 get(index) { | |
| 2941 return this.group(index); | |
| 2942 } | |
| 2943 get groupCount() { | |
| 2944 return this._match.length - 1; | |
| 2945 } | |
| 2946 groups(groups) { | |
| 2947 let out = dart.as(new List.from([]), core.List$(core.String)); | |
| 2948 for (let i of groups) { | |
| 2949 out.add(this.group(i)); | |
| 2950 } | |
| 2951 return out; | |
| 2952 } | |
| 2953 } | |
| 2954 class _AllMatchesIterable extends collection.IterableBase$(core.Match) { | |
| 2955 _AllMatchesIterable(_re, _string, _start) { | |
| 2956 this._re = _re; | |
| 2957 this._string = _string; | |
| 2958 this._start = _start; | |
| 2959 super.IterableBase(); | |
| 2960 } | |
| 2961 get iterator() { | |
| 2962 return new _AllMatchesIterator(this._re, this._string, this._start); | |
| 2963 } | |
| 2964 } | |
| 2965 class _AllMatchesIterator extends dart.Object { | |
| 2966 _AllMatchesIterator(_regExp, _string, _nextIndex) { | |
| 2967 this._regExp = _regExp; | |
| 2968 this._string = _string; | |
| 2969 this._nextIndex = _nextIndex; | |
| 2970 this._current = null; | |
| 2971 } | |
| 2972 get current() { | |
| 2973 return this._current; | |
| 2974 } | |
| 2975 moveNext() { | |
| 2976 if (this._string === null) | |
| 2977 return false; | |
| 2978 if (this._nextIndex <= this._string.length) { | |
| 2979 let match = this._regExp._execGlobal(this._string, this._nextIndex); | |
| 2980 if (match !== null) { | |
| 2981 this._current = match; | |
| 2982 let nextIndex = match.end; | |
| 2983 if (match.start === nextIndex) { | |
| 2984 nextIndex++; | |
| 2985 } | |
| 2986 this._nextIndex = nextIndex; | |
| 2987 return true; | |
| 2988 } | |
| 2989 } | |
| 2990 this._current = null; | |
| 2991 this._string = null; | |
| 2992 return false; | |
| 2993 } | |
| 2994 } | |
| 2995 // Function firstMatchAfter: (JSSyntaxRegExp, String, int) → Match | |
| 2996 function firstMatchAfter(regExp, string, start) { | |
| 2997 return regExp._execGlobal(string, start); | |
| 2998 } | |
| 2999 class StringMatch extends dart.Object { | |
| 3000 StringMatch(start, input, pattern) { | |
| 3001 this.start = start; | |
| 3002 this.input = input; | |
| 3003 this.pattern = pattern; | |
| 3004 } | |
| 3005 get end() { | |
| 3006 return this.start + this.pattern.length; | |
| 3007 } | |
| 3008 get(g) { | |
| 3009 return this.group(g); | |
| 3010 } | |
| 3011 get groupCount() { | |
| 3012 return 0; | |
| 3013 } | |
| 3014 group(group_) { | |
| 3015 if (group_ !== 0) { | |
| 3016 throw new core.RangeError.value(group_); | |
| 3017 } | |
| 3018 return this.pattern; | |
| 3019 } | |
| 3020 groups(groups_) { | |
| 3021 let result = new core.List(); | |
| 3022 for (let g of groups_) { | |
| 3023 result.add(this.group(g)); | |
| 3024 } | |
| 3025 return result; | |
| 3026 } | |
| 3027 } | |
| 3028 // Function allMatchesInStringUnchecked: (String, String, int) → List<Match> | |
| 3029 function allMatchesInStringUnchecked(needle, haystack, startIndex) { | |
| 3030 let result = new core.List(); | |
| 3031 let length = haystack.length; | |
| 3032 let patternLength = needle.length; | |
| 3033 while (true) { | |
| 3034 let position = haystack.indexOf(needle, startIndex); | |
| 3035 if (position === -1) { | |
| 3036 break; | |
| 3037 } | |
| 3038 result.add(new StringMatch(position, haystack, needle)); | |
| 3039 let endIndex = position + patternLength; | |
| 3040 if (endIndex === length) { | |
| 3041 break; | |
| 3042 } else if (position === endIndex) { | |
| 3043 ++startIndex; | |
| 3044 } else { | |
| 3045 startIndex = endIndex; | |
| 3046 } | |
| 3047 } | |
| 3048 return result; | |
| 3049 } | |
| 3050 // Function stringContainsUnchecked: (dynamic, dynamic, dynamic) → dynamic | |
| 3051 function stringContainsUnchecked(receiver, other, startIndex) { | |
| 3052 if (typeof other == string) { | |
| 3053 return !dart.equals(dart.dinvoke(receiver, 'indexOf', other, startIndex),
-1); | |
| 3054 } else if (dart.is(other, JSSyntaxRegExp)) { | |
| 3055 return dart.dinvoke(other, 'hasMatch', dart.dinvoke(receiver, 'substring',
startIndex)); | |
| 3056 } else { | |
| 3057 let substr = dart.dinvoke(receiver, 'substring', startIndex); | |
| 3058 return dart.dload(dart.dinvoke(other, 'allMatches', substr), 'isNotEmpty')
; | |
| 3059 } | |
| 3060 } | |
| 3061 // Function stringReplaceJS: (dynamic, dynamic, dynamic) → dynamic | |
| 3062 function stringReplaceJS(receiver, replacer, to) { | |
| 3063 to = to.replace(/\$/g, "$$$$"); | |
| 3064 return receiver.replace(replacer, to); | |
| 3065 } | |
| 3066 // Function stringReplaceFirstRE: (dynamic, dynamic, dynamic, dynamic) → dynam
ic | |
| 3067 function stringReplaceFirstRE(receiver, regexp, to, startIndex) { | |
| 3068 let match = dart.dinvoke(regexp, '_execGlobal', receiver, startIndex); | |
| 3069 if (match === null) | |
| 3070 return receiver; | |
| 3071 let start = dart.dload(match, 'start'); | |
| 3072 let end = dart.dload(match, 'end'); | |
| 3073 return `${dart.dinvoke(receiver, 'substring', 0, start)}${to}${dart.dinvoke(
receiver, 'substring', end)}`; | |
| 3074 } | |
| 3075 let ESCAPE_REGEXP = '[[\\]{}()*+?.\\\\^$|]'; | |
| 3076 // Function stringReplaceAllUnchecked: (dynamic, dynamic, dynamic) → dynamic | |
| 3077 function stringReplaceAllUnchecked(receiver, from, to) { | |
| 3078 checkString(to); | |
| 3079 if (typeof from == string) { | |
| 3080 if (dart.equals(from, "")) { | |
| 3081 if (dart.equals(receiver, "")) { | |
| 3082 return to; | |
| 3083 } else { | |
| 3084 let result = new core.StringBuffer(); | |
| 3085 let length = dart.as(dart.dload(receiver, 'length'), core.int); | |
| 3086 result.write(to); | |
| 3087 for (let i = 0; i < length; i++) { | |
| 3088 result.write(dart.dindex(receiver, i)); | |
| 3089 result.write(to); | |
| 3090 } | |
| 3091 return result.toString(); | |
| 3092 } | |
| 3093 } else { | |
| 3094 let quoter = new RegExp(ESCAPE_REGEXP, 'g'); | |
| 3095 let quoted = from.replace(quoter, "\\$&"); | |
| 3096 let replacer = new RegExp(quoted, 'g'); | |
| 3097 return stringReplaceJS(receiver, replacer, to); | |
| 3098 } | |
| 3099 } else if (dart.is(from, JSSyntaxRegExp)) { | |
| 3100 let re = regExpGetGlobalNative(dart.as(from, JSSyntaxRegExp)); | |
| 3101 return stringReplaceJS(receiver, re, to); | |
| 3102 } else { | |
| 3103 checkNull(from); | |
| 3104 throw "String.replaceAll(Pattern) UNIMPLEMENTED"; | |
| 3105 } | |
| 3106 } | |
| 3107 // Function _matchString: (Match) → String | |
| 3108 function _matchString(match) { | |
| 3109 return match.get(0); | |
| 3110 } | |
| 3111 // Function _stringIdentity: (String) → String | |
| 3112 function _stringIdentity(string) { | |
| 3113 return string; | |
| 3114 } | |
| 3115 // Function stringReplaceAllFuncUnchecked: (dynamic, dynamic, dynamic, dynamic
) → dynamic | |
| 3116 function stringReplaceAllFuncUnchecked(receiver, pattern, onMatch, onNonMatch)
{ | |
| 3117 if (!dart.is(pattern, core.Pattern)) { | |
| 3118 throw new core.ArgumentError(`${pattern} is not a Pattern`); | |
| 3119 } | |
| 3120 if (onMatch === null) | |
| 3121 onMatch = _matchString; | |
| 3122 if (onNonMatch === null) | |
| 3123 onNonMatch = _stringIdentity; | |
| 3124 if (typeof pattern == string) { | |
| 3125 return stringReplaceAllStringFuncUnchecked(receiver, pattern, onMatch, onN
onMatch); | |
| 3126 } | |
| 3127 let buffer = new core.StringBuffer(); | |
| 3128 let startIndex = 0; | |
| 3129 for (let match of dart.dinvoke(pattern, 'allMatches', receiver)) { | |
| 3130 buffer.write(dart.dinvokef(onNonMatch, dart.dinvoke(receiver, 'substring',
startIndex, match.start))); | |
| 3131 buffer.write(dart.dinvokef(onMatch, match)); | |
| 3132 startIndex = match.end; | |
| 3133 } | |
| 3134 buffer.write(dart.dinvokef(onNonMatch, dart.dinvoke(receiver, 'substring', s
tartIndex))); | |
| 3135 return buffer.toString(); | |
| 3136 } | |
| 3137 // Function stringReplaceAllEmptyFuncUnchecked: (dynamic, dynamic, dynamic) →
dynamic | |
| 3138 function stringReplaceAllEmptyFuncUnchecked(receiver, onMatch, onNonMatch) { | |
| 3139 let buffer = new core.StringBuffer(); | |
| 3140 let length = dart.as(dart.dload(receiver, 'length'), core.int); | |
| 3141 let i = 0; | |
| 3142 buffer.write(dart.dinvokef(onNonMatch, "")); | |
| 3143 while (i < length) { | |
| 3144 buffer.write(dart.dinvokef(onMatch, new StringMatch(i, dart.as(receiver, c
ore.String), ""))); | |
| 3145 let code = dart.as(dart.dinvoke(receiver, 'codeUnitAt', i), core.int); | |
| 3146 if (dart.notNull((code & ~1023) === 55296) && dart.notNull(length > i + 1)
) { | |
| 3147 code = dart.as(dart.dinvoke(receiver, 'codeUnitAt', i + 1), core.int); | |
| 3148 if ((code & ~1023) === 56320) { | |
| 3149 buffer.write(dart.dinvokef(onNonMatch, dart.dinvoke(receiver, 'substri
ng', i, i + 2))); | |
| 3150 i = 2; | |
| 3151 continue; | |
| 3152 } | |
| 3153 } | |
| 3154 buffer.write(dart.dinvokef(onNonMatch, dart.dindex(receiver, i))); | |
| 3155 i++; | |
| 3156 } | |
| 3157 buffer.write(dart.dinvokef(onMatch, new StringMatch(i, dart.as(receiver, cor
e.String), ""))); | |
| 3158 buffer.write(dart.dinvokef(onNonMatch, "")); | |
| 3159 return buffer.toString(); | |
| 3160 } | |
| 3161 // Function stringReplaceAllStringFuncUnchecked: (dynamic, dynamic, dynamic, d
ynamic) → dynamic | |
| 3162 function stringReplaceAllStringFuncUnchecked(receiver, pattern, onMatch, onNon
Match) { | |
| 3163 let patternLength = dart.as(dart.dload(pattern, 'length'), core.int); | |
| 3164 if (patternLength === 0) { | |
| 3165 return stringReplaceAllEmptyFuncUnchecked(receiver, onMatch, onNonMatch); | |
| 3166 } | |
| 3167 let length = dart.as(dart.dload(receiver, 'length'), core.int); | |
| 3168 let buffer = new core.StringBuffer(); | |
| 3169 let startIndex = 0; | |
| 3170 while (startIndex < length) { | |
| 3171 let position = dart.as(dart.dinvoke(receiver, 'indexOf', pattern, startInd
ex), core.int); | |
| 3172 if (position === -1) { | |
| 3173 break; | |
| 3174 } | |
| 3175 buffer.write(dart.dinvokef(onNonMatch, dart.dinvoke(receiver, 'substring',
startIndex, position))); | |
| 3176 buffer.write(dart.dinvokef(onMatch, new StringMatch(position, dart.as(rece
iver, core.String), dart.as(pattern, core.String)))); | |
| 3177 startIndex = position + patternLength; | |
| 3178 } | |
| 3179 buffer.write(dart.dinvokef(onNonMatch, dart.dinvoke(receiver, 'substring', s
tartIndex))); | |
| 3180 return buffer.toString(); | |
| 3181 } | |
| 3182 // Function stringReplaceFirstUnchecked: (dynamic, dynamic, dynamic, [int]) →
dynamic | |
| 3183 function stringReplaceFirstUnchecked(receiver, from, to, startIndex) { | |
| 3184 if (startIndex === void 0) | |
| 3185 startIndex = 0; | |
| 3186 if (typeof from == string) { | |
| 3187 let index = dart.dinvoke(receiver, 'indexOf', from, startIndex); | |
| 3188 if (dart.dbinary(index, '<', 0)) | |
| 3189 return receiver; | |
| 3190 return `${dart.dinvoke(receiver, 'substring', 0, index)}${to}` + `${dart.d
invoke(receiver, 'substring', dart.dbinary(index, '+', dart.dload(from, 'length'
)))}`; | |
| 3191 } else if (dart.is(from, JSSyntaxRegExp)) { | |
| 3192 return startIndex === 0 ? stringReplaceJS(receiver, regExpGetNative(dart.a
s(from, JSSyntaxRegExp)), to) : stringReplaceFirstRE(receiver, from, to, startIn
dex); | |
| 3193 } else { | |
| 3194 checkNull(from); | |
| 3195 throw "String.replace(Pattern) UNIMPLEMENTED"; | |
| 3196 } | |
| 3197 } | |
| 3198 // Function stringJoinUnchecked: (dynamic, dynamic) → dynamic | |
| 3199 function stringJoinUnchecked(array, separator) { | |
| 3200 return array.join(separator); | |
| 3201 } | |
| 3202 // Function createRuntimeType: (String) → Type | |
| 3203 function createRuntimeType(name) { | |
| 3204 return new TypeImpl(name); | |
| 3205 } | |
| 3206 class TypeImpl extends dart.Object { | |
| 3207 TypeImpl(_typeName) { | |
| 3208 this._typeName = _typeName; | |
| 3209 this._unmangledName = null; | |
| 3210 } | |
| 3211 toString() { | |
| 3212 if (this._unmangledName !== null) | |
| 3213 return this._unmangledName; | |
| 3214 let unmangledName = _js_names.unmangleAllIdentifiersIfPreservedAnyways(thi
s._typeName); | |
| 3215 return this._unmangledName = unmangledName; | |
| 3216 } | |
| 3217 get hashCode() { | |
| 3218 return this._typeName.hashCode; | |
| 3219 } | |
| 3220 ['=='](other) { | |
| 3221 return dart.notNull(dart.is(other, TypeImpl)) && dart.notNull(dart.equals(
this._typeName, dart.dload(other, '_typeName'))); | |
| 3222 } | |
| 3223 } | |
| 3224 class TypeVariable extends dart.Object { | |
| 3225 TypeVariable(owner, name, bound) { | |
| 3226 this.owner = owner; | |
| 3227 this.name = name; | |
| 3228 this.bound = bound; | |
| 3229 } | |
| 3230 } | |
| 3231 // Function getMangledTypeName: (TypeImpl) → dynamic | |
| 3232 function getMangledTypeName(type) { | |
| 3233 return type._typeName; | |
| 3234 } | |
| 3235 // Function setRuntimeTypeInfo: (Object, dynamic) → Object | |
| 3236 function setRuntimeTypeInfo(target, typeInfo) { | |
| 3237 dart.assert(dart.notNull(typeInfo === null) || dart.notNull(isJsArray(typeIn
fo))); | |
| 3238 if (target !== null) | |
| 3239 target.$builtinTypeInfo = typeInfo; | |
| 3240 return target; | |
| 3241 } | |
| 3242 // Function getRuntimeTypeInfo: (Object) → dynamic | |
| 3243 function getRuntimeTypeInfo(target) { | |
| 3244 if (target === null) | |
| 3245 return null; | |
| 3246 return target.$builtinTypeInfo; | |
| 3247 } | |
| 3248 // Function getRuntimeTypeArguments: (dynamic, dynamic) → dynamic | |
| 3249 function getRuntimeTypeArguments(target, substitutionName) { | |
| 3250 let substitution = getField(target, `${_foreign_helper.JS_OPERATOR_AS_PREFIX
()}${substitutionName}`); | |
| 3251 return substitute(substitution, getRuntimeTypeInfo(target)); | |
| 3252 } | |
| 3253 // Function getRuntimeTypeArgument: (Object, String, int) → dynamic | |
| 3254 function getRuntimeTypeArgument(target, substitutionName, index) { | |
| 3255 let arguments = getRuntimeTypeArguments(target, substitutionName); | |
| 3256 return arguments === null ? null : getIndex(arguments, index); | |
| 3257 } | |
| 3258 // Function getTypeArgumentByIndex: (Object, int) → dynamic | |
| 3259 function getTypeArgumentByIndex(target, index) { | |
| 3260 let rti = getRuntimeTypeInfo(target); | |
| 3261 return rti === null ? null : getIndex(rti, index); | |
| 3262 } | |
| 3263 // Function copyTypeArguments: (Object, Object) → void | |
| 3264 function copyTypeArguments(source, target) { | |
| 3265 target.$builtinTypeInfo = source.$builtinTypeInfo; | |
| 3266 } | |
| 3267 // Function getClassName: (dynamic) → String | |
| 3268 function getClassName(object) { | |
| 3269 return _interceptors.getInterceptor(object).constructor.builtin$cls; | |
| 3270 } | |
| 3271 // Function getRuntimeTypeAsString: (dynamic, {onTypeVariable: (int) → String}
) → String | |
| 3272 function getRuntimeTypeAsString(runtimeType, opt$) { | |
| 3273 let onTypeVariable = opt$.onTypeVariable === void 0 ? null : opt$.onTypeVari
able; | |
| 3274 dart.assert(isJsArray(runtimeType)); | |
| 3275 let className = getConstructorName(getIndex(runtimeType, 0)); | |
| 3276 return `${className}` + `${joinArguments(runtimeType, 1, {onTypeVariable: on
TypeVariable})}`; | |
| 3277 } | |
| 3278 // Function getConstructorName: (dynamic) → String | |
| 3279 function getConstructorName(type) { | |
| 3280 return type.builtin$cls; | |
| 3281 } | |
| 3282 // Function runtimeTypeToString: (dynamic, {onTypeVariable: (int) → String}) →
String | |
| 3283 function runtimeTypeToString(type, opt$) { | |
| 3284 let onTypeVariable = opt$.onTypeVariable === void 0 ? null : opt$.onTypeVari
able; | |
| 3285 if (type === null) { | |
| 3286 return 'dynamic'; | |
| 3287 } else if (isJsArray(type)) { | |
| 3288 return getRuntimeTypeAsString(type, {onTypeVariable: onTypeVariable}); | |
| 3289 } else if (isJsFunction(type)) { | |
| 3290 return getConstructorName(type); | |
| 3291 } else if (typeof type == number) { | |
| 3292 if (onTypeVariable === null) { | |
| 3293 return dart.as(dart.dinvoke(type, 'toString'), core.String); | |
| 3294 } else { | |
| 3295 return onTypeVariable(dart.as(type, core.int)); | |
| 3296 } | |
| 3297 } else { | |
| 3298 return null; | |
| 3299 } | |
| 3300 } | |
| 3301 // Function joinArguments: (dynamic, int, {onTypeVariable: (int) → String}) →
String | |
| 3302 function joinArguments(types, startIndex, opt$) { | |
| 3303 let onTypeVariable = opt$.onTypeVariable === void 0 ? null : opt$.onTypeVari
able; | |
| 3304 if (types === null) | |
| 3305 return ''; | |
| 3306 dart.assert(isJsArray(types)); | |
| 3307 let firstArgument = true; | |
| 3308 let allDynamic = true; | |
| 3309 let buffer = new core.StringBuffer(); | |
| 3310 for (let index = startIndex; index < getLength(types); index++) { | |
| 3311 if (firstArgument) { | |
| 3312 firstArgument = false; | |
| 3313 } else { | |
| 3314 buffer.write(', '); | |
| 3315 } | |
| 3316 let argument = getIndex(types, index); | |
| 3317 if (argument !== null) { | |
| 3318 allDynamic = false; | |
| 3319 } | |
| 3320 buffer.write(runtimeTypeToString(argument, {onTypeVariable: onTypeVariable
})); | |
| 3321 } | |
| 3322 return allDynamic ? '' : `<${buffer}>`; | |
| 3323 } | |
| 3324 // Function getRuntimeTypeString: (dynamic) → String | |
| 3325 function getRuntimeTypeString(object) { | |
| 3326 let className = getClassName(object); | |
| 3327 if (object === null) | |
| 3328 return className; | |
| 3329 let typeInfo = object.$builtinTypeInfo; | |
| 3330 return `${className}${joinArguments(typeInfo, 0)}`; | |
| 3331 } | |
| 3332 // Function getRuntimeType: (dynamic) → Type | |
| 3333 function getRuntimeType(object) { | |
| 3334 let type = getRuntimeTypeString(object); | |
| 3335 return new TypeImpl(type); | |
| 3336 } | |
| 3337 // Function substitute: (dynamic, dynamic) → dynamic | |
| 3338 function substitute(substitution, arguments) { | |
| 3339 dart.assert(dart.notNull(substitution === null) || dart.notNull(isJsFunction
(substitution))); | |
| 3340 dart.assert(dart.notNull(arguments === null) || dart.notNull(isJsArray(argum
ents))); | |
| 3341 if (isJsFunction(substitution)) { | |
| 3342 substitution = invoke(substitution, arguments); | |
| 3343 if (isJsArray(substitution)) { | |
| 3344 arguments = substitution; | |
| 3345 } else if (isJsFunction(substitution)) { | |
| 3346 arguments = invoke(substitution, arguments); | |
| 3347 } | |
| 3348 } | |
| 3349 return arguments; | |
| 3350 } | |
| 3351 // Function checkSubtype: (Object, String, List<dynamic>, String) → bool | |
| 3352 function checkSubtype(object, isField, checks, asField) { | |
| 3353 if (object === null) | |
| 3354 return false; | |
| 3355 let arguments = getRuntimeTypeInfo(object); | |
| 3356 let interceptor = _interceptors.getInterceptor(object); | |
| 3357 let isSubclass = getField(interceptor, isField); | |
| 3358 if (isSubclass === null) | |
| 3359 return false; | |
| 3360 let substitution = getField(interceptor, asField); | |
| 3361 return checkArguments(substitution, arguments, checks); | |
| 3362 } | |
| 3363 // Function computeTypeName: (String, List<dynamic>) → String | |
| 3364 function computeTypeName(isField, arguments) { | |
| 3365 let prefixLength = _foreign_helper.JS_OPERATOR_IS_PREFIX().length; | |
| 3366 return Primitives.formatType(isField.substring(prefixLength, isField.length)
, arguments); | |
| 3367 } | |
| 3368 // Function subtypeCast: (Object, String, List<dynamic>, String) → Object | |
| 3369 function subtypeCast(object, isField, checks, asField) { | |
| 3370 if (dart.notNull(object !== null) && dart.notNull(!dart.notNull(checkSubtype
(object, isField, checks, asField)))) { | |
| 3371 let actualType = Primitives.objectTypeName(object); | |
| 3372 let typeName = computeTypeName(isField, checks); | |
| 3373 throw new CastErrorImplementation(actualType, typeName); | |
| 3374 } | |
| 3375 return object; | |
| 3376 } | |
| 3377 // Function assertSubtype: (Object, String, List<dynamic>, String) → Object | |
| 3378 function assertSubtype(object, isField, checks, asField) { | |
| 3379 if (dart.notNull(object !== null) && dart.notNull(!dart.notNull(checkSubtype
(object, isField, checks, asField)))) { | |
| 3380 let typeName = computeTypeName(isField, checks); | |
| 3381 throw new TypeErrorImplementation(object, typeName); | |
| 3382 } | |
| 3383 return object; | |
| 3384 } | |
| 3385 // Function assertIsSubtype: (dynamic, dynamic, String) → dynamic | |
| 3386 function assertIsSubtype(subtype, supertype, message) { | |
| 3387 if (!dart.notNull(isSubtype(subtype, supertype))) { | |
| 3388 throwTypeError(message); | |
| 3389 } | |
| 3390 } | |
| 3391 // Function throwTypeError: (dynamic) → dynamic | |
| 3392 function throwTypeError(message) { | |
| 3393 throw new TypeErrorImplementation.fromMessage(dart.as(message, core.String))
; | |
| 3394 } | |
| 3395 // Function checkArguments: (dynamic, dynamic, dynamic) → bool | |
| 3396 function checkArguments(substitution, arguments, checks) { | |
| 3397 return areSubtypes(substitute(substitution, arguments), checks); | |
| 3398 } | |
| 3399 // Function areSubtypes: (dynamic, dynamic) → bool | |
| 3400 function areSubtypes(s, t) { | |
| 3401 if (dart.notNull(s === null) || dart.notNull(t === null)) | |
| 3402 return true; | |
| 3403 dart.assert(isJsArray(s)); | |
| 3404 dart.assert(isJsArray(t)); | |
| 3405 dart.assert(getLength(s) === getLength(t)); | |
| 3406 let len = getLength(s); | |
| 3407 for (let i = 0; i < len; i++) { | |
| 3408 if (!dart.notNull(isSubtype(getIndex(s, i), getIndex(t, i)))) { | |
| 3409 return false; | |
| 3410 } | |
| 3411 } | |
| 3412 return true; | |
| 3413 } | |
| 3414 // Function computeSignature: (dynamic, dynamic, dynamic) → dynamic | |
| 3415 function computeSignature(signature, context, contextName) { | |
| 3416 let typeArguments = getRuntimeTypeArguments(context, contextName); | |
| 3417 return invokeOn(signature, context, typeArguments); | |
| 3418 } | |
| 3419 // Function isSupertypeOfNull: (dynamic) → bool | |
| 3420 function isSupertypeOfNull(type) { | |
| 3421 return dart.notNull(dart.notNull(type === null) || dart.notNull(dart.equals(
getConstructorName(type), _foreign_helper.JS_OBJECT_CLASS_NAME()))) || dart.notN
ull(dart.equals(getConstructorName(type), _foreign_helper.JS_NULL_CLASS_NAME()))
; | |
| 3422 } | |
| 3423 // Function checkSubtypeOfRuntimeType: (dynamic, dynamic) → bool | |
| 3424 function checkSubtypeOfRuntimeType(o, t) { | |
| 3425 if (o === null) | |
| 3426 return isSupertypeOfNull(t); | |
| 3427 if (t === null) | |
| 3428 return true; | |
| 3429 let rti = getRuntimeTypeInfo(o); | |
| 3430 o = _interceptors.getInterceptor(o); | |
| 3431 let type = o.constructor; | |
| 3432 if (rti !== null) { | |
| 3433 rti = rti.slice(); | |
| 3434 rti.splice(0, 0, type); | |
| 3435 type = rti; | |
| 3436 } else if (hasField(t, `${_foreign_helper.JS_FUNCTION_TYPE_TAG()}`)) { | |
| 3437 let signatureName = `${_foreign_helper.JS_OPERATOR_IS_PREFIX()}_${getField
(t, _foreign_helper.JS_FUNCTION_TYPE_TAG())}`; | |
| 3438 if (hasField(o, signatureName)) | |
| 3439 return true; | |
| 3440 let targetSignatureFunction = getField(o, `${_foreign_helper.JS_SIGNATURE_
NAME()}`); | |
| 3441 if (targetSignatureFunction === null) | |
| 3442 return false; | |
| 3443 type = invokeOn(targetSignatureFunction, o, null); | |
| 3444 return isFunctionSubtype(type, t); | |
| 3445 } | |
| 3446 return isSubtype(type, t); | |
| 3447 } | |
| 3448 // Function subtypeOfRuntimeTypeCast: (Object, dynamic) → Object | |
| 3449 function subtypeOfRuntimeTypeCast(object, type) { | |
| 3450 if (dart.notNull(object !== null) && dart.notNull(!dart.notNull(checkSubtype
OfRuntimeType(object, type)))) { | |
| 3451 let actualType = Primitives.objectTypeName(object); | |
| 3452 throw new CastErrorImplementation(actualType, runtimeTypeToString(type)); | |
| 3453 } | |
| 3454 return object; | |
| 3455 } | |
| 3456 // Function assertSubtypeOfRuntimeType: (Object, dynamic) → Object | |
| 3457 function assertSubtypeOfRuntimeType(object, type) { | |
| 3458 if (dart.notNull(object !== null) && dart.notNull(!dart.notNull(checkSubtype
OfRuntimeType(object, type)))) { | |
| 3459 throw new TypeErrorImplementation(object, runtimeTypeToString(type)); | |
| 3460 } | |
| 3461 return object; | |
| 3462 } | |
| 3463 // Function getArguments: (dynamic) → dynamic | |
| 3464 function getArguments(type) { | |
| 3465 return isJsArray(type) ? type.slice(1) : null; | |
| 3466 } | |
| 3467 // Function isSubtype: (dynamic, dynamic) → bool | |
| 3468 function isSubtype(s, t) { | |
| 3469 if (isIdentical(s, t)) | |
| 3470 return true; | |
| 3471 if (dart.notNull(s === null) || dart.notNull(t === null)) | |
| 3472 return true; | |
| 3473 if (hasField(t, `${_foreign_helper.JS_FUNCTION_TYPE_TAG()}`)) { | |
| 3474 return isFunctionSubtype(s, t); | |
| 3475 } | |
| 3476 if (hasField(s, `${_foreign_helper.JS_FUNCTION_TYPE_TAG()}`)) { | |
| 3477 return dart.equals(getConstructorName(t), _foreign_helper.JS_FUNCTION_CLAS
S_NAME()); | |
| 3478 } | |
| 3479 let typeOfS = isJsArray(s) ? getIndex(s, 0) : s; | |
| 3480 let typeOfT = isJsArray(t) ? getIndex(t, 0) : t; | |
| 3481 let name = runtimeTypeToString(typeOfT); | |
| 3482 let substitution = null; | |
| 3483 if (isNotIdentical(typeOfT, typeOfS)) { | |
| 3484 let test = `${_foreign_helper.JS_OPERATOR_IS_PREFIX()}${name}`; | |
| 3485 let typeOfSPrototype = typeOfS.prototype; | |
| 3486 if (hasNoField(typeOfSPrototype, test)) | |
| 3487 return false; | |
| 3488 let field = `${_foreign_helper.JS_OPERATOR_AS_PREFIX()}${runtimeTypeToStri
ng(typeOfT)}`; | |
| 3489 substitution = getField(typeOfSPrototype, field); | |
| 3490 } | |
| 3491 if (dart.notNull(dart.notNull(!dart.notNull(isJsArray(s))) && dart.notNull(s
ubstitution === null)) || dart.notNull(!dart.notNull(isJsArray(t)))) { | |
| 3492 return true; | |
| 3493 } | |
| 3494 return checkArguments(substitution, getArguments(s), getArguments(t)); | |
| 3495 } | |
| 3496 // Function isAssignable: (dynamic, dynamic) → bool | |
| 3497 function isAssignable(s, t) { | |
| 3498 return dart.notNull(isSubtype(s, t)) || dart.notNull(isSubtype(t, s)); | |
| 3499 } | |
| 3500 // Function areAssignable: (List<dynamic>, List, bool) → bool | |
| 3501 function areAssignable(s, t, allowShorter) { | |
| 3502 if (dart.notNull(t === null) && dart.notNull(s === null)) | |
| 3503 return true; | |
| 3504 if (t === null) | |
| 3505 return allowShorter; | |
| 3506 if (s === null) | |
| 3507 return false; | |
| 3508 dart.assert(isJsArray(s)); | |
| 3509 dart.assert(isJsArray(t)); | |
| 3510 let sLength = getLength(s); | |
| 3511 let tLength = getLength(t); | |
| 3512 if (allowShorter) { | |
| 3513 if (sLength < tLength) | |
| 3514 return false; | |
| 3515 } else { | |
| 3516 if (sLength !== tLength) | |
| 3517 return false; | |
| 3518 } | |
| 3519 for (let i = 0; i < tLength; i++) { | |
| 3520 if (!dart.notNull(isAssignable(getIndex(s, i), getIndex(t, i)))) { | |
| 3521 return false; | |
| 3522 } | |
| 3523 } | |
| 3524 return true; | |
| 3525 } | |
| 3526 // Function areAssignableMaps: (dynamic, dynamic) → bool | |
| 3527 function areAssignableMaps(s, t) { | |
| 3528 if (t === null) | |
| 3529 return true; | |
| 3530 if (s === null) | |
| 3531 return false; | |
| 3532 dart.assert(isJsObject(s)); | |
| 3533 dart.assert(isJsObject(t)); | |
| 3534 let names = _interceptors.JSArray.markFixedList(dart.as(Object.getOwnPropert
yNames(t), core.List)); | |
| 3535 for (let i = 0; i < names.length; i++) { | |
| 3536 let name = names.get(i); | |
| 3537 if (!Object.hasOwnProperty.call(s, name)) { | |
| 3538 return false; | |
| 3539 } | |
| 3540 let tType = t[name]; | |
| 3541 let sType = s[name]; | |
| 3542 if (!dart.notNull(isAssignable(tType, sType))) | |
| 3543 return false; | |
| 3544 } | |
| 3545 return true; | |
| 3546 } | |
| 3547 // Function isFunctionSubtype: (dynamic, dynamic) → bool | |
| 3548 function isFunctionSubtype(s, t) { | |
| 3549 dart.assert(hasField(t, `${_foreign_helper.JS_FUNCTION_TYPE_TAG()}`)); | |
| 3550 if (hasNoField(s, `${_foreign_helper.JS_FUNCTION_TYPE_TAG()}`)) | |
| 3551 return false; | |
| 3552 if (hasField(s, `${_foreign_helper.JS_FUNCTION_TYPE_VOID_RETURN_TAG()}`)) { | |
| 3553 if (dart.dbinary(hasNoField(t, `${_foreign_helper.JS_FUNCTION_TYPE_VOID_RE
TURN_TAG()}`), '&&', hasField(t, `${_foreign_helper.JS_FUNCTION_TYPE_RETURN_TYPE
_TAG()}`))) { | |
| 3554 return false; | |
| 3555 } | |
| 3556 } else if (hasNoField(t, `${_foreign_helper.JS_FUNCTION_TYPE_VOID_RETURN_TAG
()}`)) { | |
| 3557 let sReturnType = getField(s, `${_foreign_helper.JS_FUNCTION_TYPE_RETURN_T
YPE_TAG()}`); | |
| 3558 let tReturnType = getField(t, `${_foreign_helper.JS_FUNCTION_TYPE_RETURN_T
YPE_TAG()}`); | |
| 3559 if (!dart.notNull(isAssignable(sReturnType, tReturnType))) | |
| 3560 return false; | |
| 3561 } | |
| 3562 let sParameterTypes = getField(s, `${_foreign_helper.JS_FUNCTION_TYPE_REQUIR
ED_PARAMETERS_TAG()}`); | |
| 3563 let tParameterTypes = getField(t, `${_foreign_helper.JS_FUNCTION_TYPE_REQUIR
ED_PARAMETERS_TAG()}`); | |
| 3564 let sOptionalParameterTypes = getField(s, `${_foreign_helper.JS_FUNCTION_TYP
E_OPTIONAL_PARAMETERS_TAG()}`); | |
| 3565 let tOptionalParameterTypes = getField(t, `${_foreign_helper.JS_FUNCTION_TYP
E_OPTIONAL_PARAMETERS_TAG()}`); | |
| 3566 let sParametersLen = sParameterTypes !== null ? getLength(sParameterTypes) :
0; | |
| 3567 let tParametersLen = tParameterTypes !== null ? getLength(tParameterTypes) :
0; | |
| 3568 let sOptionalParametersLen = sOptionalParameterTypes !== null ? getLength(sO
ptionalParameterTypes) : 0; | |
| 3569 let tOptionalParametersLen = tOptionalParameterTypes !== null ? getLength(tO
ptionalParameterTypes) : 0; | |
| 3570 if (sParametersLen > tParametersLen) { | |
| 3571 return false; | |
| 3572 } | |
| 3573 if (sParametersLen + sOptionalParametersLen < tParametersLen + tOptionalPara
metersLen) { | |
| 3574 return false; | |
| 3575 } | |
| 3576 if (sParametersLen === tParametersLen) { | |
| 3577 if (!dart.notNull(areAssignable(dart.as(sParameterTypes, core.List), dart.
as(tParameterTypes, core.List), false))) | |
| 3578 return false; | |
| 3579 if (!dart.notNull(areAssignable(dart.as(sOptionalParameterTypes, core.List
), dart.as(tOptionalParameterTypes, core.List), true))) { | |
| 3580 return false; | |
| 3581 } | |
| 3582 } else { | |
| 3583 let pos = 0; | |
| 3584 for (; pos < sParametersLen; pos++) { | |
| 3585 if (!dart.notNull(isAssignable(getIndex(sParameterTypes, pos), getIndex(
tParameterTypes, pos)))) { | |
| 3586 return false; | |
| 3587 } | |
| 3588 } | |
| 3589 let sPos = 0; | |
| 3590 let tPos = pos; | |
| 3591 for (; tPos < tParametersLen; sPos++, tPos++) { | |
| 3592 if (!dart.notNull(isAssignable(getIndex(sOptionalParameterTypes, sPos),
getIndex(tParameterTypes, tPos)))) { | |
| 3593 return false; | |
| 3594 } | |
| 3595 } | |
| 3596 tPos = 0; | |
| 3597 for (; tPos < tOptionalParametersLen; sPos++, tPos++) { | |
| 3598 if (!dart.notNull(isAssignable(getIndex(sOptionalParameterTypes, sPos),
getIndex(tOptionalParameterTypes, tPos)))) { | |
| 3599 return false; | |
| 3600 } | |
| 3601 } | |
| 3602 } | |
| 3603 let sNamedParameters = getField(s, `${_foreign_helper.JS_FUNCTION_TYPE_NAMED
_PARAMETERS_TAG()}`); | |
| 3604 let tNamedParameters = getField(t, `${_foreign_helper.JS_FUNCTION_TYPE_NAMED
_PARAMETERS_TAG()}`); | |
| 3605 return areAssignableMaps(sNamedParameters, tNamedParameters); | |
| 3606 } | |
| 3607 // Function invoke: (dynamic, dynamic) → dynamic | |
| 3608 function invoke(function, arguments) { | |
| 3609 return invokeOn(function, null, arguments); | |
| 3610 } | |
| 3611 // Function invokeOn: (dynamic, dynamic, dynamic) → Object | |
| 3612 function invokeOn(function, receiver, arguments) { | |
| 3613 dart.assert(isJsFunction(function)); | |
| 3614 dart.assert(dart.notNull(arguments === null) || dart.notNull(isJsArray(argum
ents))); | |
| 3615 return function.apply(receiver, arguments); | |
| 3616 } | |
| 3617 // Function call: (dynamic, String) → dynamic | |
| 3618 function call(object, name) { | |
| 3619 return object[name](); | |
| 3620 } | |
| 3621 // Function getField: (dynamic, String) → dynamic | |
| 3622 function getField(object, name) { | |
| 3623 return object[name]; | |
| 3624 } | |
| 3625 // Function getIndex: (dynamic, int) → dynamic | |
| 3626 function getIndex(array, index) { | |
| 3627 dart.assert(isJsArray(array)); | |
| 3628 return array[index]; | |
| 3629 } | |
| 3630 // Function getLength: (dynamic) → int | |
| 3631 function getLength(array) { | |
| 3632 dart.assert(isJsArray(array)); | |
| 3633 return array.length; | |
| 3634 } | |
| 3635 // Function isJsArray: (dynamic) → bool | |
| 3636 function isJsArray(value) { | |
| 3637 return dart.is(value, _interceptors.JSArray); | |
| 3638 } | |
| 3639 // Function hasField: (dynamic, dynamic) → dynamic | |
| 3640 function hasField(object, name) { | |
| 3641 return name in object; | |
| 3642 } | |
| 3643 // Function hasNoField: (dynamic, dynamic) → dynamic | |
| 3644 function hasNoField(object, name) { | |
| 3645 return dart.throw_("Unimplemented PrefixExpression: !hasField(object, name)"
); | |
| 3646 } | |
| 3647 // Function isJsFunction: (dynamic) → bool | |
| 3648 function isJsFunction(o) { | |
| 3649 return typeof o == "function"; | |
| 3650 } | |
| 3651 // Function isJsObject: (dynamic) → bool | |
| 3652 function isJsObject(o) { | |
| 3653 return typeof o == 'object'; | |
| 3654 } | |
| 3655 // Function isIdentical: (dynamic, dynamic) → bool | |
| 3656 function isIdentical(s, t) { | |
| 3657 return s === t; | |
| 3658 } | |
| 3659 // Function isNotIdentical: (dynamic, dynamic) → bool | |
| 3660 function isNotIdentical(s, t) { | |
| 3661 return s !== t; | |
| 3662 } | |
| 3663 // Exports: | |
| 3664 exports.patch = patch; | |
| 3665 exports.InternalMap = InternalMap; | |
| 3666 exports.requiresPreamble = requiresPreamble; | |
| 3667 exports.isJsIndexable = isJsIndexable; | |
| 3668 exports.S = S; | |
| 3669 exports.createInvocationMirror = createInvocationMirror; | |
| 3670 exports.createUnmangledInvocationMirror = createUnmangledInvocationMirror; | |
| 3671 exports.throwInvalidReflectionError = throwInvalidReflectionError; | |
| 3672 exports.traceHelper = traceHelper; | |
| 3673 exports.JSInvocationMirror = JSInvocationMirror; | |
| 3674 exports.CachedInvocation = CachedInvocation; | |
| 3675 exports.CachedCatchAllInvocation = CachedCatchAllInvocation; | |
| 3676 exports.CachedNoSuchMethodInvocation = CachedNoSuchMethodInvocation; | |
| 3677 exports.ReflectionInfo = ReflectionInfo; | |
| 3678 exports.getMetadata = getMetadata; | |
| 3679 exports.Primitives = Primitives; | |
| 3680 exports.JsCache = JsCache; | |
| 3681 exports.iae = iae; | |
| 3682 exports.ioore = ioore; | |
| 3683 exports.stringLastIndexOfUnchecked = stringLastIndexOfUnchecked; | |
| 3684 exports.checkNull = checkNull; | |
| 3685 exports.checkNum = checkNum; | |
| 3686 exports.checkInt = checkInt; | |
| 3687 exports.checkBool = checkBool; | |
| 3688 exports.checkString = checkString; | |
| 3689 exports.wrapException = wrapException; | |
| 3690 exports.toStringWrapper = toStringWrapper; | |
| 3691 exports.throwExpression = throwExpression; | |
| 3692 exports.makeLiteralListConst = makeLiteralListConst; | |
| 3693 exports.throwRuntimeError = throwRuntimeError; | |
| 3694 exports.throwAbstractClassInstantiationError = throwAbstractClassInstantiation
Error; | |
| 3695 exports.TypeErrorDecoder = TypeErrorDecoder; | |
| 3696 exports.NullError = NullError; | |
| 3697 exports.JsNoSuchMethodError = JsNoSuchMethodError; | |
| 3698 exports.UnknownJsTypeError = UnknownJsTypeError; | |
| 3699 exports.unwrapException = unwrapException; | |
| 3700 exports.getTraceFromException = getTraceFromException; | |
| 3701 exports.objectHashCode = objectHashCode; | |
| 3702 exports.fillLiteralMap = fillLiteralMap; | |
| 3703 exports.invokeClosure = invokeClosure; | |
| 3704 exports.convertDartClosureToJS = convertDartClosureToJS; | |
| 3705 exports.Closure = Closure; | |
| 3706 exports.closureFromTearOff = closureFromTearOff; | |
| 3707 exports.TearOffClosure = TearOffClosure; | |
| 3708 exports.BoundClosure = BoundClosure; | |
| 3709 exports.jsHasOwnProperty = jsHasOwnProperty; | |
| 3710 exports.jsPropertyAccess = jsPropertyAccess; | |
| 3711 exports.getFallThroughError = getFallThroughError; | |
| 3712 exports.Creates = Creates; | |
| 3713 exports.Returns = Returns; | |
| 3714 exports.JSName = JSName; | |
| 3715 exports.boolConversionCheck = boolConversionCheck; | |
| 3716 exports.stringTypeCheck = stringTypeCheck; | |
| 3717 exports.stringTypeCast = stringTypeCast; | |
| 3718 exports.doubleTypeCheck = doubleTypeCheck; | |
| 3719 exports.doubleTypeCast = doubleTypeCast; | |
| 3720 exports.numTypeCheck = numTypeCheck; | |
| 3721 exports.numTypeCast = numTypeCast; | |
| 3722 exports.boolTypeCheck = boolTypeCheck; | |
| 3723 exports.boolTypeCast = boolTypeCast; | |
| 3724 exports.intTypeCheck = intTypeCheck; | |
| 3725 exports.intTypeCast = intTypeCast; | |
| 3726 exports.propertyTypeError = propertyTypeError; | |
| 3727 exports.propertyTypeCastError = propertyTypeCastError; | |
| 3728 exports.propertyTypeCheck = propertyTypeCheck; | |
| 3729 exports.propertyTypeCast = propertyTypeCast; | |
| 3730 exports.interceptedTypeCheck = interceptedTypeCheck; | |
| 3731 exports.interceptedTypeCast = interceptedTypeCast; | |
| 3732 exports.numberOrStringSuperTypeCheck = numberOrStringSuperTypeCheck; | |
| 3733 exports.numberOrStringSuperTypeCast = numberOrStringSuperTypeCast; | |
| 3734 exports.numberOrStringSuperNativeTypeCheck = numberOrStringSuperNativeTypeChec
k; | |
| 3735 exports.numberOrStringSuperNativeTypeCast = numberOrStringSuperNativeTypeCast; | |
| 3736 exports.stringSuperTypeCheck = stringSuperTypeCheck; | |
| 3737 exports.stringSuperTypeCast = stringSuperTypeCast; | |
| 3738 exports.stringSuperNativeTypeCheck = stringSuperNativeTypeCheck; | |
| 3739 exports.stringSuperNativeTypeCast = stringSuperNativeTypeCast; | |
| 3740 exports.listTypeCheck = listTypeCheck; | |
| 3741 exports.listTypeCast = listTypeCast; | |
| 3742 exports.listSuperTypeCheck = listSuperTypeCheck; | |
| 3743 exports.listSuperTypeCast = listSuperTypeCast; | |
| 3744 exports.listSuperNativeTypeCheck = listSuperNativeTypeCheck; | |
| 3745 exports.listSuperNativeTypeCast = listSuperNativeTypeCast; | |
| 3746 exports.voidTypeCheck = voidTypeCheck; | |
| 3747 exports.checkMalformedType = checkMalformedType; | |
| 3748 exports.checkDeferredIsLoaded = checkDeferredIsLoaded; | |
| 3749 exports.JavaScriptIndexingBehavior = JavaScriptIndexingBehavior; | |
| 3750 exports.TypeErrorImplementation = TypeErrorImplementation; | |
| 3751 exports.CastErrorImplementation = CastErrorImplementation; | |
| 3752 exports.FallThroughErrorImplementation = FallThroughErrorImplementation; | |
| 3753 exports.assertHelper = assertHelper; | |
| 3754 exports.throwNoSuchMethod = throwNoSuchMethod; | |
| 3755 exports.throwCyclicInit = throwCyclicInit; | |
| 3756 exports.RuntimeError = RuntimeError; | |
| 3757 exports.DeferredNotLoadedError = DeferredNotLoadedError; | |
| 3758 exports.RuntimeType = RuntimeType; | |
| 3759 exports.RuntimeFunctionType = RuntimeFunctionType; | |
| 3760 exports.buildFunctionType = buildFunctionType; | |
| 3761 exports.buildNamedFunctionType = buildNamedFunctionType; | |
| 3762 exports.buildInterfaceType = buildInterfaceType; | |
| 3763 exports.DynamicRuntimeType = DynamicRuntimeType; | |
| 3764 exports.getDynamicRuntimeType = getDynamicRuntimeType; | |
| 3765 exports.VoidRuntimeType = VoidRuntimeType; | |
| 3766 exports.getVoidRuntimeType = getVoidRuntimeType; | |
| 3767 exports.functionTypeTestMetaHelper = functionTypeTestMetaHelper; | |
| 3768 exports.convertRtiToRuntimeType = convertRtiToRuntimeType; | |
| 3769 exports.RuntimeTypePlain = RuntimeTypePlain; | |
| 3770 exports.RuntimeTypeGeneric = RuntimeTypeGeneric; | |
| 3771 exports.FunctionTypeInfoDecoderRing = FunctionTypeInfoDecoderRing; | |
| 3772 exports.UnimplementedNoSuchMethodError = UnimplementedNoSuchMethodError; | |
| 3773 exports.random64 = random64; | |
| 3774 exports.jsonEncodeNative = jsonEncodeNative; | |
| 3775 exports.getIsolateAffinityTag = getIsolateAffinityTag; | |
| 3776 exports.loadDeferredLibrary = loadDeferredLibrary; | |
| 3777 exports.MainError = MainError; | |
| 3778 exports.missingMain = missingMain; | |
| 3779 exports.badMain = badMain; | |
| 3780 exports.mainHasTooManyParameters = mainHasTooManyParameters; | |
| 3781 exports.NoSideEffects = NoSideEffects; | |
| 3782 exports.NoThrows = NoThrows; | |
| 3783 exports.NoInline = NoInline; | |
| 3784 exports.IrRepresentation = IrRepresentation; | |
| 3785 exports.Native = Native; | |
| 3786 exports.ConstantMap = ConstantMap; | |
| 3787 exports.ConstantMap$ = ConstantMap$; | |
| 3788 exports.ConstantStringMap = ConstantStringMap; | |
| 3789 exports.ConstantStringMap$ = ConstantStringMap$; | |
| 3790 exports.ConstantProtoMap = ConstantProtoMap; | |
| 3791 exports.ConstantProtoMap$ = ConstantProtoMap$; | |
| 3792 exports.GeneralConstantMap = GeneralConstantMap; | |
| 3793 exports.GeneralConstantMap$ = GeneralConstantMap$; | |
| 3794 exports.contains = contains; | |
| 3795 exports.arrayLength = arrayLength; | |
| 3796 exports.arrayGet = arrayGet; | |
| 3797 exports.arraySet = arraySet; | |
| 3798 exports.propertyGet = propertyGet; | |
| 3799 exports.callHasOwnProperty = callHasOwnProperty; | |
| 3800 exports.propertySet = propertySet; | |
| 3801 exports.getPropertyFromPrototype = getPropertyFromPrototype; | |
| 3802 exports.toStringForNativeObject = toStringForNativeObject; | |
| 3803 exports.hashCodeForNativeObject = hashCodeForNativeObject; | |
| 3804 exports.defineProperty = defineProperty; | |
| 3805 exports.isDartObject = isDartObject; | |
| 3806 exports.interceptorsByTag = interceptorsByTag; | |
| 3807 exports.leafTags = leafTags; | |
| 3808 exports.findDispatchTagForInterceptorClass = findDispatchTagForInterceptorClas
s; | |
| 3809 exports.lookupInterceptor = lookupInterceptor; | |
| 3810 exports.UNCACHED_MARK = UNCACHED_MARK; | |
| 3811 exports.INSTANCE_CACHED_MARK = INSTANCE_CACHED_MARK; | |
| 3812 exports.LEAF_MARK = LEAF_MARK; | |
| 3813 exports.INTERIOR_MARK = INTERIOR_MARK; | |
| 3814 exports.DISCRIMINATED_MARK = DISCRIMINATED_MARK; | |
| 3815 exports.lookupAndCacheInterceptor = lookupAndCacheInterceptor; | |
| 3816 exports.patchInstance = patchInstance; | |
| 3817 exports.patchProto = patchProto; | |
| 3818 exports.patchInteriorProto = patchInteriorProto; | |
| 3819 exports.makeLeafDispatchRecord = makeLeafDispatchRecord; | |
| 3820 exports.makeDefaultDispatchRecord = makeDefaultDispatchRecord; | |
| 3821 exports.setNativeSubclassDispatchRecord = setNativeSubclassDispatchRecord; | |
| 3822 exports.constructorNameFallback = constructorNameFallback; | |
| 3823 exports.initNativeDispatch = initNativeDispatch; | |
| 3824 exports.initNativeDispatchContinue = initNativeDispatchContinue; | |
| 3825 exports.initHooks = initHooks; | |
| 3826 exports.applyHooksTransformer = applyHooksTransformer; | |
| 3827 exports.regExpGetNative = regExpGetNative; | |
| 3828 exports.regExpGetGlobalNative = regExpGetGlobalNative; | |
| 3829 exports.regExpCaptureCount = regExpCaptureCount; | |
| 3830 exports.JSSyntaxRegExp = JSSyntaxRegExp; | |
| 3831 exports.firstMatchAfter = firstMatchAfter; | |
| 3832 exports.StringMatch = StringMatch; | |
| 3833 exports.allMatchesInStringUnchecked = allMatchesInStringUnchecked; | |
| 3834 exports.stringContainsUnchecked = stringContainsUnchecked; | |
| 3835 exports.stringReplaceJS = stringReplaceJS; | |
| 3836 exports.stringReplaceFirstRE = stringReplaceFirstRE; | |
| 3837 exports.ESCAPE_REGEXP = ESCAPE_REGEXP; | |
| 3838 exports.stringReplaceAllUnchecked = stringReplaceAllUnchecked; | |
| 3839 exports.stringReplaceAllFuncUnchecked = stringReplaceAllFuncUnchecked; | |
| 3840 exports.stringReplaceAllEmptyFuncUnchecked = stringReplaceAllEmptyFuncUnchecke
d; | |
| 3841 exports.stringReplaceAllStringFuncUnchecked = stringReplaceAllStringFuncUnchec
ked; | |
| 3842 exports.stringReplaceFirstUnchecked = stringReplaceFirstUnchecked; | |
| 3843 exports.stringJoinUnchecked = stringJoinUnchecked; | |
| 3844 exports.createRuntimeType = createRuntimeType; | |
| 3845 exports.TypeImpl = TypeImpl; | |
| 3846 exports.TypeVariable = TypeVariable; | |
| 3847 exports.getMangledTypeName = getMangledTypeName; | |
| 3848 exports.setRuntimeTypeInfo = setRuntimeTypeInfo; | |
| 3849 exports.getRuntimeTypeInfo = getRuntimeTypeInfo; | |
| 3850 exports.getRuntimeTypeArguments = getRuntimeTypeArguments; | |
| 3851 exports.getRuntimeTypeArgument = getRuntimeTypeArgument; | |
| 3852 exports.getTypeArgumentByIndex = getTypeArgumentByIndex; | |
| 3853 exports.copyTypeArguments = copyTypeArguments; | |
| 3854 exports.getClassName = getClassName; | |
| 3855 exports.getRuntimeTypeAsString = getRuntimeTypeAsString; | |
| 3856 exports.getConstructorName = getConstructorName; | |
| 3857 exports.runtimeTypeToString = runtimeTypeToString; | |
| 3858 exports.joinArguments = joinArguments; | |
| 3859 exports.getRuntimeTypeString = getRuntimeTypeString; | |
| 3860 exports.getRuntimeType = getRuntimeType; | |
| 3861 exports.substitute = substitute; | |
| 3862 exports.checkSubtype = checkSubtype; | |
| 3863 exports.computeTypeName = computeTypeName; | |
| 3864 exports.subtypeCast = subtypeCast; | |
| 3865 exports.assertSubtype = assertSubtype; | |
| 3866 exports.assertIsSubtype = assertIsSubtype; | |
| 3867 exports.throwTypeError = throwTypeError; | |
| 3868 exports.checkArguments = checkArguments; | |
| 3869 exports.areSubtypes = areSubtypes; | |
| 3870 exports.computeSignature = computeSignature; | |
| 3871 exports.isSupertypeOfNull = isSupertypeOfNull; | |
| 3872 exports.checkSubtypeOfRuntimeType = checkSubtypeOfRuntimeType; | |
| 3873 exports.subtypeOfRuntimeTypeCast = subtypeOfRuntimeTypeCast; | |
| 3874 exports.assertSubtypeOfRuntimeType = assertSubtypeOfRuntimeType; | |
| 3875 exports.getArguments = getArguments; | |
| 3876 exports.isSubtype = isSubtype; | |
| 3877 exports.isAssignable = isAssignable; | |
| 3878 exports.areAssignable = areAssignable; | |
| 3879 exports.areAssignableMaps = areAssignableMaps; | |
| 3880 exports.isFunctionSubtype = isFunctionSubtype; | |
| 3881 exports.invoke = invoke; | |
| 3882 exports.invokeOn = invokeOn; | |
| 3883 exports.call = call; | |
| 3884 exports.getField = getField; | |
| 3885 exports.getIndex = getIndex; | |
| 3886 exports.getLength = getLength; | |
| 3887 exports.isJsArray = isJsArray; | |
| 3888 exports.hasField = hasField; | |
| 3889 exports.hasNoField = hasNoField; | |
| 3890 exports.isJsFunction = isJsFunction; | |
| 3891 exports.isJsObject = isJsObject; | |
| 3892 exports.isIdentical = isIdentical; | |
| 3893 exports.isNotIdentical = isNotIdentical; | |
| 3894 })(_js_helper || (_js_helper = {})); | |
| OLD | NEW |