From 2d40ca9d10906cab11f509692eeb3f52b0e1d2a2 Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Wed, 14 Aug 2024 21:25:22 +0800 Subject: [PATCH] add sort --- dart-js/out.js | 383 ++++++++++++++++++++++++++++++++++++++++++++-- dart-js/test.dart | 8 + 2 files changed, 380 insertions(+), 11 deletions(-) diff --git a/dart-js/out.js b/dart-js/out.js index 0adf013..d4cb478 100644 --- a/dart-js/out.js +++ b/dart-js/out.js @@ -270,6 +270,252 @@ MappedIterable_MappedIterable: function (iterable, $function, $S, $T) { return new H.EfficientLengthMappedIterable(iterable, $function, $S._eval$1("@<0>")._bind$1($T)._eval$1("EfficientLengthMappedIterable<1,2>")); }, + Sort_sort: function (a, compare, $E) { + H.Sort__doSort(a, 0, J.get$length$asx(a) - 1, compare, $E); + }, + Sort__doSort: function (a, left, right, compare, $E) { + if (right - left <= 32) + H.Sort__insertionSort(a, left, right, compare, $E); + else + H.Sort__dualPivotQuicksort(a, left, right, compare, $E); + }, + Sort__insertionSort: function (a, left, right, compare, $E) { + var i, t1, el, j, t2, j0; + for (i = left + 1, t1 = J.getInterceptor$asx(a); i <= right; ++i) { + el = t1.$index(a, i); + j = i; + while (true) { + if (j > left) { + t2 = compare.call$2(t1.$index(a, j - 1), el); + if (typeof t2 !== "number") + return t2.$gt(); + t2 = t2 > 0; + } else + t2 = false; + if (!t2) + break; + j0 = j - 1; + t1.$indexSet(a, j, t1.$index(a, j0)); + j = j0; + } + t1.$indexSet(a, j, el); + } + }, + Sort__dualPivotQuicksort: function (a, left, right, compare, $E) { + var t0, less, great, k, ak, comp, great0, less0, pivots_are_equal, + sixth = C.JSInt_methods._tdivFast$1(right - left + 1, 6), + index1 = left + sixth, + index5 = right - sixth, + index3 = C.JSInt_methods._tdivFast$1(left + right, 2), + index2 = index3 - sixth, + index4 = index3 + sixth, + t1 = J.getInterceptor$asx(a), + el1 = t1.$index(a, index1), + el2 = t1.$index(a, index2), + el3 = t1.$index(a, index3), + el4 = t1.$index(a, index4), + el5 = t1.$index(a, index5), + t2 = compare.call$2(el1, el2); + if (typeof t2 !== "number") + return t2.$gt(); + if (t2 > 0) { + t0 = el2; + el2 = el1; + el1 = t0; + } + t2 = compare.call$2(el4, el5); + if (typeof t2 !== "number") + return t2.$gt(); + if (t2 > 0) { + t0 = el5; + el5 = el4; + el4 = t0; + } + t2 = compare.call$2(el1, el3); + if (typeof t2 !== "number") + return t2.$gt(); + if (t2 > 0) { + t0 = el3; + el3 = el1; + el1 = t0; + } + t2 = compare.call$2(el2, el3); + if (typeof t2 !== "number") + return t2.$gt(); + if (t2 > 0) { + t0 = el3; + el3 = el2; + el2 = t0; + } + t2 = compare.call$2(el1, el4); + if (typeof t2 !== "number") + return t2.$gt(); + if (t2 > 0) { + t0 = el4; + el4 = el1; + el1 = t0; + } + t2 = compare.call$2(el3, el4); + if (typeof t2 !== "number") + return t2.$gt(); + if (t2 > 0) { + t0 = el4; + el4 = el3; + el3 = t0; + } + t2 = compare.call$2(el2, el5); + if (typeof t2 !== "number") + return t2.$gt(); + if (t2 > 0) { + t0 = el5; + el5 = el2; + el2 = t0; + } + t2 = compare.call$2(el2, el3); + if (typeof t2 !== "number") + return t2.$gt(); + if (t2 > 0) { + t0 = el3; + el3 = el2; + el2 = t0; + } + t2 = compare.call$2(el4, el5); + if (typeof t2 !== "number") + return t2.$gt(); + if (t2 > 0) { + t0 = el5; + el5 = el4; + el4 = t0; + } + t1.$indexSet(a, index1, el1); + t1.$indexSet(a, index3, el3); + t1.$indexSet(a, index5, el5); + t1.$indexSet(a, index2, t1.$index(a, left)); + t1.$indexSet(a, index4, t1.$index(a, right)); + less = left + 1; + great = right - 1; + if (J.$eq$(compare.call$2(el2, el4), 0)) { + for (k = less; k <= great; ++k) { + ak = t1.$index(a, k); + comp = compare.call$2(ak, el2); + if (comp === 0) + continue; + if (comp < 0) { + if (k !== less) { + t1.$indexSet(a, k, t1.$index(a, less)); + t1.$indexSet(a, less, ak); + } + ++less; + } else + for (; true;) { + comp = compare.call$2(t1.$index(a, great), el2); + if (comp > 0) { + --great; + continue; + } else { + great0 = great - 1; + if (comp < 0) { + t1.$indexSet(a, k, t1.$index(a, less)); + less0 = less + 1; + t1.$indexSet(a, less, t1.$index(a, great)); + t1.$indexSet(a, great, ak); + great = great0; + less = less0; + break; + } else { + t1.$indexSet(a, k, t1.$index(a, great)); + t1.$indexSet(a, great, ak); + great = great0; + break; + } + } + } + } + pivots_are_equal = true; + } else { + for (k = less; k <= great; ++k) { + ak = t1.$index(a, k); + if (compare.call$2(ak, el2) < 0) { + if (k !== less) { + t1.$indexSet(a, k, t1.$index(a, less)); + t1.$indexSet(a, less, ak); + } + ++less; + } else if (compare.call$2(ak, el4) > 0) + for (; true;) + if (compare.call$2(t1.$index(a, great), el4) > 0) { + --great; + if (great < k) + break; + continue; + } else { + great0 = great - 1; + if (compare.call$2(t1.$index(a, great), el2) < 0) { + t1.$indexSet(a, k, t1.$index(a, less)); + less0 = less + 1; + t1.$indexSet(a, less, t1.$index(a, great)); + t1.$indexSet(a, great, ak); + less = less0; + } else { + t1.$indexSet(a, k, t1.$index(a, great)); + t1.$indexSet(a, great, ak); + } + great = great0; + break; + } + } + pivots_are_equal = false; + } + t2 = less - 1; + t1.$indexSet(a, left, t1.$index(a, t2)); + t1.$indexSet(a, t2, el2); + t2 = great + 1; + t1.$indexSet(a, right, t1.$index(a, t2)); + t1.$indexSet(a, t2, el4); + H.Sort__doSort(a, left, less - 2, compare, $E); + H.Sort__doSort(a, great + 2, right, compare, $E); + if (pivots_are_equal) + return; + if (less < index1 && great > index5) { + for (; J.$eq$(compare.call$2(t1.$index(a, less), el2), 0);) + ++less; + for (; J.$eq$(compare.call$2(t1.$index(a, great), el4), 0);) + --great; + for (k = less; k <= great; ++k) { + ak = t1.$index(a, k); + if (compare.call$2(ak, el2) === 0) { + if (k !== less) { + t1.$indexSet(a, k, t1.$index(a, less)); + t1.$indexSet(a, less, ak); + } + ++less; + } else if (compare.call$2(ak, el4) === 0) + for (; true;) + if (compare.call$2(t1.$index(a, great), el4) === 0) { + --great; + if (great < k) + break; + continue; + } else { + great0 = great - 1; + if (compare.call$2(t1.$index(a, great), el2) < 0) { + t1.$indexSet(a, k, t1.$index(a, less)); + less0 = less + 1; + t1.$indexSet(a, less, t1.$index(a, great)); + t1.$indexSet(a, great, ak); + less = less0; + } else { + t1.$indexSet(a, k, t1.$index(a, great)); + t1.$indexSet(a, great, ak); + } + great = great0; + break; + } + } + H.Sort__doSort(a, less, great, compare, $E); + } else + H.Sort__doSort(a, less, great, compare, $E); + }, LateError: function LateError(t0) { this._message = t0; }, @@ -2861,6 +3107,10 @@ list.fixed$length = Array; return list; }, + JSArray__compareAny: function (a, b) { + var t1 = type$.Comparable_dynamic; + return J.compareTo$1$ns(t1._as(a), t1._as(b)); + }, getInterceptor$: function (receiver) { if (typeof receiver == "number") { if (Math.floor(receiver) == receiver) @@ -2914,6 +3164,17 @@ return receiver; return J.getNativeInterceptor(receiver); }, + getInterceptor$ns: function (receiver) { + if (typeof receiver == "number") + return J.JSNumber.prototype; + if (typeof receiver == "string") + return J.JSString.prototype; + if (receiver == null) + return receiver; + if (!(receiver instanceof P.Object)) + return J.UnknownJavaScriptObject.prototype; + return receiver; + }, getInterceptor$x: function (receiver) { if (receiver == null) return receiver; @@ -2945,6 +3206,9 @@ addEventListener$2$x: function (receiver, a0, a1) { return J.getInterceptor$x(receiver).addEventListener$2(receiver, a0, a1); }, + compareTo$1$ns: function (receiver, a0) { + return J.getInterceptor$ns(receiver).compareTo$1(receiver, a0); + }, elementAt$1$ax: function (receiver, a0) { return J.getInterceptor$ax(receiver).elementAt$1(receiver, a0); }, @@ -4281,7 +4545,7 @@ return P._asyncStartSync($async$a_run, $async$completer); }, main: function () { - var reg_exp, t1, t2, t3, comment, e, ctx, t4, double_list, t5, range, index, test_map, tr, td, plist, pbody, p, a, i, b, + var reg_exp, t1, t2, t3, comment, e, ctx, t4, double_list, string_list, t5, range, index, test_map, tr, td, plist, pbody, p, a, i, b, _s13_ = "Hello, World!", _s1_ = "b"; P.print(V.test_list("abc")); @@ -4310,6 +4574,10 @@ H.checkTypeBound(t4, t4, "T", "querySelectorAll"); t4 = t1.querySelectorAll("div"); double_list = H.setRuntimeTypeInfo([1, 2, 3, 5, 5.002], type$.JSArray_double); + C.JSArray_methods.sort$0(double_list); + string_list = H.setRuntimeTypeInfo(["a", "b", "c"], type$.JSArray_String); + C.JSArray_methods.sort$0(string_list); + P.print(string_list); P.RangeError_checkValidRange(0, 2, double_list.length); t5 = type$.double; P.print(H.SubListIterable$(double_list, 0, 2, t5).toList$0(0)); @@ -4519,6 +4787,11 @@ return H.ioore(receiver, index); return receiver[index]; }, + sort$0: function (receiver) { + if (!!receiver.immutable$list) + H.throwExpression(P.UnsupportedError$("sort")); + H.Sort_sort(receiver, J._interceptors_JSArray__compareAny$closure(), H._arrayInstanceType(receiver)._precomputed1); + }, toString$0: function (receiver) { return P.IterableBase_iterableToFullString(receiver, "[", "]"); }, @@ -4540,7 +4813,7 @@ H._arrayInstanceType(receiver)._precomputed1._as(value); if (!!receiver.immutable$list) H.throwExpression(P.UnsupportedError$("indexed set")); - if (index >= receiver.length || false) + if (index >= receiver.length || index < 0) throw H.wrapException(H.diagnoseIndexError(receiver, index)); receiver[index] = value; }, @@ -4573,6 +4846,33 @@ $isIterator: 1 }; J.JSNumber.prototype = { + compareTo$1: function (receiver, b) { + var bIsNegative; + H._asNum(b); + if (receiver < b) + return -1; + else if (receiver > b) + return 1; + else if (receiver === b) { + if (receiver === 0) { + bIsNegative = this.get$isNegative(b); + if (this.get$isNegative(receiver) === bIsNegative) + return 0; + if (this.get$isNegative(receiver)) + return -1; + return 1; + } + return 0; + } else if (isNaN(receiver)) { + if (isNaN(b)) + return 0; + return 1; + } else + return -1; + }, + get$isNegative: function (receiver) { + return receiver === 0 ? 1 / receiver < 0 : receiver < 0; + }, toString$0: function (receiver) { if (receiver === 0 && 1 / receiver < 0) return "-0.0"; @@ -4617,6 +4917,7 @@ _shrBothPositive$1: function (receiver, other) { return other > 31 ? 0 : receiver >>> other; }, + $isComparable: 1, $isdouble: 1, $isnum: 1 }; @@ -4637,6 +4938,15 @@ throw H.wrapException(P.RangeError$value(endIndex, null)); return receiver.substring(startIndex, endIndex); }, + compareTo$1: function (receiver, other) { + var t1; + H._asString(other); + if (receiver === other) + t1 = 0; + else + t1 = receiver < other ? -1 : 1; + return t1; + }, toString$0: function (receiver) { return receiver; }, @@ -4654,6 +4964,7 @@ get$length: function (receiver) { return receiver.length; }, + $isComparable: 1, $isString: 1 }; H.LateError.prototype = { @@ -5305,10 +5616,23 @@ H._checkValidIndex(index, receiver, receiver.length); return receiver[index]; }, + $indexSet: function (receiver, index, value) { + H._asDouble(value); + H._checkValidIndex(index, receiver, receiver.length); + receiver[index] = value; + }, + $isIterable: 1, + $isList: 1 + }; + H.NativeTypedArrayOfInt.prototype = { + $indexSet: function (receiver, index, value) { + H._asInt(value); + H._checkValidIndex(index, receiver, receiver.length); + receiver[index] = value; + }, $isIterable: 1, $isList: 1 }; - H.NativeTypedArrayOfInt.prototype = { $isIterable: 1, $isList: 1 }; H.NativeInt16List.prototype = { $index: function (receiver, index) { H._checkValidIndex(index, receiver, receiver.length); @@ -5951,6 +6275,9 @@ return false; return other instanceof P.DateTime && this._value === other._value && true; }, + compareTo$1: function (_, other) { + return C.JSInt_methods.compareTo$1(this._value, type$.DateTime._as(other)._value); + }, get$hashCode: function (_) { var t1 = this._value; return (t1 ^ C.JSInt_methods._shrOtherPositive$1(t1, 30)) & 1073741823; @@ -5966,7 +6293,8 @@ ms = P.DateTime__threeDigits(H.Primitives_getMilliseconds(_this)), t1 = y + "-" + m + "-" + d + " " + h + ":" + min + ":" + sec + "." + ms; return t1; - } + }, + $isComparable: 1 }; P.Duration.prototype = { $eq: function (_, other) { @@ -5977,6 +6305,9 @@ get$hashCode: function (_) { return C.JSInt_methods.get$hashCode(this._duration); }, + compareTo$1: function (_, other) { + return C.JSInt_methods.compareTo$1(this._duration, type$.Duration._as(other)._duration); + }, toString$0: function (_) { var twoDigitMinutes, twoDigitSeconds, sixDigitUs, t1 = new P.Duration_toString_twoDigits(), @@ -5987,7 +6318,8 @@ twoDigitSeconds = t1.call$1(C.JSInt_methods._tdivFast$1(t2, 1000000) % 60); sixDigitUs = new P.Duration_toString_sixDigits().call$1(t2 % 1000000); return "" + C.JSInt_methods._tdivFast$1(t2, 3600000000) + ":" + twoDigitMinutes + ":" + twoDigitSeconds + "." + sixDigitUs; - } + }, + $isComparable: 1 }; P.Duration_toString_sixDigits.prototype = { call$1: function (n) { @@ -6296,6 +6628,10 @@ if (index < 0 || index >= t1.length) return H.ioore(t1, index); return this.$ti._precomputed1._as(t1[index]); + }, + $indexSet: function (_, index, value) { + this.$ti._precomputed1._as(value); + throw H.wrapException(P.UnsupportedError$("Cannot modify list")); } }; W.Element.prototype = { @@ -6339,6 +6675,10 @@ throw H.wrapException(P.IndexError$(index, receiver, null, null, null)); return receiver[index]; }, + $indexSet: function (receiver, index, value) { + type$.Node._as(value); + throw H.wrapException(P.UnsupportedError$("Cannot assign element of immutable List.")); + }, elementAt$1: function (receiver, index) { if (index < 0 || index >= receiver.length) return H.ioore(receiver, index); @@ -6553,6 +6893,11 @@ $index: function (_, property) { return P._convertToDart(this._jsObject[property]); }, + $indexSet: function (_, property, value) { + if (typeof property != "string" && typeof property != "number") + throw H.wrapException(P.ArgumentError$("property is not a String or num")); + this._jsObject[property] = P._convertToJS(value); + }, $eq: function (_, other) { if (other == null) return false; @@ -6596,6 +6941,10 @@ this._checkIndex$1(index); return this.$ti._precomputed1._as(this.super$JsObject$$index(0, index)); }, + $indexSet: function (_, index, value) { + this._checkIndex$1(index); + this.super$_JsArray_JsObject_ListMixin$$indexSet(0, index, value); + }, get$length: function (_) { var len = this._jsObject.length; if (typeof len === "number" && len >>> 0 === len) @@ -6605,7 +6954,11 @@ $isIterable: 1, $isList: 1 }; - P._JsArray_JsObject_ListMixin.prototype = {}; + P._JsArray_JsObject_ListMixin.prototype = { + $indexSet: function (_, property, value) { + return this.super$JsObject$$indexSet(0, property, value); + } + }; V.main_closure.prototype = { call$1: function ($event) { type$.Event._as($event); @@ -6664,16 +7017,21 @@ _.super$Object$toString = _.toString$0; _ = P.JsObject.prototype; _.super$JsObject$$index = _.$index; + _.super$JsObject$$indexSet = _.$indexSet; + _ = P._JsArray_JsObject_ListMixin.prototype; + _.super$_JsArray_JsObject_ListMixin$$indexSet = _.$indexSet; })(); (function installTearOffs() { - var _static_1 = hunkHelpers._static_1, + var _static_2 = hunkHelpers._static_2, + _static_1 = hunkHelpers._static_1, _static_0 = hunkHelpers._static_0; + _static_2(J, "_interceptors_JSArray__compareAny$closure", "JSArray__compareAny", 25); _static_1(P, "async__AsyncRun__scheduleImmediateJsOverride$closure", "_AsyncRun__scheduleImmediateJsOverride", 4); _static_1(P, "async__AsyncRun__scheduleImmediateWithSetImmediate$closure", "_AsyncRun__scheduleImmediateWithSetImmediate", 4); _static_1(P, "async__AsyncRun__scheduleImmediateWithTimer$closure", "_AsyncRun__scheduleImmediateWithTimer", 4); _static_0(P, "async___startMicrotaskLoop$closure", "_startMicrotaskLoop", 0); - _static_1(P, "js___convertToJS$closure", "_convertToJS", 25); - _static_1(P, "js___convertToDart$closure", "_convertToDart", 26); + _static_1(P, "js___convertToJS$closure", "_convertToJS", 26); + _static_1(P, "js___convertToDart$closure", "_convertToDart", 27); })(); (function inheritance() { var _mixin = hunkHelpers.mixin, @@ -6742,12 +7100,12 @@ mangledNames: {}, getTypeFromName: getGlobalFromName, metadata: [], - types: ["~()", "Null()", "@(@)", "Null(@)", "~(~())", "String(int)", "Null(Event)", "~(String,@)", "@(@,String)", "@(String)", "Null(~())", "~(@)", "Null(@,StackTrace)", "~(int,@)", "Null(Object,StackTrace)", "_Future<@>(@)", "~(Object?,Object?)", "~(Symbol0,@)", "~(@,@)", "Null(@,@)", "JsFunction(@)", "JsArray<@>(@)", "JsObject(@)", "~(double)", "~(String,int)", "Object?(Object?)", "Object?(@)"], + types: ["~()", "Null()", "@(@)", "Null(@)", "~(~())", "String(int)", "Null(Event)", "~(String,@)", "@(@,String)", "@(String)", "Null(~())", "~(@)", "Null(@,StackTrace)", "~(int,@)", "Null(Object,StackTrace)", "_Future<@>(@)", "~(Object?,Object?)", "~(Symbol0,@)", "~(@,@)", "Null(@,@)", "JsFunction(@)", "JsArray<@>(@)", "JsObject(@)", "~(double)", "~(String,int)", "int(@,@)", "Object?(Object?)", "Object?(@)"], interceptorsByTag: null, leafTags: null, arrayRti: typeof Symbol == "function" && typeof Symbol() == "symbol" ? Symbol("$ti") : "$ti" }; - H._Universe_addRules(init.typeUniverse, JSON.parse('{"PlainJavaScriptObject":"JavaScriptObject","UnknownJavaScriptObject":"JavaScriptObject","JavaScriptFunction":"JavaScriptObject","AbortPaymentEvent":"Event","ExtendableEvent":"Event","AElement":"Element","GraphicsElement":"Element","SvgElement":"Element","AudioElement":"HtmlElement","MediaElement":"HtmlElement","HtmlDocument":"Node","Document":"Node","DedicatedWorkerGlobalScope":"WorkerGlobalScope","CDataSection":"CharacterData","Text":"CharacterData","NativeFloat32List":"NativeTypedArrayOfDouble","NativeByteData":"NativeTypedData","JSBool":{"bool":[]},"JSNull":{"Null":[]},"JavaScriptObject":{"JSObject":[],"Function":[]},"JSArray":{"List":["1"],"Iterable":["1"]},"JSUnmodifiableArray":{"JSArray":["1"],"List":["1"],"Iterable":["1"]},"ArrayIterator":{"Iterator":["1"]},"JSNumber":{"double":[],"num":[]},"JSInt":{"double":[],"int":[],"num":[]},"JSDouble":{"double":[],"num":[]},"JSString":{"String":[]},"LateError":{"Error":[]},"EfficientLengthIterable":{"Iterable":["1"]},"ListIterable":{"Iterable":["1"]},"SubListIterable":{"ListIterable":["1"],"Iterable":["1"],"Iterable.E":"1","ListIterable.E":"1"},"ListIterator":{"Iterator":["1"]},"MappedIterable":{"Iterable":["2"],"Iterable.E":"2"},"EfficientLengthMappedIterable":{"MappedIterable":["1","2"],"Iterable":["2"],"Iterable.E":"2"},"MappedIterator":{"Iterator":["2"]},"MappedListIterable":{"ListIterable":["2"],"Iterable":["2"],"Iterable.E":"2","ListIterable.E":"2"},"Symbol":{"Symbol0":[]},"ConstantMapView":{"UnmodifiableMapView":["1","2"],"_UnmodifiableMapView_MapView__UnmodifiableMapMixin":["1","2"],"MapView":["1","2"],"_UnmodifiableMapMixin":["1","2"],"Map":["1","2"]},"ConstantMap":{"Map":["1","2"]},"ConstantStringMap":{"ConstantMap":["1","2"],"Map":["1","2"]},"JSInvocationMirror":{"Invocation":[]},"NullError":{"Error":[]},"JsNoSuchMethodError":{"Error":[]},"UnknownJsTypeError":{"Error":[]},"_StackTrace":{"StackTrace":[]},"Closure":{"Function":[]},"TearOffClosure":{"Function":[]},"StaticClosure":{"Function":[]},"BoundClosure":{"Function":[]},"RuntimeError":{"Error":[]},"_AssertionError":{"Error":[]},"JsLinkedHashMap":{"MapMixin":["1","2"],"LinkedHashMap":["1","2"],"Map":["1","2"]},"LinkedHashMapKeyIterable":{"Iterable":["1"],"Iterable.E":"1"},"LinkedHashMapKeyIterator":{"Iterator":["1"]},"JSSyntaxRegExp":{"RegExp":[]},"NativeTypedData":{"TypedData":[]},"NativeTypedArray":{"JavaScriptIndexingBehavior":["1"],"NativeTypedData":[],"TypedData":[]},"NativeTypedArrayOfDouble":{"ListMixin":["double"],"JavaScriptIndexingBehavior":["double"],"List":["double"],"NativeTypedData":[],"TypedData":[],"Iterable":["double"],"FixedLengthListMixin":["double"],"ListMixin.E":"double"},"NativeTypedArrayOfInt":{"ListMixin":["int"],"JavaScriptIndexingBehavior":["int"],"List":["int"],"NativeTypedData":[],"TypedData":[],"Iterable":["int"],"FixedLengthListMixin":["int"]},"NativeInt16List":{"ListMixin":["int"],"JavaScriptIndexingBehavior":["int"],"List":["int"],"NativeTypedData":[],"TypedData":[],"Iterable":["int"],"FixedLengthListMixin":["int"],"ListMixin.E":"int"},"NativeInt32List":{"ListMixin":["int"],"JavaScriptIndexingBehavior":["int"],"List":["int"],"NativeTypedData":[],"TypedData":[],"Iterable":["int"],"FixedLengthListMixin":["int"],"ListMixin.E":"int"},"NativeInt8List":{"ListMixin":["int"],"JavaScriptIndexingBehavior":["int"],"List":["int"],"NativeTypedData":[],"TypedData":[],"Iterable":["int"],"FixedLengthListMixin":["int"],"ListMixin.E":"int"},"NativeUint16List":{"ListMixin":["int"],"JavaScriptIndexingBehavior":["int"],"List":["int"],"NativeTypedData":[],"TypedData":[],"Iterable":["int"],"FixedLengthListMixin":["int"],"ListMixin.E":"int"},"NativeUint32List":{"ListMixin":["int"],"JavaScriptIndexingBehavior":["int"],"List":["int"],"NativeTypedData":[],"TypedData":[],"Iterable":["int"],"FixedLengthListMixin":["int"],"ListMixin.E":"int"},"NativeUint8ClampedList":{"ListMixin":["int"],"JavaScriptIndexingBehavior":["int"],"List":["int"],"NativeTypedData":[],"TypedData":[],"Iterable":["int"],"FixedLengthListMixin":["int"],"ListMixin.E":"int"},"NativeUint8List":{"ListMixin":["int"],"JavaScriptIndexingBehavior":["int"],"List":["int"],"NativeTypedData":[],"TypedData":[],"Iterable":["int"],"FixedLengthListMixin":["int"],"ListMixin.E":"int"},"_Error":{"Error":[]},"_TypeError":{"Error":[]},"AsyncError":{"Error":[]},"_Future":{"Future":["1"]},"_Zone":{"Zone":[]},"_RootZone":{"_Zone":[],"Zone":[]},"ListBase":{"ListMixin":["1"],"List":["1"],"Iterable":["1"]},"MapBase":{"MapMixin":["1","2"],"Map":["1","2"]},"MapMixin":{"Map":["1","2"]},"MapView":{"Map":["1","2"]},"UnmodifiableMapView":{"_UnmodifiableMapView_MapView__UnmodifiableMapMixin":["1","2"],"MapView":["1","2"],"_UnmodifiableMapMixin":["1","2"],"Map":["1","2"]},"double":{"num":[]},"int":{"num":[]},"AssertionError":{"Error":[]},"TypeError":{"Error":[]},"NullThrownError":{"Error":[]},"ArgumentError":{"Error":[]},"RangeError":{"Error":[]},"IndexError":{"Error":[]},"NoSuchMethodError":{"Error":[]},"UnsupportedError":{"Error":[]},"UnimplementedError":{"Error":[]},"StateError":{"Error":[]},"ConcurrentModificationError":{"Error":[]},"StackOverflowError":{"Error":[]},"CyclicInitializationError":{"Error":[]},"_StringStackTrace":{"StackTrace":[]},"HtmlElement":{"Element":[],"Node":[]},"AnchorElement":{"Element":[],"Node":[]},"AreaElement":{"Element":[],"Node":[]},"CanvasElement":{"Element":[],"Node":[]},"CharacterData":{"Node":[]},"Comment":{"Node":[]},"DivElement":{"Element":[],"Node":[]},"_FrozenElementList":{"ListMixin":["1"],"List":["1"],"Iterable":["1"],"ListMixin.E":"1"},"Element":{"Node":[]},"File":{"Blob":[]},"FormElement":{"Element":[],"Node":[]},"NodeList":{"ListMixin":["Node"],"ImmutableListMixin":["Node"],"List":["Node"],"JavaScriptIndexingBehavior":["Node"],"Iterable":["Node"],"ListMixin.E":"Node","ImmutableListMixin.E":"Node"},"SelectElement":{"Element":[],"Node":[]},"TableCellElement":{"Element":[],"Node":[]},"Window":{"WindowBase":[]},"FixedSizeListIterator":{"Iterator":["1"]},"_DOMWindowCrossFrame":{"WindowBase":[]},"JsArray":{"ListMixin":["1"],"List":["1"],"Iterable":["1"],"ListMixin.E":"1"}}')); + H._Universe_addRules(init.typeUniverse, JSON.parse('{"PlainJavaScriptObject":"JavaScriptObject","UnknownJavaScriptObject":"JavaScriptObject","JavaScriptFunction":"JavaScriptObject","AbortPaymentEvent":"Event","ExtendableEvent":"Event","AElement":"Element","GraphicsElement":"Element","SvgElement":"Element","AudioElement":"HtmlElement","MediaElement":"HtmlElement","HtmlDocument":"Node","Document":"Node","DedicatedWorkerGlobalScope":"WorkerGlobalScope","CDataSection":"CharacterData","Text":"CharacterData","NativeFloat32List":"NativeTypedArrayOfDouble","NativeByteData":"NativeTypedData","JSBool":{"bool":[]},"JSNull":{"Null":[]},"JavaScriptObject":{"JSObject":[],"Function":[]},"JSArray":{"List":["1"],"Iterable":["1"]},"JSUnmodifiableArray":{"JSArray":["1"],"List":["1"],"Iterable":["1"]},"ArrayIterator":{"Iterator":["1"]},"JSNumber":{"double":[],"num":[],"Comparable":["num"]},"JSInt":{"double":[],"int":[],"num":[],"Comparable":["num"]},"JSDouble":{"double":[],"num":[],"Comparable":["num"]},"JSString":{"String":[],"Comparable":["String"]},"LateError":{"Error":[]},"EfficientLengthIterable":{"Iterable":["1"]},"ListIterable":{"Iterable":["1"]},"SubListIterable":{"ListIterable":["1"],"Iterable":["1"],"Iterable.E":"1","ListIterable.E":"1"},"ListIterator":{"Iterator":["1"]},"MappedIterable":{"Iterable":["2"],"Iterable.E":"2"},"EfficientLengthMappedIterable":{"MappedIterable":["1","2"],"Iterable":["2"],"Iterable.E":"2"},"MappedIterator":{"Iterator":["2"]},"MappedListIterable":{"ListIterable":["2"],"Iterable":["2"],"Iterable.E":"2","ListIterable.E":"2"},"Symbol":{"Symbol0":[]},"ConstantMapView":{"UnmodifiableMapView":["1","2"],"_UnmodifiableMapView_MapView__UnmodifiableMapMixin":["1","2"],"MapView":["1","2"],"_UnmodifiableMapMixin":["1","2"],"Map":["1","2"]},"ConstantMap":{"Map":["1","2"]},"ConstantStringMap":{"ConstantMap":["1","2"],"Map":["1","2"]},"JSInvocationMirror":{"Invocation":[]},"NullError":{"Error":[]},"JsNoSuchMethodError":{"Error":[]},"UnknownJsTypeError":{"Error":[]},"_StackTrace":{"StackTrace":[]},"Closure":{"Function":[]},"TearOffClosure":{"Function":[]},"StaticClosure":{"Function":[]},"BoundClosure":{"Function":[]},"RuntimeError":{"Error":[]},"_AssertionError":{"Error":[]},"JsLinkedHashMap":{"MapMixin":["1","2"],"LinkedHashMap":["1","2"],"Map":["1","2"]},"LinkedHashMapKeyIterable":{"Iterable":["1"],"Iterable.E":"1"},"LinkedHashMapKeyIterator":{"Iterator":["1"]},"JSSyntaxRegExp":{"RegExp":[]},"NativeTypedData":{"TypedData":[]},"NativeTypedArray":{"JavaScriptIndexingBehavior":["1"],"NativeTypedData":[],"TypedData":[]},"NativeTypedArrayOfDouble":{"ListMixin":["double"],"JavaScriptIndexingBehavior":["double"],"List":["double"],"NativeTypedData":[],"TypedData":[],"Iterable":["double"],"FixedLengthListMixin":["double"],"ListMixin.E":"double"},"NativeTypedArrayOfInt":{"ListMixin":["int"],"JavaScriptIndexingBehavior":["int"],"List":["int"],"NativeTypedData":[],"TypedData":[],"Iterable":["int"],"FixedLengthListMixin":["int"]},"NativeInt16List":{"ListMixin":["int"],"JavaScriptIndexingBehavior":["int"],"List":["int"],"NativeTypedData":[],"TypedData":[],"Iterable":["int"],"FixedLengthListMixin":["int"],"ListMixin.E":"int"},"NativeInt32List":{"ListMixin":["int"],"JavaScriptIndexingBehavior":["int"],"List":["int"],"NativeTypedData":[],"TypedData":[],"Iterable":["int"],"FixedLengthListMixin":["int"],"ListMixin.E":"int"},"NativeInt8List":{"ListMixin":["int"],"JavaScriptIndexingBehavior":["int"],"List":["int"],"NativeTypedData":[],"TypedData":[],"Iterable":["int"],"FixedLengthListMixin":["int"],"ListMixin.E":"int"},"NativeUint16List":{"ListMixin":["int"],"JavaScriptIndexingBehavior":["int"],"List":["int"],"NativeTypedData":[],"TypedData":[],"Iterable":["int"],"FixedLengthListMixin":["int"],"ListMixin.E":"int"},"NativeUint32List":{"ListMixin":["int"],"JavaScriptIndexingBehavior":["int"],"List":["int"],"NativeTypedData":[],"TypedData":[],"Iterable":["int"],"FixedLengthListMixin":["int"],"ListMixin.E":"int"},"NativeUint8ClampedList":{"ListMixin":["int"],"JavaScriptIndexingBehavior":["int"],"List":["int"],"NativeTypedData":[],"TypedData":[],"Iterable":["int"],"FixedLengthListMixin":["int"],"ListMixin.E":"int"},"NativeUint8List":{"ListMixin":["int"],"JavaScriptIndexingBehavior":["int"],"List":["int"],"NativeTypedData":[],"TypedData":[],"Iterable":["int"],"FixedLengthListMixin":["int"],"ListMixin.E":"int"},"_Error":{"Error":[]},"_TypeError":{"Error":[]},"AsyncError":{"Error":[]},"_Future":{"Future":["1"]},"_Zone":{"Zone":[]},"_RootZone":{"_Zone":[],"Zone":[]},"ListBase":{"ListMixin":["1"],"List":["1"],"Iterable":["1"]},"MapBase":{"MapMixin":["1","2"],"Map":["1","2"]},"MapMixin":{"Map":["1","2"]},"MapView":{"Map":["1","2"]},"UnmodifiableMapView":{"_UnmodifiableMapView_MapView__UnmodifiableMapMixin":["1","2"],"MapView":["1","2"],"_UnmodifiableMapMixin":["1","2"],"Map":["1","2"]},"double":{"num":[],"Comparable":["num"]},"int":{"num":[],"Comparable":["num"]},"num":{"Comparable":["num"]},"String":{"Comparable":["String"]},"DateTime":{"Comparable":["DateTime"]},"Duration":{"Comparable":["Duration"]},"AssertionError":{"Error":[]},"TypeError":{"Error":[]},"NullThrownError":{"Error":[]},"ArgumentError":{"Error":[]},"RangeError":{"Error":[]},"IndexError":{"Error":[]},"NoSuchMethodError":{"Error":[]},"UnsupportedError":{"Error":[]},"UnimplementedError":{"Error":[]},"StateError":{"Error":[]},"ConcurrentModificationError":{"Error":[]},"StackOverflowError":{"Error":[]},"CyclicInitializationError":{"Error":[]},"_StringStackTrace":{"StackTrace":[]},"HtmlElement":{"Element":[],"Node":[]},"AnchorElement":{"Element":[],"Node":[]},"AreaElement":{"Element":[],"Node":[]},"CanvasElement":{"Element":[],"Node":[]},"CharacterData":{"Node":[]},"Comment":{"Node":[]},"DivElement":{"Element":[],"Node":[]},"_FrozenElementList":{"ListMixin":["1"],"List":["1"],"Iterable":["1"],"ListMixin.E":"1"},"Element":{"Node":[]},"File":{"Blob":[]},"FormElement":{"Element":[],"Node":[]},"NodeList":{"ListMixin":["Node"],"ImmutableListMixin":["Node"],"List":["Node"],"JavaScriptIndexingBehavior":["Node"],"Iterable":["Node"],"ListMixin.E":"Node","ImmutableListMixin.E":"Node"},"SelectElement":{"Element":[],"Node":[]},"TableCellElement":{"Element":[],"Node":[]},"Window":{"WindowBase":[]},"FixedSizeListIterator":{"Iterator":["1"]},"_DOMWindowCrossFrame":{"WindowBase":[]},"JsArray":{"ListMixin":["1"],"List":["1"],"Iterable":["1"],"ListMixin.E":"1"}}')); H._Universe_addErasedTypes(init.typeUniverse, JSON.parse('{"EfficientLengthIterable":1,"NativeTypedArray":1,"ListBase":1,"MapBase":2,"_ListBase_Object_ListMixin":1,"_JsArray_JsObject_ListMixin":1}')); 0; var type$ = (function rtii() { @@ -6756,8 +7114,11 @@ AsyncError: findType("AsyncError"), Blob: findType("Blob"), CanvasRenderingContext2D: findType("CanvasRenderingContext2D"), + Comparable_dynamic: findType("Comparable<@>"), ConstantMapView_Symbol_dynamic: findType("ConstantMapView"), + DateTime: findType("DateTime"), DivElement: findType("DivElement"), + Duration: findType("Duration"), Element: findType("Element"), Error: findType("Error"), Event: findType("Event"), diff --git a/dart-js/test.dart b/dart-js/test.dart index 05231ad..2566212 100644 --- a/dart-js/test.dart +++ b/dart-js/test.dart @@ -136,6 +136,14 @@ void main() { List double_list = [1.0, 2.0, 3.0, 5.0, 5.002]; + double_list.sort(); + + List string_list = ["a", "b", "c"]; + + string_list.sort(); + + print(string_list); + // range in list print(double_list.getRange(0, 2).toList());