| OLD | NEW |
| (Empty) | |
| 1 var _js_helper; |
| 2 (function(_js_helper) { |
| 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 dart.as(_foreign_helper.JS('String', '"" + (#)', value), core.Str
ing); |
| 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, internalName, kind, arguments, argumentN
ames); |
| 46 } |
| 47 // Function createUnmangledInvocationMirror: (Symbol, dynamic, dynamic, dynami
c, dynamic) → dynamic |
| 48 function createUnmangledInvocationMirror(symbol, internalName, kind, arguments
, argumentNames) { |
| 49 return new JSInvocationMirror(symbol, internalName, kind, arguments, argumen
tNames); |
| 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 (_foreign_helper.JS('bool', '!this.cache')) { |
| 58 _foreign_helper.JS('', 'this.cache = Object.create(null)'); |
| 59 } |
| 60 if (_foreign_helper.JS('bool', '!this.cache[#]', method)) { |
| 61 _foreign_helper.JS('', 'console.log(#)', method); |
| 62 _foreign_helper.JS('', 'this.cache[#] = true', method); |
| 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(this._namedArgumentNames.get(i)
), 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 = dart.as(_foreign_helper.JS("bool", 'Object.prototype.h
asOwnProperty.call(#, #)', interceptedNames, name), core.bool); |
| 133 if (isIntercepted) { |
| 134 receiver = interceptor; |
| 135 if (_foreign_helper.JS('bool', '# === #', object, interceptor)) { |
| 136 interceptor = null; |
| 137 } |
| 138 } else { |
| 139 interceptor = null; |
| 140 } |
| 141 let isCatchAll = false; |
| 142 let method = _foreign_helper.JS('var', '#[#]', receiver, name); |
| 143 if (_foreign_helper.JS('bool', 'typeof # != "function"', method)) { |
| 144 let baseName = _internal.Symbol.getName(dart.as(this.memberName, _intern
al.Symbol)); |
| 145 method = _foreign_helper.JS('', '#[# + "*"]', receiver, baseName); |
| 146 if (method === null) { |
| 147 interceptor = _interceptors.getInterceptor(object); |
| 148 method = _foreign_helper.JS('', '#[# + "*"]', 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 (_foreign_helper.JS('bool', 'typeof # == "function"', method)) { |
| 159 if (isCatchAll) { |
| 160 return new CachedCatchAllInvocation(name, method, isIntercepted, inter
ceptor); |
| 161 } else { |
| 162 return new CachedInvocation(name, method, isIntercepted, 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 dart.as(_foreign_helper.JS("bool", "!!#.$getterStub", this.jsFuncti
on), core.bool); |
| 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 _foreign_helper.JS("var", "#.apply(#, #)", this.jsFunction, receive
r, 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 _foreign_helper.JS("var", "#.apply(#, #)", this.jsFunction, receive
r, 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(_foreign_helper.JS('JSExtendableArray|Null', '#.$reflec
tionInfo', jsFunction), core.List); |
| 280 if (data === null) |
| 281 return null; |
| 282 data = _interceptors.JSArray.markFixedList(data); |
| 283 let requiredParametersInfo = dart.as(_foreign_helper.JS('int', '#[#]', dat
a, REQUIRED_PARAMETERS_INFO), core.int); |
| 284 let requiredParameterCount = dart.as(_foreign_helper.JS('int', '# >> 1', r
equiredParametersInfo), core.int); |
| 285 let isAccessor = (requiredParametersInfo & 1) === 1; |
| 286 let optionalParametersInfo = dart.as(_foreign_helper.JS('int', '#[#]', dat
a, OPTIONAL_PARAMETERS_INFO), core.int); |
| 287 let optionalParameterCount = dart.as(_foreign_helper.JS('int', '# >> 1', o
ptionalParametersInfo), core.int); |
| 288 let areOptionalParametersNamed = (optionalParametersInfo & 1) === 1; |
| 289 let functionType = _foreign_helper.JS('', '#[#]', data, FUNCTION_TYPE_INDE
X); |
| 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 = dart.as(_foreign_helper.JS('int', '#[2 * # + # + #]', th
is.data, parameter, this.optionalParameterCount, FIRST_DEFAULT_ARGUMENT), core.i
nt); |
| 296 } else { |
| 297 metadataIndex = dart.as(_foreign_helper.JS('int', '#[# + # + #]', this.d
ata, parameter, this.optionalParameterCount, FIRST_DEFAULT_ARGUMENT), core.int); |
| 298 } |
| 299 let metadata = _foreign_helper.JS_EMBEDDED_GLOBAL('', dart.as(_js_embedded
_names.METADATA, core.String)); |
| 300 return dart.as(_foreign_helper.JS('String', '#[#]', metadata, metadataInde
x), core.String); |
| 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(_foreign_helper.JS('', '#[2 * # + # + # + 1]', this.data,
parameter, this.optionalParameterCount, FIRST_DEFAULT_ARGUMENT), core.List$(cor
e.int)); |
| 307 } |
| 308 } |
| 309 defaultValue(parameter) { |
| 310 if (parameter < this.requiredParameterCount) |
| 311 return dart.as(null, core.int); |
| 312 return dart.as(_foreign_helper.JS('int', '#[# + # - #]', this.data, FIRST_
DEFAULT_ARGUMENT, parameter, this.requiredParameterCount), core.int); |
| 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 (_foreign_helper.JS('bool', 'typeof # == "number"', this.functionType))
{ |
| 352 return getMetadata(dart.as(this.functionType, core.int)); |
| 353 } else if (_foreign_helper.JS('bool', 'typeof # == "function"', this.funct
ionType)) { |
| 354 let fakeInstance = _foreign_helper.JS('', 'new #()', jsConstructor); |
| 355 setRuntimeTypeInfo(fakeInstance, _foreign_helper.JS('JSExtendableArray',
'#["<>"]', fakeInstance)); |
| 356 return _foreign_helper.JS('=Object|Null', '#.apply({$receiver:#})', this
.functionType, fakeInstance); |
| 357 } else { |
| 358 throw new RuntimeError('Unexpected function type'); |
| 359 } |
| 360 } |
| 361 get reflectionName() { |
| 362 return dart.as(_foreign_helper.JS('String', '#.$reflectionName', this.jsFu
nction), core.String); |
| 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 _foreign_helper.JS('', '#[#]', 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(_foreign_helper.JS('int|Null', '#.$identityHash', objec
t), core.int); |
| 382 if (hash === null) { |
| 383 hash = dart.as(_foreign_helper.JS('int', '(Math.random() * 0x3fffffff) |
0'), core.int); |
| 384 _foreign_helper.JS('void', '#.$identityHash = #', object, hash); |
| 385 } |
| 386 return dart.as(_foreign_helper.JS('int', '#', hash), core.int); |
| 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 = _foreign_helper.JS('JSExtendableArray|Null', '/^\\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.as(_foreign_helper.JS('num', 'parseInt(#, 16)', source),
core.int); |
| 405 } |
| 406 if (dart.dindex(match, decimalIndex) !== null) { |
| 407 return dart.as(_foreign_helper.JS('num', 'parseInt(#, 10)', source),
core.int); |
| 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.as(_foreign_helper.JS('num', 'parseInt(#, 10)', source),
core.int); |
| 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.as(_foreign_helper.JS('num', 'parseInt(#, #)', source, radix),
core.int); |
| 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.throw_("Unimplemented PrefixExpression: !JS('bool', r'/^\\s*[+-]?
(?:Infinity|NaN|' r'(?:\\.\\d+|\\d+(?:\\.\\d*)?)(?:[eE][+-]?\\d+)?)\\s*$/.test(#
)', source)")) { |
| 447 return handleError(source); |
| 448 } |
| 449 let result = _foreign_helper.JS('num', 'parseFloat(#)', source); |
| 450 if (dart.dload(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.as(result, core.double); |
| 454 } |
| 455 return handleError(source); |
| 456 } |
| 457 return dart.as(result, core.double); |
| 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 = _foreign_helper.JS('var', '#.match(/^\\s*function\\s*(\
\S*)\\s*\\(/)[1]', _foreign_helper.JS('var', 'String(#.constructor)', object)); |
| 466 if (typeof decompiled == string) |
| 467 if (_foreign_helper.JS('bool', '/^\\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 dart.as(_foreign_helper.JS('int', 'Date.now()'), core.num); |
| 481 } |
| 482 static initTicker() { |
| 483 if (timerFrequency !== null) |
| 484 return; |
| 485 timerFrequency = 1000; |
| 486 timerTicks = dateNow; |
| 487 if (_foreign_helper.JS('bool', 'typeof window == "undefined"')) |
| 488 return; |
| 489 let window = _foreign_helper.JS('var', 'window'); |
| 490 if (window === null) |
| 491 return; |
| 492 let performance = _foreign_helper.JS('var', '#.performance', window); |
| 493 if (performance === null) |
| 494 return; |
| 495 if (_foreign_helper.JS('bool', 'typeof #.now != "function"', performance)) |
| 496 return; |
| 497 timerFrequency = 1000000; |
| 498 timerTicks = (() => 1000['*'](_foreign_helper.JS('num', '#.now()', perform
ance)).floor()).bind(this); |
| 499 } |
| 500 static get isD8() { |
| 501 return dart.as(_foreign_helper.JS('bool', 'typeof version == "function"' +
' && typeof os == "object" && "system" in os'), core.bool); |
| 502 } |
| 503 static get isJsshell() { |
| 504 return dart.as(_foreign_helper.JS('bool', 'typeof version == "function" &&
typeof system == "function"'), core.bool); |
| 505 } |
| 506 static currentUri() { |
| 507 requiresPreamble(); |
| 508 if (_foreign_helper.JS('bool', '!!self.location')) { |
| 509 return dart.as(_foreign_helper.JS('String', 'self.location.href'), core.
String); |
| 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 = _foreign_helper.JS('JSExtendableArray', '#.slice(#, #)', ar
ray, i, i + kMaxApply < end ? i + kMaxApply : end); |
| 523 } |
| 524 result = dart.as(_foreign_helper.JS('String', '# + String.fromCharCode.a
pply(#, #)', result, null, subarray), core.String); |
| 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 dart.as(_foreign_helper.JS('String', 'String.fromCharCode(#)',
charCode), core.String); |
| 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 dart.as(_foreign_helper.JS('String', 'String.fromCharCode(#, #)
', high, low), core.String); |
| 565 } |
| 566 } |
| 567 throw new core.RangeError.range(charCode, 0, 1114111); |
| 568 } |
| 569 static stringConcatUnchecked(string1, string2) { |
| 570 return _foreign_helper.JS_STRING_CONCAT(string1, string2); |
| 571 } |
| 572 static flattenString(str) { |
| 573 return dart.as(_foreign_helper.JS('String', "#.charCodeAt(0) == 0 ? # : #"
, str, str, str), core.String); |
| 574 } |
| 575 static getTimeZoneName(receiver) { |
| 576 let d = lazyAsJsDate(receiver); |
| 577 let match = dart.as(_foreign_helper.JS('JSArray|Null', '/\\((.*)\\)/.exec(
#.toString())', d), core.List); |
| 578 if (match !== null) |
| 579 return dart.as(match.get(1), core.String); |
| 580 match = dart.as(_foreign_helper.JS('JSArray|Null', '/^[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(#.toString())', d), core.List); |
| 581 if (match !== null) |
| 582 return dart.as(match.get(1), core.String); |
| 583 match = dart.as(_foreign_helper.JS('JSArray|Null', '/(?:GMT|UTC)[+-]\\d{4}
/.exec(#.toString())', d), core.List); |
| 584 if (match !== null) |
| 585 return dart.as(match.get(0), core.String); |
| 586 return ""; |
| 587 } |
| 588 static getTimeZoneOffsetInMinutes(receiver) { |
| 589 return dart.as(dart.throw_("Unimplemented PrefixExpression: -JS('int', r'#
.getTimezoneOffset()', lazyAsJsDate(receiver))"), core.int); |
| 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 = _foreign_helper.JS('num', 'Date.UTC(#, #, #, #, #, #, #)', years
, jsMonth, day, hours, minutes, seconds, milliseconds); |
| 605 } else { |
| 606 value = _foreign_helper.JS('num', 'new Date(#, #, #, #, #, #, #).valueOf
()', years, jsMonth, day, hours, minutes, seconds, milliseconds); |
| 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 = _foreign_helper.JS('', 'new Date(#)', value); |
| 617 if (isUtc) { |
| 618 _foreign_helper.JS('num', '#.setUTCFullYear(#)', date, years); |
| 619 } else { |
| 620 _foreign_helper.JS('num', '#.setFullYear(#)', date, years); |
| 621 } |
| 622 return _foreign_helper.JS('num', '#.valueOf()', date); |
| 623 } |
| 624 static lazyAsJsDate(receiver) { |
| 625 if (_foreign_helper.JS('bool', '#.date === (void 0)', receiver)) { |
| 626 _foreign_helper.JS('void', '#.date = new Date(#)', receiver, dart.dload(
receiver, 'millisecondsSinceEpoch')); |
| 627 } |
| 628 return _foreign_helper.JS('var', '#.date', receiver); |
| 629 } |
| 630 static getYear(receiver) { |
| 631 return dart.dload(receiver, 'isUtc') ? _foreign_helper.JS('int', '(#.getUT
CFullYear() + 0)', lazyAsJsDate(receiver)) : _foreign_helper.JS('int', '(#.getFu
llYear() + 0)', lazyAsJsDate(receiver)); |
| 632 } |
| 633 static getMonth(receiver) { |
| 634 return dart.dload(receiver, 'isUtc') ? _foreign_helper.JS('int', '#.getUTC
Month() + 1', lazyAsJsDate(receiver)) : _foreign_helper.JS('int', '#.getMonth()
+ 1', lazyAsJsDate(receiver)); |
| 635 } |
| 636 static getDay(receiver) { |
| 637 return dart.dload(receiver, 'isUtc') ? _foreign_helper.JS('int', '(#.getUT
CDate() + 0)', lazyAsJsDate(receiver)) : _foreign_helper.JS('int', '(#.getDate()
+ 0)', lazyAsJsDate(receiver)); |
| 638 } |
| 639 static getHours(receiver) { |
| 640 return dart.dload(receiver, 'isUtc') ? _foreign_helper.JS('int', '(#.getUT
CHours() + 0)', lazyAsJsDate(receiver)) : _foreign_helper.JS('int', '(#.getHours
() + 0)', lazyAsJsDate(receiver)); |
| 641 } |
| 642 static getMinutes(receiver) { |
| 643 return dart.dload(receiver, 'isUtc') ? _foreign_helper.JS('int', '(#.getUT
CMinutes() + 0)', lazyAsJsDate(receiver)) : _foreign_helper.JS('int', '(#.getMin
utes() + 0)', lazyAsJsDate(receiver)); |
| 644 } |
| 645 static getSeconds(receiver) { |
| 646 return dart.dload(receiver, 'isUtc') ? _foreign_helper.JS('int', '(#.getUT
CSeconds() + 0)', lazyAsJsDate(receiver)) : _foreign_helper.JS('int', '(#.getSec
onds() + 0)', lazyAsJsDate(receiver)); |
| 647 } |
| 648 static getMilliseconds(receiver) { |
| 649 return dart.dload(receiver, 'isUtc') ? _foreign_helper.JS('int', '(#.getUT
CMilliseconds() + 0)', lazyAsJsDate(receiver)) : _foreign_helper.JS('int', '(#.g
etMilliseconds() + 0)', lazyAsJsDate(receiver)); |
| 650 } |
| 651 static getWeekday(receiver) { |
| 652 let weekday = dart.as(dart.dload(receiver, 'isUtc') ? _foreign_helper.JS('
int', '#.getUTCDay() + 0', lazyAsJsDate(receiver)) : _foreign_helper.JS('int', '
#.getDay() + 0', lazyAsJsDate(receiver)), core.int); |
| 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 = _foreign_helper.JS('num', 'Date.parse(#)', str); |
| 659 if (dart.dload(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 _foreign_helper.JS('var', '#[#]', 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 _foreign_helper.JS('void', '#[#] = #', 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 (_foreign_helper.JS('bool', '# instanceof Array', positionalArguments
)) { |
| 703 arguments = positionalArguments; |
| 704 } else { |
| 705 arguments = new core.List.from(positionalArguments); |
| 706 } |
| 707 argumentCount = dart.as(_foreign_helper.JS('int', '#.length', arguments)
, core.int); |
| 708 } else { |
| 709 arguments = new List.from([]); |
| 710 } |
| 711 let selectorName = `${_foreign_helper.JS_GET_NAME("CALL_PREFIX")}$${argume
ntCount}`; |
| 712 let jsFunction = _foreign_helper.JS('var', '#[#]', function, selectorName)
; |
| 713 if (jsFunction === null) { |
| 714 return functionNoSuchMethod(function, positionalArguments, null); |
| 715 } |
| 716 return _foreign_helper.JS('var', '#.apply(#, #)', jsFunction, function, ar
guments); |
| 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 = _foreign_helper.JS('', '#["call*"]', interceptor); |
| 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 _foreign_helper.JS('', '#.apply(#, #)', jsFunction, function, posit
ionalArguments); |
| 760 } |
| 761 static _mangledNameMatchesType(mangledName, type) { |
| 762 return _foreign_helper.JS('bool', '# == #', mangledName, type._typeName); |
| 763 } |
| 764 static identicalImplementation(a, b) { |
| 765 return dart.as(_foreign_helper.JS('bool', '# == null', a) ? _foreign_helpe
r.JS('bool', '# == null', b) : _foreign_helper.JS('bool', '# === #', a, b), core
.bool); |
| 766 } |
| 767 static extractStackTrace(error) { |
| 768 return getTraceFromException(_foreign_helper.JS('', '#.$thrownJsError', er
ror)); |
| 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 = _foreign_helper.JS('=Object', 'Object.create(null)'); |
| 779 _foreign_helper.JS('void', '#.x=0', result); |
| 780 _foreign_helper.JS('void', 'delete #.x', result); |
| 781 return result; |
| 782 } |
| 783 static fetch(cache, key) { |
| 784 return _foreign_helper.JS('', '#[#]', cache, key); |
| 785 } |
| 786 static update(cache, key, value) { |
| 787 _foreign_helper.JS('void', '#[#] = #', 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(index); |
| 801 } |
| 802 // Function stringLastIndexOfUnchecked: (dynamic, dynamic, dynamic) → dynamic |
| 803 function stringLastIndexOfUnchecked(receiver, element, start) { |
| 804 return _foreign_helper.JS('int', '#.lastIndexOf(#, #)', receiver, element, s
tart); |
| 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 = _foreign_helper.JS('', 'new Error()'); |
| 845 _foreign_helper.JS('void', '#.dartException = #', wrapper, ex); |
| 846 if (_foreign_helper.JS('bool', '"defineProperty" in Object')) { |
| 847 _foreign_helper.JS('void', 'Object.defineProperty(#, "message", { get: # }
)', wrapper, _foreign_helper.DART_CLOSURE_TO_JS(toStringWrapper)); |
| 848 _foreign_helper.JS('void', '#.name = ""', wrapper); |
| 849 } else { |
| 850 _foreign_helper.JS('void', '#.toString = #', wrapper, _foreign_helper.DART
_CLOSURE_TO_JS(toStringWrapper)); |
| 851 } |
| 852 return wrapper; |
| 853 } |
| 854 // Function toStringWrapper: () → dynamic |
| 855 function toStringWrapper() { |
| 856 return dart.dinvoke(_foreign_helper.JS('', 'this.dartException'), 'toString'
); |
| 857 } |
| 858 // Function throwExpression: (dynamic) → dynamic |
| 859 function throwExpression(ex) { |
| 860 _foreign_helper.JS('void', 'throw #', wrapException(ex)); |
| 861 } |
| 862 // Function makeLiteralListConst: (dynamic) → dynamic |
| 863 function makeLiteralListConst(list) { |
| 864 _foreign_helper.JS('bool', '#.immutable$list = #', list, true); |
| 865 _foreign_helper.JS('bool', '#.fixed$length = #', list, 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(className); |
| 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 = _foreign_helper.JS('JSExtendableArray|Null', 'new RegExp(#).ex
ec(#)', this._pattern, message); |
| 887 if (match === null) |
| 888 return null; |
| 889 let result = _foreign_helper.JS('', 'Object.create(null)'); |
| 890 if (this._arguments !== -1) { |
| 891 _foreign_helper.JS('', '#.arguments = #[# + 1]', result, match, this._ar
guments); |
| 892 } |
| 893 if (this._argumentsExpr !== -1) { |
| 894 _foreign_helper.JS('', '#.argumentsExpr = #[# + 1]', result, match, this
._argumentsExpr); |
| 895 } |
| 896 if (this._expr !== -1) { |
| 897 _foreign_helper.JS('', '#.expr = #[# + 1]', result, match, this._expr); |
| 898 } |
| 899 if (this._method !== -1) { |
| 900 _foreign_helper.JS('', '#.method = #[# + 1]', result, match, this._metho
d); |
| 901 } |
| 902 if (this._receiver !== -1) { |
| 903 _foreign_helper.JS('', '#.receiver = #[# + 1]', result, match, this._rec
eiver); |
| 904 } |
| 905 return result; |
| 906 } |
| 907 static buildJavaScriptObject() { |
| 908 return _foreign_helper.JS('', '{ toString: function() { return "$receiver$
"; } }'); |
| 909 } |
| 910 static buildJavaScriptObjectWithNonClosure() { |
| 911 return _foreign_helper.JS('', '{ $method$: null, ' + 'toString: function()
{ return "$receiver$"; } }'); |
| 912 } |
| 913 static extractPattern(message) { |
| 914 message = dart.as(_foreign_helper.JS('String', "#.replace(String({}), '$re
ceiver$')", message), core.String); |
| 915 message = dart.as(_foreign_helper.JS('String', "#.replace(new RegExp(#, 'g
'), '\\\\$&')", message, ESCAPE_REGEXP), core.String); |
| 916 let match = dart.as(_foreign_helper.JS('JSExtendableArray|Null', "#.match(
/\\\\\\$[a-zA-Z]+\\\\\\$/g)", message), core.List$(core.String)); |
| 917 if (match === null) |
| 918 match = dart.as(new List.from([]), core.List$(core.String)); |
| 919 let arguments = dart.as(_foreign_helper.JS('int', '#.indexOf(#)', match, '
\\$arguments\\$'), core.int); |
| 920 let argumentsExpr = dart.as(_foreign_helper.JS('int', '#.indexOf(#)', matc
h, '\\$argumentsExpr\\$'), core.int); |
| 921 let expr = dart.as(_foreign_helper.JS('int', '#.indexOf(#)', match, '\\$ex
pr\\$'), core.int); |
| 922 let method = dart.as(_foreign_helper.JS('int', '#.indexOf(#)', match, '\\$
method\\$'), core.int); |
| 923 let receiver = dart.as(_foreign_helper.JS('int', '#.indexOf(#)', match, '\
\$receiver\\$'), core.int); |
| 924 let pattern = dart.as(_foreign_helper.JS('String', "#.replace('\\\\$argume
nts\\\\$', '((?:x|[^x])*)')" + ".replace('\\\\$argumentsExpr\\\\$', '((?:x|[^x]
)*)')" + ".replace('\\\\$expr\\\\$', '((?:x|[^x])*)')" + ".replace('\\\\$method
\\\\$', '((?:x|[^x])*)')" + ".replace('\\\\$receiver\\\\$', '((?:x|[^x])*)')",
message), core.String); |
| 925 return new TypeErrorDecoder(arguments, argumentsExpr, expr, method, receiv
er, pattern); |
| 926 } |
| 927 static provokeCallErrorOn(expression) { |
| 928 let function = _foreign_helper.JS('', "function($expr$) {\n var $argument
sExpr$ = '$arguments$';\n try {\n $expr$.$method$($argumentsExpr$);\n } cat
ch (e) {\n return e.message;\n }\n}"); |
| 929 return dart.as(_foreign_helper.JS('String', '(#)(#)', function, expression
), core.String); |
| 930 } |
| 931 static provokeCallErrorOnNull() { |
| 932 let function = _foreign_helper.JS('', "function() {\n var $argumentsExpr$
= '$arguments$';\n try {\n null.$method$($argumentsExpr$);\n } catch (e) {
\n return e.message;\n }\n}"); |
| 933 return dart.as(_foreign_helper.JS('String', '(#)()', function), core.Strin
g); |
| 934 } |
| 935 static provokeCallErrorOnUndefined() { |
| 936 let function = _foreign_helper.JS('', "function() {\n var $argumentsExpr$
= '$arguments$';\n try {\n (void 0).$method$($argumentsExpr$);\n } catch (
e) {\n return e.message;\n }\n}"); |
| 937 return dart.as(_foreign_helper.JS('String', '(#)()', function), core.Strin
g); |
| 938 } |
| 939 static provokePropertyErrorOn(expression) { |
| 940 let function = _foreign_helper.JS('', "function($expr$) {\n try {\n $e
xpr$.$method$;\n } catch (e) {\n return e.message;\n }\n}"); |
| 941 return dart.as(_foreign_helper.JS('String', '(#)(#)', function, expression
), core.String); |
| 942 } |
| 943 static provokePropertyErrorOnNull() { |
| 944 let function = _foreign_helper.JS('', "function() {\n try {\n null.$me
thod$;\n } catch (e) {\n return e.message;\n }\n}"); |
| 945 return dart.as(_foreign_helper.JS('String', '(#)()', function), core.Strin
g); |
| 946 } |
| 947 static provokePropertyErrorOnUndefined() { |
| 948 let function = _foreign_helper.JS('', "function() {\n try {\n (void 0)
.$method$;\n } catch (e) {\n return e.message;\n }\n}"); |
| 949 return dart.as(_foreign_helper.JS('String', '(#)()', function), core.Strin
g); |
| 950 } |
| 951 } |
| 952 dart.defineLazyProperties(TypeErrorDecoder, { |
| 953 get noSuchMethodPattern() { |
| 954 return dart.as(extractPattern(provokeCallErrorOn(buildJavaScriptObject()))
, TypeErrorDecoder); |
| 955 }, |
| 956 get notClosurePattern() { |
| 957 return dart.as(extractPattern(provokeCallErrorOn(buildJavaScriptObjectWith
NonClosure())), TypeErrorDecoder); |
| 958 }, |
| 959 get nullCallPattern() { |
| 960 return dart.as(extractPattern(provokeCallErrorOn(_foreign_helper.JS('', 'n
ull'))), TypeErrorDecoder); |
| 961 }, |
| 962 get nullLiteralCallPattern() { |
| 963 return dart.as(extractPattern(provokeCallErrorOnNull()), TypeErrorDecoder)
; |
| 964 }, |
| 965 get undefinedCallPattern() { |
| 966 return dart.as(extractPattern(provokeCallErrorOn(_foreign_helper.JS('', 'v
oid 0'))), TypeErrorDecoder); |
| 967 }, |
| 968 get undefinedLiteralCallPattern() { |
| 969 return dart.as(extractPattern(provokeCallErrorOnUndefined()), TypeErrorDec
oder); |
| 970 }, |
| 971 get nullPropertyPattern() { |
| 972 return dart.as(extractPattern(provokePropertyErrorOn(_foreign_helper.JS(''
, 'null'))), TypeErrorDecoder); |
| 973 }, |
| 974 get nullLiteralPropertyPattern() { |
| 975 return dart.as(extractPattern(provokePropertyErrorOnNull()), TypeErrorDeco
der); |
| 976 }, |
| 977 get undefinedPropertyPattern() { |
| 978 return dart.as(extractPattern(provokePropertyErrorOn(_foreign_helper.JS(''
, 'void 0'))), TypeErrorDecoder); |
| 979 }, |
| 980 get undefinedLiteralPropertyPattern() { |
| 981 return dart.as(extractPattern(provokePropertyErrorOnUndefined()), TypeErro
rDecoder); |
| 982 } |
| 983 }); |
| 984 class NullError extends core.Error { |
| 985 NullError(_message, match) { |
| 986 this._message = _message; |
| 987 this._method = match === null ? null : _foreign_helper.JS('', '#.method',
match); |
| 988 super.Error(); |
| 989 } |
| 990 toString() { |
| 991 if (this._method === null) |
| 992 return `NullError: ${this._message}`; |
| 993 return `NullError: Cannot call "${this._method}" on null`; |
| 994 } |
| 995 } |
| 996 class JsNoSuchMethodError extends core.Error { |
| 997 JsNoSuchMethodError(_message, match) { |
| 998 this._message = _message; |
| 999 this._method = match === null ? null : _foreign_helper.JS('String|Null', '
#.method', match); |
| 1000 this._receiver = match === null ? null : _foreign_helper.JS('String|Null',
'#.receiver', match); |
| 1001 super.Error(); |
| 1002 } |
| 1003 toString() { |
| 1004 if (this._method === null) |
| 1005 return `NoSuchMethodError: ${this._message}`; |
| 1006 if (this._receiver === null) { |
| 1007 return `NoSuchMethodError: Cannot call "${this._method}" (${this._messag
e})`; |
| 1008 } |
| 1009 return `NoSuchMethodError: Cannot call "${this._method}" on "${this._recei
ver}" ` + `(${this._message})`; |
| 1010 } |
| 1011 } |
| 1012 class UnknownJsTypeError extends core.Error { |
| 1013 UnknownJsTypeError(_message) { |
| 1014 this._message = _message; |
| 1015 super.Error(); |
| 1016 } |
| 1017 toString() { |
| 1018 return this._message.isEmpty ? 'Error' : `Error: ${this._message}`; |
| 1019 } |
| 1020 } |
| 1021 // Function unwrapException: (dynamic) → dynamic |
| 1022 function unwrapException(ex) { |
| 1023 // Function saveStackTrace: (dynamic) → dynamic |
| 1024 function saveStackTrace(error) { |
| 1025 if (dart.is(error, core.Error)) { |
| 1026 let thrownStackTrace = _foreign_helper.JS('', '#.$thrownJsError', error)
; |
| 1027 if (thrownStackTrace === null) { |
| 1028 _foreign_helper.JS('void', '#.$thrownJsError = #', error, ex); |
| 1029 } |
| 1030 } |
| 1031 return error; |
| 1032 } |
| 1033 if (ex === null) |
| 1034 return null; |
| 1035 if (_foreign_helper.JS('bool', 'typeof # !== "object"', ex)) |
| 1036 return ex; |
| 1037 if (_foreign_helper.JS('bool', '"dartException" in #', ex)) { |
| 1038 return saveStackTrace(_foreign_helper.JS('', '#.dartException', ex)); |
| 1039 } else if (dart.throw_("Unimplemented PrefixExpression: !JS('bool', r'\"mess
age\" in #', ex)")) { |
| 1040 return ex; |
| 1041 } |
| 1042 let message = _foreign_helper.JS('var', '#.message', ex); |
| 1043 if (dart.dbinary(_foreign_helper.JS('bool', '"number" in #', ex), '&&', _for
eign_helper.JS('bool', 'typeof #.number == "number"', ex))) { |
| 1044 let number = dart.as(_foreign_helper.JS('int', '#.number', ex), core.int); |
| 1045 let ieErrorCode = number & 65535; |
| 1046 let ieFacilityNumber = number >> 16 & 8191; |
| 1047 if (ieFacilityNumber === 10) { |
| 1048 switch (ieErrorCode) { |
| 1049 case 438: |
| 1050 return saveStackTrace(new JsNoSuchMethodError(`${message} (Error ${i
eErrorCode})`, null)); |
| 1051 case 445: |
| 1052 case 5007: |
| 1053 return saveStackTrace(new NullError(`${message} (Error ${ieErrorCode
})`, null)); |
| 1054 } |
| 1055 } |
| 1056 } |
| 1057 if (_foreign_helper.JS('bool', '# instanceof TypeError', ex)) { |
| 1058 let match = null; |
| 1059 let nsme = _foreign_helper.JS('TypeErrorDecoder', '#', TypeErrorDecoder.no
SuchMethodPattern); |
| 1060 let notClosure = _foreign_helper.JS('TypeErrorDecoder', '#', TypeErrorDeco
der.notClosurePattern); |
| 1061 let nullCall = _foreign_helper.JS('TypeErrorDecoder', '#', TypeErrorDecode
r.nullCallPattern); |
| 1062 let nullLiteralCall = _foreign_helper.JS('TypeErrorDecoder', '#', TypeErro
rDecoder.nullLiteralCallPattern); |
| 1063 let undefCall = _foreign_helper.JS('TypeErrorDecoder', '#', TypeErrorDecod
er.undefinedCallPattern); |
| 1064 let undefLiteralCall = _foreign_helper.JS('TypeErrorDecoder', '#', TypeErr
orDecoder.undefinedLiteralCallPattern); |
| 1065 let nullProperty = _foreign_helper.JS('TypeErrorDecoder', '#', TypeErrorDe
coder.nullPropertyPattern); |
| 1066 let nullLiteralProperty = _foreign_helper.JS('TypeErrorDecoder', '#', Type
ErrorDecoder.nullLiteralPropertyPattern); |
| 1067 let undefProperty = _foreign_helper.JS('TypeErrorDecoder', '#', TypeErrorD
ecoder.undefinedPropertyPattern); |
| 1068 let undefLiteralProperty = _foreign_helper.JS('TypeErrorDecoder', '#', Typ
eErrorDecoder.undefinedLiteralPropertyPattern); |
| 1069 if ((match = dart.dinvoke(nsme, 'matchTypeError', message)) !== null) { |
| 1070 return saveStackTrace(new JsNoSuchMethodError(message, match)); |
| 1071 } else if ((match = dart.dinvoke(notClosure, 'matchTypeError', message)) !
== null) { |
| 1072 _foreign_helper.JS('', '#.method = "call"', match); |
| 1073 return saveStackTrace(new JsNoSuchMethodError(message, match)); |
| 1074 } 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)) { |
| 1075 return saveStackTrace(new NullError(message, match)); |
| 1076 } |
| 1077 return saveStackTrace(new UnknownJsTypeError(typeof message == string ? me
ssage : '')); |
| 1078 } |
| 1079 if (_foreign_helper.JS('bool', '# instanceof RangeError', ex)) { |
| 1080 if (dart.notNull(typeof message == string) && dart.notNull(contains(dart.a
s(message, core.String), 'call stack'))) { |
| 1081 return new core.StackOverflowError(); |
| 1082 } |
| 1083 return saveStackTrace(new core.ArgumentError()); |
| 1084 } |
| 1085 if (_foreign_helper.JS('bool', 'typeof InternalError == "function" && # inst
anceof InternalError', ex)) { |
| 1086 if (dart.notNull(typeof message == string) && dart.notNull(dart.equals(mes
sage, 'too much recursion'))) { |
| 1087 return new core.StackOverflowError(); |
| 1088 } |
| 1089 } |
| 1090 return ex; |
| 1091 } |
| 1092 // Function getTraceFromException: (dynamic) → StackTrace |
| 1093 function getTraceFromException(exception) { |
| 1094 return new _StackTrace(exception); |
| 1095 } |
| 1096 class _StackTrace extends dart.Object { |
| 1097 _StackTrace(_exception) { |
| 1098 this._exception = _exception; |
| 1099 this._trace = null; |
| 1100 } |
| 1101 toString() { |
| 1102 if (this._trace !== null) |
| 1103 return this._trace; |
| 1104 let trace = null; |
| 1105 if (_foreign_helper.JS('bool', 'typeof # === "object"', this._exception))
{ |
| 1106 trace = dart.as(_foreign_helper.JS("String|Null", "#.stack", this._excep
tion), core.String); |
| 1107 } |
| 1108 return this._trace = trace === null ? '' : trace; |
| 1109 } |
| 1110 } |
| 1111 // Function objectHashCode: (dynamic) → int |
| 1112 function objectHashCode(object) { |
| 1113 if (core.bool['||'](object === null, _foreign_helper.JS('bool', "typeof # !=
'object'", object))) { |
| 1114 return dart.as(dart.dload(object, 'hashCode'), core.int); |
| 1115 } else { |
| 1116 return Primitives.objectHashCode(object); |
| 1117 } |
| 1118 } |
| 1119 // Function fillLiteralMap: (dynamic, Map<dynamic, dynamic>) → dynamic |
| 1120 function fillLiteralMap(keyValuePairs, result) { |
| 1121 let index = 0; |
| 1122 let length = getLength(keyValuePairs); |
| 1123 while (index < length) { |
| 1124 let key = getIndex(keyValuePairs, index++); |
| 1125 let value = getIndex(keyValuePairs, index++); |
| 1126 result.set(key, value); |
| 1127 } |
| 1128 return result; |
| 1129 } |
| 1130 // Function invokeClosure: (Function, dynamic, int, dynamic, dynamic, dynamic,
dynamic) → dynamic |
| 1131 function invokeClosure(closure, isolate, numberOfArguments, arg1, arg2, arg3,
arg4) { |
| 1132 if (numberOfArguments === 0) { |
| 1133 return _foreign_helper.JS_CALL_IN_ISOLATE(isolate, () => dart.dinvokef(clo
sure)); |
| 1134 } else if (numberOfArguments === 1) { |
| 1135 return _foreign_helper.JS_CALL_IN_ISOLATE(isolate, () => dart.dinvokef(clo
sure, arg1)); |
| 1136 } else if (numberOfArguments === 2) { |
| 1137 return _foreign_helper.JS_CALL_IN_ISOLATE(isolate, () => dart.dinvokef(clo
sure, arg1, arg2)); |
| 1138 } else if (numberOfArguments === 3) { |
| 1139 return _foreign_helper.JS_CALL_IN_ISOLATE(isolate, () => dart.dinvokef(clo
sure, arg1, arg2, arg3)); |
| 1140 } else if (numberOfArguments === 4) { |
| 1141 return _foreign_helper.JS_CALL_IN_ISOLATE(isolate, () => dart.dinvokef(clo
sure, arg1, arg2, arg3, arg4)); |
| 1142 } else { |
| 1143 throw new core.Exception('Unsupported number of arguments for wrapped clos
ure'); |
| 1144 } |
| 1145 } |
| 1146 // Function convertDartClosureToJS: (dynamic, int) → dynamic |
| 1147 function convertDartClosureToJS(closure, arity) { |
| 1148 if (closure === null) |
| 1149 return null; |
| 1150 let function = _foreign_helper.JS('var', '#.$identity', closure); |
| 1151 if (_foreign_helper.JS('bool', '!!#', function)) |
| 1152 return function; |
| 1153 function = _foreign_helper.JS('var', '(function(closure, arity, context, inv
oke) {' + ' return function(a1, a2, a3, a4) {' + ' return invoke(closure, c
ontext, arity, a1, a2, a3, a4);' + ' };' + '})(#,#,#,#)', closure, arity, _fore
ign_helper.JS_CURRENT_ISOLATE_CONTEXT(), _foreign_helper.DART_CLOSURE_TO_JS(invo
keClosure)); |
| 1154 _foreign_helper.JS('void', '#.$identity = #', closure, function); |
| 1155 return function; |
| 1156 } |
| 1157 class Closure extends dart.Object { |
| 1158 Closure() { |
| 1159 } |
| 1160 static fromTearOff(receiver, functions, reflectionInfo, isStatic, jsArgument
s, propertyName) { |
| 1161 _foreign_helper.JS_EFFECT(() => { |
| 1162 BoundClosure.receiverOf(dart.as(_foreign_helper.JS('BoundClosure', 'void
0'), BoundClosure)); |
| 1163 BoundClosure.selfOf(dart.as(_foreign_helper.JS('BoundClosure', 'void 0')
, BoundClosure)); |
| 1164 }); |
| 1165 let function = _foreign_helper.JS('', '#[#]', functions, 0); |
| 1166 let name = dart.as(_foreign_helper.JS('String|Null', '#.$stubName', functi
on), core.String); |
| 1167 let callName = dart.as(_foreign_helper.JS('String|Null', '#.$callName', fu
nction), core.String); |
| 1168 _foreign_helper.JS('', '#.$reflectionInfo = #', function, reflectionInfo); |
| 1169 let info = new ReflectionInfo(function); |
| 1170 let functionType = info.functionType; |
| 1171 let prototype = isStatic ? _foreign_helper.JS('TearOffClosure', 'Object.cr
eate(#.constructor.prototype)', new TearOffClosure()) : _foreign_helper.JS('Boun
dClosure', 'Object.create(#.constructor.prototype)', new BoundClosure(null, null
, null, null)); |
| 1172 _foreign_helper.JS('', '#.$initialize = #', prototype, _foreign_helper.JS(
'', '#.constructor', prototype)); |
| 1173 let constructor = isStatic ? _foreign_helper.JS('', 'function(){this.$init
ialize()}') : isCsp ? _foreign_helper.JS('', 'function(a,b,c,d) {this.$initializ
e(a,b,c,d)}') : _foreign_helper.JS('', 'new Function("a","b","c","d",' + '"this.
$initialize(a,b,c,d);"+#)', functionCounter++); |
| 1174 _foreign_helper.JS('', '#.constructor = #', prototype, constructor); |
| 1175 _foreign_helper.JS('', '#.prototype = #', constructor, prototype); |
| 1176 let trampoline = function; |
| 1177 let isIntercepted = false; |
| 1178 if (!dart.notNull(isStatic)) { |
| 1179 if (_foreign_helper.JS('bool', '#.length == 1', jsArguments)) { |
| 1180 isIntercepted = true; |
| 1181 } |
| 1182 trampoline = forwardCallTo(receiver, function, isIntercepted); |
| 1183 _foreign_helper.JS('', '#.$reflectionInfo = #', trampoline, reflectionIn
fo); |
| 1184 } else { |
| 1185 _foreign_helper.JS('', '#.$name = #', prototype, propertyName); |
| 1186 } |
| 1187 let signatureFunction = null; |
| 1188 if (_foreign_helper.JS('bool', 'typeof # == "number"', functionType)) { |
| 1189 let metadata = _foreign_helper.JS_EMBEDDED_GLOBAL('', dart.as(_js_embedd
ed_names.METADATA, core.String)); |
| 1190 signatureFunction = _foreign_helper.JS('', '(function(s){return function
(){return #[s]}})(#)', metadata, functionType); |
| 1191 } else if (core.bool['&&'](!dart.notNull(isStatic), _foreign_helper.JS('bo
ol', 'typeof # == "function"', functionType))) { |
| 1192 let getReceiver = isIntercepted ? _foreign_helper.RAW_DART_FUNCTION_REF(
BoundClosure.receiverOf) : _foreign_helper.RAW_DART_FUNCTION_REF(BoundClosure.se
lfOf); |
| 1193 signatureFunction = _foreign_helper.JS('', 'function(f,r){' + 'return fu
nction(){' + 'return f.apply({$receiver:r(this)},arguments)' + '}' + '}(#,#)', f
unctionType, getReceiver); |
| 1194 } else { |
| 1195 throw 'Error in reflectionInfo.'; |
| 1196 } |
| 1197 _foreign_helper.JS('', '#[#] = #', prototype, _foreign_helper.JS_SIGNATURE
_NAME(), signatureFunction); |
| 1198 _foreign_helper.JS('', '#[#] = #', prototype, callName, trampoline); |
| 1199 for (let i = 1; i < functions.length; i++) { |
| 1200 let stub = functions.get(i); |
| 1201 let stubCallName = _foreign_helper.JS('String|Null', '#.$callName', stub
); |
| 1202 if (stubCallName !== null) { |
| 1203 _foreign_helper.JS('', '#[#] = #', prototype, stubCallName, isStatic ?
stub : forwardCallTo(receiver, stub, isIntercepted)); |
| 1204 } |
| 1205 } |
| 1206 _foreign_helper.JS('', '#["call*"] = #', prototype, trampoline); |
| 1207 return constructor; |
| 1208 } |
| 1209 static cspForwardCall(arity, isSuperCall, stubName, function) { |
| 1210 let getSelf = _foreign_helper.RAW_DART_FUNCTION_REF(BoundClosure.selfOf); |
| 1211 if (isSuperCall) |
| 1212 arity = -1; |
| 1213 switch (arity) { |
| 1214 case 0: |
| 1215 return _foreign_helper.JS('', 'function(n,S){' + 'return function(){'
+ 'return S(this)[n]()' + '}' + '}(#,#)', stubName, getSelf); |
| 1216 case 1: |
| 1217 return _foreign_helper.JS('', 'function(n,S){' + 'return function(a){'
+ 'return S(this)[n](a)' + '}' + '}(#,#)', stubName, getSelf); |
| 1218 case 2: |
| 1219 return _foreign_helper.JS('', 'function(n,S){' + 'return function(a,b)
{' + 'return S(this)[n](a,b)' + '}' + '}(#,#)', stubName, getSelf); |
| 1220 case 3: |
| 1221 return _foreign_helper.JS('', 'function(n,S){' + 'return function(a,b,
c){' + 'return S(this)[n](a,b,c)' + '}' + '}(#,#)', stubName, getSelf); |
| 1222 case 4: |
| 1223 return _foreign_helper.JS('', 'function(n,S){' + 'return function(a,b,
c,d){' + 'return S(this)[n](a,b,c,d)' + '}' + '}(#,#)', stubName, getSelf); |
| 1224 case 5: |
| 1225 return _foreign_helper.JS('', 'function(n,S){' + 'return function(a,b,
c,d,e){' + 'return S(this)[n](a,b,c,d,e)' + '}' + '}(#,#)', stubName, getSelf); |
| 1226 default: |
| 1227 return _foreign_helper.JS('', 'function(f,s){' + 'return function(){'
+ 'return f.apply(s(this),arguments)' + '}' + '}(#,#)', function, getSelf); |
| 1228 } |
| 1229 } |
| 1230 static get isCsp() { |
| 1231 return dart.as(_foreign_helper.JS('bool', 'typeof dart_precompiled == "fun
ction"'), core.bool); |
| 1232 } |
| 1233 static forwardCallTo(receiver, function, isIntercepted) { |
| 1234 if (isIntercepted) |
| 1235 return forwardInterceptedCallTo(receiver, function); |
| 1236 let stubName = dart.as(_foreign_helper.JS('String|Null', '#.$stubName', fu
nction), core.String); |
| 1237 let arity = dart.as(_foreign_helper.JS('int', '#.length', function), core.
int); |
| 1238 let lookedUpFunction = _foreign_helper.JS("", "#[#]", receiver, stubName); |
| 1239 let isSuperCall = !dart.notNull(core.identical(function, lookedUpFunction)
); |
| 1240 if (dart.notNull(dart.notNull(isCsp) || dart.notNull(isSuperCall)) || dart
.notNull(arity >= 27)) { |
| 1241 return cspForwardCall(arity, isSuperCall, stubName, function); |
| 1242 } |
| 1243 if (arity === 0) { |
| 1244 return _foreign_helper.JS('', '(new Function(#))()', 'return function(){
' + `return this.${BoundClosure.selfFieldName()}.${stubName}();` + `${functionCo
unter++}` + '}'); |
| 1245 } |
| 1246 dart.assert(dart.notNull(1 <= arity) && dart.notNull(arity < 27)); |
| 1247 let arguments = dart.as(_foreign_helper.JS('String', '"abcdefghijklmnopqrs
tuvwxyz".split("").splice(0,#).join(",")', arity), core.String); |
| 1248 return _foreign_helper.JS('', '(new Function(#))()', `return function(${ar
guments}){` + `return this.${BoundClosure.selfFieldName()}.${stubName}(${argumen
ts});` + `${functionCounter++}` + '}'); |
| 1249 } |
| 1250 static cspForwardInterceptedCall(arity, isSuperCall, name, function) { |
| 1251 let getSelf = _foreign_helper.RAW_DART_FUNCTION_REF(BoundClosure.selfOf); |
| 1252 let getReceiver = _foreign_helper.RAW_DART_FUNCTION_REF(BoundClosure.recei
verOf); |
| 1253 if (isSuperCall) |
| 1254 arity = -1; |
| 1255 switch (arity) { |
| 1256 case 0: |
| 1257 throw new RuntimeError('Intercepted function with no arguments.'); |
| 1258 case 1: |
| 1259 return _foreign_helper.JS('', 'function(n,s,r){' + 'return function(){
' + 'return s(this)[n](r(this))' + '}' + '}(#,#,#)', name, getSelf, getReceiver)
; |
| 1260 case 2: |
| 1261 return _foreign_helper.JS('', 'function(n,s,r){' + 'return function(a)
{' + 'return s(this)[n](r(this),a)' + '}' + '}(#,#,#)', name, getSelf, getReceiv
er); |
| 1262 case 3: |
| 1263 return _foreign_helper.JS('', 'function(n,s,r){' + 'return function(a,
b){' + 'return s(this)[n](r(this),a,b)' + '}' + '}(#,#,#)', name, getSelf, getRe
ceiver); |
| 1264 case 4: |
| 1265 return _foreign_helper.JS('', 'function(n,s,r){' + 'return function(a,
b,c){' + 'return s(this)[n](r(this),a,b,c)' + '}' + '}(#,#,#)', name, getSelf, g
etReceiver); |
| 1266 case 5: |
| 1267 return _foreign_helper.JS('', 'function(n,s,r){' + 'return function(a,
b,c,d){' + 'return s(this)[n](r(this),a,b,c,d)' + '}' + '}(#,#,#)', name, getSel
f, getReceiver); |
| 1268 case 6: |
| 1269 return _foreign_helper.JS('', 'function(n,s,r){' + 'return function(a,
b,c,d,e){' + 'return s(this)[n](r(this),a,b,c,d,e)' + '}' + '}(#,#,#)', name, ge
tSelf, getReceiver); |
| 1270 default: |
| 1271 return _foreign_helper.JS('', 'function(f,s,r,a){' + 'return function(
){' + 'a=[r(this)];' + 'Array.prototype.push.apply(a,arguments);' + 'return f.ap
ply(s(this),a)' + '}' + '}(#,#,#)', function, getSelf, getReceiver); |
| 1272 } |
| 1273 } |
| 1274 static forwardInterceptedCallTo(receiver, function) { |
| 1275 let selfField = BoundClosure.selfFieldName(); |
| 1276 let receiverField = BoundClosure.receiverFieldName(); |
| 1277 let stubName = dart.as(_foreign_helper.JS('String|Null', '#.$stubName', fu
nction), core.String); |
| 1278 let arity = dart.as(_foreign_helper.JS('int', '#.length', function), core.
int); |
| 1279 let isCsp = dart.as(_foreign_helper.JS('bool', 'typeof dart_precompiled ==
"function"'), core.bool); |
| 1280 let lookedUpFunction = _foreign_helper.JS("", "#[#]", receiver, stubName); |
| 1281 let isSuperCall = !dart.notNull(core.identical(function, lookedUpFunction)
); |
| 1282 if (dart.notNull(dart.notNull(isCsp) || dart.notNull(isSuperCall)) || dart
.notNull(arity >= 28)) { |
| 1283 return cspForwardInterceptedCall(arity, isSuperCall, stubName, function)
; |
| 1284 } |
| 1285 if (arity === 1) { |
| 1286 return _foreign_helper.JS('', '(new Function(#))()', 'return function(){
' + `return this.${selfField}.${stubName}(this.${receiverField});` + `${function
Counter++}` + '}'); |
| 1287 } |
| 1288 dart.assert(dart.notNull(1 < arity) && dart.notNull(arity < 28)); |
| 1289 let arguments = dart.as(_foreign_helper.JS('String', '"abcdefghijklmnopqrs
tuvwxyz".split("").splice(0,#).join(",")', arity - 1), core.String); |
| 1290 return _foreign_helper.JS('', '(new Function(#))()', `return function(${ar
guments}){` + `return this.${selfField}.${stubName}(this.${receiverField}, ${arg
uments});` + `${functionCounter++}` + '}'); |
| 1291 } |
| 1292 toString() { |
| 1293 return "Closure"; |
| 1294 } |
| 1295 } |
| 1296 Closure.FUNCTION_INDEX = 0; |
| 1297 Closure.NAME_INDEX = 1; |
| 1298 Closure.CALL_NAME_INDEX = 2; |
| 1299 Closure.REQUIRED_PARAMETER_INDEX = 3; |
| 1300 Closure.OPTIONAL_PARAMETER_INDEX = 4; |
| 1301 Closure.DEFAULT_ARGUMENTS_INDEX = 5; |
| 1302 Closure.functionCounter = 0; |
| 1303 // Function closureFromTearOff: (dynamic, dynamic, dynamic, dynamic, dynamic,
dynamic) → dynamic |
| 1304 function closureFromTearOff(receiver, functions, reflectionInfo, isStatic, jsA
rguments, name) { |
| 1305 return Closure.fromTearOff(receiver, _interceptors.JSArray.markFixedList(dar
t.as(functions, core.List)), _interceptors.JSArray.markFixedList(dart.as(reflect
ionInfo, core.List)), dart.as(_foreign_helper.JS('bool', '!!#', isStatic), core.
bool), jsArguments, dart.as(_foreign_helper.JS('String', '#', name), core.String
)); |
| 1306 } |
| 1307 class TearOffClosure extends Closure { |
| 1308 } |
| 1309 class BoundClosure extends TearOffClosure { |
| 1310 BoundClosure(_self, _target, _receiver, _name) { |
| 1311 this._self = _self; |
| 1312 this._target = _target; |
| 1313 this._receiver = _receiver; |
| 1314 this._name = _name; |
| 1315 super.TearOffClosure(); |
| 1316 } |
| 1317 ['=='](other) { |
| 1318 if (core.identical(this, other)) |
| 1319 return true; |
| 1320 if (!dart.is(other, BoundClosure)) |
| 1321 return false; |
| 1322 return dart.as(_foreign_helper.JS('bool', '# === # && # === # && # === #',
this._self, dart.dload(other, '_self'), this._target, dart.dload(other, '_targe
t'), this._receiver, dart.dload(other, '_receiver')), core.bool); |
| 1323 } |
| 1324 get hashCode() { |
| 1325 let receiverHashCode = null; |
| 1326 if (this._receiver === null) { |
| 1327 receiverHashCode = Primitives.objectHashCode(this._self); |
| 1328 } else if (!dart.equals(_foreign_helper.JS('String', 'typeof #', this._rec
eiver), 'object')) { |
| 1329 receiverHashCode = dart.as(dart.dload(this._receiver, 'hashCode'), core.
int); |
| 1330 } else { |
| 1331 receiverHashCode = Primitives.objectHashCode(this._receiver); |
| 1332 } |
| 1333 return receiverHashCode ^ Primitives.objectHashCode(this._target); |
| 1334 } |
| 1335 static selfOf(closure) { |
| 1336 return closure._self; |
| 1337 } |
| 1338 static targetOf(closure) { |
| 1339 return closure._target; |
| 1340 } |
| 1341 static receiverOf(closure) { |
| 1342 return closure._receiver; |
| 1343 } |
| 1344 static nameOf(closure) { |
| 1345 return closure._name; |
| 1346 } |
| 1347 static selfFieldName() { |
| 1348 if (selfFieldNameCache === null) { |
| 1349 selfFieldNameCache = computeFieldNamed('self'); |
| 1350 } |
| 1351 return selfFieldNameCache; |
| 1352 } |
| 1353 static receiverFieldName() { |
| 1354 if (receiverFieldNameCache === null) { |
| 1355 receiverFieldNameCache = computeFieldNamed('receiver'); |
| 1356 } |
| 1357 return receiverFieldNameCache; |
| 1358 } |
| 1359 static computeFieldNamed(fieldName) { |
| 1360 let template = new BoundClosure('self', 'target', 'receiver', 'name'); |
| 1361 let names = _interceptors.JSArray.markFixedList(dart.as(_foreign_helper.JS
('', 'Object.getOwnPropertyNames(#)', template), core.List)); |
| 1362 for (let i = 0; i < names.length; i++) { |
| 1363 let name = names.get(i); |
| 1364 if (_foreign_helper.JS('bool', '#[#] === #', template, name, fieldName))
{ |
| 1365 return dart.as(_foreign_helper.JS('String', '#', name), core.String); |
| 1366 } |
| 1367 } |
| 1368 } |
| 1369 } |
| 1370 BoundClosure.selfFieldNameCache = null; |
| 1371 BoundClosure.receiverFieldNameCache = null; |
| 1372 // Function jsHasOwnProperty: (dynamic, String) → bool |
| 1373 function jsHasOwnProperty(jsObject, property) { |
| 1374 return dart.as(_foreign_helper.JS('bool', '#.hasOwnProperty(#)', jsObject, p
roperty), core.bool); |
| 1375 } |
| 1376 // Function jsPropertyAccess: (dynamic, String) → dynamic |
| 1377 function jsPropertyAccess(jsObject, property) { |
| 1378 return _foreign_helper.JS('var', '#[#]', jsObject, property); |
| 1379 } |
| 1380 // Function getFallThroughError: () → dynamic |
| 1381 function getFallThroughError() { |
| 1382 return new FallThroughErrorImplementation(); |
| 1383 } |
| 1384 class Creates extends dart.Object { |
| 1385 Creates(types) { |
| 1386 this.types = types; |
| 1387 } |
| 1388 } |
| 1389 class Returns extends dart.Object { |
| 1390 Returns(types) { |
| 1391 this.types = types; |
| 1392 } |
| 1393 } |
| 1394 class JSName extends dart.Object { |
| 1395 JSName(name) { |
| 1396 this.name = name; |
| 1397 } |
| 1398 } |
| 1399 // Function boolConversionCheck: (dynamic) → dynamic |
| 1400 function boolConversionCheck(value) { |
| 1401 if (typeof value == boolean) |
| 1402 return value; |
| 1403 boolTypeCheck(value); |
| 1404 dart.assert(value !== null); |
| 1405 return false; |
| 1406 } |
| 1407 // Function stringTypeCheck: (dynamic) → dynamic |
| 1408 function stringTypeCheck(value) { |
| 1409 if (value === null) |
| 1410 return value; |
| 1411 if (typeof value == string) |
| 1412 return value; |
| 1413 throw new TypeErrorImplementation(value, 'String'); |
| 1414 } |
| 1415 // Function stringTypeCast: (dynamic) → dynamic |
| 1416 function stringTypeCast(value) { |
| 1417 if (dart.notNull(typeof value == string) || dart.notNull(value === null)) |
| 1418 return value; |
| 1419 throw new CastErrorImplementation(Primitives.objectTypeName(value), 'String'
); |
| 1420 } |
| 1421 // Function doubleTypeCheck: (dynamic) → dynamic |
| 1422 function doubleTypeCheck(value) { |
| 1423 if (value === null) |
| 1424 return value; |
| 1425 if (typeof value == number) |
| 1426 return value; |
| 1427 throw new TypeErrorImplementation(value, 'double'); |
| 1428 } |
| 1429 // Function doubleTypeCast: (dynamic) → dynamic |
| 1430 function doubleTypeCast(value) { |
| 1431 if (dart.notNull(typeof value == number) || dart.notNull(value === null)) |
| 1432 return value; |
| 1433 throw new CastErrorImplementation(Primitives.objectTypeName(value), 'double'
); |
| 1434 } |
| 1435 // Function numTypeCheck: (dynamic) → dynamic |
| 1436 function numTypeCheck(value) { |
| 1437 if (value === null) |
| 1438 return value; |
| 1439 if (dart.is(value, core.num)) |
| 1440 return value; |
| 1441 throw new TypeErrorImplementation(value, 'num'); |
| 1442 } |
| 1443 // Function numTypeCast: (dynamic) → dynamic |
| 1444 function numTypeCast(value) { |
| 1445 if (dart.notNull(dart.is(value, core.num)) || dart.notNull(value === null)) |
| 1446 return value; |
| 1447 throw new CastErrorImplementation(Primitives.objectTypeName(value), 'num'); |
| 1448 } |
| 1449 // Function boolTypeCheck: (dynamic) → dynamic |
| 1450 function boolTypeCheck(value) { |
| 1451 if (value === null) |
| 1452 return value; |
| 1453 if (typeof value == boolean) |
| 1454 return value; |
| 1455 throw new TypeErrorImplementation(value, 'bool'); |
| 1456 } |
| 1457 // Function boolTypeCast: (dynamic) → dynamic |
| 1458 function boolTypeCast(value) { |
| 1459 if (dart.notNull(typeof value == boolean) || dart.notNull(value === null)) |
| 1460 return value; |
| 1461 throw new CastErrorImplementation(Primitives.objectTypeName(value), 'bool'); |
| 1462 } |
| 1463 // Function intTypeCheck: (dynamic) → dynamic |
| 1464 function intTypeCheck(value) { |
| 1465 if (value === null) |
| 1466 return value; |
| 1467 if (typeof value == number) |
| 1468 return value; |
| 1469 throw new TypeErrorImplementation(value, 'int'); |
| 1470 } |
| 1471 // Function intTypeCast: (dynamic) → dynamic |
| 1472 function intTypeCast(value) { |
| 1473 if (dart.notNull(typeof value == number) || dart.notNull(value === null)) |
| 1474 return value; |
| 1475 throw new CastErrorImplementation(Primitives.objectTypeName(value), 'int'); |
| 1476 } |
| 1477 // Function propertyTypeError: (dynamic, dynamic) → void |
| 1478 function propertyTypeError(value, property) { |
| 1479 let name = dart.as(dart.dinvoke(property, 'substring', 3, dart.dload(propert
y, 'length')), core.String); |
| 1480 throw new TypeErrorImplementation(value, name); |
| 1481 } |
| 1482 // Function propertyTypeCastError: (dynamic, dynamic) → void |
| 1483 function propertyTypeCastError(value, property) { |
| 1484 let actualType = Primitives.objectTypeName(value); |
| 1485 let expectedType = dart.as(dart.dinvoke(property, 'substring', 3, dart.dload
(property, 'length')), core.String); |
| 1486 throw new CastErrorImplementation(actualType, expectedType); |
| 1487 } |
| 1488 // Function propertyTypeCheck: (dynamic, dynamic) → dynamic |
| 1489 function propertyTypeCheck(value, property) { |
| 1490 if (value === null) |
| 1491 return value; |
| 1492 if (_foreign_helper.JS('bool', '!!#[#]', value, property)) |
| 1493 return value; |
| 1494 propertyTypeError(value, property); |
| 1495 } |
| 1496 // Function propertyTypeCast: (dynamic, dynamic) → dynamic |
| 1497 function propertyTypeCast(value, property) { |
| 1498 if (core.bool['||'](value === null, _foreign_helper.JS('bool', '!!#[#]', val
ue, property))) |
| 1499 return value; |
| 1500 propertyTypeCastError(value, property); |
| 1501 } |
| 1502 // Function interceptedTypeCheck: (dynamic, dynamic) → dynamic |
| 1503 function interceptedTypeCheck(value, property) { |
| 1504 if (value === null) |
| 1505 return value; |
| 1506 if (core.bool['&&'](core.identical(_foreign_helper.JS('String', 'typeof #',
value), 'object'), _foreign_helper.JS('bool', '#[#]', _interceptors.getIntercept
or(value), property))) { |
| 1507 return value; |
| 1508 } |
| 1509 propertyTypeError(value, property); |
| 1510 } |
| 1511 // Function interceptedTypeCast: (dynamic, dynamic) → dynamic |
| 1512 function interceptedTypeCast(value, property) { |
| 1513 if (dart.notNull(value === null) || dart.notNull(dart.dbinary(_foreign_helpe
r.JS('bool', 'typeof # === "object"', value), '&&', _foreign_helper.JS('bool', '
#[#]', _interceptors.getInterceptor(value), property)))) { |
| 1514 return value; |
| 1515 } |
| 1516 propertyTypeCastError(value, property); |
| 1517 } |
| 1518 // Function numberOrStringSuperTypeCheck: (dynamic, dynamic) → dynamic |
| 1519 function numberOrStringSuperTypeCheck(value, property) { |
| 1520 if (value === null) |
| 1521 return value; |
| 1522 if (typeof value == string) |
| 1523 return value; |
| 1524 if (dart.is(value, core.num)) |
| 1525 return value; |
| 1526 if (_foreign_helper.JS('bool', '!!#[#]', value, property)) |
| 1527 return value; |
| 1528 propertyTypeError(value, property); |
| 1529 } |
| 1530 // Function numberOrStringSuperTypeCast: (dynamic, dynamic) → dynamic |
| 1531 function numberOrStringSuperTypeCast(value, property) { |
| 1532 if (typeof value == string) |
| 1533 return value; |
| 1534 if (dart.is(value, core.num)) |
| 1535 return value; |
| 1536 return propertyTypeCast(value, property); |
| 1537 } |
| 1538 // Function numberOrStringSuperNativeTypeCheck: (dynamic, dynamic) → dynamic |
| 1539 function numberOrStringSuperNativeTypeCheck(value, property) { |
| 1540 if (value === null) |
| 1541 return value; |
| 1542 if (typeof value == string) |
| 1543 return value; |
| 1544 if (dart.is(value, core.num)) |
| 1545 return value; |
| 1546 if (_foreign_helper.JS('bool', '#[#]', _interceptors.getInterceptor(value),
property)) |
| 1547 return value; |
| 1548 propertyTypeError(value, property); |
| 1549 } |
| 1550 // Function numberOrStringSuperNativeTypeCast: (dynamic, dynamic) → dynamic |
| 1551 function numberOrStringSuperNativeTypeCast(value, property) { |
| 1552 if (value === null) |
| 1553 return value; |
| 1554 if (typeof value == string) |
| 1555 return value; |
| 1556 if (dart.is(value, core.num)) |
| 1557 return value; |
| 1558 if (_foreign_helper.JS('bool', '#[#]', _interceptors.getInterceptor(value),
property)) |
| 1559 return value; |
| 1560 propertyTypeCastError(value, property); |
| 1561 } |
| 1562 // Function stringSuperTypeCheck: (dynamic, dynamic) → dynamic |
| 1563 function stringSuperTypeCheck(value, property) { |
| 1564 if (value === null) |
| 1565 return value; |
| 1566 if (typeof value == string) |
| 1567 return value; |
| 1568 if (_foreign_helper.JS('bool', '!!#[#]', value, property)) |
| 1569 return value; |
| 1570 propertyTypeError(value, property); |
| 1571 } |
| 1572 // Function stringSuperTypeCast: (dynamic, dynamic) → dynamic |
| 1573 function stringSuperTypeCast(value, property) { |
| 1574 if (typeof value == string) |
| 1575 return value; |
| 1576 return propertyTypeCast(value, property); |
| 1577 } |
| 1578 // Function stringSuperNativeTypeCheck: (dynamic, dynamic) → dynamic |
| 1579 function stringSuperNativeTypeCheck(value, property) { |
| 1580 if (value === null) |
| 1581 return value; |
| 1582 if (typeof value == string) |
| 1583 return value; |
| 1584 if (_foreign_helper.JS('bool', '#[#]', _interceptors.getInterceptor(value),
property)) |
| 1585 return value; |
| 1586 propertyTypeError(value, property); |
| 1587 } |
| 1588 // Function stringSuperNativeTypeCast: (dynamic, dynamic) → dynamic |
| 1589 function stringSuperNativeTypeCast(value, property) { |
| 1590 if (dart.notNull(typeof value == string) || dart.notNull(value === null)) |
| 1591 return value; |
| 1592 if (_foreign_helper.JS('bool', '#[#]', _interceptors.getInterceptor(value),
property)) |
| 1593 return value; |
| 1594 propertyTypeCastError(value, property); |
| 1595 } |
| 1596 // Function listTypeCheck: (dynamic) → dynamic |
| 1597 function listTypeCheck(value) { |
| 1598 if (value === null) |
| 1599 return value; |
| 1600 if (dart.is(value, core.List)) |
| 1601 return value; |
| 1602 throw new TypeErrorImplementation(value, 'List'); |
| 1603 } |
| 1604 // Function listTypeCast: (dynamic) → dynamic |
| 1605 function listTypeCast(value) { |
| 1606 if (dart.notNull(dart.is(value, core.List)) || dart.notNull(value === null)) |
| 1607 return value; |
| 1608 throw new CastErrorImplementation(Primitives.objectTypeName(value), 'List'); |
| 1609 } |
| 1610 // Function listSuperTypeCheck: (dynamic, dynamic) → dynamic |
| 1611 function listSuperTypeCheck(value, property) { |
| 1612 if (value === null) |
| 1613 return value; |
| 1614 if (dart.is(value, core.List)) |
| 1615 return value; |
| 1616 if (_foreign_helper.JS('bool', '!!#[#]', value, property)) |
| 1617 return value; |
| 1618 propertyTypeError(value, property); |
| 1619 } |
| 1620 // Function listSuperTypeCast: (dynamic, dynamic) → dynamic |
| 1621 function listSuperTypeCast(value, property) { |
| 1622 if (dart.is(value, core.List)) |
| 1623 return value; |
| 1624 return propertyTypeCast(value, property); |
| 1625 } |
| 1626 // Function listSuperNativeTypeCheck: (dynamic, dynamic) → dynamic |
| 1627 function listSuperNativeTypeCheck(value, property) { |
| 1628 if (value === null) |
| 1629 return value; |
| 1630 if (dart.is(value, core.List)) |
| 1631 return value; |
| 1632 if (_foreign_helper.JS('bool', '#[#]', _interceptors.getInterceptor(value),
property)) |
| 1633 return value; |
| 1634 propertyTypeError(value, property); |
| 1635 } |
| 1636 // Function listSuperNativeTypeCast: (dynamic, dynamic) → dynamic |
| 1637 function listSuperNativeTypeCast(value, property) { |
| 1638 if (dart.notNull(dart.is(value, core.List)) || dart.notNull(value === null)) |
| 1639 return value; |
| 1640 if (_foreign_helper.JS('bool', '#[#]', _interceptors.getInterceptor(value),
property)) |
| 1641 return value; |
| 1642 propertyTypeCastError(value, property); |
| 1643 } |
| 1644 // Function voidTypeCheck: (dynamic) → dynamic |
| 1645 function voidTypeCheck(value) { |
| 1646 if (value === null) |
| 1647 return value; |
| 1648 throw new TypeErrorImplementation(value, 'void'); |
| 1649 } |
| 1650 // Function checkMalformedType: (dynamic, dynamic) → dynamic |
| 1651 function checkMalformedType(value, message) { |
| 1652 if (value === null) |
| 1653 return value; |
| 1654 throw new TypeErrorImplementation.fromMessage(message); |
| 1655 } |
| 1656 // Function checkDeferredIsLoaded: (String, String) → void |
| 1657 function checkDeferredIsLoaded(loadId, uri) { |
| 1658 if (!dart.notNull(_js_helper._loadedLibraries.contains(loadId))) { |
| 1659 throw new DeferredNotLoadedError(uri); |
| 1660 } |
| 1661 } |
| 1662 class JavaScriptIndexingBehavior extends _interceptors.JSMutableIndexable { |
| 1663 } |
| 1664 class TypeErrorImplementation extends core.Error { |
| 1665 TypeErrorImplementation(value, type) { |
| 1666 this.message = `type '${Primitives.objectTypeName(value)}' is not a subtyp
e ` + `of type '${type}'`; |
| 1667 super.Error(); |
| 1668 } |
| 1669 TypeErrorImplementation$fromMessage(message) { |
| 1670 this.message = message; |
| 1671 super.Error(); |
| 1672 } |
| 1673 toString() { |
| 1674 return this.message; |
| 1675 } |
| 1676 } |
| 1677 dart.defineNamedConstructor(TypeErrorImplementation, 'fromMessage'); |
| 1678 class CastErrorImplementation extends core.Error { |
| 1679 CastErrorImplementation(actualType, expectedType) { |
| 1680 this.message = `CastError: Casting value of type ${actualType} to` + ` inc
ompatible type ${expectedType}`; |
| 1681 super.Error(); |
| 1682 } |
| 1683 toString() { |
| 1684 return this.message; |
| 1685 } |
| 1686 } |
| 1687 class FallThroughErrorImplementation extends core.FallThroughError { |
| 1688 FallThroughErrorImplementation() { |
| 1689 super.FallThroughError(); |
| 1690 } |
| 1691 toString() { |
| 1692 return "Switch case fall-through."; |
| 1693 } |
| 1694 } |
| 1695 // Function assertHelper: (dynamic) → void |
| 1696 function assertHelper(condition) { |
| 1697 if (!(typeof condition == boolean)) { |
| 1698 if (dart.is(condition, core.Function)) |
| 1699 condition = dart.dinvokef(condition); |
| 1700 if (!(typeof condition == boolean)) { |
| 1701 throw new TypeErrorImplementation(condition, 'bool'); |
| 1702 } |
| 1703 } |
| 1704 if (true !== condition) |
| 1705 throw new core.AssertionError(); |
| 1706 } |
| 1707 // Function throwNoSuchMethod: (dynamic, dynamic, dynamic, dynamic) → void |
| 1708 function throwNoSuchMethod(obj, name, arguments, expectedArgumentNames) { |
| 1709 let memberName = new _internal.Symbol.unvalidated(name); |
| 1710 throw new core.NoSuchMethodError(obj, memberName, arguments, new core.Map(),
expectedArgumentNames); |
| 1711 } |
| 1712 // Function throwCyclicInit: (String) → void |
| 1713 function throwCyclicInit(staticName) { |
| 1714 throw new core.CyclicInitializationError(`Cyclic initialization for static $
{staticName}`); |
| 1715 } |
| 1716 class RuntimeError extends core.Error { |
| 1717 RuntimeError(message) { |
| 1718 this.message = message; |
| 1719 super.Error(); |
| 1720 } |
| 1721 toString() { |
| 1722 return `RuntimeError: ${this.message}`; |
| 1723 } |
| 1724 } |
| 1725 class DeferredNotLoadedError extends core.Error { |
| 1726 DeferredNotLoadedError(libraryName) { |
| 1727 this.libraryName = libraryName; |
| 1728 super.Error(); |
| 1729 } |
| 1730 toString() { |
| 1731 return `Deferred library ${this.libraryName} was not loaded.`; |
| 1732 } |
| 1733 } |
| 1734 class RuntimeType extends dart.Object { |
| 1735 RuntimeType() { |
| 1736 } |
| 1737 } |
| 1738 class RuntimeFunctionType extends RuntimeType { |
| 1739 RuntimeFunctionType(returnType, parameterTypes, optionalParameterTypes, name
dParameters) { |
| 1740 this.returnType = returnType; |
| 1741 this.parameterTypes = parameterTypes; |
| 1742 this.optionalParameterTypes = optionalParameterTypes; |
| 1743 this.namedParameters = namedParameters; |
| 1744 super.RuntimeType(); |
| 1745 } |
| 1746 get isVoid() { |
| 1747 return dart.is(this.returnType, VoidRuntimeType); |
| 1748 } |
| 1749 _isTest(expression) { |
| 1750 let functionTypeObject = this._extractFunctionTypeObjectFrom(expression); |
| 1751 return functionTypeObject === null ? false : isFunctionSubtype(functionTyp
eObject, this.toRti()); |
| 1752 } |
| 1753 _asCheck(expression) { |
| 1754 return this._check(_foreign_helper.JS('', '#', expression), true); |
| 1755 } |
| 1756 _assertCheck(expression) { |
| 1757 if (inAssert) |
| 1758 return null; |
| 1759 inAssert = true; |
| 1760 try { |
| 1761 return this._check(_foreign_helper.JS('', '#', expression), false); |
| 1762 } finally { |
| 1763 inAssert = false; |
| 1764 } |
| 1765 } |
| 1766 _check(expression, isCast) { |
| 1767 if (expression === null) |
| 1768 return null; |
| 1769 if (this._isTest(expression)) |
| 1770 return expression; |
| 1771 let self = new FunctionTypeInfoDecoderRing(this.toRti()).toString(); |
| 1772 if (isCast) { |
| 1773 let functionTypeObject = this._extractFunctionTypeObjectFrom(expression)
; |
| 1774 let pretty = null; |
| 1775 if (functionTypeObject !== null) { |
| 1776 pretty = new FunctionTypeInfoDecoderRing(functionTypeObject).toString(
); |
| 1777 } else { |
| 1778 pretty = Primitives.objectTypeName(expression); |
| 1779 } |
| 1780 throw new CastErrorImplementation(pretty, self); |
| 1781 } else { |
| 1782 throw new TypeErrorImplementation(expression, self); |
| 1783 } |
| 1784 } |
| 1785 _extractFunctionTypeObjectFrom(o) { |
| 1786 let interceptor = _interceptors.getInterceptor(o); |
| 1787 return _foreign_helper.JS('bool', '# in #', _foreign_helper.JS_SIGNATURE_N
AME(), interceptor) ? _foreign_helper.JS('', '#[#]()', interceptor, _foreign_hel
per.JS_SIGNATURE_NAME()) : null; |
| 1788 } |
| 1789 toRti() { |
| 1790 let result = _foreign_helper.JS('=Object', '{ #: "dynafunc" }', _foreign_h
elper.JS_FUNCTION_TYPE_TAG()); |
| 1791 if (this.isVoid) { |
| 1792 _foreign_helper.JS('', '#[#] = true', result, _foreign_helper.JS_FUNCTIO
N_TYPE_VOID_RETURN_TAG()); |
| 1793 } else { |
| 1794 if (!dart.is(this.returnType, DynamicRuntimeType)) { |
| 1795 _foreign_helper.JS('', '#[#] = #', result, _foreign_helper.JS_FUNCTION
_TYPE_RETURN_TYPE_TAG(), this.returnType.toRti()); |
| 1796 } |
| 1797 } |
| 1798 if (dart.notNull(this.parameterTypes !== null) && dart.notNull(!dart.notNu
ll(this.parameterTypes.isEmpty))) { |
| 1799 _foreign_helper.JS('', '#[#] = #', result, _foreign_helper.JS_FUNCTION_T
YPE_REQUIRED_PARAMETERS_TAG(), listToRti(this.parameterTypes)); |
| 1800 } |
| 1801 if (dart.notNull(this.optionalParameterTypes !== null) && dart.notNull(!da
rt.notNull(this.optionalParameterTypes.isEmpty))) { |
| 1802 _foreign_helper.JS('', '#[#] = #', result, _foreign_helper.JS_FUNCTION_T
YPE_OPTIONAL_PARAMETERS_TAG(), listToRti(this.optionalParameterTypes)); |
| 1803 } |
| 1804 if (this.namedParameters !== null) { |
| 1805 let namedRti = _foreign_helper.JS('=Object', 'Object.create(null)'); |
| 1806 let keys = _js_names.extractKeys(this.namedParameters); |
| 1807 for (let i = 0; i < keys.length; i++) { |
| 1808 let name = keys.get(i); |
| 1809 let rti = dart.dinvoke(_foreign_helper.JS('', '#[#]', this.namedParame
ters, name), 'toRti'); |
| 1810 _foreign_helper.JS('', '#[#] = #', namedRti, name, rti); |
| 1811 } |
| 1812 _foreign_helper.JS('', '#[#] = #', result, _foreign_helper.JS_FUNCTION_T
YPE_NAMED_PARAMETERS_TAG(), namedRti); |
| 1813 } |
| 1814 return result; |
| 1815 } |
| 1816 static listToRti(list) { |
| 1817 list = _foreign_helper.JS('JSFixedArray', '#', list); |
| 1818 let result = _foreign_helper.JS('JSExtendableArray', '[]'); |
| 1819 for (let i = 0; i['<'](dart.dload(list, 'length')); i++) { |
| 1820 _foreign_helper.JS('', '#.push(#)', result, dart.dinvoke(dart.dindex(lis
t, i), 'toRti')); |
| 1821 } |
| 1822 return result; |
| 1823 } |
| 1824 toString() { |
| 1825 let result = '('; |
| 1826 let needsComma = false; |
| 1827 if (this.parameterTypes !== null) { |
| 1828 for (let i = 0; i < this.parameterTypes.length; i++) { |
| 1829 let type = this.parameterTypes.get(i); |
| 1830 if (needsComma) |
| 1831 result = ', '; |
| 1832 result = `${type}`; |
| 1833 needsComma = true; |
| 1834 } |
| 1835 } |
| 1836 if (dart.notNull(this.optionalParameterTypes !== null) && dart.notNull(!da
rt.notNull(this.optionalParameterTypes.isEmpty))) { |
| 1837 if (needsComma) |
| 1838 result = ', '; |
| 1839 needsComma = false; |
| 1840 result = '['; |
| 1841 for (let i = 0; i < this.optionalParameterTypes.length; i++) { |
| 1842 let type = this.optionalParameterTypes.get(i); |
| 1843 if (needsComma) |
| 1844 result = ', '; |
| 1845 result = `${type}`; |
| 1846 needsComma = true; |
| 1847 } |
| 1848 result = ']'; |
| 1849 } else if (this.namedParameters !== null) { |
| 1850 if (needsComma) |
| 1851 result = ', '; |
| 1852 needsComma = false; |
| 1853 result = '{'; |
| 1854 let keys = _js_names.extractKeys(this.namedParameters); |
| 1855 for (let i = 0; i < keys.length; i++) { |
| 1856 let name = keys.get(i); |
| 1857 if (needsComma) |
| 1858 result = ', '; |
| 1859 let rti = dart.dinvoke(_foreign_helper.JS('', '#[#]', this.namedParame
ters, name), 'toRti'); |
| 1860 result = `${rti} ${_foreign_helper.JS("String", "#", name)}`; |
| 1861 needsComma = true; |
| 1862 } |
| 1863 result = '}'; |
| 1864 } |
| 1865 result = `) -> ${this.returnType}`; |
| 1866 return result; |
| 1867 } |
| 1868 } |
| 1869 RuntimeFunctionType.inAssert = false; |
| 1870 // Function buildFunctionType: (dynamic, dynamic, dynamic) → RuntimeFunctionTy
pe |
| 1871 function buildFunctionType(returnType, parameterTypes, optionalParameterTypes)
{ |
| 1872 return new RuntimeFunctionType(returnType, parameterTypes, optionalParameter
Types, null); |
| 1873 } |
| 1874 // Function buildNamedFunctionType: (dynamic, dynamic, dynamic) → RuntimeFunct
ionType |
| 1875 function buildNamedFunctionType(returnType, parameterTypes, namedParameters) { |
| 1876 return new RuntimeFunctionType(returnType, parameterTypes, null, namedParame
ters); |
| 1877 } |
| 1878 // Function buildInterfaceType: (dynamic, dynamic) → RuntimeType |
| 1879 function buildInterfaceType(rti, typeArguments) { |
| 1880 let name = dart.as(_foreign_helper.JS('String|Null', '#.name', rti), core.St
ring); |
| 1881 if (core.bool['||'](typeArguments === null, dart.dload(typeArguments, 'isEmp
ty'))) { |
| 1882 return new RuntimeTypePlain(name); |
| 1883 } |
| 1884 return new RuntimeTypeGeneric(name, typeArguments, null); |
| 1885 } |
| 1886 class DynamicRuntimeType extends RuntimeType { |
| 1887 DynamicRuntimeType() { |
| 1888 super.RuntimeType(); |
| 1889 } |
| 1890 toString() { |
| 1891 return 'dynamic'; |
| 1892 } |
| 1893 toRti() { |
| 1894 return null; |
| 1895 } |
| 1896 } |
| 1897 // Function getDynamicRuntimeType: () → RuntimeType |
| 1898 function getDynamicRuntimeType() { |
| 1899 return new DynamicRuntimeType(); |
| 1900 } |
| 1901 class VoidRuntimeType extends RuntimeType { |
| 1902 VoidRuntimeType() { |
| 1903 super.RuntimeType(); |
| 1904 } |
| 1905 toString() { |
| 1906 return 'void'; |
| 1907 } |
| 1908 toRti() { |
| 1909 return dart.throw_('internal error'); |
| 1910 } |
| 1911 } |
| 1912 // Function getVoidRuntimeType: () → RuntimeType |
| 1913 function getVoidRuntimeType() { |
| 1914 return new VoidRuntimeType(); |
| 1915 } |
| 1916 // Function functionTypeTestMetaHelper: () → dynamic |
| 1917 function functionTypeTestMetaHelper() { |
| 1918 let dyn = _foreign_helper.JS('', 'x'); |
| 1919 let dyn2 = _foreign_helper.JS('', 'x'); |
| 1920 let fixedListOrNull = dart.as(_foreign_helper.JS('JSFixedArray|Null', 'x'),
core.List); |
| 1921 let fixedListOrNull2 = dart.as(_foreign_helper.JS('JSFixedArray|Null', 'x'),
core.List); |
| 1922 let fixedList = dart.as(_foreign_helper.JS('JSFixedArray', 'x'), core.List); |
| 1923 let jsObject = _foreign_helper.JS('=Object', 'x'); |
| 1924 buildFunctionType(dyn, fixedListOrNull, fixedListOrNull2); |
| 1925 buildNamedFunctionType(dyn, fixedList, jsObject); |
| 1926 buildInterfaceType(dyn, fixedListOrNull); |
| 1927 getDynamicRuntimeType(); |
| 1928 getVoidRuntimeType(); |
| 1929 convertRtiToRuntimeType(dyn); |
| 1930 dart.dinvoke(dyn, '_isTest', dyn2); |
| 1931 dart.dinvoke(dyn, '_asCheck', dyn2); |
| 1932 dart.dinvoke(dyn, '_assertCheck', dyn2); |
| 1933 } |
| 1934 // Function convertRtiToRuntimeType: (dynamic) → RuntimeType |
| 1935 function convertRtiToRuntimeType(rti) { |
| 1936 if (rti === null) { |
| 1937 return getDynamicRuntimeType(); |
| 1938 } else if (_foreign_helper.JS('bool', 'typeof # == "function"', rti)) { |
| 1939 return new RuntimeTypePlain(_foreign_helper.JS('String', 'rti.name')); |
| 1940 } else if (_foreign_helper.JS('bool', '#.constructor == Array', rti)) { |
| 1941 let list = dart.as(_foreign_helper.JS('JSFixedArray', '#', rti), core.List
); |
| 1942 let name = dart.as(_foreign_helper.JS('String', '#.name', list.get(0)), co
re.String); |
| 1943 let arguments = new List.from([]); |
| 1944 for (let i = 1; i < list.length; i++) { |
| 1945 arguments.add(convertRtiToRuntimeType(list.get(i))); |
| 1946 } |
| 1947 return new RuntimeTypeGeneric(name, arguments, rti); |
| 1948 } else if (_foreign_helper.JS('bool', '"func" in #', rti)) { |
| 1949 return new FunctionTypeInfoDecoderRing(rti).toRuntimeType(); |
| 1950 } else { |
| 1951 throw new RuntimeError("Cannot convert " + `'${_foreign_helper.JS('String'
, 'JSON.stringify(#)', rti)}' to RuntimeType.`); |
| 1952 } |
| 1953 } |
| 1954 class RuntimeTypePlain extends RuntimeType { |
| 1955 RuntimeTypePlain(name) { |
| 1956 this.name = name; |
| 1957 super.RuntimeType(); |
| 1958 } |
| 1959 toRti() { |
| 1960 let allClasses = _foreign_helper.JS_EMBEDDED_GLOBAL('', dart.as(_js_embedd
ed_names.ALL_CLASSES, core.String)); |
| 1961 let rti = _foreign_helper.JS('', '#[#]', allClasses, this.name); |
| 1962 if (rti === null) |
| 1963 throw `no type for '${this.name}'`; |
| 1964 return rti; |
| 1965 } |
| 1966 toString() { |
| 1967 return this.name; |
| 1968 } |
| 1969 } |
| 1970 class RuntimeTypeGeneric extends RuntimeType { |
| 1971 RuntimeTypeGeneric(name, arguments, rti) { |
| 1972 this.name = name; |
| 1973 this.arguments = arguments; |
| 1974 this.rti = rti; |
| 1975 super.RuntimeType(); |
| 1976 } |
| 1977 toRti() { |
| 1978 if (this.rti !== null) |
| 1979 return this.rti; |
| 1980 let allClasses = _foreign_helper.JS_EMBEDDED_GLOBAL('', dart.as(_js_embedd
ed_names.ALL_CLASSES, core.String)); |
| 1981 let result = _foreign_helper.JS('JSExtendableArray', '[#[#]]', allClasses,
this.name); |
| 1982 if (dart.dindex(result, 0) === null) { |
| 1983 throw `no type for '${this.name}<...>'`; |
| 1984 } |
| 1985 for (let argument of this.arguments) { |
| 1986 _foreign_helper.JS('', '#.push(#)', result, argument.toRti()); |
| 1987 } |
| 1988 return this.rti = result; |
| 1989 } |
| 1990 toString() { |
| 1991 return `${this.name}<${this.arguments.join(", ")}>`; |
| 1992 } |
| 1993 } |
| 1994 class FunctionTypeInfoDecoderRing extends dart.Object { |
| 1995 FunctionTypeInfoDecoderRing(_typeData) { |
| 1996 this._typeData = _typeData; |
| 1997 this._cachedToString = null; |
| 1998 } |
| 1999 get _hasReturnType() { |
| 2000 return dart.as(_foreign_helper.JS('bool', '"ret" in #', this._typeData), c
ore.bool); |
| 2001 } |
| 2002 get _returnType() { |
| 2003 return _foreign_helper.JS('', '#.ret', this._typeData); |
| 2004 } |
| 2005 get _isVoid() { |
| 2006 return dart.as(_foreign_helper.JS('bool', '!!#.void', this._typeData), cor
e.bool); |
| 2007 } |
| 2008 get _hasArguments() { |
| 2009 return dart.as(_foreign_helper.JS('bool', '"args" in #', this._typeData),
core.bool); |
| 2010 } |
| 2011 get _arguments() { |
| 2012 return dart.as(_foreign_helper.JS('JSExtendableArray', '#.args', this._typ
eData), core.List); |
| 2013 } |
| 2014 get _hasOptionalArguments() { |
| 2015 return dart.as(_foreign_helper.JS('bool', '"opt" in #', this._typeData), c
ore.bool); |
| 2016 } |
| 2017 get _optionalArguments() { |
| 2018 return dart.as(_foreign_helper.JS('JSExtendableArray', '#.opt', this._type
Data), core.List); |
| 2019 } |
| 2020 get _hasNamedArguments() { |
| 2021 return dart.as(_foreign_helper.JS('bool', '"named" in #', this._typeData),
core.bool); |
| 2022 } |
| 2023 get _namedArguments() { |
| 2024 return _foreign_helper.JS('=Object', '#.named', this._typeData); |
| 2025 } |
| 2026 toRuntimeType() { |
| 2027 return new DynamicRuntimeType(); |
| 2028 } |
| 2029 _convert(type) { |
| 2030 let result = runtimeTypeToString(type); |
| 2031 if (result !== null) |
| 2032 return result; |
| 2033 if (_foreign_helper.JS('bool', '"func" in #', type)) { |
| 2034 return new FunctionTypeInfoDecoderRing(type).toString(); |
| 2035 } else { |
| 2036 throw 'bad type'; |
| 2037 } |
| 2038 } |
| 2039 toString() { |
| 2040 if (this._cachedToString !== null) |
| 2041 return this._cachedToString; |
| 2042 let s = "("; |
| 2043 let sep = ''; |
| 2044 if (this._hasArguments) { |
| 2045 for (let argument of this._arguments) { |
| 2046 s = sep; |
| 2047 s = this._convert(argument); |
| 2048 sep = ', '; |
| 2049 } |
| 2050 } |
| 2051 if (this._hasOptionalArguments) { |
| 2052 s = `${sep}[`; |
| 2053 sep = ''; |
| 2054 for (let argument of this._optionalArguments) { |
| 2055 s = sep; |
| 2056 s = this._convert(argument); |
| 2057 sep = ', '; |
| 2058 } |
| 2059 s = ']'; |
| 2060 } |
| 2061 if (this._hasNamedArguments) { |
| 2062 s = `${sep}{`; |
| 2063 sep = ''; |
| 2064 for (let name of _js_names.extractKeys(this._namedArguments)) { |
| 2065 s = sep; |
| 2066 s = `${name}: `; |
| 2067 s = this._convert(_foreign_helper.JS('', '#[#]', this._namedArguments,
name)); |
| 2068 sep = ', '; |
| 2069 } |
| 2070 s = '}'; |
| 2071 } |
| 2072 s = ') -> '; |
| 2073 if (this._isVoid) { |
| 2074 s = 'void'; |
| 2075 } else if (this._hasReturnType) { |
| 2076 s = this._convert(this._returnType); |
| 2077 } else { |
| 2078 s = 'dynamic'; |
| 2079 } |
| 2080 return this._cachedToString = `${s}`; |
| 2081 } |
| 2082 } |
| 2083 class UnimplementedNoSuchMethodError extends core.Error { |
| 2084 UnimplementedNoSuchMethodError(_message) { |
| 2085 this._message = _message; |
| 2086 super.Error(); |
| 2087 } |
| 2088 toString() { |
| 2089 return `Unsupported operation: ${this._message}`; |
| 2090 } |
| 2091 } |
| 2092 // Function random64: () → int |
| 2093 function random64() { |
| 2094 let int32a = dart.as(_foreign_helper.JS("int", "(Math.random() * 0x100000000
) >>> 0"), core.int); |
| 2095 let int32b = dart.as(_foreign_helper.JS("int", "(Math.random() * 0x100000000
) >>> 0"), core.int); |
| 2096 return int32a + int32b * 4294967296; |
| 2097 } |
| 2098 // Function jsonEncodeNative: (String) → String |
| 2099 function jsonEncodeNative(string) { |
| 2100 return dart.as(_foreign_helper.JS("String", "JSON.stringify(#)", string), co
re.String); |
| 2101 } |
| 2102 // Function getIsolateAffinityTag: (String) → String |
| 2103 function getIsolateAffinityTag(name) { |
| 2104 let isolateTagGetter = _foreign_helper.JS_EMBEDDED_GLOBAL('', dart.as(_js_em
bedded_names.GET_ISOLATE_TAG, core.String)); |
| 2105 return dart.as(_foreign_helper.JS('String', '#(#)', isolateTagGetter, name),
core.String); |
| 2106 } |
| 2107 // Function _loadLibraryWrapper: (String) → () → Future<Null> |
| 2108 function _loadLibraryWrapper(loadId) { |
| 2109 return () => loadDeferredLibrary(loadId); |
| 2110 } |
| 2111 dart.defineLazyProperties(_js_helper, { |
| 2112 get _loadingLibraries() { |
| 2113 return dart.map(); |
| 2114 }, |
| 2115 get _loadedLibraries() { |
| 2116 return new core.Set(); |
| 2117 } |
| 2118 }); |
| 2119 _js_helper.deferredLoadHook = null; |
| 2120 // Function loadDeferredLibrary: (String) → Future<Null> |
| 2121 function loadDeferredLibrary(loadId) { |
| 2122 let urisMap = _foreign_helper.JS_EMBEDDED_GLOBAL('', dart.as(_js_embedded_na
mes.DEFERRED_LIBRARY_URIS, core.String)); |
| 2123 let uris = dart.as(_foreign_helper.JS('JSExtendableArray|Null', '#[#]', uris
Map, loadId), core.List$(core.String)); |
| 2124 let hashesMap = _foreign_helper.JS_EMBEDDED_GLOBAL('', dart.as(_js_embedded_
names.DEFERRED_LIBRARY_HASHES, core.String)); |
| 2125 let hashes = dart.as(_foreign_helper.JS('JSExtendableArray|Null', '#[#]', ha
shesMap, loadId), core.List$(core.String)); |
| 2126 if (uris === null) |
| 2127 return dart.as(new async.Future.value(null), async.Future$(core.Null)); |
| 2128 let indices = dart.as(new core.List.generate(uris.length, (i) => i), core.Li
st$(core.int)); |
| 2129 let isHunkLoaded = _foreign_helper.JS_EMBEDDED_GLOBAL('', dart.as(_js_embedd
ed_names.IS_HUNK_LOADED, core.String)); |
| 2130 let isHunkInitialized = _foreign_helper.JS_EMBEDDED_GLOBAL('', dart.as(_js_e
mbedded_names.IS_HUNK_INITIALIZED, core.String)); |
| 2131 let indicesToLoad = indices.where((i) => dart.throw_("Unimplemented PrefixEx
pression: !JS('bool', '#(#)', isHunkLoaded, hashes[i])")).toList(); |
| 2132 return dart.as(async.Future.wait(dart.as(indicesToLoad.map((i) => _loadHunk(
uris.get(i))), core.Iterable$(async.Future))).then((_) => { |
| 2133 let indicesToInitialize = indices.where((i) => dart.throw_("Unimplemented
PrefixExpression: !JS('bool', '#(#)', isHunkInitialized, hashes[i])")).toList(); |
| 2134 for (let i of indicesToInitialize) { |
| 2135 let initializer = _foreign_helper.JS_EMBEDDED_GLOBAL('', dart.as(_js_emb
edded_names.INITIALIZE_LOADED_HUNK, core.String)); |
| 2136 _foreign_helper.JS('void', '#(#)', initializer, hashes.get(i)); |
| 2137 } |
| 2138 let updated = _js_helper._loadedLibraries.add(loadId); |
| 2139 if (dart.notNull(updated) && dart.notNull(_js_helper.deferredLoadHook !==
null)) { |
| 2140 _js_helper.deferredLoadHook(); |
| 2141 } |
| 2142 }), async.Future$(core.Null)); |
| 2143 } |
| 2144 // Function _loadHunk: (String) → Future<Null> |
| 2145 function _loadHunk(hunkName) { |
| 2146 let future = _js_helper._loadingLibraries.get(hunkName); |
| 2147 if (future !== null) { |
| 2148 return dart.as(future.then((_) => null), async.Future$(core.Null)); |
| 2149 } |
| 2150 let uri = _isolate_helper.IsolateNatives.thisScript; |
| 2151 let index = uri.lastIndexOf('/'); |
| 2152 uri = `${uri.substring(0, index + 1)}${hunkName}`; |
| 2153 if (dart.notNull(Primitives.isJsshell) || dart.notNull(Primitives.isD8)) { |
| 2154 return _js_helper._loadingLibraries.set(hunkName, new async.Future(() => { |
| 2155 try { |
| 2156 _foreign_helper.JS('void', '(new Function(#))()', `load("${uri}")`); |
| 2157 } catch (error) { |
| 2158 let stackTrace = dart.stackTrace(error); |
| 2159 throw new async.DeferredLoadException(`Loading ${uri} failed.`); |
| 2160 } |
| 2161 |
| 2162 return null; |
| 2163 })); |
| 2164 } else if (_isolate_helper.isWorker()) { |
| 2165 return _js_helper._loadingLibraries.set(hunkName, new async.Future(() => { |
| 2166 let completer = new async.Completer(); |
| 2167 _isolate_helper.enterJsAsync(); |
| 2168 let leavingFuture = dart.as(completer.future.whenComplete(() => { |
| 2169 _isolate_helper.leaveJsAsync(); |
| 2170 }), async.Future$(core.Null)); |
| 2171 let index = uri.lastIndexOf('/'); |
| 2172 uri = `${uri.substring(0, index + 1)}${hunkName}`; |
| 2173 let xhr = _foreign_helper.JS('dynamic', 'new XMLHttpRequest()'); |
| 2174 _foreign_helper.JS('void', '#.open("GET", #)', xhr, uri); |
| 2175 _foreign_helper.JS('void', '#.addEventListener("load", #, false)', xhr,
convertDartClosureToJS((event) => { |
| 2176 if (!dart.equals(_foreign_helper.JS('int', '#.status', xhr), 200)) { |
| 2177 completer.completeError(new async.DeferredLoadException(`Loading ${u
ri} failed.`)); |
| 2178 return; |
| 2179 } |
| 2180 let code = dart.as(_foreign_helper.JS('String', '#.responseText', xhr)
, core.String); |
| 2181 try { |
| 2182 _foreign_helper.JS('void', '(new Function(#))()', code); |
| 2183 } catch (error) { |
| 2184 let stackTrace = dart.stackTrace(error); |
| 2185 completer.completeError(new async.DeferredLoadException(`Evaluating
${uri} failed.`)); |
| 2186 return; |
| 2187 } |
| 2188 |
| 2189 completer.complete(null); |
| 2190 }, 1)); |
| 2191 let fail = convertDartClosureToJS((event) => { |
| 2192 new async.DeferredLoadException(`Loading ${uri} failed.`); |
| 2193 }, 1); |
| 2194 _foreign_helper.JS('void', '#.addEventListener("error", #, false)', xhr,
fail); |
| 2195 _foreign_helper.JS('void', '#.addEventListener("abort", #, false)', xhr,
fail); |
| 2196 _foreign_helper.JS('void', '#.send()', xhr); |
| 2197 return leavingFuture; |
| 2198 })); |
| 2199 } |
| 2200 return _js_helper._loadingLibraries.set(hunkName, new async.Future(() => { |
| 2201 let completer = new async.Completer(); |
| 2202 let script = _foreign_helper.JS('', 'document.createElement("script")'); |
| 2203 _foreign_helper.JS('', '#.type = "text/javascript"', script); |
| 2204 _foreign_helper.JS('', '#.src = #', script, uri); |
| 2205 _foreign_helper.JS('', '#.addEventListener("load", #, false)', script, con
vertDartClosureToJS((event) => { |
| 2206 completer.complete(null); |
| 2207 }, 1)); |
| 2208 _foreign_helper.JS('', '#.addEventListener("error", #, false)', script, co
nvertDartClosureToJS((event) => { |
| 2209 completer.completeError(new async.DeferredLoadException(`Loading ${uri}
failed.`)); |
| 2210 }, 1)); |
| 2211 _foreign_helper.JS('', 'document.body.appendChild(#)', script); |
| 2212 return completer.future; |
| 2213 })); |
| 2214 } |
| 2215 class MainError extends core.Error { |
| 2216 MainError(_message) { |
| 2217 this._message = _message; |
| 2218 super.Error(); |
| 2219 } |
| 2220 toString() { |
| 2221 return `NoSuchMethodError: ${this._message}`; |
| 2222 } |
| 2223 } |
| 2224 // Function missingMain: () → void |
| 2225 function missingMain() { |
| 2226 throw new MainError("No top-level function named 'main'."); |
| 2227 } |
| 2228 // Function badMain: () → void |
| 2229 function badMain() { |
| 2230 throw new MainError("'main' is not a function."); |
| 2231 } |
| 2232 // Function mainHasTooManyParameters: () → void |
| 2233 function mainHasTooManyParameters() { |
| 2234 throw new MainError("'main' expects too many parameters."); |
| 2235 } |
| 2236 class NoSideEffects extends dart.Object { |
| 2237 NoSideEffects() { |
| 2238 } |
| 2239 } |
| 2240 class NoThrows extends dart.Object { |
| 2241 NoThrows() { |
| 2242 } |
| 2243 } |
| 2244 class NoInline extends dart.Object { |
| 2245 NoInline() { |
| 2246 } |
| 2247 } |
| 2248 class IrRepresentation extends dart.Object { |
| 2249 IrRepresentation(value) { |
| 2250 this.value = value; |
| 2251 } |
| 2252 } |
| 2253 class Native extends dart.Object { |
| 2254 Native(name) { |
| 2255 this.name = name; |
| 2256 } |
| 2257 } |
| 2258 let ConstantMap$ = dart.generic(function(K, V) { |
| 2259 class ConstantMap extends dart.Object { |
| 2260 ConstantMap$_() { |
| 2261 } |
| 2262 get isEmpty() { |
| 2263 return this.length === 0; |
| 2264 } |
| 2265 get isNotEmpty() { |
| 2266 return !dart.notNull(this.isEmpty); |
| 2267 } |
| 2268 toString() { |
| 2269 return collection.Maps.mapToString(this); |
| 2270 } |
| 2271 _throwUnmodifiable() { |
| 2272 throw new core.UnsupportedError("Cannot modify unmodifiable Map"); |
| 2273 } |
| 2274 set(key, val) { |
| 2275 return this._throwUnmodifiable(); |
| 2276 } |
| 2277 putIfAbsent(key, ifAbsent) { |
| 2278 return dart.as(this._throwUnmodifiable(), V); |
| 2279 } |
| 2280 remove(key) { |
| 2281 return dart.as(this._throwUnmodifiable(), V); |
| 2282 } |
| 2283 clear() { |
| 2284 return this._throwUnmodifiable(); |
| 2285 } |
| 2286 addAll(other) { |
| 2287 return this._throwUnmodifiable(); |
| 2288 } |
| 2289 } |
| 2290 dart.defineNamedConstructor(ConstantMap, '_'); |
| 2291 return ConstantMap; |
| 2292 }); |
| 2293 let ConstantMap = ConstantMap$(dynamic, dynamic); |
| 2294 let ConstantStringMap$ = dart.generic(function(K, V) { |
| 2295 class ConstantStringMap extends ConstantMap$(K, V) { |
| 2296 ConstantStringMap$_(length, _jsObject, _keys) { |
| 2297 this.length = length; |
| 2298 this._jsObject = _jsObject; |
| 2299 this._keys = _keys; |
| 2300 super.ConstantMap$_(); |
| 2301 } |
| 2302 containsValue(needle) { |
| 2303 return this.values.any((value) => dart.equals(value, needle)); |
| 2304 } |
| 2305 containsKey(key) { |
| 2306 if (!(typeof key == string)) |
| 2307 return false; |
| 2308 if (dart.equals('__proto__', key)) |
| 2309 return false; |
| 2310 return jsHasOwnProperty(this._jsObject, dart.as(key, core.String)); |
| 2311 } |
| 2312 get(key) { |
| 2313 if (!dart.notNull(this.containsKey(key))) |
| 2314 return dart.as(null, V); |
| 2315 return dart.as(this._fetch(key), V); |
| 2316 } |
| 2317 _fetch(key) { |
| 2318 return jsPropertyAccess(this._jsObject, dart.as(key, core.String)); |
| 2319 } |
| 2320 forEach(f) { |
| 2321 let keys = _foreign_helper.JS('JSArray', '#', this._keys); |
| 2322 for (let i = 0; i['<'](dart.dload(keys, 'length')); i++) { |
| 2323 let key = dart.dindex(keys, i); |
| 2324 f(dart.as(key, K), dart.as(this._fetch(key), V)); |
| 2325 } |
| 2326 } |
| 2327 get keys() { |
| 2328 return new _ConstantMapKeyIterable(this); |
| 2329 } |
| 2330 get values() { |
| 2331 return new _internal.MappedIterable(this._keys, ((key) => this._fetch(ke
y)).bind(this)); |
| 2332 } |
| 2333 } |
| 2334 dart.defineNamedConstructor(ConstantStringMap, '_'); |
| 2335 return ConstantStringMap; |
| 2336 }); |
| 2337 let ConstantStringMap = ConstantStringMap$(dynamic, dynamic); |
| 2338 let ConstantProtoMap$ = dart.generic(function(K, V) { |
| 2339 class ConstantProtoMap extends ConstantStringMap$(K, V) { |
| 2340 ConstantProtoMap$_(length, jsObject, keys, _protoValue) { |
| 2341 this._protoValue = _protoValue; |
| 2342 super.ConstantStringMap$_(dart.as(length, core.int), jsObject, dart.as(k
eys, core.List$(K))); |
| 2343 } |
| 2344 containsKey(key) { |
| 2345 if (!(typeof key == string)) |
| 2346 return false; |
| 2347 if (dart.equals('__proto__', key)) |
| 2348 return true; |
| 2349 return jsHasOwnProperty(this._jsObject, dart.as(key, core.String)); |
| 2350 } |
| 2351 _fetch(key) { |
| 2352 return dart.equals('__proto__', key) ? this._protoValue : jsPropertyAcce
ss(this._jsObject, dart.as(key, core.String)); |
| 2353 } |
| 2354 } |
| 2355 dart.defineNamedConstructor(ConstantProtoMap, '_'); |
| 2356 return ConstantProtoMap; |
| 2357 }); |
| 2358 let ConstantProtoMap = ConstantProtoMap$(dynamic, dynamic); |
| 2359 let _ConstantMapKeyIterable$ = dart.generic(function(K) { |
| 2360 class _ConstantMapKeyIterable extends collection.IterableBase$(K) { |
| 2361 _ConstantMapKeyIterable(_map) { |
| 2362 this._map = _map; |
| 2363 super.IterableBase(); |
| 2364 } |
| 2365 get iterator() { |
| 2366 return this._map._keys.iterator; |
| 2367 } |
| 2368 get length() { |
| 2369 return this._map._keys.length; |
| 2370 } |
| 2371 } |
| 2372 return _ConstantMapKeyIterable; |
| 2373 }); |
| 2374 let _ConstantMapKeyIterable = _ConstantMapKeyIterable$(dynamic); |
| 2375 let GeneralConstantMap$ = dart.generic(function(K, V) { |
| 2376 class GeneralConstantMap extends ConstantMap$(K, V) { |
| 2377 GeneralConstantMap(_jsData) { |
| 2378 this._jsData = _jsData; |
| 2379 super.ConstantMap$_(); |
| 2380 } |
| 2381 _getMap() { |
| 2382 if (_foreign_helper.JS('bool', '!this.$map')) { |
| 2383 let backingMap = new collection.LinkedHashMap(); |
| 2384 _foreign_helper.JS('', 'this.$map = #', fillLiteralMap(this._jsData, b
ackingMap)); |
| 2385 } |
| 2386 return dart.as(_foreign_helper.JS('Map', 'this.$map'), core.Map$(K, V)); |
| 2387 } |
| 2388 containsValue(needle) { |
| 2389 return this._getMap().containsValue(needle); |
| 2390 } |
| 2391 containsKey(key) { |
| 2392 return this._getMap().containsKey(key); |
| 2393 } |
| 2394 get(key) { |
| 2395 return this._getMap().get(key); |
| 2396 } |
| 2397 forEach(f) { |
| 2398 this._getMap().forEach(f); |
| 2399 } |
| 2400 get keys() { |
| 2401 return this._getMap().keys; |
| 2402 } |
| 2403 get values() { |
| 2404 return this._getMap().values; |
| 2405 } |
| 2406 get length() { |
| 2407 return this._getMap().length; |
| 2408 } |
| 2409 } |
| 2410 return GeneralConstantMap; |
| 2411 }); |
| 2412 let GeneralConstantMap = GeneralConstantMap$(dynamic, dynamic); |
| 2413 // Function contains: (String, String) → bool |
| 2414 function contains(userAgent, name) { |
| 2415 return !dart.equals(_foreign_helper.JS('int', '#.indexOf(#)', userAgent, nam
e), -1); |
| 2416 } |
| 2417 // Function arrayLength: (List<dynamic>) → int |
| 2418 function arrayLength(array) { |
| 2419 return dart.as(_foreign_helper.JS('int', '#.length', array), core.int); |
| 2420 } |
| 2421 // Function arrayGet: (List<dynamic>, int) → dynamic |
| 2422 function arrayGet(array, index) { |
| 2423 return _foreign_helper.JS('var', '#[#]', array, index); |
| 2424 } |
| 2425 // Function arraySet: (List<dynamic>, int, dynamic) → void |
| 2426 function arraySet(array, index, value) { |
| 2427 _foreign_helper.JS('var', '#[#] = #', array, index, value); |
| 2428 } |
| 2429 // Function propertyGet: (dynamic, String) → dynamic |
| 2430 function propertyGet(object, property) { |
| 2431 return _foreign_helper.JS('var', '#[#]', object, property); |
| 2432 } |
| 2433 // Function callHasOwnProperty: (dynamic, dynamic, String) → bool |
| 2434 function callHasOwnProperty(function, object, property) { |
| 2435 return dart.as(_foreign_helper.JS('bool', '#.call(#, #)', function, object,
property), core.bool); |
| 2436 } |
| 2437 // Function propertySet: (dynamic, String, dynamic) → void |
| 2438 function propertySet(object, property, value) { |
| 2439 _foreign_helper.JS('var', '#[#] = #', object, property, value); |
| 2440 } |
| 2441 // Function getPropertyFromPrototype: (dynamic, String) → dynamic |
| 2442 function getPropertyFromPrototype(object, name) { |
| 2443 return _foreign_helper.JS('var', 'Object.getPrototypeOf(#)[#]', object, name
); |
| 2444 } |
| 2445 _js_helper.getTagFunction = null; |
| 2446 _js_helper.alternateTagFunction = null; |
| 2447 _js_helper.prototypeForTagFunction = null; |
| 2448 // Function toStringForNativeObject: (dynamic) → String |
| 2449 function toStringForNativeObject(obj) { |
| 2450 let name = dart.as(_js_helper.getTagFunction === null ? '<Unknown>' : _forei
gn_helper.JS('String', '#', dart.dinvokef(_js_helper.getTagFunction, obj)), core
.String); |
| 2451 return `Instance of ${name}`; |
| 2452 } |
| 2453 // Function hashCodeForNativeObject: (dynamic) → int |
| 2454 function hashCodeForNativeObject(object) { |
| 2455 return Primitives.objectHashCode(object); |
| 2456 } |
| 2457 // Function defineProperty: (dynamic, String, dynamic) → void |
| 2458 function defineProperty(obj, property, value) { |
| 2459 _foreign_helper.JS('void', 'Object.defineProperty(#, #, ' + '{value: #, enum
erable: false, writable: true, configurable: true})', obj, property, value); |
| 2460 } |
| 2461 // Function isDartObject: (dynamic) → bool |
| 2462 function isDartObject(obj) { |
| 2463 return dart.as(_foreign_helper.JS('bool', '((#) instanceof (#))', obj, _fore
ign_helper.JS_DART_OBJECT_CONSTRUCTOR()), core.bool); |
| 2464 } |
| 2465 dart.copyProperties(_js_helper, { |
| 2466 get interceptorsByTag() { |
| 2467 return _foreign_helper.JS_EMBEDDED_GLOBAL('=Object', dart.as(_js_embedded_
names.INTERCEPTORS_BY_TAG, core.String)); |
| 2468 }, |
| 2469 get leafTags() { |
| 2470 return _foreign_helper.JS_EMBEDDED_GLOBAL('=Object', dart.as(_js_embedded_
names.LEAF_TAGS, core.String)); |
| 2471 } |
| 2472 }); |
| 2473 // Function findDispatchTagForInterceptorClass: (dynamic) → String |
| 2474 function findDispatchTagForInterceptorClass(interceptorClassConstructor) { |
| 2475 return dart.as(_foreign_helper.JS('', '#.#', interceptorClassConstructor, _j
s_embedded_names.NATIVE_SUPERCLASS_TAG_NAME), core.String); |
| 2476 } |
| 2477 _js_helper.dispatchRecordsForInstanceTags = null; |
| 2478 _js_helper.interceptorsForUncacheableTags = null; |
| 2479 // Function lookupInterceptor: (String) → dynamic |
| 2480 function lookupInterceptor(tag) { |
| 2481 return propertyGet(_js_helper.interceptorsByTag, tag); |
| 2482 } |
| 2483 let UNCACHED_MARK = '~'; |
| 2484 let INSTANCE_CACHED_MARK = '!'; |
| 2485 let LEAF_MARK = '-'; |
| 2486 let INTERIOR_MARK = '+'; |
| 2487 let DISCRIMINATED_MARK = '*'; |
| 2488 // Function lookupAndCacheInterceptor: (dynamic) → dynamic |
| 2489 function lookupAndCacheInterceptor(obj) { |
| 2490 dart.assert(!dart.notNull(isDartObject(obj))); |
| 2491 let tag = dart.as(dart.dinvokef(_js_helper.getTagFunction, obj), core.String
); |
| 2492 let record = propertyGet(_js_helper.dispatchRecordsForInstanceTags, tag); |
| 2493 if (record !== null) |
| 2494 return patchInstance(obj, record); |
| 2495 let interceptor = propertyGet(_js_helper.interceptorsForUncacheableTags, tag
); |
| 2496 if (interceptor !== null) |
| 2497 return interceptor; |
| 2498 let interceptorClass = lookupInterceptor(tag); |
| 2499 if (interceptorClass === null) { |
| 2500 tag = dart.as(dart.dinvokef(_js_helper.alternateTagFunction, obj, tag), co
re.String); |
| 2501 if (tag !== null) { |
| 2502 record = propertyGet(_js_helper.dispatchRecordsForInstanceTags, tag); |
| 2503 if (record !== null) |
| 2504 return patchInstance(obj, record); |
| 2505 interceptor = propertyGet(_js_helper.interceptorsForUncacheableTags, tag
); |
| 2506 if (interceptor !== null) |
| 2507 return interceptor; |
| 2508 interceptorClass = lookupInterceptor(tag); |
| 2509 } |
| 2510 } |
| 2511 if (interceptorClass === null) { |
| 2512 return null; |
| 2513 } |
| 2514 interceptor = _foreign_helper.JS('', '#.prototype', interceptorClass); |
| 2515 let mark = _foreign_helper.JS('String|Null', '#[0]', tag); |
| 2516 if (dart.equals(mark, INSTANCE_CACHED_MARK)) { |
| 2517 record = makeLeafDispatchRecord(interceptor); |
| 2518 propertySet(_js_helper.dispatchRecordsForInstanceTags, tag, record); |
| 2519 return patchInstance(obj, record); |
| 2520 } |
| 2521 if (dart.equals(mark, UNCACHED_MARK)) { |
| 2522 propertySet(_js_helper.interceptorsForUncacheableTags, tag, interceptor); |
| 2523 return interceptor; |
| 2524 } |
| 2525 if (dart.equals(mark, LEAF_MARK)) { |
| 2526 return patchProto(obj, makeLeafDispatchRecord(interceptor)); |
| 2527 } |
| 2528 if (dart.equals(mark, INTERIOR_MARK)) { |
| 2529 return patchInteriorProto(obj, interceptor); |
| 2530 } |
| 2531 if (dart.equals(mark, DISCRIMINATED_MARK)) { |
| 2532 throw new core.UnimplementedError(tag); |
| 2533 } |
| 2534 let isLeaf = _foreign_helper.JS('bool', '(#[#]) === true', _js_helper.leafTa
gs, tag); |
| 2535 if (isLeaf) { |
| 2536 return patchProto(obj, makeLeafDispatchRecord(interceptor)); |
| 2537 } else { |
| 2538 return patchInteriorProto(obj, interceptor); |
| 2539 } |
| 2540 } |
| 2541 // Function patchInstance: (dynamic, dynamic) → dynamic |
| 2542 function patchInstance(obj, record) { |
| 2543 _interceptors.setDispatchProperty(obj, record); |
| 2544 return _interceptors.dispatchRecordInterceptor(record); |
| 2545 } |
| 2546 // Function patchProto: (dynamic, dynamic) → dynamic |
| 2547 function patchProto(obj, record) { |
| 2548 _interceptors.setDispatchProperty(_foreign_helper.JS('', 'Object.getPrototyp
eOf(#)', obj), record); |
| 2549 return _interceptors.dispatchRecordInterceptor(record); |
| 2550 } |
| 2551 // Function patchInteriorProto: (dynamic, dynamic) → dynamic |
| 2552 function patchInteriorProto(obj, interceptor) { |
| 2553 let proto = _foreign_helper.JS('', 'Object.getPrototypeOf(#)', obj); |
| 2554 let record = _interceptors.makeDispatchRecord(interceptor, proto, null, null
); |
| 2555 _interceptors.setDispatchProperty(proto, record); |
| 2556 return interceptor; |
| 2557 } |
| 2558 // Function makeLeafDispatchRecord: (dynamic) → dynamic |
| 2559 function makeLeafDispatchRecord(interceptor) { |
| 2560 let fieldName = _foreign_helper.JS_IS_INDEXABLE_FIELD_NAME(); |
| 2561 let indexability = dart.as(_foreign_helper.JS('bool', '!!#[#]', interceptor,
fieldName), core.bool); |
| 2562 return _interceptors.makeDispatchRecord(interceptor, false, null, indexabili
ty); |
| 2563 } |
| 2564 // Function makeDefaultDispatchRecord: (dynamic, dynamic, dynamic) → dynamic |
| 2565 function makeDefaultDispatchRecord(tag, interceptorClass, proto) { |
| 2566 let interceptor = _foreign_helper.JS('', '#.prototype', interceptorClass); |
| 2567 let isLeaf = _foreign_helper.JS('bool', '(#[#]) === true', _js_helper.leafTa
gs, tag); |
| 2568 if (isLeaf) { |
| 2569 return makeLeafDispatchRecord(interceptor); |
| 2570 } else { |
| 2571 return _interceptors.makeDispatchRecord(interceptor, proto, null, null); |
| 2572 } |
| 2573 } |
| 2574 // Function setNativeSubclassDispatchRecord: (dynamic, dynamic) → dynamic |
| 2575 function setNativeSubclassDispatchRecord(proto, interceptor) { |
| 2576 _interceptors.setDispatchProperty(proto, makeLeafDispatchRecord(interceptor)
); |
| 2577 } |
| 2578 // Function constructorNameFallback: (dynamic) → String |
| 2579 function constructorNameFallback(object) { |
| 2580 return dart.as(_foreign_helper.JS('String', '#(#)', _constructorNameFallback
, object), core.String); |
| 2581 } |
| 2582 _js_helper.initNativeDispatchFlag = null; |
| 2583 // Function initNativeDispatch: () → void |
| 2584 function initNativeDispatch() { |
| 2585 if (true === _js_helper.initNativeDispatchFlag) |
| 2586 return; |
| 2587 _js_helper.initNativeDispatchFlag = true; |
| 2588 initNativeDispatchContinue(); |
| 2589 } |
| 2590 // Function initNativeDispatchContinue: () → void |
| 2591 function initNativeDispatchContinue() { |
| 2592 _js_helper.dispatchRecordsForInstanceTags = _foreign_helper.JS('', 'Object.c
reate(null)'); |
| 2593 _js_helper.interceptorsForUncacheableTags = _foreign_helper.JS('', 'Object.c
reate(null)'); |
| 2594 initHooks(); |
| 2595 let map = _js_helper.interceptorsByTag; |
| 2596 let tags = _foreign_helper.JS('JSMutableArray', 'Object.getOwnPropertyNames(
#)', map); |
| 2597 if (_foreign_helper.JS('bool', 'typeof window != "undefined"')) { |
| 2598 let context = _foreign_helper.JS('=Object', 'window'); |
| 2599 let fun = _foreign_helper.JS('=Object', 'function () {}'); |
| 2600 for (let i = 0; i['<'](dart.dload(tags, 'length')); i++) { |
| 2601 let tag = dart.dindex(tags, i); |
| 2602 let proto = dart.dinvokef(_js_helper.prototypeForTagFunction, tag); |
| 2603 if (proto !== null) { |
| 2604 let interceptorClass = _foreign_helper.JS('', '#[#]', map, tag); |
| 2605 let record = makeDefaultDispatchRecord(tag, interceptorClass, proto); |
| 2606 if (record !== null) { |
| 2607 _interceptors.setDispatchProperty(proto, record); |
| 2608 _foreign_helper.JS('', '#.prototype = #', fun, proto); |
| 2609 } |
| 2610 } |
| 2611 } |
| 2612 } |
| 2613 for (let i = 0; i['<'](dart.dload(tags, 'length')); i++) { |
| 2614 let tag = _foreign_helper.JS('String', '#[#]', tags, i); |
| 2615 if (_foreign_helper.JS('bool', '/^[A-Za-z_]/.test(#)', tag)) { |
| 2616 let interceptorClass = propertyGet(map, dart.as(tag, core.String)); |
| 2617 propertySet(map, dart.as(dart.dbinary(INSTANCE_CACHED_MARK, '+', tag), c
ore.String), interceptorClass); |
| 2618 propertySet(map, dart.as(dart.dbinary(UNCACHED_MARK, '+', tag), core.Str
ing), interceptorClass); |
| 2619 propertySet(map, dart.as(dart.dbinary(LEAF_MARK, '+', tag), core.String)
, interceptorClass); |
| 2620 propertySet(map, dart.as(dart.dbinary(INTERIOR_MARK, '+', tag), core.Str
ing), interceptorClass); |
| 2621 propertySet(map, dart.as(dart.dbinary(DISCRIMINATED_MARK, '+', tag), cor
e.String), interceptorClass); |
| 2622 } |
| 2623 } |
| 2624 } |
| 2625 // Function initHooks: () → void |
| 2626 function initHooks() { |
| 2627 let hooks = _foreign_helper.JS('', '#()', _baseHooks); |
| 2628 let _fallbackConstructorHooksTransformer = _foreign_helper.JS('', '#(#)', _f
allbackConstructorHooksTransformerGenerator, _constructorNameFallback); |
| 2629 hooks = applyHooksTransformer(_fallbackConstructorHooksTransformer, hooks); |
| 2630 hooks = applyHooksTransformer(_firefoxHooksTransformer, hooks); |
| 2631 hooks = applyHooksTransformer(_ieHooksTransformer, hooks); |
| 2632 hooks = applyHooksTransformer(_operaHooksTransformer, hooks); |
| 2633 hooks = applyHooksTransformer(_safariHooksTransformer, hooks); |
| 2634 hooks = applyHooksTransformer(_fixDocumentHooksTransformer, hooks); |
| 2635 hooks = applyHooksTransformer(_dartExperimentalFixupGetTagHooksTransformer,
hooks); |
| 2636 if (_foreign_helper.JS('bool', 'typeof dartNativeDispatchHooksTransformer !=
"undefined"')) { |
| 2637 let transformers = _foreign_helper.JS('', 'dartNativeDispatchHooksTransfor
mer'); |
| 2638 if (_foreign_helper.JS('bool', 'typeof # == "function"', transformers)) { |
| 2639 transformers = new List.from([transformers]); |
| 2640 } |
| 2641 if (_foreign_helper.JS('bool', '#.constructor == Array', transformers)) { |
| 2642 for (let i = 0; i['<'](_foreign_helper.JS('int', '#.length', transformer
s)); i++) { |
| 2643 let transformer = _foreign_helper.JS('', '#[#]', transformers, i); |
| 2644 if (_foreign_helper.JS('bool', 'typeof # == "function"', transformer))
{ |
| 2645 hooks = applyHooksTransformer(transformer, hooks); |
| 2646 } |
| 2647 } |
| 2648 } |
| 2649 } |
| 2650 let getTag = _foreign_helper.JS('', '#.getTag', hooks); |
| 2651 let getUnknownTag = _foreign_helper.JS('', '#.getUnknownTag', hooks); |
| 2652 let prototypeForTag = _foreign_helper.JS('', '#.prototypeForTag', hooks); |
| 2653 _js_helper.getTagFunction = (o) => _foreign_helper.JS('String|Null', '#(#)',
getTag, o); |
| 2654 _js_helper.alternateTagFunction = (o, tag) => _foreign_helper.JS('String|Nul
l', '#(#, #)', getUnknownTag, o, tag); |
| 2655 _js_helper.prototypeForTagFunction = (tag) => _foreign_helper.JS('', '#(#)',
prototypeForTag, tag); |
| 2656 } |
| 2657 // Function applyHooksTransformer: (dynamic, dynamic) → dynamic |
| 2658 function applyHooksTransformer(transformer, hooks) { |
| 2659 let newHooks = _foreign_helper.JS('=Object|Null', '#(#)', transformer, hooks
); |
| 2660 return _foreign_helper.JS('', '# || #', newHooks, hooks); |
| 2661 } |
| 2662 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}'); |
| 2663 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}'); |
| 2664 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}'); |
| 2665 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}'); |
| 2666 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}'); |
| 2667 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}'); |
| 2668 let _operaHooksTransformer = new _foreign_helper.JS_CONST('\nfunction(hooks) {
return hooks; }\n'); |
| 2669 let _safariHooksTransformer = new _foreign_helper.JS_CONST('\nfunction(hooks)
{ return hooks; }\n'); |
| 2670 let _dartExperimentalFixupGetTagHooksTransformer = new _foreign_helper.JS_CONS
T('\nfunction(hooks) {\n if (typeof dartExperimentalFixupGetTag != "function")
return hooks;\n hooks.getTag = dartExperimentalFixupGetTag(hooks.getTag);\n}'); |
| 2671 // Function regExpGetNative: (JSSyntaxRegExp) → dynamic |
| 2672 function regExpGetNative(regexp) { |
| 2673 return regexp._nativeRegExp; |
| 2674 } |
| 2675 // Function regExpGetGlobalNative: (JSSyntaxRegExp) → dynamic |
| 2676 function regExpGetGlobalNative(regexp) { |
| 2677 let nativeRegexp = regexp._nativeGlobalVersion; |
| 2678 _foreign_helper.JS("void", "#.lastIndex = 0", nativeRegexp); |
| 2679 return nativeRegexp; |
| 2680 } |
| 2681 // Function regExpCaptureCount: (JSSyntaxRegExp) → int |
| 2682 function regExpCaptureCount(regexp) { |
| 2683 let nativeAnchoredRegExp = regexp._nativeAnchoredVersion; |
| 2684 let match = _foreign_helper.JS('JSExtendableArray', "#.exec('')", nativeAnch
oredRegExp); |
| 2685 return dart.as(dart.dbinary(dart.dload(match, 'length'), '-', 2), core.int); |
| 2686 } |
| 2687 class JSSyntaxRegExp extends dart.Object { |
| 2688 toString() { |
| 2689 return `RegExp/${this.pattern}/`; |
| 2690 } |
| 2691 JSSyntaxRegExp(source, opt$) { |
| 2692 let multiLine = opt$.multiLine === void 0 ? false : opt$.multiLine; |
| 2693 let caseSensitive = opt$.caseSensitive === void 0 ? true : opt$.caseSensit
ive; |
| 2694 this.pattern = source; |
| 2695 this._nativeRegExp = makeNative(source, multiLine, caseSensitive, false); |
| 2696 this._nativeGlobalRegExp = null; |
| 2697 this._nativeAnchoredRegExp = null; |
| 2698 } |
| 2699 get _nativeGlobalVersion() { |
| 2700 if (this._nativeGlobalRegExp !== null) |
| 2701 return this._nativeGlobalRegExp; |
| 2702 return this._nativeGlobalRegExp = makeNative(this.pattern, this._isMultiLi
ne, this._isCaseSensitive, true); |
| 2703 } |
| 2704 get _nativeAnchoredVersion() { |
| 2705 if (this._nativeAnchoredRegExp !== null) |
| 2706 return this._nativeAnchoredRegExp; |
| 2707 return this._nativeAnchoredRegExp = makeNative(`${this.pattern}|()`, this.
_isMultiLine, this._isCaseSensitive, true); |
| 2708 } |
| 2709 get _isMultiLine() { |
| 2710 return dart.as(_foreign_helper.JS("bool", "#.multiline", this._nativeRegEx
p), core.bool); |
| 2711 } |
| 2712 get _isCaseSensitive() { |
| 2713 return dart.as(_foreign_helper.JS("bool", "!#.ignoreCase", this._nativeReg
Exp), core.bool); |
| 2714 } |
| 2715 static makeNative(source, multiLine, caseSensitive, global) { |
| 2716 checkString(source); |
| 2717 let m = multiLine ? 'm' : ''; |
| 2718 let i = caseSensitive ? '' : 'i'; |
| 2719 let g = global ? 'g' : ''; |
| 2720 let regexp = _foreign_helper.JS('', '(function() {' + 'try {' + 'return ne
w RegExp(#, # + # + #);' + '} catch (e) {' + 'return e;' + '}' + '})()', source,
m, i, g); |
| 2721 if (_foreign_helper.JS('bool', '# instanceof RegExp', regexp)) |
| 2722 return regexp; |
| 2723 let errorMessage = dart.as(_foreign_helper.JS('String', 'String(#)', regex
p), core.String); |
| 2724 throw new core.FormatException(`Illegal RegExp pattern: ${source}, ${error
Message}`); |
| 2725 } |
| 2726 firstMatch(string) { |
| 2727 let m = dart.as(_foreign_helper.JS('JSExtendableArray|Null', '#.exec(#)',
this._nativeRegExp, checkString(string)), core.List$(core.String)); |
| 2728 if (m === null) |
| 2729 return null; |
| 2730 return new _MatchImplementation(this, m); |
| 2731 } |
| 2732 hasMatch(string) { |
| 2733 return dart.as(_foreign_helper.JS('bool', '#.test(#)', this._nativeRegExp,
checkString(string)), core.bool); |
| 2734 } |
| 2735 stringMatch(string) { |
| 2736 let match = this.firstMatch(string); |
| 2737 if (match !== null) |
| 2738 return match.group(0); |
| 2739 return null; |
| 2740 } |
| 2741 allMatches(string, start) { |
| 2742 if (start === void 0) |
| 2743 start = 0; |
| 2744 checkString(string); |
| 2745 checkInt(start); |
| 2746 if (dart.notNull(start < 0) || dart.notNull(start > string.length)) { |
| 2747 throw new core.RangeError.range(start, 0, string.length); |
| 2748 } |
| 2749 return new _AllMatchesIterable(this, string, start); |
| 2750 } |
| 2751 _execGlobal(string, start) { |
| 2752 let regexp = this._nativeGlobalVersion; |
| 2753 _foreign_helper.JS("void", "#.lastIndex = #", regexp, start); |
| 2754 let match = dart.as(_foreign_helper.JS("JSExtendableArray|Null", "#.exec(#
)", regexp, string), core.List); |
| 2755 if (match === null) |
| 2756 return null; |
| 2757 return new _MatchImplementation(this, match); |
| 2758 } |
| 2759 _execAnchored(string, start) { |
| 2760 let regexp = this._nativeAnchoredVersion; |
| 2761 _foreign_helper.JS("void", "#.lastIndex = #", regexp, start); |
| 2762 let match = dart.as(_foreign_helper.JS("JSExtendableArray|Null", "#.exec(#
)", regexp, string), core.List); |
| 2763 if (match === null) |
| 2764 return null; |
| 2765 if (match.get(match.length - 1) !== null) |
| 2766 return null; |
| 2767 match.length = 1; |
| 2768 return new _MatchImplementation(this, match); |
| 2769 } |
| 2770 matchAsPrefix(string, start) { |
| 2771 if (start === void 0) |
| 2772 start = 0; |
| 2773 if (dart.notNull(start < 0) || dart.notNull(start > string.length)) { |
| 2774 throw new core.RangeError.range(start, 0, string.length); |
| 2775 } |
| 2776 return this._execAnchored(string, start); |
| 2777 } |
| 2778 get isMultiLine() { |
| 2779 return this._isMultiLine; |
| 2780 } |
| 2781 get isCaseSensitive() { |
| 2782 return this._isCaseSensitive; |
| 2783 } |
| 2784 } |
| 2785 class _MatchImplementation extends dart.Object { |
| 2786 _MatchImplementation(pattern, _match) { |
| 2787 this.pattern = pattern; |
| 2788 this._match = _match; |
| 2789 dart.assert(typeof _foreign_helper.JS("var", "#.input", this._match) == st
ring); |
| 2790 dart.assert(typeof _foreign_helper.JS("var", "#.index", this._match) == nu
mber); |
| 2791 } |
| 2792 get input() { |
| 2793 return dart.as(_foreign_helper.JS("String", "#.input", this._match), core.
String); |
| 2794 } |
| 2795 get start() { |
| 2796 return dart.as(_foreign_helper.JS("int", "#.index", this._match), core.int
); |
| 2797 } |
| 2798 get end() { |
| 2799 return this.start + this._match.get(0).length; |
| 2800 } |
| 2801 group(index) { |
| 2802 return this._match.get(index); |
| 2803 } |
| 2804 get(index) { |
| 2805 return this.group(index); |
| 2806 } |
| 2807 get groupCount() { |
| 2808 return this._match.length - 1; |
| 2809 } |
| 2810 groups(groups) { |
| 2811 let out = dart.as(new List.from([]), core.List$(core.String)); |
| 2812 for (let i of groups) { |
| 2813 out.add(this.group(i)); |
| 2814 } |
| 2815 return out; |
| 2816 } |
| 2817 } |
| 2818 class _AllMatchesIterable extends collection.IterableBase$(core.Match) { |
| 2819 _AllMatchesIterable(_re, _string, _start) { |
| 2820 this._re = _re; |
| 2821 this._string = _string; |
| 2822 this._start = _start; |
| 2823 super.IterableBase(); |
| 2824 } |
| 2825 get iterator() { |
| 2826 return new _AllMatchesIterator(this._re, this._string, this._start); |
| 2827 } |
| 2828 } |
| 2829 class _AllMatchesIterator extends dart.Object { |
| 2830 _AllMatchesIterator(_regExp, _string, _nextIndex) { |
| 2831 this._regExp = _regExp; |
| 2832 this._string = _string; |
| 2833 this._nextIndex = _nextIndex; |
| 2834 this._current = null; |
| 2835 } |
| 2836 get current() { |
| 2837 return this._current; |
| 2838 } |
| 2839 moveNext() { |
| 2840 if (this._string === null) |
| 2841 return false; |
| 2842 if (this._nextIndex <= this._string.length) { |
| 2843 let match = this._regExp._execGlobal(this._string, this._nextIndex); |
| 2844 if (match !== null) { |
| 2845 this._current = match; |
| 2846 let nextIndex = match.end; |
| 2847 if (match.start === nextIndex) { |
| 2848 nextIndex++; |
| 2849 } |
| 2850 this._nextIndex = nextIndex; |
| 2851 return true; |
| 2852 } |
| 2853 } |
| 2854 this._current = null; |
| 2855 this._string = null; |
| 2856 return false; |
| 2857 } |
| 2858 } |
| 2859 // Function firstMatchAfter: (JSSyntaxRegExp, String, int) → Match |
| 2860 function firstMatchAfter(regExp, string, start) { |
| 2861 return regExp._execGlobal(string, start); |
| 2862 } |
| 2863 class StringMatch extends dart.Object { |
| 2864 StringMatch(start, input, pattern) { |
| 2865 this.start = start; |
| 2866 this.input = input; |
| 2867 this.pattern = pattern; |
| 2868 } |
| 2869 get end() { |
| 2870 return this.start + this.pattern.length; |
| 2871 } |
| 2872 get(g) { |
| 2873 return this.group(g); |
| 2874 } |
| 2875 get groupCount() { |
| 2876 return 0; |
| 2877 } |
| 2878 group(group_) { |
| 2879 if (group_ !== 0) { |
| 2880 throw new core.RangeError.value(group_); |
| 2881 } |
| 2882 return this.pattern; |
| 2883 } |
| 2884 groups(groups_) { |
| 2885 let result = new core.List(); |
| 2886 for (let g of groups_) { |
| 2887 result.add(this.group(g)); |
| 2888 } |
| 2889 return result; |
| 2890 } |
| 2891 } |
| 2892 // Function allMatchesInStringUnchecked: (String, String, int) → List<Match> |
| 2893 function allMatchesInStringUnchecked(needle, haystack, startIndex) { |
| 2894 let result = new core.List(); |
| 2895 let length = haystack.length; |
| 2896 let patternLength = needle.length; |
| 2897 while (true) { |
| 2898 let position = haystack.indexOf(needle, startIndex); |
| 2899 if (position === -1) { |
| 2900 break; |
| 2901 } |
| 2902 result.add(new StringMatch(position, haystack, needle)); |
| 2903 let endIndex = position + patternLength; |
| 2904 if (endIndex === length) { |
| 2905 break; |
| 2906 } else if (position === endIndex) { |
| 2907 ++startIndex; |
| 2908 } else { |
| 2909 startIndex = endIndex; |
| 2910 } |
| 2911 } |
| 2912 return result; |
| 2913 } |
| 2914 // Function stringContainsUnchecked: (dynamic, dynamic, dynamic) → dynamic |
| 2915 function stringContainsUnchecked(receiver, other, startIndex) { |
| 2916 if (typeof other == string) { |
| 2917 return !dart.equals(dart.dinvoke(receiver, 'indexOf', other, startIndex),
-1); |
| 2918 } else if (dart.is(other, JSSyntaxRegExp)) { |
| 2919 return dart.dinvoke(other, 'hasMatch', dart.dinvoke(receiver, 'substring',
startIndex)); |
| 2920 } else { |
| 2921 let substr = dart.dinvoke(receiver, 'substring', startIndex); |
| 2922 return dart.dload(dart.dinvoke(other, 'allMatches', substr), 'isNotEmpty')
; |
| 2923 } |
| 2924 } |
| 2925 // Function stringReplaceJS: (dynamic, dynamic, dynamic) → dynamic |
| 2926 function stringReplaceJS(receiver, replacer, to) { |
| 2927 to = _foreign_helper.JS('String', '#.replace(/\\$/g, "$$$$")', to); |
| 2928 return _foreign_helper.JS('String', '#.replace(#, #)', receiver, replacer, t
o); |
| 2929 } |
| 2930 // Function stringReplaceFirstRE: (dynamic, dynamic, dynamic, dynamic) → dynam
ic |
| 2931 function stringReplaceFirstRE(receiver, regexp, to, startIndex) { |
| 2932 let match = dart.dinvoke(regexp, '_execGlobal', receiver, startIndex); |
| 2933 if (match === null) |
| 2934 return receiver; |
| 2935 let start = dart.dload(match, 'start'); |
| 2936 let end = dart.dload(match, 'end'); |
| 2937 return `${dart.dinvoke(receiver, 'substring', 0, start)}${to}${dart.dinvoke(
receiver, 'substring', end)}`; |
| 2938 } |
| 2939 let ESCAPE_REGEXP = '[[\\]{}()*+?.\\\\^$|]'; |
| 2940 // Function stringReplaceAllUnchecked: (dynamic, dynamic, dynamic) → dynamic |
| 2941 function stringReplaceAllUnchecked(receiver, from, to) { |
| 2942 checkString(to); |
| 2943 if (typeof from == string) { |
| 2944 if (dart.equals(from, "")) { |
| 2945 if (dart.equals(receiver, "")) { |
| 2946 return to; |
| 2947 } else { |
| 2948 let result = new core.StringBuffer(); |
| 2949 let length = dart.as(dart.dload(receiver, 'length'), core.int); |
| 2950 result.write(to); |
| 2951 for (let i = 0; i < length; i++) { |
| 2952 result.write(dart.dindex(receiver, i)); |
| 2953 result.write(to); |
| 2954 } |
| 2955 return result.toString(); |
| 2956 } |
| 2957 } else { |
| 2958 let quoter = _foreign_helper.JS('', "new RegExp(#, 'g')", ESCAPE_REGEXP)
; |
| 2959 let quoted = _foreign_helper.JS('String', '#.replace(#, "\\\\$&")', from
, quoter); |
| 2960 let replacer = _foreign_helper.JS('', "new RegExp(#, 'g')", quoted); |
| 2961 return stringReplaceJS(receiver, replacer, to); |
| 2962 } |
| 2963 } else if (dart.is(from, JSSyntaxRegExp)) { |
| 2964 let re = regExpGetGlobalNative(dart.as(from, JSSyntaxRegExp)); |
| 2965 return stringReplaceJS(receiver, re, to); |
| 2966 } else { |
| 2967 checkNull(from); |
| 2968 throw "String.replaceAll(Pattern) UNIMPLEMENTED"; |
| 2969 } |
| 2970 } |
| 2971 // Function _matchString: (Match) → String |
| 2972 function _matchString(match) { |
| 2973 return match.get(0); |
| 2974 } |
| 2975 // Function _stringIdentity: (String) → String |
| 2976 function _stringIdentity(string) { |
| 2977 return string; |
| 2978 } |
| 2979 // Function stringReplaceAllFuncUnchecked: (dynamic, dynamic, dynamic, dynamic
) → dynamic |
| 2980 function stringReplaceAllFuncUnchecked(receiver, pattern, onMatch, onNonMatch)
{ |
| 2981 if (!dart.is(pattern, core.Pattern)) { |
| 2982 throw new core.ArgumentError(`${pattern} is not a Pattern`); |
| 2983 } |
| 2984 if (onMatch === null) |
| 2985 onMatch = _matchString; |
| 2986 if (onNonMatch === null) |
| 2987 onNonMatch = _stringIdentity; |
| 2988 if (typeof pattern == string) { |
| 2989 return stringReplaceAllStringFuncUnchecked(receiver, pattern, onMatch, onN
onMatch); |
| 2990 } |
| 2991 let buffer = new core.StringBuffer(); |
| 2992 let startIndex = 0; |
| 2993 for (let match of dart.dinvoke(pattern, 'allMatches', receiver)) { |
| 2994 buffer.write(dart.dinvokef(onNonMatch, dart.dinvoke(receiver, 'substring',
startIndex, match.start))); |
| 2995 buffer.write(dart.dinvokef(onMatch, match)); |
| 2996 startIndex = match.end; |
| 2997 } |
| 2998 buffer.write(dart.dinvokef(onNonMatch, dart.dinvoke(receiver, 'substring', s
tartIndex))); |
| 2999 return buffer.toString(); |
| 3000 } |
| 3001 // Function stringReplaceAllEmptyFuncUnchecked: (dynamic, dynamic, dynamic) →
dynamic |
| 3002 function stringReplaceAllEmptyFuncUnchecked(receiver, onMatch, onNonMatch) { |
| 3003 let buffer = new core.StringBuffer(); |
| 3004 let length = dart.as(dart.dload(receiver, 'length'), core.int); |
| 3005 let i = 0; |
| 3006 buffer.write(dart.dinvokef(onNonMatch, "")); |
| 3007 while (i < length) { |
| 3008 buffer.write(dart.dinvokef(onMatch, new StringMatch(i, receiver, ""))); |
| 3009 let code = dart.as(dart.dinvoke(receiver, 'codeUnitAt', i), core.int); |
| 3010 if (dart.notNull((code & ~1023) === 55296) && dart.notNull(length > i + 1)
) { |
| 3011 code = dart.as(dart.dinvoke(receiver, 'codeUnitAt', i + 1), core.int); |
| 3012 if ((code & ~1023) === 56320) { |
| 3013 buffer.write(dart.dinvokef(onNonMatch, dart.dinvoke(receiver, 'substri
ng', i, i + 2))); |
| 3014 i = 2; |
| 3015 continue; |
| 3016 } |
| 3017 } |
| 3018 buffer.write(dart.dinvokef(onNonMatch, dart.dindex(receiver, i))); |
| 3019 i++; |
| 3020 } |
| 3021 buffer.write(dart.dinvokef(onMatch, new StringMatch(i, receiver, ""))); |
| 3022 buffer.write(dart.dinvokef(onNonMatch, "")); |
| 3023 return buffer.toString(); |
| 3024 } |
| 3025 // Function stringReplaceAllStringFuncUnchecked: (dynamic, dynamic, dynamic, d
ynamic) → dynamic |
| 3026 function stringReplaceAllStringFuncUnchecked(receiver, pattern, onMatch, onNon
Match) { |
| 3027 let patternLength = dart.as(dart.dload(pattern, 'length'), core.int); |
| 3028 if (patternLength === 0) { |
| 3029 return stringReplaceAllEmptyFuncUnchecked(receiver, onMatch, onNonMatch); |
| 3030 } |
| 3031 let length = dart.as(dart.dload(receiver, 'length'), core.int); |
| 3032 let buffer = new core.StringBuffer(); |
| 3033 let startIndex = 0; |
| 3034 while (startIndex < length) { |
| 3035 let position = dart.as(dart.dinvoke(receiver, 'indexOf', pattern, startInd
ex), core.int); |
| 3036 if (position === -1) { |
| 3037 break; |
| 3038 } |
| 3039 buffer.write(dart.dinvokef(onNonMatch, dart.dinvoke(receiver, 'substring',
startIndex, position))); |
| 3040 buffer.write(dart.dinvokef(onMatch, new StringMatch(position, receiver, pa
ttern))); |
| 3041 startIndex = position + patternLength; |
| 3042 } |
| 3043 buffer.write(dart.dinvokef(onNonMatch, dart.dinvoke(receiver, 'substring', s
tartIndex))); |
| 3044 return buffer.toString(); |
| 3045 } |
| 3046 // Function stringReplaceFirstUnchecked: (dynamic, dynamic, dynamic, [int]) →
dynamic |
| 3047 function stringReplaceFirstUnchecked(receiver, from, to, startIndex) { |
| 3048 if (startIndex === void 0) |
| 3049 startIndex = 0; |
| 3050 if (typeof from == string) { |
| 3051 let index = dart.dinvoke(receiver, 'indexOf', from, startIndex); |
| 3052 if (dart.dbinary(index, '<', 0)) |
| 3053 return receiver; |
| 3054 return `${dart.dinvoke(receiver, 'substring', 0, index)}${to}` + `${dart.d
invoke(receiver, 'substring', dart.dbinary(index, '+', dart.dload(from, 'length'
)))}`; |
| 3055 } else if (dart.is(from, JSSyntaxRegExp)) { |
| 3056 return startIndex === 0 ? stringReplaceJS(receiver, regExpGetNative(dart.a
s(from, JSSyntaxRegExp)), to) : stringReplaceFirstRE(receiver, from, to, startIn
dex); |
| 3057 } else { |
| 3058 checkNull(from); |
| 3059 throw "String.replace(Pattern) UNIMPLEMENTED"; |
| 3060 } |
| 3061 } |
| 3062 // Function stringJoinUnchecked: (dynamic, dynamic) → dynamic |
| 3063 function stringJoinUnchecked(array, separator) { |
| 3064 return _foreign_helper.JS('String', '#.join(#)', array, separator); |
| 3065 } |
| 3066 // Function createRuntimeType: (String) → Type |
| 3067 function createRuntimeType(name) { |
| 3068 return new TypeImpl(name); |
| 3069 } |
| 3070 class TypeImpl extends dart.Object { |
| 3071 TypeImpl(_typeName) { |
| 3072 this._typeName = _typeName; |
| 3073 this._unmangledName = null; |
| 3074 } |
| 3075 toString() { |
| 3076 if (this._unmangledName !== null) |
| 3077 return this._unmangledName; |
| 3078 let unmangledName = _js_names.unmangleAllIdentifiersIfPreservedAnyways(thi
s._typeName); |
| 3079 return this._unmangledName = unmangledName; |
| 3080 } |
| 3081 get hashCode() { |
| 3082 return this._typeName.hashCode; |
| 3083 } |
| 3084 ['=='](other) { |
| 3085 return dart.notNull(dart.is(other, TypeImpl)) && dart.notNull(dart.equals(
this._typeName, dart.dload(other, '_typeName'))); |
| 3086 } |
| 3087 } |
| 3088 class TypeVariable extends dart.Object { |
| 3089 TypeVariable(owner, name, bound) { |
| 3090 this.owner = owner; |
| 3091 this.name = name; |
| 3092 this.bound = bound; |
| 3093 } |
| 3094 } |
| 3095 // Function getMangledTypeName: (TypeImpl) → dynamic |
| 3096 function getMangledTypeName(type) { |
| 3097 return type._typeName; |
| 3098 } |
| 3099 // Function setRuntimeTypeInfo: (Object, dynamic) → Object |
| 3100 function setRuntimeTypeInfo(target, typeInfo) { |
| 3101 dart.assert(dart.notNull(typeInfo === null) || dart.notNull(isJsArray(typeIn
fo))); |
| 3102 if (target !== null) |
| 3103 _foreign_helper.JS('var', '#.$builtinTypeInfo = #', target, typeInfo); |
| 3104 return target; |
| 3105 } |
| 3106 // Function getRuntimeTypeInfo: (Object) → dynamic |
| 3107 function getRuntimeTypeInfo(target) { |
| 3108 if (target === null) |
| 3109 return null; |
| 3110 return _foreign_helper.JS('var', '#.$builtinTypeInfo', target); |
| 3111 } |
| 3112 // Function getRuntimeTypeArguments: (dynamic, dynamic) → dynamic |
| 3113 function getRuntimeTypeArguments(target, substitutionName) { |
| 3114 let substitution = getField(target, `${_foreign_helper.JS_OPERATOR_AS_PREFIX
()}${substitutionName}`); |
| 3115 return substitute(substitution, getRuntimeTypeInfo(target)); |
| 3116 } |
| 3117 // Function getRuntimeTypeArgument: (Object, String, int) → dynamic |
| 3118 function getRuntimeTypeArgument(target, substitutionName, index) { |
| 3119 let arguments = getRuntimeTypeArguments(target, substitutionName); |
| 3120 return arguments === null ? null : getIndex(arguments, index); |
| 3121 } |
| 3122 // Function getTypeArgumentByIndex: (Object, int) → dynamic |
| 3123 function getTypeArgumentByIndex(target, index) { |
| 3124 let rti = getRuntimeTypeInfo(target); |
| 3125 return rti === null ? null : getIndex(rti, index); |
| 3126 } |
| 3127 // Function copyTypeArguments: (Object, Object) → void |
| 3128 function copyTypeArguments(source, target) { |
| 3129 _foreign_helper.JS('var', '#.$builtinTypeInfo = #.$builtinTypeInfo', target,
source); |
| 3130 } |
| 3131 // Function getClassName: (dynamic) → String |
| 3132 function getClassName(object) { |
| 3133 return dart.as(_foreign_helper.JS('String', '#.constructor.builtin$cls', _in
terceptors.getInterceptor(object)), core.String); |
| 3134 } |
| 3135 // Function getRuntimeTypeAsString: (dynamic, {onTypeVariable: (int) → String}
) → String |
| 3136 function getRuntimeTypeAsString(runtimeType, opt$) { |
| 3137 let onTypeVariable = opt$.onTypeVariable === void 0 ? null : opt$.onTypeVari
able; |
| 3138 dart.assert(isJsArray(runtimeType)); |
| 3139 let className = getConstructorName(getIndex(runtimeType, 0)); |
| 3140 return `${className}` + `${joinArguments(runtimeType, 1, {onTypeVariable: on
TypeVariable})}`; |
| 3141 } |
| 3142 // Function getConstructorName: (dynamic) → String |
| 3143 function getConstructorName(type) { |
| 3144 return dart.as(_foreign_helper.JS('String', '#.builtin$cls', type), core.Str
ing); |
| 3145 } |
| 3146 // Function runtimeTypeToString: (dynamic, {onTypeVariable: (int) → String}) →
String |
| 3147 function runtimeTypeToString(type, opt$) { |
| 3148 let onTypeVariable = opt$.onTypeVariable === void 0 ? null : opt$.onTypeVari
able; |
| 3149 if (type === null) { |
| 3150 return 'dynamic'; |
| 3151 } else if (isJsArray(type)) { |
| 3152 return getRuntimeTypeAsString(type, {onTypeVariable: onTypeVariable}); |
| 3153 } else if (isJsFunction(type)) { |
| 3154 return getConstructorName(type); |
| 3155 } else if (typeof type == number) { |
| 3156 if (onTypeVariable === null) { |
| 3157 return dart.as(dart.dinvoke(type, 'toString'), core.String); |
| 3158 } else { |
| 3159 return onTypeVariable(dart.as(type, core.int)); |
| 3160 } |
| 3161 } else { |
| 3162 return null; |
| 3163 } |
| 3164 } |
| 3165 // Function joinArguments: (dynamic, int, {onTypeVariable: (int) → String}) →
String |
| 3166 function joinArguments(types, startIndex, opt$) { |
| 3167 let onTypeVariable = opt$.onTypeVariable === void 0 ? null : opt$.onTypeVari
able; |
| 3168 if (types === null) |
| 3169 return ''; |
| 3170 dart.assert(isJsArray(types)); |
| 3171 let firstArgument = true; |
| 3172 let allDynamic = true; |
| 3173 let buffer = new core.StringBuffer(); |
| 3174 for (let index = startIndex; index < getLength(types); index++) { |
| 3175 if (firstArgument) { |
| 3176 firstArgument = false; |
| 3177 } else { |
| 3178 buffer.write(', '); |
| 3179 } |
| 3180 let argument = getIndex(types, index); |
| 3181 if (argument !== null) { |
| 3182 allDynamic = false; |
| 3183 } |
| 3184 buffer.write(runtimeTypeToString(argument, {onTypeVariable: onTypeVariable
})); |
| 3185 } |
| 3186 return allDynamic ? '' : `<${buffer}>`; |
| 3187 } |
| 3188 // Function getRuntimeTypeString: (dynamic) → String |
| 3189 function getRuntimeTypeString(object) { |
| 3190 let className = getClassName(object); |
| 3191 if (object === null) |
| 3192 return className; |
| 3193 let typeInfo = _foreign_helper.JS('var', '#.$builtinTypeInfo', object); |
| 3194 return `${className}${joinArguments(typeInfo, 0)}`; |
| 3195 } |
| 3196 // Function getRuntimeType: (dynamic) → Type |
| 3197 function getRuntimeType(object) { |
| 3198 let type = getRuntimeTypeString(object); |
| 3199 return new TypeImpl(type); |
| 3200 } |
| 3201 // Function substitute: (dynamic, dynamic) → dynamic |
| 3202 function substitute(substitution, arguments) { |
| 3203 dart.assert(dart.notNull(substitution === null) || dart.notNull(isJsFunction
(substitution))); |
| 3204 dart.assert(dart.notNull(arguments === null) || dart.notNull(isJsArray(argum
ents))); |
| 3205 if (isJsFunction(substitution)) { |
| 3206 substitution = invoke(substitution, arguments); |
| 3207 if (isJsArray(substitution)) { |
| 3208 arguments = substitution; |
| 3209 } else if (isJsFunction(substitution)) { |
| 3210 arguments = invoke(substitution, arguments); |
| 3211 } |
| 3212 } |
| 3213 return arguments; |
| 3214 } |
| 3215 // Function checkSubtype: (Object, String, List<dynamic>, String) → bool |
| 3216 function checkSubtype(object, isField, checks, asField) { |
| 3217 if (object === null) |
| 3218 return false; |
| 3219 let arguments = getRuntimeTypeInfo(object); |
| 3220 let interceptor = _interceptors.getInterceptor(object); |
| 3221 let isSubclass = getField(interceptor, isField); |
| 3222 if (isSubclass === null) |
| 3223 return false; |
| 3224 let substitution = getField(interceptor, asField); |
| 3225 return checkArguments(substitution, arguments, checks); |
| 3226 } |
| 3227 // Function computeTypeName: (String, List<dynamic>) → String |
| 3228 function computeTypeName(isField, arguments) { |
| 3229 let prefixLength = _foreign_helper.JS_OPERATOR_IS_PREFIX().length; |
| 3230 return Primitives.formatType(isField.substring(prefixLength, isField.length)
, arguments); |
| 3231 } |
| 3232 // Function subtypeCast: (Object, String, List<dynamic>, String) → Object |
| 3233 function subtypeCast(object, isField, checks, asField) { |
| 3234 if (dart.notNull(object !== null) && dart.notNull(!dart.notNull(checkSubtype
(object, isField, checks, asField)))) { |
| 3235 let actualType = Primitives.objectTypeName(object); |
| 3236 let typeName = computeTypeName(isField, checks); |
| 3237 throw new CastErrorImplementation(actualType, typeName); |
| 3238 } |
| 3239 return object; |
| 3240 } |
| 3241 // Function assertSubtype: (Object, String, List<dynamic>, String) → Object |
| 3242 function assertSubtype(object, isField, checks, asField) { |
| 3243 if (dart.notNull(object !== null) && dart.notNull(!dart.notNull(checkSubtype
(object, isField, checks, asField)))) { |
| 3244 let typeName = computeTypeName(isField, checks); |
| 3245 throw new TypeErrorImplementation(object, typeName); |
| 3246 } |
| 3247 return object; |
| 3248 } |
| 3249 // Function assertIsSubtype: (dynamic, dynamic, String) → dynamic |
| 3250 function assertIsSubtype(subtype, supertype, message) { |
| 3251 if (!dart.notNull(isSubtype(subtype, supertype))) { |
| 3252 throwTypeError(message); |
| 3253 } |
| 3254 } |
| 3255 // Function throwTypeError: (dynamic) → dynamic |
| 3256 function throwTypeError(message) { |
| 3257 throw new TypeErrorImplementation.fromMessage(message); |
| 3258 } |
| 3259 // Function checkArguments: (dynamic, dynamic, dynamic) → bool |
| 3260 function checkArguments(substitution, arguments, checks) { |
| 3261 return areSubtypes(substitute(substitution, arguments), checks); |
| 3262 } |
| 3263 // Function areSubtypes: (dynamic, dynamic) → bool |
| 3264 function areSubtypes(s, t) { |
| 3265 if (dart.notNull(s === null) || dart.notNull(t === null)) |
| 3266 return true; |
| 3267 dart.assert(isJsArray(s)); |
| 3268 dart.assert(isJsArray(t)); |
| 3269 dart.assert(getLength(s) === getLength(t)); |
| 3270 let len = getLength(s); |
| 3271 for (let i = 0; i < len; i++) { |
| 3272 if (!dart.notNull(isSubtype(getIndex(s, i), getIndex(t, i)))) { |
| 3273 return false; |
| 3274 } |
| 3275 } |
| 3276 return true; |
| 3277 } |
| 3278 // Function computeSignature: (dynamic, dynamic, dynamic) → dynamic |
| 3279 function computeSignature(signature, context, contextName) { |
| 3280 let typeArguments = getRuntimeTypeArguments(context, contextName); |
| 3281 return invokeOn(signature, context, typeArguments); |
| 3282 } |
| 3283 // Function isSupertypeOfNull: (dynamic) → bool |
| 3284 function isSupertypeOfNull(type) { |
| 3285 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()))
; |
| 3286 } |
| 3287 // Function checkSubtypeOfRuntimeType: (dynamic, dynamic) → bool |
| 3288 function checkSubtypeOfRuntimeType(o, t) { |
| 3289 if (o === null) |
| 3290 return isSupertypeOfNull(t); |
| 3291 if (t === null) |
| 3292 return true; |
| 3293 let rti = getRuntimeTypeInfo(o); |
| 3294 o = _interceptors.getInterceptor(o); |
| 3295 let type = _foreign_helper.JS('', '#.constructor', o); |
| 3296 if (rti !== null) { |
| 3297 rti = _foreign_helper.JS('JSExtendableArray', '#.slice()', rti); |
| 3298 _foreign_helper.JS('', '#.splice(0, 0, #)', rti, type); |
| 3299 type = rti; |
| 3300 } else if (hasField(t, `${_foreign_helper.JS_FUNCTION_TYPE_TAG()}`)) { |
| 3301 let signatureName = `${_foreign_helper.JS_OPERATOR_IS_PREFIX()}_${getField
(t, _foreign_helper.JS_FUNCTION_TYPE_TAG())}`; |
| 3302 if (hasField(o, signatureName)) |
| 3303 return true; |
| 3304 let targetSignatureFunction = getField(o, `${_foreign_helper.JS_SIGNATURE_
NAME()}`); |
| 3305 if (targetSignatureFunction === null) |
| 3306 return false; |
| 3307 type = invokeOn(targetSignatureFunction, o, null); |
| 3308 return isFunctionSubtype(type, t); |
| 3309 } |
| 3310 return isSubtype(type, t); |
| 3311 } |
| 3312 // Function subtypeOfRuntimeTypeCast: (Object, dynamic) → Object |
| 3313 function subtypeOfRuntimeTypeCast(object, type) { |
| 3314 if (dart.notNull(object !== null) && dart.notNull(!dart.notNull(checkSubtype
OfRuntimeType(object, type)))) { |
| 3315 let actualType = Primitives.objectTypeName(object); |
| 3316 throw new CastErrorImplementation(actualType, runtimeTypeToString(type)); |
| 3317 } |
| 3318 return object; |
| 3319 } |
| 3320 // Function assertSubtypeOfRuntimeType: (Object, dynamic) → Object |
| 3321 function assertSubtypeOfRuntimeType(object, type) { |
| 3322 if (dart.notNull(object !== null) && dart.notNull(!dart.notNull(checkSubtype
OfRuntimeType(object, type)))) { |
| 3323 throw new TypeErrorImplementation(object, runtimeTypeToString(type)); |
| 3324 } |
| 3325 return object; |
| 3326 } |
| 3327 // Function getArguments: (dynamic) → dynamic |
| 3328 function getArguments(type) { |
| 3329 return isJsArray(type) ? _foreign_helper.JS('var', '#.slice(1)', type) : nul
l; |
| 3330 } |
| 3331 // Function isSubtype: (dynamic, dynamic) → bool |
| 3332 function isSubtype(s, t) { |
| 3333 if (isIdentical(s, t)) |
| 3334 return true; |
| 3335 if (dart.notNull(s === null) || dart.notNull(t === null)) |
| 3336 return true; |
| 3337 if (hasField(t, `${_foreign_helper.JS_FUNCTION_TYPE_TAG()}`)) { |
| 3338 return isFunctionSubtype(s, t); |
| 3339 } |
| 3340 if (hasField(s, `${_foreign_helper.JS_FUNCTION_TYPE_TAG()}`)) { |
| 3341 return dart.equals(getConstructorName(t), _foreign_helper.JS_FUNCTION_CLAS
S_NAME()); |
| 3342 } |
| 3343 let typeOfS = isJsArray(s) ? getIndex(s, 0) : s; |
| 3344 let typeOfT = isJsArray(t) ? getIndex(t, 0) : t; |
| 3345 let name = runtimeTypeToString(typeOfT); |
| 3346 let substitution = null; |
| 3347 if (isNotIdentical(typeOfT, typeOfS)) { |
| 3348 let test = `${_foreign_helper.JS_OPERATOR_IS_PREFIX()}${name}`; |
| 3349 let typeOfSPrototype = _foreign_helper.JS('', '#.prototype', typeOfS); |
| 3350 if (hasNoField(typeOfSPrototype, test)) |
| 3351 return false; |
| 3352 let field = `${_foreign_helper.JS_OPERATOR_AS_PREFIX()}${runtimeTypeToStri
ng(typeOfT)}`; |
| 3353 substitution = getField(typeOfSPrototype, field); |
| 3354 } |
| 3355 if (dart.notNull(dart.notNull(!dart.notNull(isJsArray(s))) && dart.notNull(s
ubstitution === null)) || dart.notNull(!dart.notNull(isJsArray(t)))) { |
| 3356 return true; |
| 3357 } |
| 3358 return checkArguments(substitution, getArguments(s), getArguments(t)); |
| 3359 } |
| 3360 // Function isAssignable: (dynamic, dynamic) → bool |
| 3361 function isAssignable(s, t) { |
| 3362 return dart.notNull(isSubtype(s, t)) || dart.notNull(isSubtype(t, s)); |
| 3363 } |
| 3364 // Function areAssignable: (List<dynamic>, List, bool) → bool |
| 3365 function areAssignable(s, t, allowShorter) { |
| 3366 if (dart.notNull(t === null) && dart.notNull(s === null)) |
| 3367 return true; |
| 3368 if (t === null) |
| 3369 return allowShorter; |
| 3370 if (s === null) |
| 3371 return false; |
| 3372 dart.assert(isJsArray(s)); |
| 3373 dart.assert(isJsArray(t)); |
| 3374 let sLength = getLength(s); |
| 3375 let tLength = getLength(t); |
| 3376 if (allowShorter) { |
| 3377 if (sLength < tLength) |
| 3378 return false; |
| 3379 } else { |
| 3380 if (sLength !== tLength) |
| 3381 return false; |
| 3382 } |
| 3383 for (let i = 0; i < tLength; i++) { |
| 3384 if (!dart.notNull(isAssignable(getIndex(s, i), getIndex(t, i)))) { |
| 3385 return false; |
| 3386 } |
| 3387 } |
| 3388 return true; |
| 3389 } |
| 3390 // Function areAssignableMaps: (dynamic, dynamic) → bool |
| 3391 function areAssignableMaps(s, t) { |
| 3392 if (t === null) |
| 3393 return true; |
| 3394 if (s === null) |
| 3395 return false; |
| 3396 dart.assert(isJsObject(s)); |
| 3397 dart.assert(isJsObject(t)); |
| 3398 let names = _interceptors.JSArray.markFixedList(dart.as(_foreign_helper.JS('
', 'Object.getOwnPropertyNames(#)', t), core.List)); |
| 3399 for (let i = 0; i < names.length; i++) { |
| 3400 let name = names.get(i); |
| 3401 if (_foreign_helper.JS('bool', '!Object.hasOwnProperty.call(#, #)', s, nam
e)) { |
| 3402 return false; |
| 3403 } |
| 3404 let tType = _foreign_helper.JS('', '#[#]', t, name); |
| 3405 let sType = _foreign_helper.JS('', '#[#]', s, name); |
| 3406 if (!dart.notNull(isAssignable(tType, sType))) |
| 3407 return false; |
| 3408 } |
| 3409 return true; |
| 3410 } |
| 3411 // Function isFunctionSubtype: (dynamic, dynamic) → bool |
| 3412 function isFunctionSubtype(s, t) { |
| 3413 dart.assert(hasField(t, `${_foreign_helper.JS_FUNCTION_TYPE_TAG()}`)); |
| 3414 if (hasNoField(s, `${_foreign_helper.JS_FUNCTION_TYPE_TAG()}`)) |
| 3415 return false; |
| 3416 if (hasField(s, `${_foreign_helper.JS_FUNCTION_TYPE_VOID_RETURN_TAG()}`)) { |
| 3417 if (dart.dbinary(hasNoField(t, `${_foreign_helper.JS_FUNCTION_TYPE_VOID_RE
TURN_TAG()}`), '&&', hasField(t, `${_foreign_helper.JS_FUNCTION_TYPE_RETURN_TYPE
_TAG()}`))) { |
| 3418 return false; |
| 3419 } |
| 3420 } else if (hasNoField(t, `${_foreign_helper.JS_FUNCTION_TYPE_VOID_RETURN_TAG
()}`)) { |
| 3421 let sReturnType = getField(s, `${_foreign_helper.JS_FUNCTION_TYPE_RETURN_T
YPE_TAG()}`); |
| 3422 let tReturnType = getField(t, `${_foreign_helper.JS_FUNCTION_TYPE_RETURN_T
YPE_TAG()}`); |
| 3423 if (!dart.notNull(isAssignable(sReturnType, tReturnType))) |
| 3424 return false; |
| 3425 } |
| 3426 let sParameterTypes = getField(s, `${_foreign_helper.JS_FUNCTION_TYPE_REQUIR
ED_PARAMETERS_TAG()}`); |
| 3427 let tParameterTypes = getField(t, `${_foreign_helper.JS_FUNCTION_TYPE_REQUIR
ED_PARAMETERS_TAG()}`); |
| 3428 let sOptionalParameterTypes = getField(s, `${_foreign_helper.JS_FUNCTION_TYP
E_OPTIONAL_PARAMETERS_TAG()}`); |
| 3429 let tOptionalParameterTypes = getField(t, `${_foreign_helper.JS_FUNCTION_TYP
E_OPTIONAL_PARAMETERS_TAG()}`); |
| 3430 let sParametersLen = sParameterTypes !== null ? getLength(sParameterTypes) :
0; |
| 3431 let tParametersLen = tParameterTypes !== null ? getLength(tParameterTypes) :
0; |
| 3432 let sOptionalParametersLen = sOptionalParameterTypes !== null ? getLength(sO
ptionalParameterTypes) : 0; |
| 3433 let tOptionalParametersLen = tOptionalParameterTypes !== null ? getLength(tO
ptionalParameterTypes) : 0; |
| 3434 if (sParametersLen > tParametersLen) { |
| 3435 return false; |
| 3436 } |
| 3437 if (sParametersLen + sOptionalParametersLen < tParametersLen + tOptionalPara
metersLen) { |
| 3438 return false; |
| 3439 } |
| 3440 if (sParametersLen === tParametersLen) { |
| 3441 if (!dart.notNull(areAssignable(dart.as(sParameterTypes, core.List), dart.
as(tParameterTypes, core.List), false))) |
| 3442 return false; |
| 3443 if (!dart.notNull(areAssignable(dart.as(sOptionalParameterTypes, core.List
), dart.as(tOptionalParameterTypes, core.List), true))) { |
| 3444 return false; |
| 3445 } |
| 3446 } else { |
| 3447 let pos = 0; |
| 3448 for (; pos < sParametersLen; pos++) { |
| 3449 if (!dart.notNull(isAssignable(getIndex(sParameterTypes, pos), getIndex(
tParameterTypes, pos)))) { |
| 3450 return false; |
| 3451 } |
| 3452 } |
| 3453 let sPos = 0; |
| 3454 let tPos = pos; |
| 3455 for (; tPos < tParametersLen; sPos++, tPos++) { |
| 3456 if (!dart.notNull(isAssignable(getIndex(sOptionalParameterTypes, sPos),
getIndex(tParameterTypes, tPos)))) { |
| 3457 return false; |
| 3458 } |
| 3459 } |
| 3460 tPos = 0; |
| 3461 for (; tPos < tOptionalParametersLen; sPos++, tPos++) { |
| 3462 if (!dart.notNull(isAssignable(getIndex(sOptionalParameterTypes, sPos),
getIndex(tOptionalParameterTypes, tPos)))) { |
| 3463 return false; |
| 3464 } |
| 3465 } |
| 3466 } |
| 3467 let sNamedParameters = getField(s, `${_foreign_helper.JS_FUNCTION_TYPE_NAMED
_PARAMETERS_TAG()}`); |
| 3468 let tNamedParameters = getField(t, `${_foreign_helper.JS_FUNCTION_TYPE_NAMED
_PARAMETERS_TAG()}`); |
| 3469 return areAssignableMaps(sNamedParameters, tNamedParameters); |
| 3470 } |
| 3471 // Function invoke: (dynamic, dynamic) → dynamic |
| 3472 function invoke(function, arguments) { |
| 3473 return invokeOn(function, null, arguments); |
| 3474 } |
| 3475 // Function invokeOn: (dynamic, dynamic, dynamic) → Object |
| 3476 function invokeOn(function, receiver, arguments) { |
| 3477 dart.assert(isJsFunction(function)); |
| 3478 dart.assert(dart.notNull(arguments === null) || dart.notNull(isJsArray(argum
ents))); |
| 3479 return _foreign_helper.JS('var', '#.apply(#, #)', function, receiver, argume
nts); |
| 3480 } |
| 3481 // Function call: (dynamic, String) → dynamic |
| 3482 function call(object, name) { |
| 3483 return _foreign_helper.JS('var', '#[#]()', object, name); |
| 3484 } |
| 3485 // Function getField: (dynamic, String) → dynamic |
| 3486 function getField(object, name) { |
| 3487 return _foreign_helper.JS('var', '#[#]', object, name); |
| 3488 } |
| 3489 // Function getIndex: (dynamic, int) → dynamic |
| 3490 function getIndex(array, index) { |
| 3491 dart.assert(isJsArray(array)); |
| 3492 return _foreign_helper.JS('var', '#[#]', array, index); |
| 3493 } |
| 3494 // Function getLength: (dynamic) → int |
| 3495 function getLength(array) { |
| 3496 dart.assert(isJsArray(array)); |
| 3497 return dart.as(_foreign_helper.JS('int', '#.length', array), core.int); |
| 3498 } |
| 3499 // Function isJsArray: (dynamic) → bool |
| 3500 function isJsArray(value) { |
| 3501 return dart.is(value, _interceptors.JSArray); |
| 3502 } |
| 3503 // Function hasField: (dynamic, dynamic) → dynamic |
| 3504 function hasField(object, name) { |
| 3505 return _foreign_helper.JS('bool', '# in #', name, object); |
| 3506 } |
| 3507 // Function hasNoField: (dynamic, dynamic) → dynamic |
| 3508 function hasNoField(object, name) { |
| 3509 return dart.throw_("Unimplemented PrefixExpression: !hasField(object, name)"
); |
| 3510 } |
| 3511 // Function isJsFunction: (dynamic) → bool |
| 3512 function isJsFunction(o) { |
| 3513 return dart.as(_foreign_helper.JS('bool', 'typeof # == "function"', o), core
.bool); |
| 3514 } |
| 3515 // Function isJsObject: (dynamic) → bool |
| 3516 function isJsObject(o) { |
| 3517 return dart.as(_foreign_helper.JS('bool', "typeof # == 'object'", o), core.b
ool); |
| 3518 } |
| 3519 // Function isIdentical: (dynamic, dynamic) → bool |
| 3520 function isIdentical(s, t) { |
| 3521 return dart.as(_foreign_helper.JS('bool', '# === #', s, t), core.bool); |
| 3522 } |
| 3523 // Function isNotIdentical: (dynamic, dynamic) → bool |
| 3524 function isNotIdentical(s, t) { |
| 3525 return dart.as(_foreign_helper.JS('bool', '# !== #', s, t), core.bool); |
| 3526 } |
| 3527 // Exports: |
| 3528 _js_helper.patch = patch; |
| 3529 _js_helper.InternalMap = InternalMap; |
| 3530 _js_helper.requiresPreamble = requiresPreamble; |
| 3531 _js_helper.isJsIndexable = isJsIndexable; |
| 3532 _js_helper.S = S; |
| 3533 _js_helper.createInvocationMirror = createInvocationMirror; |
| 3534 _js_helper.createUnmangledInvocationMirror = createUnmangledInvocationMirror; |
| 3535 _js_helper.throwInvalidReflectionError = throwInvalidReflectionError; |
| 3536 _js_helper.traceHelper = traceHelper; |
| 3537 _js_helper.JSInvocationMirror = JSInvocationMirror; |
| 3538 _js_helper.CachedInvocation = CachedInvocation; |
| 3539 _js_helper.CachedCatchAllInvocation = CachedCatchAllInvocation; |
| 3540 _js_helper.CachedNoSuchMethodInvocation = CachedNoSuchMethodInvocation; |
| 3541 _js_helper.ReflectionInfo = ReflectionInfo; |
| 3542 _js_helper.getMetadata = getMetadata; |
| 3543 _js_helper.Primitives = Primitives; |
| 3544 _js_helper.JsCache = JsCache; |
| 3545 _js_helper.iae = iae; |
| 3546 _js_helper.ioore = ioore; |
| 3547 _js_helper.stringLastIndexOfUnchecked = stringLastIndexOfUnchecked; |
| 3548 _js_helper.checkNull = checkNull; |
| 3549 _js_helper.checkNum = checkNum; |
| 3550 _js_helper.checkInt = checkInt; |
| 3551 _js_helper.checkBool = checkBool; |
| 3552 _js_helper.checkString = checkString; |
| 3553 _js_helper.wrapException = wrapException; |
| 3554 _js_helper.toStringWrapper = toStringWrapper; |
| 3555 _js_helper.throwExpression = throwExpression; |
| 3556 _js_helper.makeLiteralListConst = makeLiteralListConst; |
| 3557 _js_helper.throwRuntimeError = throwRuntimeError; |
| 3558 _js_helper.throwAbstractClassInstantiationError = throwAbstractClassInstantiat
ionError; |
| 3559 _js_helper.TypeErrorDecoder = TypeErrorDecoder; |
| 3560 _js_helper.NullError = NullError; |
| 3561 _js_helper.JsNoSuchMethodError = JsNoSuchMethodError; |
| 3562 _js_helper.UnknownJsTypeError = UnknownJsTypeError; |
| 3563 _js_helper.unwrapException = unwrapException; |
| 3564 _js_helper.getTraceFromException = getTraceFromException; |
| 3565 _js_helper.objectHashCode = objectHashCode; |
| 3566 _js_helper.fillLiteralMap = fillLiteralMap; |
| 3567 _js_helper.invokeClosure = invokeClosure; |
| 3568 _js_helper.convertDartClosureToJS = convertDartClosureToJS; |
| 3569 _js_helper.Closure = Closure; |
| 3570 _js_helper.closureFromTearOff = closureFromTearOff; |
| 3571 _js_helper.TearOffClosure = TearOffClosure; |
| 3572 _js_helper.BoundClosure = BoundClosure; |
| 3573 _js_helper.jsHasOwnProperty = jsHasOwnProperty; |
| 3574 _js_helper.jsPropertyAccess = jsPropertyAccess; |
| 3575 _js_helper.getFallThroughError = getFallThroughError; |
| 3576 _js_helper.Creates = Creates; |
| 3577 _js_helper.Returns = Returns; |
| 3578 _js_helper.JSName = JSName; |
| 3579 _js_helper.boolConversionCheck = boolConversionCheck; |
| 3580 _js_helper.stringTypeCheck = stringTypeCheck; |
| 3581 _js_helper.stringTypeCast = stringTypeCast; |
| 3582 _js_helper.doubleTypeCheck = doubleTypeCheck; |
| 3583 _js_helper.doubleTypeCast = doubleTypeCast; |
| 3584 _js_helper.numTypeCheck = numTypeCheck; |
| 3585 _js_helper.numTypeCast = numTypeCast; |
| 3586 _js_helper.boolTypeCheck = boolTypeCheck; |
| 3587 _js_helper.boolTypeCast = boolTypeCast; |
| 3588 _js_helper.intTypeCheck = intTypeCheck; |
| 3589 _js_helper.intTypeCast = intTypeCast; |
| 3590 _js_helper.propertyTypeError = propertyTypeError; |
| 3591 _js_helper.propertyTypeCastError = propertyTypeCastError; |
| 3592 _js_helper.propertyTypeCheck = propertyTypeCheck; |
| 3593 _js_helper.propertyTypeCast = propertyTypeCast; |
| 3594 _js_helper.interceptedTypeCheck = interceptedTypeCheck; |
| 3595 _js_helper.interceptedTypeCast = interceptedTypeCast; |
| 3596 _js_helper.numberOrStringSuperTypeCheck = numberOrStringSuperTypeCheck; |
| 3597 _js_helper.numberOrStringSuperTypeCast = numberOrStringSuperTypeCast; |
| 3598 _js_helper.numberOrStringSuperNativeTypeCheck = numberOrStringSuperNativeTypeC
heck; |
| 3599 _js_helper.numberOrStringSuperNativeTypeCast = numberOrStringSuperNativeTypeCa
st; |
| 3600 _js_helper.stringSuperTypeCheck = stringSuperTypeCheck; |
| 3601 _js_helper.stringSuperTypeCast = stringSuperTypeCast; |
| 3602 _js_helper.stringSuperNativeTypeCheck = stringSuperNativeTypeCheck; |
| 3603 _js_helper.stringSuperNativeTypeCast = stringSuperNativeTypeCast; |
| 3604 _js_helper.listTypeCheck = listTypeCheck; |
| 3605 _js_helper.listTypeCast = listTypeCast; |
| 3606 _js_helper.listSuperTypeCheck = listSuperTypeCheck; |
| 3607 _js_helper.listSuperTypeCast = listSuperTypeCast; |
| 3608 _js_helper.listSuperNativeTypeCheck = listSuperNativeTypeCheck; |
| 3609 _js_helper.listSuperNativeTypeCast = listSuperNativeTypeCast; |
| 3610 _js_helper.voidTypeCheck = voidTypeCheck; |
| 3611 _js_helper.checkMalformedType = checkMalformedType; |
| 3612 _js_helper.checkDeferredIsLoaded = checkDeferredIsLoaded; |
| 3613 _js_helper.JavaScriptIndexingBehavior = JavaScriptIndexingBehavior; |
| 3614 _js_helper.TypeErrorImplementation = TypeErrorImplementation; |
| 3615 _js_helper.CastErrorImplementation = CastErrorImplementation; |
| 3616 _js_helper.FallThroughErrorImplementation = FallThroughErrorImplementation; |
| 3617 _js_helper.assertHelper = assertHelper; |
| 3618 _js_helper.throwNoSuchMethod = throwNoSuchMethod; |
| 3619 _js_helper.throwCyclicInit = throwCyclicInit; |
| 3620 _js_helper.RuntimeError = RuntimeError; |
| 3621 _js_helper.DeferredNotLoadedError = DeferredNotLoadedError; |
| 3622 _js_helper.RuntimeType = RuntimeType; |
| 3623 _js_helper.RuntimeFunctionType = RuntimeFunctionType; |
| 3624 _js_helper.buildFunctionType = buildFunctionType; |
| 3625 _js_helper.buildNamedFunctionType = buildNamedFunctionType; |
| 3626 _js_helper.buildInterfaceType = buildInterfaceType; |
| 3627 _js_helper.DynamicRuntimeType = DynamicRuntimeType; |
| 3628 _js_helper.getDynamicRuntimeType = getDynamicRuntimeType; |
| 3629 _js_helper.VoidRuntimeType = VoidRuntimeType; |
| 3630 _js_helper.getVoidRuntimeType = getVoidRuntimeType; |
| 3631 _js_helper.functionTypeTestMetaHelper = functionTypeTestMetaHelper; |
| 3632 _js_helper.convertRtiToRuntimeType = convertRtiToRuntimeType; |
| 3633 _js_helper.RuntimeTypePlain = RuntimeTypePlain; |
| 3634 _js_helper.RuntimeTypeGeneric = RuntimeTypeGeneric; |
| 3635 _js_helper.FunctionTypeInfoDecoderRing = FunctionTypeInfoDecoderRing; |
| 3636 _js_helper.UnimplementedNoSuchMethodError = UnimplementedNoSuchMethodError; |
| 3637 _js_helper.random64 = random64; |
| 3638 _js_helper.jsonEncodeNative = jsonEncodeNative; |
| 3639 _js_helper.getIsolateAffinityTag = getIsolateAffinityTag; |
| 3640 _js_helper.loadDeferredLibrary = loadDeferredLibrary; |
| 3641 _js_helper.MainError = MainError; |
| 3642 _js_helper.missingMain = missingMain; |
| 3643 _js_helper.badMain = badMain; |
| 3644 _js_helper.mainHasTooManyParameters = mainHasTooManyParameters; |
| 3645 _js_helper.NoSideEffects = NoSideEffects; |
| 3646 _js_helper.NoThrows = NoThrows; |
| 3647 _js_helper.NoInline = NoInline; |
| 3648 _js_helper.IrRepresentation = IrRepresentation; |
| 3649 _js_helper.Native = Native; |
| 3650 _js_helper.ConstantMap = ConstantMap; |
| 3651 _js_helper.ConstantMap$ = ConstantMap$; |
| 3652 _js_helper.ConstantStringMap = ConstantStringMap; |
| 3653 _js_helper.ConstantStringMap$ = ConstantStringMap$; |
| 3654 _js_helper.ConstantProtoMap = ConstantProtoMap; |
| 3655 _js_helper.ConstantProtoMap$ = ConstantProtoMap$; |
| 3656 _js_helper.GeneralConstantMap = GeneralConstantMap; |
| 3657 _js_helper.GeneralConstantMap$ = GeneralConstantMap$; |
| 3658 _js_helper.contains = contains; |
| 3659 _js_helper.arrayLength = arrayLength; |
| 3660 _js_helper.arrayGet = arrayGet; |
| 3661 _js_helper.arraySet = arraySet; |
| 3662 _js_helper.propertyGet = propertyGet; |
| 3663 _js_helper.callHasOwnProperty = callHasOwnProperty; |
| 3664 _js_helper.propertySet = propertySet; |
| 3665 _js_helper.getPropertyFromPrototype = getPropertyFromPrototype; |
| 3666 _js_helper.toStringForNativeObject = toStringForNativeObject; |
| 3667 _js_helper.hashCodeForNativeObject = hashCodeForNativeObject; |
| 3668 _js_helper.defineProperty = defineProperty; |
| 3669 _js_helper.isDartObject = isDartObject; |
| 3670 _js_helper.interceptorsByTag = interceptorsByTag; |
| 3671 _js_helper.leafTags = leafTags; |
| 3672 _js_helper.findDispatchTagForInterceptorClass = findDispatchTagForInterceptorC
lass; |
| 3673 _js_helper.lookupInterceptor = lookupInterceptor; |
| 3674 _js_helper.UNCACHED_MARK = UNCACHED_MARK; |
| 3675 _js_helper.INSTANCE_CACHED_MARK = INSTANCE_CACHED_MARK; |
| 3676 _js_helper.LEAF_MARK = LEAF_MARK; |
| 3677 _js_helper.INTERIOR_MARK = INTERIOR_MARK; |
| 3678 _js_helper.DISCRIMINATED_MARK = DISCRIMINATED_MARK; |
| 3679 _js_helper.lookupAndCacheInterceptor = lookupAndCacheInterceptor; |
| 3680 _js_helper.patchInstance = patchInstance; |
| 3681 _js_helper.patchProto = patchProto; |
| 3682 _js_helper.patchInteriorProto = patchInteriorProto; |
| 3683 _js_helper.makeLeafDispatchRecord = makeLeafDispatchRecord; |
| 3684 _js_helper.makeDefaultDispatchRecord = makeDefaultDispatchRecord; |
| 3685 _js_helper.setNativeSubclassDispatchRecord = setNativeSubclassDispatchRecord; |
| 3686 _js_helper.constructorNameFallback = constructorNameFallback; |
| 3687 _js_helper.initNativeDispatch = initNativeDispatch; |
| 3688 _js_helper.initNativeDispatchContinue = initNativeDispatchContinue; |
| 3689 _js_helper.initHooks = initHooks; |
| 3690 _js_helper.applyHooksTransformer = applyHooksTransformer; |
| 3691 _js_helper.regExpGetNative = regExpGetNative; |
| 3692 _js_helper.regExpGetGlobalNative = regExpGetGlobalNative; |
| 3693 _js_helper.regExpCaptureCount = regExpCaptureCount; |
| 3694 _js_helper.JSSyntaxRegExp = JSSyntaxRegExp; |
| 3695 _js_helper.firstMatchAfter = firstMatchAfter; |
| 3696 _js_helper.StringMatch = StringMatch; |
| 3697 _js_helper.allMatchesInStringUnchecked = allMatchesInStringUnchecked; |
| 3698 _js_helper.stringContainsUnchecked = stringContainsUnchecked; |
| 3699 _js_helper.stringReplaceJS = stringReplaceJS; |
| 3700 _js_helper.stringReplaceFirstRE = stringReplaceFirstRE; |
| 3701 _js_helper.ESCAPE_REGEXP = ESCAPE_REGEXP; |
| 3702 _js_helper.stringReplaceAllUnchecked = stringReplaceAllUnchecked; |
| 3703 _js_helper.stringReplaceAllFuncUnchecked = stringReplaceAllFuncUnchecked; |
| 3704 _js_helper.stringReplaceAllEmptyFuncUnchecked = stringReplaceAllEmptyFuncUnche
cked; |
| 3705 _js_helper.stringReplaceAllStringFuncUnchecked = stringReplaceAllStringFuncUnc
hecked; |
| 3706 _js_helper.stringReplaceFirstUnchecked = stringReplaceFirstUnchecked; |
| 3707 _js_helper.stringJoinUnchecked = stringJoinUnchecked; |
| 3708 _js_helper.createRuntimeType = createRuntimeType; |
| 3709 _js_helper.TypeImpl = TypeImpl; |
| 3710 _js_helper.TypeVariable = TypeVariable; |
| 3711 _js_helper.getMangledTypeName = getMangledTypeName; |
| 3712 _js_helper.setRuntimeTypeInfo = setRuntimeTypeInfo; |
| 3713 _js_helper.getRuntimeTypeInfo = getRuntimeTypeInfo; |
| 3714 _js_helper.getRuntimeTypeArguments = getRuntimeTypeArguments; |
| 3715 _js_helper.getRuntimeTypeArgument = getRuntimeTypeArgument; |
| 3716 _js_helper.getTypeArgumentByIndex = getTypeArgumentByIndex; |
| 3717 _js_helper.copyTypeArguments = copyTypeArguments; |
| 3718 _js_helper.getClassName = getClassName; |
| 3719 _js_helper.getRuntimeTypeAsString = getRuntimeTypeAsString; |
| 3720 _js_helper.getConstructorName = getConstructorName; |
| 3721 _js_helper.runtimeTypeToString = runtimeTypeToString; |
| 3722 _js_helper.joinArguments = joinArguments; |
| 3723 _js_helper.getRuntimeTypeString = getRuntimeTypeString; |
| 3724 _js_helper.getRuntimeType = getRuntimeType; |
| 3725 _js_helper.substitute = substitute; |
| 3726 _js_helper.checkSubtype = checkSubtype; |
| 3727 _js_helper.computeTypeName = computeTypeName; |
| 3728 _js_helper.subtypeCast = subtypeCast; |
| 3729 _js_helper.assertSubtype = assertSubtype; |
| 3730 _js_helper.assertIsSubtype = assertIsSubtype; |
| 3731 _js_helper.throwTypeError = throwTypeError; |
| 3732 _js_helper.checkArguments = checkArguments; |
| 3733 _js_helper.areSubtypes = areSubtypes; |
| 3734 _js_helper.computeSignature = computeSignature; |
| 3735 _js_helper.isSupertypeOfNull = isSupertypeOfNull; |
| 3736 _js_helper.checkSubtypeOfRuntimeType = checkSubtypeOfRuntimeType; |
| 3737 _js_helper.subtypeOfRuntimeTypeCast = subtypeOfRuntimeTypeCast; |
| 3738 _js_helper.assertSubtypeOfRuntimeType = assertSubtypeOfRuntimeType; |
| 3739 _js_helper.getArguments = getArguments; |
| 3740 _js_helper.isSubtype = isSubtype; |
| 3741 _js_helper.isAssignable = isAssignable; |
| 3742 _js_helper.areAssignable = areAssignable; |
| 3743 _js_helper.areAssignableMaps = areAssignableMaps; |
| 3744 _js_helper.isFunctionSubtype = isFunctionSubtype; |
| 3745 _js_helper.invoke = invoke; |
| 3746 _js_helper.invokeOn = invokeOn; |
| 3747 _js_helper.call = call; |
| 3748 _js_helper.getField = getField; |
| 3749 _js_helper.getIndex = getIndex; |
| 3750 _js_helper.getLength = getLength; |
| 3751 _js_helper.isJsArray = isJsArray; |
| 3752 _js_helper.hasField = hasField; |
| 3753 _js_helper.hasNoField = hasNoField; |
| 3754 _js_helper.isJsFunction = isJsFunction; |
| 3755 _js_helper.isJsObject = isJsObject; |
| 3756 _js_helper.isIdentical = isIdentical; |
| 3757 _js_helper.isNotIdentical = isNotIdentical; |
| 3758 })(_js_helper || (_js_helper = {})); |
| OLD | NEW |