Created
December 15, 2022 08:05
-
-
Save lancejpollard/42359b444dbb67a3c98c7250cc43cb26 to your computer and use it in GitHub Desktop.
Dart Example JS Compilation Output
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
main() { | |
var i = 0; | |
// while conditions are evaluated before the loop | |
while(i++ < 2) { | |
print("while $i"); | |
} | |
var j = 0; | |
// do-while conditions are evaluated after the loop | |
do { | |
print("dowhile $j"); | |
} while (j++ < 2); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Generated by dart2js (NullSafetyMode.sound, no-legacy-javascript, csp), the Dart to JavaScript compiler version: 2.16.2. | |
// The code supports the following hooks: | |
// dartPrint(message): | |
// if this function is defined it is called instead of the Dart [print] | |
// method. | |
// | |
// dartMainRunner(main, args): | |
// if this function is defined, the Dart [main] method will not be invoked | |
// directly. Instead, a closure that will invoke [main], and its arguments | |
// [args] is passed to [dartMainRunner]. | |
// | |
// dartDeferredLibraryLoader(uri, successCallback, errorCallback, loadId): | |
// if this function is defined, it will be called when a deferred library | |
// is loaded. It should load and eval the javascript of `uri`, and call | |
// successCallback. If it fails to do so, it should call errorCallback with | |
// an error. The loadId argument is the deferred import that resulted in | |
// this uri being loaded. | |
// | |
// dartCallInstrumentation(id, qualifiedName): | |
// if this function is defined, it will be called at each entry of a | |
// method or constructor. Used only when compiling programs with | |
// --experiment-call-instrumentation. | |
(function dartProgram() { | |
function copyProperties(from, to) { | |
var keys = Object.keys(from); | |
for (var i = 0; i < keys.length; i++) { | |
var key = keys[i]; | |
to[key] = from[key]; | |
} | |
} | |
function mixinPropertiesHard(from, to) { | |
var keys = Object.keys(from); | |
for (var i = 0; i < keys.length; i++) { | |
var key = keys[i]; | |
if (!to.hasOwnProperty(key)) | |
to[key] = from[key]; | |
} | |
} | |
function mixinPropertiesEasy(from, to) { | |
Object.assign(to, from); | |
} | |
var supportsDirectProtoAccess = function() { | |
var cls = function() { | |
}; | |
cls.prototype = {p: {}}; | |
var object = new cls(); | |
if (!(object.__proto__ && object.__proto__.p === cls.prototype.p)) | |
return false; | |
try { | |
if (typeof navigator != "undefined" && typeof navigator.userAgent == "string" && navigator.userAgent.indexOf("Chrome/") >= 0) | |
return true; | |
if (typeof version == "function" && version.length == 0) { | |
var v = version(); | |
if (/^\d+\.\d+\.\d+\.\d+$/.test(v)) | |
return true; | |
} | |
} catch (_) { | |
} | |
return false; | |
}(); | |
function setFunctionNamesIfNecessary(holders) { | |
function t() { | |
} | |
; | |
if (typeof t.name == "string") | |
return; | |
for (var i = 0; i < holders.length; i++) { | |
var holder = holders[i]; | |
var keys = Object.keys(holder); | |
for (var j = 0; j < keys.length; j++) { | |
var key = keys[j]; | |
var f = holder[key]; | |
if (typeof f == "function") | |
f.name = key; | |
} | |
} | |
} | |
function inherit(cls, sup) { | |
cls.prototype.constructor = cls; | |
cls.prototype["$is" + cls.name] = cls; | |
if (sup != null) { | |
if (supportsDirectProtoAccess) { | |
cls.prototype.__proto__ = sup.prototype; | |
return; | |
} | |
var clsPrototype = Object.create(sup.prototype); | |
copyProperties(cls.prototype, clsPrototype); | |
cls.prototype = clsPrototype; | |
} | |
} | |
function inheritMany(sup, classes) { | |
for (var i = 0; i < classes.length; i++) | |
inherit(classes[i], sup); | |
} | |
function mixinEasy(cls, mixin) { | |
mixinPropertiesEasy(mixin.prototype, cls.prototype); | |
cls.prototype.constructor = cls; | |
} | |
function mixinHard(cls, mixin) { | |
mixinPropertiesHard(mixin.prototype, cls.prototype); | |
cls.prototype.constructor = cls; | |
} | |
function lazyOld(holder, name, getterName, initializer) { | |
var uninitializedSentinel = holder; | |
holder[name] = uninitializedSentinel; | |
holder[getterName] = function() { | |
holder[getterName] = function() { | |
A.throwCyclicInit(name); | |
}; | |
var result; | |
var sentinelInProgress = initializer; | |
try { | |
if (holder[name] === uninitializedSentinel) { | |
result = holder[name] = sentinelInProgress; | |
result = holder[name] = initializer(); | |
} else | |
result = holder[name]; | |
} finally { | |
if (result === sentinelInProgress) | |
holder[name] = null; | |
holder[getterName] = function() { | |
return this[name]; | |
}; | |
} | |
return result; | |
}; | |
} | |
function lazy(holder, name, getterName, initializer) { | |
var uninitializedSentinel = holder; | |
holder[name] = uninitializedSentinel; | |
holder[getterName] = function() { | |
if (holder[name] === uninitializedSentinel) | |
holder[name] = initializer(); | |
holder[getterName] = function() { | |
return this[name]; | |
}; | |
return holder[name]; | |
}; | |
} | |
function lazyFinal(holder, name, getterName, initializer) { | |
var uninitializedSentinel = holder; | |
holder[name] = uninitializedSentinel; | |
holder[getterName] = function() { | |
if (holder[name] === uninitializedSentinel) { | |
var value = initializer(); | |
if (holder[name] !== uninitializedSentinel) | |
A.throwLateFieldADI(name); | |
holder[name] = value; | |
} | |
var finalValue = holder[name]; | |
holder[getterName] = function() { | |
return finalValue; | |
}; | |
return finalValue; | |
}; | |
} | |
function makeConstList(list) { | |
list.immutable$list = Array; | |
list.fixed$length = Array; | |
return list; | |
} | |
function convertToFastObject(properties) { | |
function t() { | |
} | |
t.prototype = properties; | |
new t(); | |
return properties; | |
} | |
function convertAllToFastObject(arrayOfObjects) { | |
for (var i = 0; i < arrayOfObjects.length; ++i) | |
convertToFastObject(arrayOfObjects[i]); | |
} | |
var functionCounter = 0; | |
function instanceTearOffGetter(isIntercepted, parameters) { | |
var cache = null; | |
return isIntercepted ? function(receiver) { | |
if (cache === null) | |
cache = A.closureFromTearOff(parameters); | |
return new cache(receiver, this); | |
} : function() { | |
if (cache === null) | |
cache = A.closureFromTearOff(parameters); | |
return new cache(this, null); | |
}; | |
} | |
function staticTearOffGetter(parameters) { | |
var cache = null; | |
return function() { | |
if (cache === null) | |
cache = A.closureFromTearOff(parameters).prototype; | |
return cache; | |
}; | |
} | |
var typesOffset = 0; | |
function tearOffParameters(container, isStatic, isIntercepted, requiredParameterCount, optionalParameterDefaultValues, callNames, funsOrNames, funType, applyIndex, needsDirectAccess) { | |
if (typeof funType == "number") | |
funType += typesOffset; | |
return {co: container, iS: isStatic, iI: isIntercepted, rC: requiredParameterCount, dV: optionalParameterDefaultValues, cs: callNames, fs: funsOrNames, fT: funType, aI: applyIndex || 0, nDA: needsDirectAccess}; | |
} | |
function installStaticTearOff(holder, getterName, requiredParameterCount, optionalParameterDefaultValues, callNames, funsOrNames, funType, applyIndex) { | |
var parameters = tearOffParameters(holder, true, false, requiredParameterCount, optionalParameterDefaultValues, callNames, funsOrNames, funType, applyIndex, false); | |
var getterFunction = staticTearOffGetter(parameters); | |
holder[getterName] = getterFunction; | |
} | |
function installInstanceTearOff(prototype, getterName, isIntercepted, requiredParameterCount, optionalParameterDefaultValues, callNames, funsOrNames, funType, applyIndex, needsDirectAccess) { | |
isIntercepted = !!isIntercepted; | |
var parameters = tearOffParameters(prototype, false, isIntercepted, requiredParameterCount, optionalParameterDefaultValues, callNames, funsOrNames, funType, applyIndex, !!needsDirectAccess); | |
var getterFunction = instanceTearOffGetter(isIntercepted, parameters); | |
prototype[getterName] = getterFunction; | |
} | |
function setOrUpdateInterceptorsByTag(newTags) { | |
var tags = init.interceptorsByTag; | |
if (!tags) { | |
init.interceptorsByTag = newTags; | |
return; | |
} | |
copyProperties(newTags, tags); | |
} | |
function setOrUpdateLeafTags(newTags) { | |
var tags = init.leafTags; | |
if (!tags) { | |
init.leafTags = newTags; | |
return; | |
} | |
copyProperties(newTags, tags); | |
} | |
function updateTypes(newTypes) { | |
var types = init.types; | |
var length = types.length; | |
types.push.apply(types, newTypes); | |
return length; | |
} | |
function updateHolder(holder, newHolder) { | |
copyProperties(newHolder, holder); | |
return holder; | |
} | |
var hunkHelpers = function() { | |
var mkInstance = function(isIntercepted, requiredParameterCount, optionalParameterDefaultValues, callNames, applyIndex) { | |
return function(container, getterName, name, funType) { | |
return installInstanceTearOff(container, getterName, isIntercepted, requiredParameterCount, optionalParameterDefaultValues, callNames, [name], funType, applyIndex, false); | |
}; | |
}, | |
mkStatic = function(requiredParameterCount, optionalParameterDefaultValues, callNames, applyIndex) { | |
return function(container, getterName, name, funType) { | |
return installStaticTearOff(container, getterName, requiredParameterCount, optionalParameterDefaultValues, callNames, [name], funType, applyIndex); | |
}; | |
}; | |
return {inherit: inherit, inheritMany: inheritMany, mixin: mixinEasy, mixinHard: mixinHard, installStaticTearOff: installStaticTearOff, installInstanceTearOff: installInstanceTearOff, _instance_0u: mkInstance(0, 0, null, ["call$0"], 0), _instance_1u: mkInstance(0, 1, null, ["call$1"], 0), _instance_2u: mkInstance(0, 2, null, ["call$2"], 0), _instance_0i: mkInstance(1, 0, null, ["call$0"], 0), _instance_1i: mkInstance(1, 1, null, ["call$1"], 0), _instance_2i: mkInstance(1, 2, null, ["call$2"], 0), _static_0: mkStatic(0, null, ["call$0"], 0), _static_1: mkStatic(1, null, ["call$1"], 0), _static_2: mkStatic(2, null, ["call$2"], 0), makeConstList: makeConstList, lazy: lazy, lazyFinal: lazyFinal, lazyOld: lazyOld, updateHolder: updateHolder, convertToFastObject: convertToFastObject, setFunctionNamesIfNecessary: setFunctionNamesIfNecessary, updateTypes: updateTypes, setOrUpdateInterceptorsByTag: setOrUpdateInterceptorsByTag, setOrUpdateLeafTags: setOrUpdateLeafTags}; | |
}(); | |
function initializeDeferredHunk(hunk) { | |
typesOffset = init.types.length; | |
hunk(hunkHelpers, init, holders, $); | |
} | |
var A = {JS_CONST: function JS_CONST() { | |
}, LateError: function LateError(t0) { | |
this._message = t0; | |
}, | |
unminifyOrTag(rawClassName) { | |
var preserved = init.mangledGlobalNames[rawClassName]; | |
if (preserved != null) | |
return preserved; | |
return rawClassName; | |
}, | |
S(value) { | |
var result; | |
if (typeof value == "string") | |
return value; | |
if (typeof value == "number") { | |
if (value !== 0) | |
return "" + value; | |
} else if (true === value) | |
return "true"; | |
else if (false === value) | |
return "false"; | |
else if (value == null) | |
return "null"; | |
result = J.toString$0$(value); | |
return result; | |
}, | |
Primitives_objectTypeName(object) { | |
return A.Primitives__objectTypeNameNewRti(object); | |
}, | |
Primitives__objectTypeNameNewRti(object) { | |
var interceptor, dispatchName, t1, $constructor, constructorName; | |
if (object instanceof A.Object) | |
return A._rtiToString(A.instanceType(object), null); | |
interceptor = J.getInterceptor$(object); | |
if (interceptor === B.Interceptor_methods || interceptor === B.JavaScriptObject_methods || false) { | |
dispatchName = B.C_JS_CONST(object); | |
t1 = dispatchName !== "Object" && dispatchName !== ""; | |
if (t1) | |
return dispatchName; | |
$constructor = object.constructor; | |
if (typeof $constructor == "function") { | |
constructorName = $constructor.name; | |
if (typeof constructorName == "string") | |
t1 = constructorName !== "Object" && constructorName !== ""; | |
else | |
t1 = false; | |
if (t1) | |
return constructorName; | |
} | |
} | |
return A._rtiToString(A.instanceType(object), null); | |
}, | |
ioore(receiver, index) { | |
if (receiver == null) | |
J.get$length$as(receiver); | |
throw A.wrapException(A.diagnoseIndexError(receiver, index)); | |
}, | |
diagnoseIndexError(indexable, index) { | |
var $length, _s5_ = "index"; | |
if (!A._isInt(index)) | |
return new A.ArgumentError(true, index, _s5_, null); | |
$length = J.get$length$as(indexable); | |
if (index < 0 || index >= $length) | |
return new A.IndexError($length, true, index, _s5_, "Index out of range"); | |
return new A.RangeError(true, index, _s5_, "Value not in range"); | |
}, | |
wrapException(ex) { | |
var wrapper, t1; | |
if (ex == null) | |
ex = new A.NullThrownError(); | |
wrapper = new Error(); | |
wrapper.dartException = ex; | |
t1 = A.toStringWrapper; | |
if ("defineProperty" in Object) { | |
Object.defineProperty(wrapper, "message", {get: t1}); | |
wrapper.name = ""; | |
} else | |
wrapper.toString = t1; | |
return wrapper; | |
}, | |
toStringWrapper() { | |
return J.toString$0$(this.dartException); | |
}, | |
throwExpression(ex) { | |
throw A.wrapException(ex); | |
}, | |
throwConcurrentModificationError(collection) { | |
throw A.wrapException(new A.ConcurrentModificationError(collection)); | |
}, | |
Closure_fromTearOff(parameters) { | |
var $prototype, $constructor, t2, trampoline, applyTrampoline, i, stub, stub0, stubName, stubCallName, | |
container = parameters.co, | |
isStatic = parameters.iS, | |
isIntercepted = parameters.iI, | |
needsDirectAccess = parameters.nDA, | |
applyTrampolineIndex = parameters.aI, | |
funsOrNames = parameters.fs, | |
callNames = parameters.cs, | |
$name = funsOrNames[0], | |
callName = callNames[0], | |
$function = container[$name], | |
t1 = parameters.fT; | |
t1.toString; | |
$prototype = isStatic ? Object.create(new A.StaticClosure().constructor.prototype) : Object.create(new A.BoundClosure(null, null).constructor.prototype); | |
$prototype.$initialize = $prototype.constructor; | |
if (isStatic) | |
$constructor = function static_tear_off() { | |
this.$initialize(); | |
}; | |
else | |
$constructor = function tear_off(a, b) { | |
this.$initialize(a, b); | |
}; | |
$prototype.constructor = $constructor; | |
$constructor.prototype = $prototype; | |
$prototype.$_name = $name; | |
$prototype.$_target = $function; | |
t2 = !isStatic; | |
if (t2) | |
trampoline = A.Closure_forwardCallTo($name, $function, isIntercepted, needsDirectAccess); | |
else { | |
$prototype.$static_name = $name; | |
trampoline = $function; | |
} | |
$prototype.$signature = A.Closure__computeSignatureFunctionNewRti(t1, isStatic, isIntercepted); | |
$prototype[callName] = trampoline; | |
for (applyTrampoline = trampoline, i = 1; i < funsOrNames.length; ++i) { | |
stub = funsOrNames[i]; | |
if (typeof stub == "string") { | |
stub0 = container[stub]; | |
stubName = stub; | |
stub = stub0; | |
} else | |
stubName = ""; | |
stubCallName = callNames[i]; | |
if (stubCallName != null) { | |
if (t2) | |
stub = A.Closure_forwardCallTo(stubName, stub, isIntercepted, needsDirectAccess); | |
$prototype[stubCallName] = stub; | |
} | |
if (i === applyTrampolineIndex) | |
applyTrampoline = stub; | |
} | |
$prototype["call*"] = applyTrampoline; | |
$prototype.$requiredArgCount = parameters.rC; | |
$prototype.$defaultValues = parameters.dV; | |
return $constructor; | |
}, | |
Closure__computeSignatureFunctionNewRti(functionType, isStatic, isIntercepted) { | |
if (typeof functionType == "number") | |
return functionType; | |
if (typeof functionType == "string") { | |
if (isStatic) | |
throw A.wrapException("Cannot compute signature for static tearoff."); | |
return function(recipe, evalOnReceiver) { | |
return function() { | |
return evalOnReceiver(this, recipe); | |
}; | |
}(functionType, A.BoundClosure_evalRecipe); | |
} | |
throw A.wrapException("Error in functionType of tearoff"); | |
}, | |
Closure_cspForwardCall(arity, needsDirectAccess, stubName, $function) { | |
var getReceiver = A.BoundClosure_receiverOf; | |
switch (needsDirectAccess ? -1 : arity) { | |
case 0: | |
return function(entry, receiverOf) { | |
return function() { | |
return receiverOf(this)[entry](); | |
}; | |
}(stubName, getReceiver); | |
case 1: | |
return function(entry, receiverOf) { | |
return function(a) { | |
return receiverOf(this)[entry](a); | |
}; | |
}(stubName, getReceiver); | |
case 2: | |
return function(entry, receiverOf) { | |
return function(a, b) { | |
return receiverOf(this)[entry](a, b); | |
}; | |
}(stubName, getReceiver); | |
case 3: | |
return function(entry, receiverOf) { | |
return function(a, b, c) { | |
return receiverOf(this)[entry](a, b, c); | |
}; | |
}(stubName, getReceiver); | |
case 4: | |
return function(entry, receiverOf) { | |
return function(a, b, c, d) { | |
return receiverOf(this)[entry](a, b, c, d); | |
}; | |
}(stubName, getReceiver); | |
case 5: | |
return function(entry, receiverOf) { | |
return function(a, b, c, d, e) { | |
return receiverOf(this)[entry](a, b, c, d, e); | |
}; | |
}(stubName, getReceiver); | |
default: | |
return function(f, receiverOf) { | |
return function() { | |
return f.apply(receiverOf(this), arguments); | |
}; | |
}($function, getReceiver); | |
} | |
}, | |
Closure_forwardCallTo(stubName, $function, isIntercepted, needsDirectAccess) { | |
var arity, t1; | |
if (isIntercepted) | |
return A.Closure_forwardInterceptedCallTo(stubName, $function, needsDirectAccess); | |
arity = $function.length; | |
t1 = A.Closure_cspForwardCall(arity, needsDirectAccess, stubName, $function); | |
return t1; | |
}, | |
Closure_cspForwardInterceptedCall(arity, needsDirectAccess, stubName, $function) { | |
var getReceiver = A.BoundClosure_receiverOf, | |
getInterceptor = A.BoundClosure_interceptorOf; | |
switch (needsDirectAccess ? -1 : arity) { | |
case 0: | |
throw A.wrapException(new A.RuntimeError("Intercepted function with no arguments.")); | |
case 1: | |
return function(entry, interceptorOf, receiverOf) { | |
return function() { | |
return interceptorOf(this)[entry](receiverOf(this)); | |
}; | |
}(stubName, getInterceptor, getReceiver); | |
case 2: | |
return function(entry, interceptorOf, receiverOf) { | |
return function(a) { | |
return interceptorOf(this)[entry](receiverOf(this), a); | |
}; | |
}(stubName, getInterceptor, getReceiver); | |
case 3: | |
return function(entry, interceptorOf, receiverOf) { | |
return function(a, b) { | |
return interceptorOf(this)[entry](receiverOf(this), a, b); | |
}; | |
}(stubName, getInterceptor, getReceiver); | |
case 4: | |
return function(entry, interceptorOf, receiverOf) { | |
return function(a, b, c) { | |
return interceptorOf(this)[entry](receiverOf(this), a, b, c); | |
}; | |
}(stubName, getInterceptor, getReceiver); | |
case 5: | |
return function(entry, interceptorOf, receiverOf) { | |
return function(a, b, c, d) { | |
return interceptorOf(this)[entry](receiverOf(this), a, b, c, d); | |
}; | |
}(stubName, getInterceptor, getReceiver); | |
case 6: | |
return function(entry, interceptorOf, receiverOf) { | |
return function(a, b, c, d, e) { | |
return interceptorOf(this)[entry](receiverOf(this), a, b, c, d, e); | |
}; | |
}(stubName, getInterceptor, getReceiver); | |
default: | |
return function(f, interceptorOf, receiverOf) { | |
return function() { | |
var a = [receiverOf(this)]; | |
Array.prototype.push.apply(a, arguments); | |
return f.apply(interceptorOf(this), a); | |
}; | |
}($function, getInterceptor, getReceiver); | |
} | |
}, | |
Closure_forwardInterceptedCallTo(stubName, $function, needsDirectAccess) { | |
var receiverField, arity, t1, | |
interceptorField = $.BoundClosure__interceptorFieldNameCache; | |
interceptorField == null ? $.BoundClosure__interceptorFieldNameCache = A.BoundClosure__computeFieldNamed("interceptor") : interceptorField; | |
receiverField = $.BoundClosure__receiverFieldNameCache; | |
receiverField == null ? $.BoundClosure__receiverFieldNameCache = A.BoundClosure__computeFieldNamed("receiver") : receiverField; | |
arity = $function.length; | |
t1 = A.Closure_cspForwardInterceptedCall(arity, needsDirectAccess, stubName, $function); | |
return t1; | |
}, | |
closureFromTearOff(parameters) { | |
return A.Closure_fromTearOff(parameters); | |
}, | |
BoundClosure_evalRecipe(closure, recipe) { | |
return A._Universe_evalInEnvironment(init.typeUniverse, A.instanceType(closure._receiver), recipe); | |
}, | |
BoundClosure_receiverOf(closure) { | |
return closure._receiver; | |
}, | |
BoundClosure_interceptorOf(closure) { | |
return closure._interceptor; | |
}, | |
BoundClosure__computeFieldNamed(fieldName) { | |
var names, i, $name, | |
template = new A.BoundClosure("receiver", "interceptor"), | |
t1 = Object.getOwnPropertyNames(template); | |
t1.fixed$length = Array; | |
names = t1; | |
for (t1 = names.length, i = 0; i < t1; ++i) { | |
$name = names[i]; | |
if (template[$name] === fieldName) | |
return $name; | |
} | |
throw A.wrapException(new A.ArgumentError(false, null, null, "Field name " + fieldName + " not found.")); | |
}, | |
throwCyclicInit(staticName) { | |
throw A.wrapException(new A.CyclicInitializationError(staticName)); | |
}, | |
Closure: function Closure() { | |
}, | |
TearOffClosure: function TearOffClosure() { | |
}, | |
StaticClosure: function StaticClosure() { | |
}, | |
BoundClosure: function BoundClosure(t0, t1) { | |
this._receiver = t0; | |
this._interceptor = t1; | |
}, | |
RuntimeError: function RuntimeError(t0) { | |
this.message = t0; | |
}, | |
Rti__getQuestionFromStar(universe, rti) { | |
var question = rti._precomputed1; | |
return question == null ? rti._precomputed1 = A._Universe__lookupQuestionRti(universe, rti._primary, true) : question; | |
}, | |
Rti__getFutureFromFutureOr(universe, rti) { | |
var future = rti._precomputed1; | |
return future == null ? rti._precomputed1 = A._Universe__lookupInterfaceRti(universe, "Future", [rti._primary]) : future; | |
}, | |
Rti__isUnionOfFunctionType(rti) { | |
var kind = rti._kind; | |
if (kind === 6 || kind === 7 || kind === 8) | |
return A.Rti__isUnionOfFunctionType(rti._primary); | |
return kind === 11 || kind === 12; | |
}, | |
Rti__getCanonicalRecipe(rti) { | |
return rti._canonicalRecipe; | |
}, | |
findType(recipe) { | |
return A._Universe_eval(init.typeUniverse, recipe, false); | |
}, | |
_substitute(universe, rti, typeArguments, depth) { | |
var baseType, substitutedBaseType, interfaceTypeArguments, substitutedInterfaceTypeArguments, base, substitutedBase, $arguments, substitutedArguments, returnType, substitutedReturnType, functionParameters, substitutedFunctionParameters, bounds, substitutedBounds, index, argument, | |
kind = rti._kind; | |
switch (kind) { | |
case 5: | |
case 1: | |
case 2: | |
case 3: | |
case 4: | |
return rti; | |
case 6: | |
baseType = rti._primary; | |
substitutedBaseType = A._substitute(universe, baseType, typeArguments, depth); | |
if (substitutedBaseType === baseType) | |
return rti; | |
return A._Universe__lookupStarRti(universe, substitutedBaseType, true); | |
case 7: | |
baseType = rti._primary; | |
substitutedBaseType = A._substitute(universe, baseType, typeArguments, depth); | |
if (substitutedBaseType === baseType) | |
return rti; | |
return A._Universe__lookupQuestionRti(universe, substitutedBaseType, true); | |
case 8: | |
baseType = rti._primary; | |
substitutedBaseType = A._substitute(universe, baseType, typeArguments, depth); | |
if (substitutedBaseType === baseType) | |
return rti; | |
return A._Universe__lookupFutureOrRti(universe, substitutedBaseType, true); | |
case 9: | |
interfaceTypeArguments = rti._rest; | |
substitutedInterfaceTypeArguments = A._substituteArray(universe, interfaceTypeArguments, typeArguments, depth); | |
if (substitutedInterfaceTypeArguments === interfaceTypeArguments) | |
return rti; | |
return A._Universe__lookupInterfaceRti(universe, rti._primary, substitutedInterfaceTypeArguments); | |
case 10: | |
base = rti._primary; | |
substitutedBase = A._substitute(universe, base, typeArguments, depth); | |
$arguments = rti._rest; | |
substitutedArguments = A._substituteArray(universe, $arguments, typeArguments, depth); | |
if (substitutedBase === base && substitutedArguments === $arguments) | |
return rti; | |
return A._Universe__lookupBindingRti(universe, substitutedBase, substitutedArguments); | |
case 11: | |
returnType = rti._primary; | |
substitutedReturnType = A._substitute(universe, returnType, typeArguments, depth); | |
functionParameters = rti._rest; | |
substitutedFunctionParameters = A._substituteFunctionParameters(universe, functionParameters, typeArguments, depth); | |
if (substitutedReturnType === returnType && substitutedFunctionParameters === functionParameters) | |
return rti; | |
return A._Universe__lookupFunctionRti(universe, substitutedReturnType, substitutedFunctionParameters); | |
case 12: | |
bounds = rti._rest; | |
depth += bounds.length; | |
substitutedBounds = A._substituteArray(universe, bounds, typeArguments, depth); | |
base = rti._primary; | |
substitutedBase = A._substitute(universe, base, typeArguments, depth); | |
if (substitutedBounds === bounds && substitutedBase === base) | |
return rti; | |
return A._Universe__lookupGenericFunctionRti(universe, substitutedBase, substitutedBounds, true); | |
case 13: | |
index = rti._primary; | |
if (index < depth) | |
return rti; | |
argument = typeArguments[index - depth]; | |
if (argument == null) | |
return rti; | |
return argument; | |
default: | |
throw A.wrapException(A.AssertionError$("Attempted to substitute unexpected RTI kind " + kind)); | |
} | |
}, | |
_substituteArray(universe, rtiArray, typeArguments, depth) { | |
var changed, i, rti, substitutedRti, | |
$length = rtiArray.length, | |
result = A._Utils_newArrayOrEmpty($length); | |
for (changed = false, i = 0; i < $length; ++i) { | |
rti = rtiArray[i]; | |
substitutedRti = A._substitute(universe, rti, typeArguments, depth); | |
if (substitutedRti !== rti) | |
changed = true; | |
result[i] = substitutedRti; | |
} | |
return changed ? result : rtiArray; | |
}, | |
_substituteNamed(universe, namedArray, typeArguments, depth) { | |
var changed, i, t1, t2, rti, substitutedRti, | |
$length = namedArray.length, | |
result = A._Utils_newArrayOrEmpty($length); | |
for (changed = false, i = 0; i < $length; i += 3) { | |
t1 = namedArray[i]; | |
t2 = namedArray[i + 1]; | |
rti = namedArray[i + 2]; | |
substitutedRti = A._substitute(universe, rti, typeArguments, depth); | |
if (substitutedRti !== rti) | |
changed = true; | |
result.splice(i, 3, t1, t2, substitutedRti); | |
} | |
return changed ? result : namedArray; | |
}, | |
_substituteFunctionParameters(universe, functionParameters, typeArguments, depth) { | |
var result, | |
requiredPositional = functionParameters._requiredPositional, | |
substitutedRequiredPositional = A._substituteArray(universe, requiredPositional, typeArguments, depth), | |
optionalPositional = functionParameters._optionalPositional, | |
substitutedOptionalPositional = A._substituteArray(universe, optionalPositional, typeArguments, depth), | |
named = functionParameters._named, | |
substitutedNamed = A._substituteNamed(universe, named, typeArguments, depth); | |
if (substitutedRequiredPositional === requiredPositional && substitutedOptionalPositional === optionalPositional && substitutedNamed === named) | |
return functionParameters; | |
result = new A._FunctionParameters(); | |
result._requiredPositional = substitutedRequiredPositional; | |
result._optionalPositional = substitutedOptionalPositional; | |
result._named = substitutedNamed; | |
return result; | |
}, | |
_setArrayType(target, rti) { | |
target[init.arrayRti] = rti; | |
return target; | |
}, | |
closureFunctionType(closure) { | |
var signature = closure.$signature; | |
if (signature != null) { | |
if (typeof signature == "number") | |
return A.getTypeFromTypesTable(signature); | |
return closure.$signature(); | |
} | |
return null; | |
}, | |
instanceOrFunctionType(object, testRti) { | |
var rti; | |
if (A.Rti__isUnionOfFunctionType(testRti)) | |
if (object instanceof A.Closure) { | |
rti = A.closureFunctionType(object); | |
if (rti != null) | |
return rti; | |
} | |
return A.instanceType(object); | |
}, | |
instanceType(object) { | |
var rti; | |
if (object instanceof A.Object) { | |
rti = object.$ti; | |
return rti != null ? rti : A._instanceTypeFromConstructor(object); | |
} | |
if (Array.isArray(object)) | |
return A._arrayInstanceType(object); | |
return A._instanceTypeFromConstructor(J.getInterceptor$(object)); | |
}, | |
_arrayInstanceType(object) { | |
var rti = object[init.arrayRti], | |
defaultRti = type$.JSArray_dynamic; | |
if (rti == null) | |
return defaultRti; | |
if (rti.constructor !== defaultRti.constructor) | |
return defaultRti; | |
return rti; | |
}, | |
_instanceType(object) { | |
var rti = object.$ti; | |
return rti != null ? rti : A._instanceTypeFromConstructor(object); | |
}, | |
_instanceTypeFromConstructor(instance) { | |
var $constructor = instance.constructor, | |
probe = $constructor.$ccache; | |
if (probe != null) | |
return probe; | |
return A._instanceTypeFromConstructorMiss(instance, $constructor); | |
}, | |
_instanceTypeFromConstructorMiss(instance, $constructor) { | |
var effectiveConstructor = instance instanceof A.Closure ? instance.__proto__.__proto__.constructor : $constructor, | |
rti = A._Universe_findErasedType(init.typeUniverse, effectiveConstructor.name); | |
$constructor.$ccache = rti; | |
return rti; | |
}, | |
getTypeFromTypesTable(index) { | |
var rti, | |
table = init.types, | |
type = table[index]; | |
if (typeof type == "string") { | |
rti = A._Universe_eval(init.typeUniverse, type, false); | |
table[index] = rti; | |
return rti; | |
} | |
return type; | |
}, | |
_installSpecializedIsTest(object) { | |
var t1, unstarred, isFn, $name, testRti = this; | |
if (testRti === type$.Object) | |
return A._finishIsFn(testRti, object, A._isObject); | |
if (!A.isStrongTopType(testRti)) | |
if (!(testRti === type$.legacy_Object)) | |
t1 = false; | |
else | |
t1 = true; | |
else | |
t1 = true; | |
if (t1) | |
return A._finishIsFn(testRti, object, A._isTop); | |
t1 = testRti._kind; | |
unstarred = t1 === 6 ? testRti._primary : testRti; | |
if (unstarred === type$.int) | |
isFn = A._isInt; | |
else if (unstarred === type$.double || unstarred === type$.num) | |
isFn = A._isNum; | |
else if (unstarred === type$.String) | |
isFn = A._isString; | |
else | |
isFn = unstarred === type$.bool ? A._isBool : null; | |
if (isFn != null) | |
return A._finishIsFn(testRti, object, isFn); | |
if (unstarred._kind === 9) { | |
$name = unstarred._primary; | |
if (unstarred._rest.every(A.isTopType)) { | |
testRti._specializedTestResource = "$is" + $name; | |
if ($name === "List") | |
return A._finishIsFn(testRti, object, A._isListTestViaProperty); | |
return A._finishIsFn(testRti, object, A._isTestViaProperty); | |
} | |
} else if (t1 === 7) | |
return A._finishIsFn(testRti, object, A._generalNullableIsTestImplementation); | |
return A._finishIsFn(testRti, object, A._generalIsTestImplementation); | |
}, | |
_finishIsFn(testRti, object, isFn) { | |
testRti._is = isFn; | |
return testRti._is(object); | |
}, | |
_installSpecializedAsCheck(object) { | |
var t1, testRti = this, | |
asFn = A._generalAsCheckImplementation; | |
if (!A.isStrongTopType(testRti)) | |
if (!(testRti === type$.legacy_Object)) | |
t1 = false; | |
else | |
t1 = true; | |
else | |
t1 = true; | |
if (t1) | |
asFn = A._asTop; | |
else if (testRti === type$.Object) | |
asFn = A._asObject; | |
else { | |
t1 = A.isNullable(testRti); | |
if (t1) | |
asFn = A._generalNullableAsCheckImplementation; | |
} | |
testRti._as = asFn; | |
return testRti._as(object); | |
}, | |
_nullIs(testRti) { | |
var t1, | |
kind = testRti._kind; | |
if (!A.isStrongTopType(testRti)) | |
if (!(testRti === type$.legacy_Object)) | |
if (!(testRti === type$.legacy_Never)) | |
if (kind !== 7) | |
t1 = kind === 8 && A._nullIs(testRti._primary) || testRti === type$.Null || testRti === type$.JSNull; | |
else | |
t1 = true; | |
else | |
t1 = true; | |
else | |
t1 = true; | |
else | |
t1 = true; | |
return t1; | |
}, | |
_generalIsTestImplementation(object) { | |
var testRti = this; | |
if (object == null) | |
return A._nullIs(testRti); | |
return A._isSubtype(init.typeUniverse, A.instanceOrFunctionType(object, testRti), null, testRti, null); | |
}, | |
_generalNullableIsTestImplementation(object) { | |
if (object == null) | |
return true; | |
return this._primary._is(object); | |
}, | |
_isTestViaProperty(object) { | |
var tag, testRti = this; | |
if (object == null) | |
return A._nullIs(testRti); | |
tag = testRti._specializedTestResource; | |
if (object instanceof A.Object) | |
return !!object[tag]; | |
return !!J.getInterceptor$(object)[tag]; | |
}, | |
_isListTestViaProperty(object) { | |
var tag, testRti = this; | |
if (object == null) | |
return A._nullIs(testRti); | |
if (typeof object != "object") | |
return false; | |
if (Array.isArray(object)) | |
return true; | |
tag = testRti._specializedTestResource; | |
if (object instanceof A.Object) | |
return !!object[tag]; | |
return !!J.getInterceptor$(object)[tag]; | |
}, | |
_generalAsCheckImplementation(object) { | |
var t1, testRti = this; | |
if (object == null) { | |
t1 = A.isNullable(testRti); | |
if (t1) | |
return object; | |
} else if (testRti._is(object)) | |
return object; | |
A._failedAsCheck(object, testRti); | |
}, | |
_generalNullableAsCheckImplementation(object) { | |
var testRti = this; | |
if (object == null) | |
return object; | |
else if (testRti._is(object)) | |
return object; | |
A._failedAsCheck(object, testRti); | |
}, | |
_failedAsCheck(object, testRti) { | |
throw A.wrapException(A._TypeError$fromMessage(A._Error_compose(object, A.instanceOrFunctionType(object, testRti), A._rtiToString(testRti, null)))); | |
}, | |
_Error_compose(object, objectRti, checkedTypeDescription) { | |
var objectDescription = A.Error_safeToString(object), | |
objectTypeDescription = A._rtiToString(objectRti == null ? A.instanceType(object) : objectRti, null); | |
return objectDescription + ": type '" + objectTypeDescription + "' is not a subtype of type '" + checkedTypeDescription + "'"; | |
}, | |
_TypeError$fromMessage(message) { | |
return new A._TypeError("TypeError: " + message); | |
}, | |
_TypeError__TypeError$forType(object, type) { | |
return new A._TypeError("TypeError: " + A._Error_compose(object, null, type)); | |
}, | |
_isObject(object) { | |
return object != null; | |
}, | |
_asObject(object) { | |
if (object != null) | |
return object; | |
throw A.wrapException(A._TypeError__TypeError$forType(object, "Object")); | |
}, | |
_isTop(object) { | |
return true; | |
}, | |
_asTop(object) { | |
return object; | |
}, | |
_isBool(object) { | |
return true === object || false === object; | |
}, | |
_asBool(object) { | |
if (true === object) | |
return true; | |
if (false === object) | |
return false; | |
throw A.wrapException(A._TypeError__TypeError$forType(object, "bool")); | |
}, | |
_asBoolS(object) { | |
if (true === object) | |
return true; | |
if (false === object) | |
return false; | |
if (object == null) | |
return object; | |
throw A.wrapException(A._TypeError__TypeError$forType(object, "bool")); | |
}, | |
_asBoolQ(object) { | |
if (true === object) | |
return true; | |
if (false === object) | |
return false; | |
if (object == null) | |
return object; | |
throw A.wrapException(A._TypeError__TypeError$forType(object, "bool?")); | |
}, | |
_asDouble(object) { | |
if (typeof object == "number") | |
return object; | |
throw A.wrapException(A._TypeError__TypeError$forType(object, "double")); | |
}, | |
_asDoubleS(object) { | |
if (typeof object == "number") | |
return object; | |
if (object == null) | |
return object; | |
throw A.wrapException(A._TypeError__TypeError$forType(object, "double")); | |
}, | |
_asDoubleQ(object) { | |
if (typeof object == "number") | |
return object; | |
if (object == null) | |
return object; | |
throw A.wrapException(A._TypeError__TypeError$forType(object, "double?")); | |
}, | |
_isInt(object) { | |
return typeof object == "number" && Math.floor(object) === object; | |
}, | |
_asInt(object) { | |
if (typeof object == "number" && Math.floor(object) === object) | |
return object; | |
throw A.wrapException(A._TypeError__TypeError$forType(object, "int")); | |
}, | |
_asIntS(object) { | |
if (typeof object == "number" && Math.floor(object) === object) | |
return object; | |
if (object == null) | |
return object; | |
throw A.wrapException(A._TypeError__TypeError$forType(object, "int")); | |
}, | |
_asIntQ(object) { | |
if (typeof object == "number" && Math.floor(object) === object) | |
return object; | |
if (object == null) | |
return object; | |
throw A.wrapException(A._TypeError__TypeError$forType(object, "int?")); | |
}, | |
_isNum(object) { | |
return typeof object == "number"; | |
}, | |
_asNum(object) { | |
if (typeof object == "number") | |
return object; | |
throw A.wrapException(A._TypeError__TypeError$forType(object, "num")); | |
}, | |
_asNumS(object) { | |
if (typeof object == "number") | |
return object; | |
if (object == null) | |
return object; | |
throw A.wrapException(A._TypeError__TypeError$forType(object, "num")); | |
}, | |
_asNumQ(object) { | |
if (typeof object == "number") | |
return object; | |
if (object == null) | |
return object; | |
throw A.wrapException(A._TypeError__TypeError$forType(object, "num?")); | |
}, | |
_isString(object) { | |
return typeof object == "string"; | |
}, | |
_asString(object) { | |
if (typeof object == "string") | |
return object; | |
throw A.wrapException(A._TypeError__TypeError$forType(object, "String")); | |
}, | |
_asStringS(object) { | |
if (typeof object == "string") | |
return object; | |
if (object == null) | |
return object; | |
throw A.wrapException(A._TypeError__TypeError$forType(object, "String")); | |
}, | |
_asStringQ(object) { | |
if (typeof object == "string") | |
return object; | |
if (object == null) | |
return object; | |
throw A.wrapException(A._TypeError__TypeError$forType(object, "String?")); | |
}, | |
_rtiArrayToString(array, genericContext) { | |
var s, sep, i; | |
for (s = "", sep = "", i = 0; i < array.length; ++i, sep = ", ") | |
s += sep + A._rtiToString(array[i], genericContext); | |
return s; | |
}, | |
_functionRtiToString(functionType, genericContext, bounds) { | |
var boundsLength, outerContextLength, offset, i, t1, t2, typeParametersText, typeSep, t3, t4, boundRti, kind, parameters, requiredPositional, requiredPositionalLength, optionalPositional, optionalPositionalLength, named, namedLength, returnTypeText, argumentsText, sep, _s2_ = ", "; | |
if (bounds != null) { | |
boundsLength = bounds.length; | |
if (genericContext == null) { | |
genericContext = A._setArrayType([], type$.JSArray_String); | |
outerContextLength = null; | |
} else | |
outerContextLength = genericContext.length; | |
offset = genericContext.length; | |
for (i = boundsLength; i > 0; --i) | |
B.JSArray_methods.add$1(genericContext, "T" + (offset + i)); | |
for (t1 = type$.nullable_Object, t2 = type$.legacy_Object, typeParametersText = "<", typeSep = "", i = 0; i < boundsLength; ++i, typeSep = _s2_) { | |
typeParametersText += typeSep; | |
t3 = genericContext.length; | |
t4 = t3 - 1 - i; | |
if (!(t4 >= 0)) | |
return A.ioore(genericContext, t4); | |
typeParametersText = B.JSString_methods.$add(typeParametersText, genericContext[t4]); | |
boundRti = bounds[i]; | |
kind = boundRti._kind; | |
if (!(kind === 2 || kind === 3 || kind === 4 || kind === 5 || boundRti === t1)) | |
if (!(boundRti === t2)) | |
t3 = false; | |
else | |
t3 = true; | |
else | |
t3 = true; | |
if (!t3) | |
typeParametersText += " extends " + A._rtiToString(boundRti, genericContext); | |
} | |
typeParametersText += ">"; | |
} else { | |
typeParametersText = ""; | |
outerContextLength = null; | |
} | |
t1 = functionType._primary; | |
parameters = functionType._rest; | |
requiredPositional = parameters._requiredPositional; | |
requiredPositionalLength = requiredPositional.length; | |
optionalPositional = parameters._optionalPositional; | |
optionalPositionalLength = optionalPositional.length; | |
named = parameters._named; | |
namedLength = named.length; | |
returnTypeText = A._rtiToString(t1, genericContext); | |
for (argumentsText = "", sep = "", i = 0; i < requiredPositionalLength; ++i, sep = _s2_) | |
argumentsText += sep + A._rtiToString(requiredPositional[i], genericContext); | |
if (optionalPositionalLength > 0) { | |
argumentsText += sep + "["; | |
for (sep = "", i = 0; i < optionalPositionalLength; ++i, sep = _s2_) | |
argumentsText += sep + A._rtiToString(optionalPositional[i], genericContext); | |
argumentsText += "]"; | |
} | |
if (namedLength > 0) { | |
argumentsText += sep + "{"; | |
for (sep = "", i = 0; i < namedLength; i += 3, sep = _s2_) { | |
argumentsText += sep; | |
if (named[i + 1]) | |
argumentsText += "required "; | |
argumentsText += A._rtiToString(named[i + 2], genericContext) + " " + named[i]; | |
} | |
argumentsText += "}"; | |
} | |
if (outerContextLength != null) { | |
genericContext.toString; | |
genericContext.length = outerContextLength; | |
} | |
return typeParametersText + "(" + argumentsText + ") => " + returnTypeText; | |
}, | |
_rtiToString(rti, genericContext) { | |
var s, questionArgument, argumentKind, $name, $arguments, t1, t2, | |
kind = rti._kind; | |
if (kind === 5) | |
return "erased"; | |
if (kind === 2) | |
return "dynamic"; | |
if (kind === 3) | |
return "void"; | |
if (kind === 1) | |
return "Never"; | |
if (kind === 4) | |
return "any"; | |
if (kind === 6) { | |
s = A._rtiToString(rti._primary, genericContext); | |
return s; | |
} | |
if (kind === 7) { | |
questionArgument = rti._primary; | |
s = A._rtiToString(questionArgument, genericContext); | |
argumentKind = questionArgument._kind; | |
return (argumentKind === 11 || argumentKind === 12 ? "(" + s + ")" : s) + "?"; | |
} | |
if (kind === 8) | |
return "FutureOr<" + A._rtiToString(rti._primary, genericContext) + ">"; | |
if (kind === 9) { | |
$name = A._unminifyOrTag(rti._primary); | |
$arguments = rti._rest; | |
return $arguments.length > 0 ? $name + ("<" + A._rtiArrayToString($arguments, genericContext) + ">") : $name; | |
} | |
if (kind === 11) | |
return A._functionRtiToString(rti, genericContext, null); | |
if (kind === 12) | |
return A._functionRtiToString(rti._primary, genericContext, rti._rest); | |
if (kind === 13) { | |
t1 = rti._primary; | |
t2 = genericContext.length; | |
t1 = t2 - 1 - t1; | |
if (!(t1 >= 0 && t1 < t2)) | |
return A.ioore(genericContext, t1); | |
return genericContext[t1]; | |
} | |
return "?"; | |
}, | |
_unminifyOrTag(rawClassName) { | |
var preserved = init.mangledGlobalNames[rawClassName]; | |
if (preserved != null) | |
return preserved; | |
return rawClassName; | |
}, | |
_Universe_findRule(universe, targetType) { | |
var rule = universe.tR[targetType]; | |
for (; typeof rule == "string";) | |
rule = universe.tR[rule]; | |
return rule; | |
}, | |
_Universe_findErasedType(universe, cls) { | |
var $length, erased, $arguments, i, $interface, | |
t1 = universe.eT, | |
probe = t1[cls]; | |
if (probe == null) | |
return A._Universe_eval(universe, cls, false); | |
else if (typeof probe == "number") { | |
$length = probe; | |
erased = A._Universe__lookupTerminalRti(universe, 5, "#"); | |
$arguments = A._Utils_newArrayOrEmpty($length); | |
for (i = 0; i < $length; ++i) | |
$arguments[i] = erased; | |
$interface = A._Universe__lookupInterfaceRti(universe, cls, $arguments); | |
t1[cls] = $interface; | |
return $interface; | |
} else | |
return probe; | |
}, | |
_Universe_addRules(universe, rules) { | |
return A._Utils_objectAssign(universe.tR, rules); | |
}, | |
_Universe_addErasedTypes(universe, types) { | |
return A._Utils_objectAssign(universe.eT, types); | |
}, | |
_Universe_eval(universe, recipe, normalize) { | |
var rti, | |
t1 = universe.eC, | |
probe = t1.get(recipe); | |
if (probe != null) | |
return probe; | |
rti = A._Parser_parse(A._Parser_create(universe, null, recipe, normalize)); | |
t1.set(recipe, rti); | |
return rti; | |
}, | |
_Universe_evalInEnvironment(universe, environment, recipe) { | |
var probe, rti, | |
cache = environment._evalCache; | |
if (cache == null) | |
cache = environment._evalCache = new Map(); | |
probe = cache.get(recipe); | |
if (probe != null) | |
return probe; | |
rti = A._Parser_parse(A._Parser_create(universe, environment, recipe, true)); | |
cache.set(recipe, rti); | |
return rti; | |
}, | |
_Universe_bind(universe, environment, argumentsRti) { | |
var argumentsRecipe, probe, rti, | |
cache = environment._bindCache; | |
if (cache == null) | |
cache = environment._bindCache = new Map(); | |
argumentsRecipe = argumentsRti._canonicalRecipe; | |
probe = cache.get(argumentsRecipe); | |
if (probe != null) | |
return probe; | |
rti = A._Universe__lookupBindingRti(universe, environment, argumentsRti._kind === 10 ? argumentsRti._rest : [argumentsRti]); | |
cache.set(argumentsRecipe, rti); | |
return rti; | |
}, | |
_Universe__installTypeTests(universe, rti) { | |
rti._as = A._installSpecializedAsCheck; | |
rti._is = A._installSpecializedIsTest; | |
return rti; | |
}, | |
_Universe__lookupTerminalRti(universe, kind, key) { | |
var rti, t1, | |
probe = universe.eC.get(key); | |
if (probe != null) | |
return probe; | |
rti = new A.Rti(null, null); | |
rti._kind = kind; | |
rti._canonicalRecipe = key; | |
t1 = A._Universe__installTypeTests(universe, rti); | |
universe.eC.set(key, t1); | |
return t1; | |
}, | |
_Universe__lookupStarRti(universe, baseType, normalize) { | |
var t1, | |
key = baseType._canonicalRecipe + "*", | |
probe = universe.eC.get(key); | |
if (probe != null) | |
return probe; | |
t1 = A._Universe__createStarRti(universe, baseType, key, normalize); | |
universe.eC.set(key, t1); | |
return t1; | |
}, | |
_Universe__createStarRti(universe, baseType, key, normalize) { | |
var baseKind, t1, rti; | |
if (normalize) { | |
baseKind = baseType._kind; | |
if (!A.isStrongTopType(baseType)) | |
t1 = baseType === type$.Null || baseType === type$.JSNull || baseKind === 7 || baseKind === 6; | |
else | |
t1 = true; | |
if (t1) | |
return baseType; | |
} | |
rti = new A.Rti(null, null); | |
rti._kind = 6; | |
rti._primary = baseType; | |
rti._canonicalRecipe = key; | |
return A._Universe__installTypeTests(universe, rti); | |
}, | |
_Universe__lookupQuestionRti(universe, baseType, normalize) { | |
var t1, | |
key = baseType._canonicalRecipe + "?", | |
probe = universe.eC.get(key); | |
if (probe != null) | |
return probe; | |
t1 = A._Universe__createQuestionRti(universe, baseType, key, normalize); | |
universe.eC.set(key, t1); | |
return t1; | |
}, | |
_Universe__createQuestionRti(universe, baseType, key, normalize) { | |
var baseKind, t1, starArgument, rti; | |
if (normalize) { | |
baseKind = baseType._kind; | |
if (!A.isStrongTopType(baseType)) | |
if (!(baseType === type$.Null || baseType === type$.JSNull)) | |
if (baseKind !== 7) | |
t1 = baseKind === 8 && A.isNullable(baseType._primary); | |
else | |
t1 = true; | |
else | |
t1 = true; | |
else | |
t1 = true; | |
if (t1) | |
return baseType; | |
else if (baseKind === 1 || baseType === type$.legacy_Never) | |
return type$.Null; | |
else if (baseKind === 6) { | |
starArgument = baseType._primary; | |
if (starArgument._kind === 8 && A.isNullable(starArgument._primary)) | |
return starArgument; | |
else | |
return A.Rti__getQuestionFromStar(universe, baseType); | |
} | |
} | |
rti = new A.Rti(null, null); | |
rti._kind = 7; | |
rti._primary = baseType; | |
rti._canonicalRecipe = key; | |
return A._Universe__installTypeTests(universe, rti); | |
}, | |
_Universe__lookupFutureOrRti(universe, baseType, normalize) { | |
var t1, | |
key = baseType._canonicalRecipe + "/", | |
probe = universe.eC.get(key); | |
if (probe != null) | |
return probe; | |
t1 = A._Universe__createFutureOrRti(universe, baseType, key, normalize); | |
universe.eC.set(key, t1); | |
return t1; | |
}, | |
_Universe__createFutureOrRti(universe, baseType, key, normalize) { | |
var t1, t2, rti; | |
if (normalize) { | |
t1 = baseType._kind; | |
if (!A.isStrongTopType(baseType)) | |
if (!(baseType === type$.legacy_Object)) | |
t2 = false; | |
else | |
t2 = true; | |
else | |
t2 = true; | |
if (t2 || baseType === type$.Object) | |
return baseType; | |
else if (t1 === 1) | |
return A._Universe__lookupInterfaceRti(universe, "Future", [baseType]); | |
else if (baseType === type$.Null || baseType === type$.JSNull) | |
return type$.nullable_Future_Null; | |
} | |
rti = new A.Rti(null, null); | |
rti._kind = 8; | |
rti._primary = baseType; | |
rti._canonicalRecipe = key; | |
return A._Universe__installTypeTests(universe, rti); | |
}, | |
_Universe__lookupGenericFunctionParameterRti(universe, index) { | |
var rti, t1, | |
key = "" + index + "^", | |
probe = universe.eC.get(key); | |
if (probe != null) | |
return probe; | |
rti = new A.Rti(null, null); | |
rti._kind = 13; | |
rti._primary = index; | |
rti._canonicalRecipe = key; | |
t1 = A._Universe__installTypeTests(universe, rti); | |
universe.eC.set(key, t1); | |
return t1; | |
}, | |
_Universe__canonicalRecipeJoin($arguments) { | |
var s, sep, i, | |
$length = $arguments.length; | |
for (s = "", sep = "", i = 0; i < $length; ++i, sep = ",") | |
s += sep + $arguments[i]._canonicalRecipe; | |
return s; | |
}, | |
_Universe__canonicalRecipeJoinNamed($arguments) { | |
var s, sep, i, t1, nameSep, s0, | |
$length = $arguments.length; | |
for (s = "", sep = "", i = 0; i < $length; i += 3, sep = ",") { | |
t1 = $arguments[i]; | |
nameSep = $arguments[i + 1] ? "!" : ":"; | |
s0 = $arguments[i + 2]._canonicalRecipe; | |
s += sep + t1 + nameSep + s0; | |
} | |
return s; | |
}, | |
_Universe__lookupInterfaceRti(universe, $name, $arguments) { | |
var probe, rti, t1, | |
s = $name; | |
if ($arguments.length > 0) | |
s += "<" + A._Universe__canonicalRecipeJoin($arguments) + ">"; | |
probe = universe.eC.get(s); | |
if (probe != null) | |
return probe; | |
rti = new A.Rti(null, null); | |
rti._kind = 9; | |
rti._primary = $name; | |
rti._rest = $arguments; | |
if ($arguments.length > 0) | |
rti._precomputed1 = $arguments[0]; | |
rti._canonicalRecipe = s; | |
t1 = A._Universe__installTypeTests(universe, rti); | |
universe.eC.set(s, t1); | |
return t1; | |
}, | |
_Universe__lookupBindingRti(universe, base, $arguments) { | |
var newBase, newArguments, key, probe, rti, t1; | |
if (base._kind === 10) { | |
newBase = base._primary; | |
newArguments = base._rest.concat($arguments); | |
} else { | |
newArguments = $arguments; | |
newBase = base; | |
} | |
key = newBase._canonicalRecipe + (";<" + A._Universe__canonicalRecipeJoin(newArguments) + ">"); | |
probe = universe.eC.get(key); | |
if (probe != null) | |
return probe; | |
rti = new A.Rti(null, null); | |
rti._kind = 10; | |
rti._primary = newBase; | |
rti._rest = newArguments; | |
rti._canonicalRecipe = key; | |
t1 = A._Universe__installTypeTests(universe, rti); | |
universe.eC.set(key, t1); | |
return t1; | |
}, | |
_Universe__lookupFunctionRti(universe, returnType, parameters) { | |
var sep, t1, key, probe, rti, | |
s = returnType._canonicalRecipe, | |
requiredPositional = parameters._requiredPositional, | |
requiredPositionalLength = requiredPositional.length, | |
optionalPositional = parameters._optionalPositional, | |
optionalPositionalLength = optionalPositional.length, | |
named = parameters._named, | |
namedLength = named.length, | |
recipe = "(" + A._Universe__canonicalRecipeJoin(requiredPositional); | |
if (optionalPositionalLength > 0) { | |
sep = requiredPositionalLength > 0 ? "," : ""; | |
t1 = A._Universe__canonicalRecipeJoin(optionalPositional); | |
recipe += sep + "[" + t1 + "]"; | |
} | |
if (namedLength > 0) { | |
sep = requiredPositionalLength > 0 ? "," : ""; | |
t1 = A._Universe__canonicalRecipeJoinNamed(named); | |
recipe += sep + "{" + t1 + "}"; | |
} | |
key = s + (recipe + ")"); | |
probe = universe.eC.get(key); | |
if (probe != null) | |
return probe; | |
rti = new A.Rti(null, null); | |
rti._kind = 11; | |
rti._primary = returnType; | |
rti._rest = parameters; | |
rti._canonicalRecipe = key; | |
t1 = A._Universe__installTypeTests(universe, rti); | |
universe.eC.set(key, t1); | |
return t1; | |
}, | |
_Universe__lookupGenericFunctionRti(universe, baseFunctionType, bounds, normalize) { | |
var t1, | |
key = baseFunctionType._canonicalRecipe + ("<" + A._Universe__canonicalRecipeJoin(bounds) + ">"), | |
probe = universe.eC.get(key); | |
if (probe != null) | |
return probe; | |
t1 = A._Universe__createGenericFunctionRti(universe, baseFunctionType, bounds, key, normalize); | |
universe.eC.set(key, t1); | |
return t1; | |
}, | |
_Universe__createGenericFunctionRti(universe, baseFunctionType, bounds, key, normalize) { | |
var $length, typeArguments, count, i, bound, substitutedBase, substitutedBounds, rti; | |
if (normalize) { | |
$length = bounds.length; | |
typeArguments = A._Utils_newArrayOrEmpty($length); | |
for (count = 0, i = 0; i < $length; ++i) { | |
bound = bounds[i]; | |
if (bound._kind === 1) { | |
typeArguments[i] = bound; | |
++count; | |
} | |
} | |
if (count > 0) { | |
substitutedBase = A._substitute(universe, baseFunctionType, typeArguments, 0); | |
substitutedBounds = A._substituteArray(universe, bounds, typeArguments, 0); | |
return A._Universe__lookupGenericFunctionRti(universe, substitutedBase, substitutedBounds, bounds !== substitutedBounds); | |
} | |
} | |
rti = new A.Rti(null, null); | |
rti._kind = 12; | |
rti._primary = baseFunctionType; | |
rti._rest = bounds; | |
rti._canonicalRecipe = key; | |
return A._Universe__installTypeTests(universe, rti); | |
}, | |
_Parser_create(universe, environment, recipe, normalize) { | |
return {u: universe, e: environment, r: recipe, s: [], p: 0, n: normalize}; | |
}, | |
_Parser_parse(parser) { | |
var t2, i, ch, t3, array, head, base, parameters, optionalPositional, named, item, | |
source = parser.r, | |
t1 = parser.s; | |
for (t2 = source.length, i = 0; i < t2;) { | |
ch = source.charCodeAt(i); | |
if (ch >= 48 && ch <= 57) | |
i = A._Parser_handleDigit(i + 1, ch, source, t1); | |
else if ((((ch | 32) >>> 0) - 97 & 65535) < 26 || ch === 95 || ch === 36) | |
i = A._Parser_handleIdentifier(parser, i, source, t1, false); | |
else if (ch === 46) | |
i = A._Parser_handleIdentifier(parser, i, source, t1, true); | |
else { | |
++i; | |
switch (ch) { | |
case 44: | |
break; | |
case 58: | |
t1.push(false); | |
break; | |
case 33: | |
t1.push(true); | |
break; | |
case 59: | |
t1.push(A._Parser_toType(parser.u, parser.e, t1.pop())); | |
break; | |
case 94: | |
t1.push(A._Universe__lookupGenericFunctionParameterRti(parser.u, t1.pop())); | |
break; | |
case 35: | |
t1.push(A._Universe__lookupTerminalRti(parser.u, 5, "#")); | |
break; | |
case 64: | |
t1.push(A._Universe__lookupTerminalRti(parser.u, 2, "@")); | |
break; | |
case 126: | |
t1.push(A._Universe__lookupTerminalRti(parser.u, 3, "~")); | |
break; | |
case 60: | |
t1.push(parser.p); | |
parser.p = t1.length; | |
break; | |
case 62: | |
t3 = parser.u; | |
array = t1.splice(parser.p); | |
A._Parser_toTypes(parser.u, parser.e, array); | |
parser.p = t1.pop(); | |
head = t1.pop(); | |
if (typeof head == "string") | |
t1.push(A._Universe__lookupInterfaceRti(t3, head, array)); | |
else { | |
base = A._Parser_toType(t3, parser.e, head); | |
switch (base._kind) { | |
case 11: | |
t1.push(A._Universe__lookupGenericFunctionRti(t3, base, array, parser.n)); | |
break; | |
default: | |
t1.push(A._Universe__lookupBindingRti(t3, base, array)); | |
break; | |
} | |
} | |
break; | |
case 38: | |
A._Parser_handleExtendedOperations(parser, t1); | |
break; | |
case 42: | |
t3 = parser.u; | |
t1.push(A._Universe__lookupStarRti(t3, A._Parser_toType(t3, parser.e, t1.pop()), parser.n)); | |
break; | |
case 63: | |
t3 = parser.u; | |
t1.push(A._Universe__lookupQuestionRti(t3, A._Parser_toType(t3, parser.e, t1.pop()), parser.n)); | |
break; | |
case 47: | |
t3 = parser.u; | |
t1.push(A._Universe__lookupFutureOrRti(t3, A._Parser_toType(t3, parser.e, t1.pop()), parser.n)); | |
break; | |
case 40: | |
t1.push(parser.p); | |
parser.p = t1.length; | |
break; | |
case 41: | |
t3 = parser.u; | |
parameters = new A._FunctionParameters(); | |
optionalPositional = t3.sEA; | |
named = t3.sEA; | |
head = t1.pop(); | |
if (typeof head == "number") | |
switch (head) { | |
case -1: | |
optionalPositional = t1.pop(); | |
break; | |
case -2: | |
named = t1.pop(); | |
break; | |
default: | |
t1.push(head); | |
break; | |
} | |
else | |
t1.push(head); | |
array = t1.splice(parser.p); | |
A._Parser_toTypes(parser.u, parser.e, array); | |
parser.p = t1.pop(); | |
parameters._requiredPositional = array; | |
parameters._optionalPositional = optionalPositional; | |
parameters._named = named; | |
t1.push(A._Universe__lookupFunctionRti(t3, A._Parser_toType(t3, parser.e, t1.pop()), parameters)); | |
break; | |
case 91: | |
t1.push(parser.p); | |
parser.p = t1.length; | |
break; | |
case 93: | |
array = t1.splice(parser.p); | |
A._Parser_toTypes(parser.u, parser.e, array); | |
parser.p = t1.pop(); | |
t1.push(array); | |
t1.push(-1); | |
break; | |
case 123: | |
t1.push(parser.p); | |
parser.p = t1.length; | |
break; | |
case 125: | |
array = t1.splice(parser.p); | |
A._Parser_toTypesNamed(parser.u, parser.e, array); | |
parser.p = t1.pop(); | |
t1.push(array); | |
t1.push(-2); | |
break; | |
default: | |
throw "Bad character " + ch; | |
} | |
} | |
} | |
item = t1.pop(); | |
return A._Parser_toType(parser.u, parser.e, item); | |
}, | |
_Parser_handleDigit(i, digit, source, stack) { | |
var t1, ch, | |
value = digit - 48; | |
for (t1 = source.length; i < t1; ++i) { | |
ch = source.charCodeAt(i); | |
if (!(ch >= 48 && ch <= 57)) | |
break; | |
value = value * 10 + (ch - 48); | |
} | |
stack.push(value); | |
return i; | |
}, | |
_Parser_handleIdentifier(parser, start, source, stack, hasPeriod) { | |
var t1, ch, t2, string, environment, recipe, | |
i = start + 1; | |
for (t1 = source.length; i < t1; ++i) { | |
ch = source.charCodeAt(i); | |
if (ch === 46) { | |
if (hasPeriod) | |
break; | |
hasPeriod = true; | |
} else { | |
if (!((((ch | 32) >>> 0) - 97 & 65535) < 26 || ch === 95 || ch === 36)) | |
t2 = ch >= 48 && ch <= 57; | |
else | |
t2 = true; | |
if (!t2) | |
break; | |
} | |
} | |
string = source.substring(start, i); | |
if (hasPeriod) { | |
t1 = parser.u; | |
environment = parser.e; | |
if (environment._kind === 10) | |
environment = environment._primary; | |
recipe = A._Universe_findRule(t1, environment._primary)[string]; | |
if (recipe == null) | |
A.throwExpression('No "' + string + '" in "' + A.Rti__getCanonicalRecipe(environment) + '"'); | |
stack.push(A._Universe_evalInEnvironment(t1, environment, recipe)); | |
} else | |
stack.push(string); | |
return i; | |
}, | |
_Parser_handleExtendedOperations(parser, stack) { | |
var $top = stack.pop(); | |
if (0 === $top) { | |
stack.push(A._Universe__lookupTerminalRti(parser.u, 1, "0&")); | |
return; | |
} | |
if (1 === $top) { | |
stack.push(A._Universe__lookupTerminalRti(parser.u, 4, "1&")); | |
return; | |
} | |
throw A.wrapException(A.AssertionError$("Unexpected extended operation " + A.S($top))); | |
}, | |
_Parser_toType(universe, environment, item) { | |
if (typeof item == "string") | |
return A._Universe__lookupInterfaceRti(universe, item, universe.sEA); | |
else if (typeof item == "number") | |
return A._Parser_indexToType(universe, environment, item); | |
else | |
return item; | |
}, | |
_Parser_toTypes(universe, environment, items) { | |
var i, | |
$length = items.length; | |
for (i = 0; i < $length; ++i) | |
items[i] = A._Parser_toType(universe, environment, items[i]); | |
}, | |
_Parser_toTypesNamed(universe, environment, items) { | |
var i, | |
$length = items.length; | |
for (i = 2; i < $length; i += 3) | |
items[i] = A._Parser_toType(universe, environment, items[i]); | |
}, | |
_Parser_indexToType(universe, environment, index) { | |
var typeArguments, len, | |
kind = environment._kind; | |
if (kind === 10) { | |
if (index === 0) | |
return environment._primary; | |
typeArguments = environment._rest; | |
len = typeArguments.length; | |
if (index <= len) | |
return typeArguments[index - 1]; | |
index -= len; | |
environment = environment._primary; | |
kind = environment._kind; | |
} else if (index === 0) | |
return environment; | |
if (kind !== 9) | |
throw A.wrapException(A.AssertionError$("Indexed base must be an interface type")); | |
typeArguments = environment._rest; | |
if (index <= typeArguments.length) | |
return typeArguments[index - 1]; | |
throw A.wrapException(A.AssertionError$("Bad index " + index + " for " + environment.toString$0(0))); | |
}, | |
_isSubtype(universe, s, sEnv, t, tEnv) { | |
var t1, sKind, leftTypeVariable, tKind, sBounds, tBounds, sLength, i, sBound, tBound; | |
if (s === t) | |
return true; | |
if (!A.isStrongTopType(t)) | |
if (!(t === type$.legacy_Object)) | |
t1 = false; | |
else | |
t1 = true; | |
else | |
t1 = true; | |
if (t1) | |
return true; | |
sKind = s._kind; | |
if (sKind === 4) | |
return true; | |
if (A.isStrongTopType(s)) | |
return false; | |
if (s._kind !== 1) | |
t1 = false; | |
else | |
t1 = true; | |
if (t1) | |
return true; | |
leftTypeVariable = sKind === 13; | |
if (leftTypeVariable) | |
if (A._isSubtype(universe, sEnv[s._primary], sEnv, t, tEnv)) | |
return true; | |
tKind = t._kind; | |
t1 = s === type$.Null || s === type$.JSNull; | |
if (t1) { | |
if (tKind === 8) | |
return A._isSubtype(universe, s, sEnv, t._primary, tEnv); | |
return t === type$.Null || t === type$.JSNull || tKind === 7 || tKind === 6; | |
} | |
if (t === type$.Object) { | |
if (sKind === 8) | |
return A._isSubtype(universe, s._primary, sEnv, t, tEnv); | |
if (sKind === 6) | |
return A._isSubtype(universe, s._primary, sEnv, t, tEnv); | |
return sKind !== 7; | |
} | |
if (sKind === 6) | |
return A._isSubtype(universe, s._primary, sEnv, t, tEnv); | |
if (tKind === 6) { | |
t1 = A.Rti__getQuestionFromStar(universe, t); | |
return A._isSubtype(universe, s, sEnv, t1, tEnv); | |
} | |
if (sKind === 8) { | |
if (!A._isSubtype(universe, s._primary, sEnv, t, tEnv)) | |
return false; | |
return A._isSubtype(universe, A.Rti__getFutureFromFutureOr(universe, s), sEnv, t, tEnv); | |
} | |
if (sKind === 7) { | |
t1 = A._isSubtype(universe, type$.Null, sEnv, t, tEnv); | |
return t1 && A._isSubtype(universe, s._primary, sEnv, t, tEnv); | |
} | |
if (tKind === 8) { | |
if (A._isSubtype(universe, s, sEnv, t._primary, tEnv)) | |
return true; | |
return A._isSubtype(universe, s, sEnv, A.Rti__getFutureFromFutureOr(universe, t), tEnv); | |
} | |
if (tKind === 7) { | |
t1 = A._isSubtype(universe, s, sEnv, type$.Null, tEnv); | |
return t1 || A._isSubtype(universe, s, sEnv, t._primary, tEnv); | |
} | |
if (leftTypeVariable) | |
return false; | |
t1 = sKind !== 11; | |
if ((!t1 || sKind === 12) && t === type$.Function) | |
return true; | |
if (tKind === 12) { | |
if (s === type$.JavaScriptFunction) | |
return true; | |
if (sKind !== 12) | |
return false; | |
sBounds = s._rest; | |
tBounds = t._rest; | |
sLength = sBounds.length; | |
if (sLength !== tBounds.length) | |
return false; | |
sEnv = sEnv == null ? sBounds : sBounds.concat(sEnv); | |
tEnv = tEnv == null ? tBounds : tBounds.concat(tEnv); | |
for (i = 0; i < sLength; ++i) { | |
sBound = sBounds[i]; | |
tBound = tBounds[i]; | |
if (!A._isSubtype(universe, sBound, sEnv, tBound, tEnv) || !A._isSubtype(universe, tBound, tEnv, sBound, sEnv)) | |
return false; | |
} | |
return A._isFunctionSubtype(universe, s._primary, sEnv, t._primary, tEnv); | |
} | |
if (tKind === 11) { | |
if (s === type$.JavaScriptFunction) | |
return true; | |
if (t1) | |
return false; | |
return A._isFunctionSubtype(universe, s, sEnv, t, tEnv); | |
} | |
if (sKind === 9) { | |
if (tKind !== 9) | |
return false; | |
return A._isInterfaceSubtype(universe, s, sEnv, t, tEnv); | |
} | |
return false; | |
}, | |
_isFunctionSubtype(universe, s, sEnv, t, tEnv) { | |
var sParameters, tParameters, sRequiredPositional, tRequiredPositional, sRequiredPositionalLength, tRequiredPositionalLength, requiredPositionalDelta, sOptionalPositional, tOptionalPositional, sOptionalPositionalLength, tOptionalPositionalLength, i, t1, sNamed, tNamed, sNamedLength, tNamedLength, sIndex, tIndex, tName, sName, sIsRequired; | |
if (!A._isSubtype(universe, s._primary, sEnv, t._primary, tEnv)) | |
return false; | |
sParameters = s._rest; | |
tParameters = t._rest; | |
sRequiredPositional = sParameters._requiredPositional; | |
tRequiredPositional = tParameters._requiredPositional; | |
sRequiredPositionalLength = sRequiredPositional.length; | |
tRequiredPositionalLength = tRequiredPositional.length; | |
if (sRequiredPositionalLength > tRequiredPositionalLength) | |
return false; | |
requiredPositionalDelta = tRequiredPositionalLength - sRequiredPositionalLength; | |
sOptionalPositional = sParameters._optionalPositional; | |
tOptionalPositional = tParameters._optionalPositional; | |
sOptionalPositionalLength = sOptionalPositional.length; | |
tOptionalPositionalLength = tOptionalPositional.length; | |
if (sRequiredPositionalLength + sOptionalPositionalLength < tRequiredPositionalLength + tOptionalPositionalLength) | |
return false; | |
for (i = 0; i < sRequiredPositionalLength; ++i) { | |
t1 = sRequiredPositional[i]; | |
if (!A._isSubtype(universe, tRequiredPositional[i], tEnv, t1, sEnv)) | |
return false; | |
} | |
for (i = 0; i < requiredPositionalDelta; ++i) { | |
t1 = sOptionalPositional[i]; | |
if (!A._isSubtype(universe, tRequiredPositional[sRequiredPositionalLength + i], tEnv, t1, sEnv)) | |
return false; | |
} | |
for (i = 0; i < tOptionalPositionalLength; ++i) { | |
t1 = sOptionalPositional[requiredPositionalDelta + i]; | |
if (!A._isSubtype(universe, tOptionalPositional[i], tEnv, t1, sEnv)) | |
return false; | |
} | |
sNamed = sParameters._named; | |
tNamed = tParameters._named; | |
sNamedLength = sNamed.length; | |
tNamedLength = tNamed.length; | |
for (sIndex = 0, tIndex = 0; tIndex < tNamedLength; tIndex += 3) { | |
tName = tNamed[tIndex]; | |
for (; true;) { | |
if (sIndex >= sNamedLength) | |
return false; | |
sName = sNamed[sIndex]; | |
sIndex += 3; | |
if (tName < sName) | |
return false; | |
sIsRequired = sNamed[sIndex - 2]; | |
if (sName < tName) { | |
if (sIsRequired) | |
return false; | |
continue; | |
} | |
t1 = tNamed[tIndex + 1]; | |
if (sIsRequired && !t1) | |
return false; | |
t1 = sNamed[sIndex - 1]; | |
if (!A._isSubtype(universe, tNamed[tIndex + 2], tEnv, t1, sEnv)) | |
return false; | |
break; | |
} | |
} | |
for (; sIndex < sNamedLength;) { | |
if (sNamed[sIndex + 1]) | |
return false; | |
sIndex += 3; | |
} | |
return true; | |
}, | |
_isInterfaceSubtype(universe, s, sEnv, t, tEnv) { | |
var rule, recipes, $length, supertypeArgs, i, t1, t2, | |
sName = s._primary, | |
tName = t._primary; | |
for (; sName !== tName;) { | |
rule = universe.tR[sName]; | |
if (rule == null) | |
return false; | |
if (typeof rule == "string") { | |
sName = rule; | |
continue; | |
} | |
recipes = rule[tName]; | |
if (recipes == null) | |
return false; | |
$length = recipes.length; | |
supertypeArgs = $length > 0 ? new Array($length) : init.typeUniverse.sEA; | |
for (i = 0; i < $length; ++i) | |
supertypeArgs[i] = A._Universe_evalInEnvironment(universe, s, recipes[i]); | |
return A._areArgumentsSubtypes(universe, supertypeArgs, null, sEnv, t._rest, tEnv); | |
} | |
t1 = s._rest; | |
t2 = t._rest; | |
return A._areArgumentsSubtypes(universe, t1, null, sEnv, t2, tEnv); | |
}, | |
_areArgumentsSubtypes(universe, sArgs, sVariances, sEnv, tArgs, tEnv) { | |
var i, t1, t2, | |
$length = sArgs.length; | |
for (i = 0; i < $length; ++i) { | |
t1 = sArgs[i]; | |
t2 = tArgs[i]; | |
if (!A._isSubtype(universe, t1, sEnv, t2, tEnv)) | |
return false; | |
} | |
return true; | |
}, | |
isNullable(t) { | |
var t1, | |
kind = t._kind; | |
if (!(t === type$.Null || t === type$.JSNull)) | |
if (!A.isStrongTopType(t)) | |
if (kind !== 7) | |
if (!(kind === 6 && A.isNullable(t._primary))) | |
t1 = kind === 8 && A.isNullable(t._primary); | |
else | |
t1 = true; | |
else | |
t1 = true; | |
else | |
t1 = true; | |
else | |
t1 = true; | |
return t1; | |
}, | |
isTopType(t) { | |
var t1; | |
if (!A.isStrongTopType(t)) | |
if (!(t === type$.legacy_Object)) | |
t1 = false; | |
else | |
t1 = true; | |
else | |
t1 = true; | |
return t1; | |
}, | |
isStrongTopType(t) { | |
var kind = t._kind; | |
return kind === 2 || kind === 3 || kind === 4 || kind === 5 || t === type$.nullable_Object; | |
}, | |
_Utils_objectAssign(o, other) { | |
var i, key, | |
keys = Object.keys(other), | |
$length = keys.length; | |
for (i = 0; i < $length; ++i) { | |
key = keys[i]; | |
o[key] = other[key]; | |
} | |
}, | |
_Utils_newArrayOrEmpty($length) { | |
return $length > 0 ? new Array($length) : init.typeUniverse.sEA; | |
}, | |
Rti: function Rti(t0, t1) { | |
var _ = this; | |
_._as = t0; | |
_._is = t1; | |
_._cachedRuntimeType = _._specializedTestResource = _._precomputed1 = null; | |
_._kind = 0; | |
_._canonicalRecipe = _._bindCache = _._evalCache = _._rest = _._primary = null; | |
}, | |
_FunctionParameters: function _FunctionParameters() { | |
this._named = this._optionalPositional = this._requiredPositional = null; | |
}, | |
_Error: function _Error() { | |
}, | |
_TypeError: function _TypeError(t0) { | |
this.__rti$_message = t0; | |
}, | |
Error__objectToString(object) { | |
if (object instanceof A.Closure) | |
return object.toString$0(0); | |
return "Instance of '" + A.Primitives_objectTypeName(object) + "'"; | |
}, | |
StringBuffer__writeAll(string, objects, separator) { | |
var t1 = A._arrayInstanceType(objects), | |
iterator = new J.ArrayIterator(objects, objects.length, t1._eval$1("ArrayIterator<1>")); | |
if (!iterator.moveNext$0()) | |
return string; | |
t1 = t1._precomputed1; | |
if (separator.length === 0) { | |
do | |
string += A.S(t1._as(iterator._current)); | |
while (iterator.moveNext$0()); | |
} else { | |
string += A.S(t1._as(iterator._current)); | |
for (; iterator.moveNext$0();) | |
string = string + separator + A.S(t1._as(iterator._current)); | |
} | |
return string; | |
}, | |
Error_safeToString(object) { | |
if (typeof object == "number" || A._isBool(object) || object == null) | |
return J.toString$0$(object); | |
if (typeof object == "string") | |
return JSON.stringify(object); | |
return A.Error__objectToString(object); | |
}, | |
AssertionError$(message) { | |
return new A.AssertionError(message); | |
}, | |
UnsupportedError$(message) { | |
return new A.UnsupportedError(message); | |
}, | |
print(object) { | |
A.printString(object); | |
}, | |
Error: function Error() { | |
}, | |
AssertionError: function AssertionError(t0) { | |
this.message = t0; | |
}, | |
NullThrownError: function NullThrownError() { | |
}, | |
ArgumentError: function ArgumentError(t0, t1, t2, t3) { | |
var _ = this; | |
_._hasValue = t0; | |
_.invalidValue = t1; | |
_.name = t2; | |
_.message = t3; | |
}, | |
RangeError: function RangeError(t0, t1, t2, t3) { | |
var _ = this; | |
_._hasValue = t0; | |
_.invalidValue = t1; | |
_.name = t2; | |
_.message = t3; | |
}, | |
IndexError: function IndexError(t0, t1, t2, t3, t4) { | |
var _ = this; | |
_.length = t0; | |
_._hasValue = t1; | |
_.invalidValue = t2; | |
_.name = t3; | |
_.message = t4; | |
}, | |
UnsupportedError: function UnsupportedError(t0) { | |
this.message = t0; | |
}, | |
ConcurrentModificationError: function ConcurrentModificationError(t0) { | |
this.modifiedObject = t0; | |
}, | |
CyclicInitializationError: function CyclicInitializationError(t0) { | |
this.variableName = t0; | |
}, | |
Null: function Null() { | |
}, | |
Object: function Object() { | |
}, | |
StringBuffer: function StringBuffer(t0) { | |
this._contents = t0; | |
}, | |
printString(string) { | |
if (typeof dartPrint == "function") { | |
dartPrint(string); | |
return; | |
} | |
if (typeof console == "object" && typeof console.log != "undefined") { | |
console.log(string); | |
return; | |
} | |
if (typeof window == "object") | |
return; | |
if (typeof print == "function") { | |
print(string); | |
return; | |
} | |
throw "Unable to print message: " + String(string); | |
}, | |
throwLateFieldADI(fieldName) { | |
return A.throwExpression(new A.LateError("Field '" + fieldName + "' has been assigned during initialization.")); | |
}, | |
IterableBase_iterableToFullString(iterable, leftDelimiter, rightDelimiter) { | |
var buffer, t1; | |
if (A._isToStringVisiting(iterable)) | |
return leftDelimiter + "..." + rightDelimiter; | |
buffer = new A.StringBuffer(leftDelimiter); | |
B.JSArray_methods.add$1($._toStringVisiting, iterable); | |
try { | |
t1 = buffer; | |
t1._contents = A.StringBuffer__writeAll(t1._contents, iterable, ", "); | |
} finally { | |
if (0 >= $._toStringVisiting.length) | |
return A.ioore($._toStringVisiting, -1); | |
$._toStringVisiting.pop(); | |
} | |
buffer._contents += rightDelimiter; | |
t1 = buffer._contents; | |
return t1.charCodeAt(0) == 0 ? t1 : t1; | |
}, | |
_isToStringVisiting(o) { | |
var t1, i; | |
for (t1 = $._toStringVisiting.length, i = 0; i < t1; ++i) | |
if (o === $._toStringVisiting[i]) | |
return true; | |
return false; | |
}, | |
main() { | |
var i, i0, j, j0; | |
for (i = 0; i0 = i + 1, i < 2; i = i0) | |
A.printString("while " + i0); | |
j = 0; | |
do { | |
A.print("dowhile " + j); | |
if (j0 = j + 1, j < 2) { | |
j = j0; | |
continue; | |
} else | |
break; | |
} while (true); | |
} | |
}, | |
J = { | |
getInterceptor$(receiver) { | |
if (typeof receiver == "number") { | |
if (Math.floor(receiver) == receiver) | |
return J.JSInt.prototype; | |
return J.JSNumNotInt.prototype; | |
} | |
if (typeof receiver == "string") | |
return J.JSString.prototype; | |
if (receiver == null) | |
return J.JSNull.prototype; | |
if (typeof receiver == "boolean") | |
return J.JSBool.prototype; | |
if (receiver.constructor == Array) | |
return J.JSArray.prototype; | |
return receiver; | |
}, | |
getInterceptor$as(receiver) { | |
if (typeof receiver == "string") | |
return J.JSString.prototype; | |
if (receiver == null) | |
return receiver; | |
if (receiver.constructor == Array) | |
return J.JSArray.prototype; | |
return receiver; | |
}, | |
get$length$as(receiver) { | |
return J.getInterceptor$as(receiver).get$length(receiver); | |
}, | |
toString$0$(receiver) { | |
return J.getInterceptor$(receiver).toString$0(receiver); | |
}, | |
Interceptor: function Interceptor() { | |
}, | |
JSBool: function JSBool() { | |
}, | |
JSNull: function JSNull() { | |
}, | |
JavaScriptObject: function JavaScriptObject() { | |
}, | |
JSArray: function JSArray(t0) { | |
this.$ti = t0; | |
}, | |
JSUnmodifiableArray: function JSUnmodifiableArray(t0) { | |
this.$ti = t0; | |
}, | |
ArrayIterator: function ArrayIterator(t0, t1, t2) { | |
var _ = this; | |
_._iterable = t0; | |
_._length = t1; | |
_._index = 0; | |
_._current = null; | |
_.$ti = t2; | |
}, | |
JSNumber: function JSNumber() { | |
}, | |
JSInt: function JSInt() { | |
}, | |
JSNumNotInt: function JSNumNotInt() { | |
}, | |
JSString: function JSString() { | |
} | |
}, | |
B = {}; | |
var holders = [A, J, B]; | |
hunkHelpers.setFunctionNamesIfNecessary(holders); | |
var $ = {}; | |
A.JS_CONST.prototype = {}; | |
J.Interceptor.prototype = { | |
toString$0(receiver) { | |
return "Instance of '" + A.Primitives_objectTypeName(receiver) + "'"; | |
} | |
}; | |
J.JSBool.prototype = { | |
toString$0(receiver) { | |
return String(receiver); | |
}, | |
$isbool: 1 | |
}; | |
J.JSNull.prototype = { | |
toString$0(receiver) { | |
return "null"; | |
} | |
}; | |
J.JavaScriptObject.prototype = {}; | |
J.JSArray.prototype = { | |
add$1(receiver, value) { | |
A._arrayInstanceType(receiver)._precomputed1._as(value); | |
if (!!receiver.fixed$length) | |
A.throwExpression(A.UnsupportedError$("add")); | |
receiver.push(value); | |
}, | |
toString$0(receiver) { | |
return A.IterableBase_iterableToFullString(receiver, "[", "]"); | |
}, | |
get$length(receiver) { | |
return receiver.length; | |
}, | |
$isIterable: 1 | |
}; | |
J.JSUnmodifiableArray.prototype = {}; | |
J.ArrayIterator.prototype = { | |
moveNext$0() { | |
var t2, _this = this, | |
t1 = _this._iterable, | |
$length = t1.length; | |
if (_this._length !== $length) | |
throw A.wrapException(A.throwConcurrentModificationError(t1)); | |
t2 = _this._index; | |
if (t2 >= $length) { | |
_this.set$_current(null); | |
return false; | |
} | |
_this.set$_current(t1[t2]); | |
++_this._index; | |
return true; | |
}, | |
set$_current(_current) { | |
this._current = this.$ti._eval$1("1?")._as(_current); | |
} | |
}; | |
J.JSNumber.prototype = { | |
toString$0(receiver) { | |
if (receiver === 0 && 1 / receiver < 0) | |
return "-0.0"; | |
else | |
return "" + receiver; | |
} | |
}; | |
J.JSInt.prototype = {$isint: 1}; | |
J.JSNumNotInt.prototype = {}; | |
J.JSString.prototype = { | |
$add(receiver, other) { | |
return receiver + other; | |
}, | |
toString$0(receiver) { | |
return receiver; | |
}, | |
get$length(receiver) { | |
return receiver.length; | |
}, | |
$isString: 1 | |
}; | |
A.LateError.prototype = { | |
toString$0(_) { | |
var t1 = "LateInitializationError: " + this._message; | |
return t1; | |
} | |
}; | |
A.Closure.prototype = { | |
toString$0(_) { | |
var $constructor = this.constructor, | |
$name = $constructor == null ? null : $constructor.name; | |
return "Closure '" + A.unminifyOrTag($name == null ? "unknown" : $name) + "'"; | |
}, | |
get$$call() { | |
return this; | |
}, | |
"call*": "call$1", | |
$requiredArgCount: 1, | |
$defaultValues: null | |
}; | |
A.TearOffClosure.prototype = {}; | |
A.StaticClosure.prototype = { | |
toString$0(_) { | |
var $name = this.$static_name; | |
if ($name == null) | |
return "Closure of unknown static method"; | |
return "Closure '" + A.unminifyOrTag($name) + "'"; | |
} | |
}; | |
A.BoundClosure.prototype = { | |
toString$0(_) { | |
return "Closure '" + this.$_name + "' of " + ("Instance of '" + A.Primitives_objectTypeName(type$.Object._as(this._receiver)) + "'"); | |
} | |
}; | |
A.RuntimeError.prototype = { | |
toString$0(_) { | |
return "RuntimeError: " + this.message; | |
} | |
}; | |
A.Rti.prototype = { | |
_eval$1(recipe) { | |
return A._Universe_evalInEnvironment(init.typeUniverse, this, recipe); | |
}, | |
_bind$1(typeOrTuple) { | |
return A._Universe_bind(init.typeUniverse, this, typeOrTuple); | |
} | |
}; | |
A._FunctionParameters.prototype = {}; | |
A._Error.prototype = { | |
toString$0(_) { | |
return this.__rti$_message; | |
} | |
}; | |
A._TypeError.prototype = {}; | |
A.Error.prototype = {}; | |
A.AssertionError.prototype = { | |
toString$0(_) { | |
var t1 = this.message; | |
if (t1 != null) | |
return "Assertion failed: " + A.Error_safeToString(t1); | |
return "Assertion failed"; | |
} | |
}; | |
A.NullThrownError.prototype = { | |
toString$0(_) { | |
return "Throw of null."; | |
} | |
}; | |
A.ArgumentError.prototype = { | |
get$_errorName() { | |
return "Invalid argument" + (!this._hasValue ? "(s)" : ""); | |
}, | |
get$_errorExplanation() { | |
return ""; | |
}, | |
toString$0(_) { | |
var explanation, errorValue, _this = this, | |
$name = _this.name, | |
nameString = $name == null ? "" : " (" + $name + ")", | |
message = _this.message, | |
messageString = message == null ? "" : ": " + message, | |
prefix = _this.get$_errorName() + nameString + messageString; | |
if (!_this._hasValue) | |
return prefix; | |
explanation = _this.get$_errorExplanation(); | |
errorValue = A.Error_safeToString(_this.invalidValue); | |
return prefix + explanation + ": " + errorValue; | |
} | |
}; | |
A.RangeError.prototype = { | |
get$_errorName() { | |
return "RangeError"; | |
}, | |
get$_errorExplanation() { | |
return ""; | |
} | |
}; | |
A.IndexError.prototype = { | |
get$_errorName() { | |
return "RangeError"; | |
}, | |
get$_errorExplanation() { | |
if (A._asInt(this.invalidValue) < 0) | |
return ": index must not be negative"; | |
var t1 = this.length; | |
if (t1 === 0) | |
return ": no indices are valid"; | |
return ": index should be less than " + t1; | |
}, | |
get$length(receiver) { | |
return this.length; | |
} | |
}; | |
A.UnsupportedError.prototype = { | |
toString$0(_) { | |
return "Unsupported operation: " + this.message; | |
} | |
}; | |
A.ConcurrentModificationError.prototype = { | |
toString$0(_) { | |
return "Concurrent modification during iteration: " + A.Error_safeToString(this.modifiedObject) + "."; | |
} | |
}; | |
A.CyclicInitializationError.prototype = { | |
toString$0(_) { | |
var t1 = "Reading static variable '" + this.variableName + "' during its initialization"; | |
return t1; | |
} | |
}; | |
A.Null.prototype = { | |
toString$0(_) { | |
return "null"; | |
} | |
}; | |
A.Object.prototype = {$isObject: 1, | |
toString$0(_) { | |
return "Instance of '" + A.Primitives_objectTypeName(this) + "'"; | |
}, | |
toString() { | |
return this.toString$0(this); | |
} | |
}; | |
A.StringBuffer.prototype = { | |
get$length(_) { | |
return this._contents.length; | |
}, | |
toString$0(_) { | |
var t1 = this._contents; | |
return t1.charCodeAt(0) == 0 ? t1 : t1; | |
} | |
}; | |
(function inheritance() { | |
var _inherit = hunkHelpers.inherit, | |
_inheritMany = hunkHelpers.inheritMany; | |
_inherit(A.Object, null); | |
_inheritMany(A.Object, [A.JS_CONST, J.Interceptor, J.ArrayIterator, A.Error, A.Closure, A.Rti, A._FunctionParameters, A.Null, A.StringBuffer]); | |
_inheritMany(J.Interceptor, [J.JSBool, J.JSNull, J.JavaScriptObject, J.JSArray, J.JSNumber, J.JSString]); | |
_inherit(J.JSUnmodifiableArray, J.JSArray); | |
_inheritMany(J.JSNumber, [J.JSInt, J.JSNumNotInt]); | |
_inheritMany(A.Error, [A.LateError, A.RuntimeError, A._Error, A.AssertionError, A.NullThrownError, A.ArgumentError, A.UnsupportedError, A.ConcurrentModificationError, A.CyclicInitializationError]); | |
_inherit(A.TearOffClosure, A.Closure); | |
_inheritMany(A.TearOffClosure, [A.StaticClosure, A.BoundClosure]); | |
_inherit(A._TypeError, A._Error); | |
_inheritMany(A.ArgumentError, [A.RangeError, A.IndexError]); | |
})(); | |
var init = { | |
typeUniverse: {eC: new Map(), tR: {}, eT: {}, tPV: {}, sEA: []}, | |
mangledGlobalNames: {int: "int", double: "double", num: "num", String: "String", bool: "bool", Null: "Null", List: "List"}, | |
mangledNames: {}, | |
types: [], | |
arrayRti: Symbol("$ti") | |
}; | |
A._Universe_addRules(init.typeUniverse, JSON.parse('{"JSBool":{"bool":[]},"JSArray":{"Iterable":["1"]},"JSUnmodifiableArray":{"JSArray":["1"],"Iterable":["1"]},"JSInt":{"int":[]},"JSString":{"String":[]}}')); | |
var type$ = (function rtii() { | |
var findType = A.findType; | |
return { | |
Function: findType("Function"), | |
JSArray_String: findType("JSArray<String>"), | |
JSArray_dynamic: findType("JSArray<@>"), | |
JSNull: findType("JSNull"), | |
JavaScriptFunction: findType("JavaScriptFunction"), | |
Null: findType("Null"), | |
Object: findType("Object"), | |
String: findType("String"), | |
bool: findType("bool"), | |
double: findType("double"), | |
int: findType("int"), | |
legacy_Never: findType("0&*"), | |
legacy_Object: findType("Object*"), | |
nullable_Future_Null: findType("Future<Null>?"), | |
nullable_Object: findType("Object?"), | |
num: findType("num") | |
}; | |
})(); | |
(function constants() { | |
B.Interceptor_methods = J.Interceptor.prototype; | |
B.JSArray_methods = J.JSArray.prototype; | |
B.JSString_methods = J.JSString.prototype; | |
B.JavaScriptObject_methods = J.JavaScriptObject.prototype; | |
B.C_JS_CONST = function getTagFallback(o) { | |
var s = Object.prototype.toString.call(o); | |
return s.substring(8, s.length - 1); | |
}; | |
})(); | |
(function staticFields() { | |
$.BoundClosure__receiverFieldNameCache = null; | |
$.BoundClosure__interceptorFieldNameCache = null; | |
$._toStringVisiting = A._setArrayType([], A.findType("JSArray<Object>")); | |
})(); | |
(function nativeSupport() { | |
hunkHelpers.setOrUpdateInterceptorsByTag({}); | |
hunkHelpers.setOrUpdateLeafTags({}); | |
})(); | |
convertAllToFastObject(holders); | |
convertToFastObject($); | |
(function(callback) { | |
if (typeof document === "undefined") { | |
callback(null); | |
return; | |
} | |
if (typeof document.currentScript != "undefined") { | |
callback(document.currentScript); | |
return; | |
} | |
var scripts = document.scripts; | |
function onLoad(event) { | |
for (var i = 0; i < scripts.length; ++i) | |
scripts[i].removeEventListener("load", onLoad, false); | |
callback(event.target); | |
} | |
for (var i = 0; i < scripts.length; ++i) | |
scripts[i].addEventListener("load", onLoad, false); | |
})(function(currentScript) { | |
init.currentScript = currentScript; | |
var callMain = A.main; | |
if (typeof dartMainRunner === "function") | |
dartMainRunner(callMain, []); | |
else | |
callMain([]); | |
}); | |
})(); | |
//# sourceMappingURL=1.js.map |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment