Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Minesweeper implementation in Dart
library minesweeper;
class Minesweeper {
int width;
int height;
List<String> _lines;
Minesweeper (){
width = 0;
height = 0;
}
Minesweeper.fromGrid(String grid) {
var lines = grid.split('\n');
var dimensions = lines[0].split(' ');
width = int.parse(dimensions[0]);
height = int.parse(dimensions[1]);
_lines = lines.getRange(1, lines.length -1);
}
bool isBomb (x, y){
if (x < 0 || x >= width || y < 0 || y >= height){
return false;
}
return _lines[y][x] == "*";
}
int countBomb(x,y) {
int result = 0;
for(var xx = x -1 ; xx <= x+1; ++xx) {
for(var yy = y -1 ; yy <= y+1; ++yy) {
if(isBomb(xx, yy)) {
result++;
}
}
}
return result;
}
String get solution {
var result = "";
for (var y=0; y < height; y++){
for (var x=0; x < width; x++){
result = "$result${isBomb(x,y) ? "*" : countBomb(x,y)}";
}
result = "$result\n";
}
return result;
}
}
import "packages/unittest/unittest.dart";
import "minesweeper.dart";
main (){
group ("Minesweeper", (){
test ("Should be instantiable with with and height", (){
Minesweeper minesweeper = new Minesweeper ();
expect (minesweeper.width, 0);
expect (minesweeper.height, 0);
});
Minesweeper minesweeper = new Minesweeper.fromGrid ("""
4 2
.*..
*...
""");
test ("Should be instantiable with a grid", (){
expect (minesweeper.width, 4);
expect (minesweeper.height, 2);
});
test("Should detect a bomb", () {
expect(minesweeper.isBomb(0,0), false);
expect(minesweeper.isBomb(1,0), true);
expect(minesweeper.isBomb(-1,0), false);
});
test("Should count the number of bomb", () {
expect(minesweeper.countBomb(0,0),2);
expect(minesweeper.countBomb(3,1),0);
});
test("Should render correctly the grid", () {
expect(minesweeper.solution, """
2*10
*210
""");
});
});
}
// Generated by dart2js, the Dart to JavaScript compiler.
// The code supports the following hooks:
// dartPrint(message) - if this function is defined it is called
// instead of the Dart [print] method.
// dartMainRunner(main) - if this function is defined, the Dart [main]
// method will not be invoked directly.
// Instead, a closure that will invoke [main] is
// passed to [dartMainRunner].
function Isolate() {}
init();
var $$ = {};
var $ = Isolate.$isolateProperties;
$$.DartError = {"": "Object;",
get$stack: function() {
return this.stack;
},
toString$0: function() {
var dartException = this.dartException;
if (!!Error.captureStackTrace || this.get$stack() == null)
return $.toString(dartException);
else
return $.S(dartException) + "\n" + $.S(this.get$stack());
},
DartError$1: function(dartException) {
this.dartException = dartException;
this.toString = $.DartError_toStringWrapper.call$0;
}
};
$$.StackTrace = {"": "Object;stack",
toString$0: function() {
var t1 = this.stack;
return !(t1 == null) ? t1 : "";
}
};
$$.Closure = {"": "Object;",
toString$0: function() {
return "Closure";
},
$isFunction: true
};
$$.Null = {"": "Object;"};
$$.MetaInfo = {"": "Object;_tag>,_tags,_set>"};
$$.JSSyntaxRegExp = {"": "Object;_liblib0$_pattern,_isMultiLine,_isCaseSensitive",
hasMatch$1: function(str) {
return $.regExpTest(this, $.checkString(str));
},
get$pattern: function() {
return this._liblib0$_pattern;
},
get$isMultiLine: function() {
return this._isMultiLine;
},
get$isCaseSensitive: function() {
return this._isCaseSensitive;
},
$isRegExp: true
};
$$.JsStringBuffer = {"": "Object;_contents",
get$length: function() {
return $.length(this._contents);
},
get$isEmpty: function() {
return $.$$eq($.length(this), 0);
},
add$1: function(obj) {
var t1, t2;
if (typeof obj !== "string")
return this.add$1$bailout(1, obj);
t1 = this._contents;
t2 = obj;
this._contents = t1 + t2;
},
add$1$bailout: function(state0, obj) {
var t1, t2;
t1 = this._contents;
t2 = typeof obj === "string" ? obj : $.S(obj);
this._contents = t1 + t2;
},
toString$0: function() {
return this._contents;
}
};
$$.Collection = {"": "Iterable;", $isCollection: true};
$$.DateTime = {"": "Object;millisecondsSinceEpoch>,isUtc",
$eq: function(other) {
if (other == null)
return false;
if (!(typeof other === "object" && other !== null && !!other.$isDateTime))
return false;
return $.$$eq(this.millisecondsSinceEpoch, other.millisecondsSinceEpoch);
},
$lt: function(other) {
var t1, t3;
t1 = this.millisecondsSinceEpoch;
t3 = other.get$millisecondsSinceEpoch();
if (typeof t1 !== "number")
return this.$$lt$bailout(1, other, t1);
if (typeof t3 !== "number")
return this.$$lt$bailout(2, null, t1, t3);
return t1 < t3;
},
$$lt$bailout: function(state0, other, t1, t3) {
switch (state0) {
case 0:
t1 = this.millisecondsSinceEpoch;
case 1:
state0 = 0;
t3 = other.get$millisecondsSinceEpoch();
case 2:
state0 = 0;
return $.$$lt(t1, t3);
}
},
$gt: function(other) {
var t1, t3;
t1 = this.millisecondsSinceEpoch;
t3 = other.get$millisecondsSinceEpoch();
if (typeof t1 !== "number")
return this.$$gt$bailout(1, other, t1);
if (typeof t3 !== "number")
return this.$$gt$bailout(2, null, t1, t3);
return t1 > t3;
},
$$gt$bailout: function(state0, other, t1, t3) {
switch (state0) {
case 0:
t1 = this.millisecondsSinceEpoch;
case 1:
state0 = 0;
t3 = other.get$millisecondsSinceEpoch();
case 2:
state0 = 0;
return $.$$gt(t1, t3);
}
},
$ge: function(other) {
return $.$$ge(this.millisecondsSinceEpoch, other.get$millisecondsSinceEpoch());
},
get$hashCode: function() {
return this.millisecondsSinceEpoch;
},
toString$0: function() {
var t1, t2, t3, y, m, d, h, min, sec, ms;
t1 = new $.DateTime_toString_fourDigits();
t2 = new $.DateTime_toString_threeDigits();
t3 = new $.DateTime_toString_twoDigits();
y = t1.call$1(this.get$year());
m = t3.call$1(this.get$month());
d = t3.call$1(this.get$day());
h = t3.call$1(this.get$hour());
min = t3.call$1(this.get$minute());
sec = t3.call$1(this.get$second());
ms = t2.call$1(this.get$millisecond());
if (this.isUtc === true)
return $.S(y) + "-" + $.S(m) + "-" + $.S(d) + " " + $.S(h) + ":" + $.S(min) + ":" + $.S(sec) + "." + $.S(ms) + "Z";
else
return $.S(y) + "-" + $.S(m) + "-" + $.S(d) + " " + $.S(h) + ":" + $.S(min) + ":" + $.S(sec) + "." + $.S(ms);
},
add$1: function(duration) {
var ms, t2;
ms = this.millisecondsSinceEpoch;
t2 = duration.get$inMilliseconds();
if (typeof ms !== "number")
return this.add$1$bailout0(1, duration, ms);
if (typeof t2 !== "number")
return this.add$1$bailout0(2, null, ms, t2);
return $.DateTime$fromMillisecondsSinceEpoch(ms + t2, this.isUtc);
},
add$1$bailout0: function(state0, duration, ms, t2) {
switch (state0) {
case 0:
ms = this.millisecondsSinceEpoch;
case 1:
state0 = 0;
t2 = duration.get$inMilliseconds();
case 2:
state0 = 0;
return $.DateTime$fromMillisecondsSinceEpoch($.$$add(ms, t2), this.isUtc);
}
},
get$year: function() {
return $.Primitives_getYear(this);
},
get$month: function() {
return $.Primitives_getMonth(this);
},
get$day: function() {
return $.Primitives_getDay(this);
},
get$hour: function() {
return $.Primitives_getHours(this);
},
get$minute: function() {
return $.Primitives_getMinutes(this);
},
get$second: function() {
return $.Primitives_getSeconds(this);
},
get$millisecond: function() {
return $.Primitives_getMilliseconds(this);
},
DateTime$_now$0: function() {
$.Primitives_lazyAsJsDate(this);
},
DateTime$fromMillisecondsSinceEpoch$2$isUtc: function(millisecondsSinceEpoch, isUtc) {
if ($.$$gt($.abs(millisecondsSinceEpoch), 8640000000000000) === true)
throw $.$$throw($.ArgumentError$(millisecondsSinceEpoch));
if (isUtc == null)
throw $.$$throw($.ArgumentError$(isUtc));
},
$isDateTime: true
};
$$.Duration = {"": "Object;inMilliseconds>",
get$inHours: function() {
return $.$$tdiv(this.inMilliseconds, 3600000);
},
get$inMinutes: function() {
return $.$$tdiv(this.inMilliseconds, 60000);
},
get$inSeconds: function() {
return $.$$tdiv(this.inMilliseconds, 1000);
},
$eq: function(other) {
if (other == null)
return false;
if (!(typeof other === "object" && other !== null && !!other.$isDuration))
return false;
return $.$$eq(this.inMilliseconds, other.inMilliseconds);
},
get$hashCode: function() {
return $.hashCode(this.inMilliseconds);
},
toString$0: function() {
var t1, t2, t3, t4, twoDigitMinutes, twoDigitSeconds, threeDigitMs;
t1 = new $.Duration_toString_threeDigits();
t2 = new $.Duration_toString_twoDigits();
t3 = this.inMilliseconds;
t4 = $.getInterceptor$JSNumber(t3);
if (t4.$lt(t3, 0) === true)
return "-" + $.S($.Duration$(0, 0, t4.$negate(t3), 0, 0));
twoDigitMinutes = t2.call$1($.remainder(this.get$inMinutes(), 60));
twoDigitSeconds = t2.call$1($.remainder(this.get$inSeconds(), 60));
threeDigitMs = t1.call$1(t4.remainder$1(t3, 1000));
return $.S(this.get$inHours()) + ":" + $.S(twoDigitMinutes) + ":" + $.S(twoDigitSeconds) + "." + $.S(threeDigitMs);
},
$isDuration: true
};
$$.NullThrownError = {"": "Object;",
toString$0: function() {
return "Throw of null.";
}
};
$$.ArgumentError = {"": "Object;message>",
toString$0: function() {
var t1 = this.message;
if (!(t1 == null))
return "Illegal argument(s): " + $.S(t1);
return "Illegal argument(s)";
}
};
$$.RangeError = {"": "ArgumentError;message",
toString$0: function() {
return "RangeError: " + $.S(this.message);
}
};
$$.NoSuchMethodError = {"": "Object;_receiver,_memberName,_arguments,_namedArguments,_existingArgumentNames",
toString$0: function() {
var t1, t2, t3, t4, i;
t1 = {};
t1.sb_0 = $.StringBuffer_StringBuffer("");
t1.i_1 = 0;
t2 = this._arguments;
if (typeof t2 !== "string" && (typeof t2 !== "object" || t2 === null || t2.constructor !== Array && !t2.$isJavaScriptIndexingBehavior))
return this.toString$0$bailout(1, t1, t2);
for (; $.$$lt(t1.i_1, t2.length) === true; t1.i_1 = $.$$add(t1.i_1, 1)) {
if ($.$$gt(t1.i_1, 0) === true)
$.add(t1.sb_0, ", ");
t3 = t1.sb_0;
t4 = t1.i_1;
if (t4 !== (t4 | 0))
throw $.iae(t4);
if (t4 < 0 || t4 >= t2.length)
throw $.ioore(t4);
$.add(t3, $.Error_safeToString(t2[t4]));
}
t2 = this._namedArguments;
if (!(t2 == null))
$.forEach(t2, new $.NoSuchMethodError_toString_anon(t1));
t2 = this._existingArgumentNames;
if (typeof t2 !== "string" && (typeof t2 !== "object" || t2 === null || t2.constructor !== Array && !t2.$isJavaScriptIndexingBehavior))
return this.toString$0$bailout(2, t1, t2);
t3 = $.toString(t1.sb_0);
t1.sb_0 = $.StringBuffer_StringBuffer("");
for (i = 0; i < t2.length; ++i) {
if (i > 0)
$.add(t1.sb_0, ", ");
t4 = t1.sb_0;
if (i >= t2.length)
throw $.ioore(i);
$.add(t4, t2[i]);
}
t2 = $.toString(t1.sb_0);
t4 = this._memberName;
return "NoSuchMethodError: incorrect number of arguments passed to method named '" + $.S(t4) + "'\n" + "Receiver: " + $.S($.Error_safeToString(this._receiver)) + "\n" + "Tried calling: " + $.S(t4) + "(" + $.S(t3) + ")\n" + "Found: " + $.S(t4) + "(" + $.S(t2) + ")";
},
toString$0$bailout: function(state0, t1, t2) {
switch (state0) {
case 0:
t1 = {};
t1.sb_0 = $.StringBuffer_StringBuffer("");
t1.i_1 = 0;
t2 = this._arguments;
case 1:
state0 = 0;
if (!(t2 == null))
for (t3 = $.getInterceptor$JSStringJSArray(t2); $.$$lt(t1.i_1, t3.get$length(t2)) === true; t1.i_1 = $.$$add(t1.i_1, 1)) {
if ($.$$gt(t1.i_1, 0) === true)
$.add(t1.sb_0, ", ");
$.add(t1.sb_0, $.Error_safeToString(t3.$index(t2, t1.i_1)));
}
t2 = this._namedArguments;
if (!(t2 == null))
$.forEach(t2, new $.NoSuchMethodError_toString_anon(t1));
t2 = this._existingArgumentNames;
case 2:
var t3, t4, i;
state0 = 0;
if (t2 == null)
return "NoSuchMethodError : method not found: '" + $.S(this._memberName) + "'\n" + "Receiver: " + $.S($.Error_safeToString(this._receiver)) + "\n" + "Arguments: [" + $.S(t1.sb_0) + "]";
else {
t3 = $.toString(t1.sb_0);
t1.sb_0 = $.StringBuffer_StringBuffer("");
for (t4 = $.getInterceptor$JSStringJSArray(t2), i = 0; $.CONSTANT2.$lt(i, t4.get$length(t2)); ++i) {
if (i > 0)
$.add(t1.sb_0, ", ");
$.add(t1.sb_0, t4.$index(t2, i));
}
t2 = $.toString(t1.sb_0);
t4 = this._memberName;
return "NoSuchMethodError: incorrect number of arguments passed to method named '" + $.S(t4) + "'\n" + "Receiver: " + $.S($.Error_safeToString(this._receiver)) + "\n" + "Tried calling: " + $.S(t4) + "(" + $.S(t3) + ")\n" + "Found: " + $.S(t4) + "(" + $.S(t2) + ")";
}
}
}
};
$$.UnsupportedError = {"": "Object;message>",
toString$0: function() {
return "Unsupported operation: " + $.S(this.get$message());
}
};
$$.UnimplementedError = {"": "Object;message>",
toString$0: function() {
var t1 = this.message;
return !(t1 == null) ? "UnimplementedError: " + $.S(t1) : "UnimplementedError";
}
};
$$.StateError = {"": "Object;message>",
toString$0: function() {
return "Bad state: " + this.message;
}
};
$$.ConcurrentModificationError = {"": "Object;modifiedObject",
toString$0: function() {
var t1 = this.modifiedObject;
if (t1 == null)
return "Concurrent modification during iteration.";
return "Concurrent modification during iteration: " + $.S($.Error_safeToString(t1)) + ".";
}
};
$$.StackOverflowError = {"": "Object;",
toString$0: function() {
return "Stack Overflow";
}
};
$$.RuntimeError = {"": "Object;message>",
toString$0: function() {
return "RuntimeError: " + this.message;
}
};
$$._ExceptionImplementation = {"": "Object;message>",
toString$0: function() {
var t1 = this.message;
if (t1 == null)
return "Exception";
return "Exception: " + $.S(t1);
},
$isException: true
};
$$.FormatException = {"": "Object;message>",
toString$0: function() {
return "FormatException: " + $.S(this.message);
},
$isException: true
};
$$.IllegalJSRegExpException = {"": "Object;_pattern,_errmsg",
toString$0: function() {
return "IllegalJSRegExpException: '" + $.S(this._pattern) + "' '" + this._errmsg + "'";
},
$isException: true
};
$$.ExpectException = {"": "Object;message>",
toString$0: function() {
return this.message;
},
$isExpectException: true,
$isException: true
};
$$.Iterable = {"": "Object;",
mappedBy$1: function(f) {
return $.MappedIterable$(this, f);
},
where$1: function(f) {
return $.WhereIterable$(this, f);
},
forEach$1: function(f) {
var t1;
for (t1 = $.iterator(this); t1.moveNext$0() === true;)
f.call$1(t1.get$current());
},
toList$0: function() {
return $.List_List$from(this);
},
get$length: function() {
var t1, count;
t1 = $.iterator(this);
for (count = 0; t1.moveNext$0() === true;)
++count;
return count;
},
get$isEmpty: function() {
return $.iterator(this).moveNext$0() !== true;
},
$isIterable: true
};
$$.Iterator = {"": "Object;"};
$$.Object = {"": ";",
$eq: function(other) {
if (other == null)
return false;
return this === other;
},
get$hashCode: function() {
return $.Primitives_objectHashCode(this);
},
toString$0: function() {
return "Instance of '" + $.S($.Primitives_objectTypeName(this)) + "'";
}
};
$$.ObjectInterceptor = {"": "Object;",
toString$0: function(receiver) {
return receiver.toString$0();
},
$eq: function(receiver, a0) {
return receiver.$eq(a0);
},
charCodeAt$1: function(receiver, a0) {
return receiver.charCodeAt$1(a0);
},
get$iterator: function(receiver) {
return receiver.get$iterator();
},
substring$1: function(receiver, a0) {
return receiver.substring$1(a0);
},
$indexSet: function(receiver, a0, a1) {
return receiver.$indexSet(a0, a1);
},
removeLast$0: function(receiver) {
return receiver.removeLast$0();
},
endsWith$1: function(receiver, a0) {
return receiver.endsWith$1(a0);
},
replaceAll$2: function(receiver, a0, a1) {
return receiver.replaceAll$2(a0, a1);
},
forEach$1: function(receiver, a0) {
return receiver.forEach$1(a0);
},
get$length: function(receiver) {
return receiver.get$length();
},
$add: function(receiver, a0) {
return receiver.$add(a0);
},
getRange$2: function(receiver, a0, a1) {
return receiver.getRange$2(a0, a1);
},
toList$0: function(receiver) {
return receiver.toList$0();
},
get$hashCode: function(receiver) {
return receiver.get$hashCode();
},
$lt: function(receiver, a0) {
return receiver.$lt(a0);
},
$xor: function(receiver, a0) {
return receiver.$xor(a0);
},
truncate$0: function(receiver) {
return receiver.truncate$0();
},
$mul: function(receiver, a0) {
return receiver.$mul(a0);
},
startsWith$1: function(receiver, a0) {
return receiver.startsWith$1(a0);
},
abs$0: function(receiver) {
return receiver.abs$0();
},
$tdiv: function(receiver, a0) {
return receiver.$tdiv(a0);
},
toUpperCase$0: function(receiver) {
return receiver.toUpperCase$0();
},
$and: function(receiver, a0) {
return receiver.$and(a0);
},
$index: function(receiver, a0) {
return receiver.$index(a0);
},
mappedBy$1: function(receiver, a0) {
return receiver.mappedBy$1(a0);
},
ceil$0: function(receiver) {
return receiver.ceil$0();
},
$gt: function(receiver, a0) {
return receiver.$gt(a0);
},
where$1: function(receiver, a0) {
return receiver.where$1(a0);
},
$negate: function(receiver) {
return receiver.$negate();
},
$ge: function(receiver, a0) {
return receiver.$ge(a0);
},
toLowerCase$0: function(receiver) {
return receiver.toLowerCase$0();
},
$or: function(receiver, a0) {
return receiver.$or(a0);
},
floor$0: function(receiver) {
return receiver.floor$0();
},
add$1: function(receiver, a0) {
return receiver.add$1(a0);
},
remove$1: function(receiver, a0) {
return receiver.remove$1(a0);
},
get$isEmpty: function(receiver) {
return receiver.get$isEmpty();
},
addLast$1: function(receiver, a0) {
return receiver.addLast$1(a0);
},
$sub: function(receiver, a0) {
return receiver.$sub(a0);
},
remainder$1: function(receiver, a0) {
return receiver.remainder$1(a0);
},
split$1: function(receiver, a0) {
return receiver.split$1(a0);
},
$shl: function(receiver, a0) {
return receiver.$shl(a0);
}
};
$$.JSFunction = {"": "Object;",
toString$0: function(receiver) {
return "Closure";
},
$isFunction: true,
$eq: function(receiver, a) {
return receiver === a;
}
};
$$.JSBool = {"": "Object;",
toString$0: function(receiver) {
return String(receiver);
},
get$hashCode: function(receiver) {
return receiver ? 519018 : 218159;
},
$isbool: true,
$eq: function(receiver, a) {
return receiver === a;
}
};
$$.JSNull = {"": "Object;",
toString$0: function(receiver) {
return "null";
},
get$hashCode: function(receiver) {
return 0;
},
$eq: function(receiver, a) {
return receiver == a;
}
};
$$.JSArray = {"": "Object;",
add$1: function(receiver, value) {
$.checkGrowable(receiver, "add");
receiver.push(value);
},
removeLast$0: function(receiver) {
$.checkGrowable(receiver, "removeLast");
if (receiver.length === 0)
throw $.$$throw($.RangeError$value(-1));
return receiver.pop();
},
remove$1: function(receiver, element) {
var i;
$.checkGrowable(receiver, "remove");
for (i = 0; i < receiver.length; ++i)
if ($.$$eq(receiver[i], element) === true) {
receiver.splice(i, 1);
return;
}
},
where$1: function(receiver, f) {
return $.WhereIterable$(receiver, f);
},
addLast$1: function(receiver, value) {
$.checkGrowable(receiver, "addLast");
receiver.push(value);
},
forEach$1: function(receiver, f) {
var t1;
for (t1 = this.get$iterator(receiver); t1.moveNext$0() === true;)
f.call$1(t1.get$current());
return;
},
mappedBy$1: function(receiver, f) {
return $.MappedList$(receiver, f);
},
getRange$2: function(receiver, start, length) {
var t1, end;
if (0 === length)
return [];
$.checkNull(start);
$.checkNull(length);
if (!(typeof length === "number" && Math.floor(length) === length))
throw $.$$throw($.ArgumentError$(length));
t1 = length < 0;
if (t1)
throw $.$$throw($.ArgumentError$(length));
if (start < 0)
throw $.$$throw($.RangeError$value(start));
end = start + length;
if (end > receiver.length)
throw $.$$throw($.RangeError$value(length));
if (t1)
throw $.$$throw($.ArgumentError$(length));
return receiver.slice(start, end);
},
get$isEmpty: function(receiver) {
return receiver.length === 0;
},
toString$0: function(receiver) {
return $.Collections_collectionToString(receiver);
},
toList$0: function(receiver) {
return $.List_List$from(receiver);
},
get$iterator: function(receiver) {
return $.ListIterator$(receiver);
},
get$hashCode: function(receiver) {
return $.Primitives_objectHashCode(receiver);
},
get$length: function(receiver) {
return receiver.length;
},
$index: function(receiver, index) {
if (!(typeof index === "number" && Math.floor(index) === index))
throw $.$$throw($.ArgumentError$(index));
if (index >= receiver.length || index < 0)
throw $.$$throw($.RangeError$value(index));
return receiver[index];
},
$indexSet: function(receiver, index, value) {
$.checkMutable(receiver, "indexed set");
if (!(typeof index === "number" && Math.floor(index) === index))
throw $.$$throw($.ArgumentError$(index));
if (index >= receiver.length || index < 0)
throw $.$$throw($.RangeError$value(index));
receiver[index] = value;
},
$isList: true,
$isCollection: true,
$isIterable: true,
$eq: function(receiver, a) {
return receiver === a;
}
};
$$.JSNumber = {"": "Object;",
remainder$1: function(receiver, b) {
$.checkNull(b);
return receiver % b;
},
abs$0: function(receiver) {
return Math.abs(receiver);
},
ceil$0: function(receiver) {
return Math.ceil(receiver);
},
floor$0: function(receiver) {
return Math.floor(receiver);
},
truncate$0: function(receiver) {
return receiver < 0 ? this.ceil$0(receiver) : this.floor$0(receiver);
},
toString$0: function(receiver) {
if (receiver === 0 && (1 / receiver) < 0)
return "-0.0";
else
return String(receiver);
},
get$hashCode: function(receiver) {
return receiver & 0x1FFFFFFF;
},
$negate: function(receiver) {
return -receiver;
},
$add: function(receiver, other) {
if (!(typeof other === "number"))
throw $.$$throw($.ArgumentError$(other));
return receiver + other;
},
$sub: function(receiver, other) {
if (!(typeof other === "number"))
throw $.$$throw($.ArgumentError$(other));
return receiver - other;
},
$mul: function(receiver, other) {
return receiver * other;
},
$tdiv: function(receiver, other) {
return this.truncate$0(receiver / other);
},
$shl: function(receiver, other) {
if (other < 0)
throw $.$$throw($.ArgumentError$(other));
if (other > 31)
return 0;
return (receiver << other) >>> 0;
},
$and: function(receiver, other) {
if (!(typeof other === "number"))
throw $.$$throw($.ArgumentError$(other));
return (receiver & other) >>> 0;
},
$or: function(receiver, other) {
return (receiver | other) >>> 0;
},
$xor: function(receiver, other) {
if (!(typeof other === "number"))
throw $.$$throw($.ArgumentError$(other));
return (receiver ^ other) >>> 0;
},
$lt: function(receiver, other) {
if (!(typeof other === "number"))
throw $.$$throw($.ArgumentError$(other));
return receiver < other;
},
$gt: function(receiver, other) {
if (!(typeof other === "number"))
throw $.$$throw($.ArgumentError$(other));
return receiver > other;
},
$ge: function(receiver, other) {
if (!(typeof other === "number"))
throw $.$$throw($.ArgumentError$(other));
return receiver >= other;
},
$eq: function(receiver, a) {
return receiver === a;
}
};
$$.JSInt = {"": "JSNumber;",
$eq: function(receiver, a) {
return receiver === a;
}
};
$$.JSDouble = {"": "JSNumber;",
$eq: function(receiver, a) {
return receiver === a;
}
};
$$.JSString = {"": "Object;",
charCodeAt$1: function(receiver, index) {
if (index < 0)
throw $.$$throw($.RangeError$value(index));
if (index >= receiver.length)
throw $.$$throw($.RangeError$value(index));
return receiver.charCodeAt(index);
},
endsWith$1: function(receiver, other) {
var otherLength, t1;
$.checkString(other);
otherLength = other.length;
t1 = receiver.length;
if (otherLength > t1)
return false;
return other === this.substring$1(receiver, t1 - otherLength);
},
replaceAll$2: function(receiver, from, to) {
$.checkString(to);
return $.stringReplaceAllUnchecked(receiver, from, to);
},
split$1: function(receiver, pattern) {
$.checkNull(pattern);
return receiver.split(pattern);
},
startsWith$1: function(receiver, other) {
var otherLength;
$.checkString(other);
otherLength = other.length;
if (otherLength > receiver.length)
return false;
return other == receiver.substring(0, otherLength);
},
substring$2: function(receiver, startIndex, endIndex) {
var t1;
$.checkNum(startIndex);
if (endIndex == null)
endIndex = receiver.length;
$.checkNum(endIndex);
t1 = $.getInterceptor$JSNumber(startIndex);
if (t1.$lt(startIndex, 0) === true)
throw $.$$throw($.RangeError$value(startIndex));
if (t1.$gt(startIndex, endIndex) === true)
throw $.$$throw($.RangeError$value(startIndex));
if ($.$$gt(endIndex, receiver.length) === true)
throw $.$$throw($.RangeError$value(endIndex));
return receiver.substring(startIndex, endIndex);
},
substring$1: function($receiver, startIndex) {
return this.substring$2($receiver, startIndex, null);
},
toLowerCase$0: function(receiver) {
return receiver.toLowerCase();
},
toUpperCase$0: function(receiver) {
return receiver.toUpperCase();
},
get$isEmpty: function(receiver) {
return receiver.length === 0;
},
toString$0: function(receiver) {
return receiver;
},
get$hashCode: function(receiver) {
var hash, i, hash0, hash1;
for (hash = 0, i = 0; i < receiver.length; ++i, hash = hash1) {
hash0 = 536870911 & hash + receiver.charCodeAt(i);
hash1 = 536870911 & hash0 + ((524287 & hash0) << 10 >>> 0);
hash1 = hash1 ^ (hash1 >> 6);
}
hash0 = 536870911 & hash + ((67108863 & hash) << 3 >>> 0);
hash0 = hash0 ^ (hash0 >> 11);
return 536870911 & hash0 + ((16383 & hash0) << 15 >>> 0);
},
get$length: function(receiver) {
return receiver.length;
},
$index: function(receiver, index) {
if (!(typeof index === "number" && Math.floor(index) === index))
throw $.$$throw($.ArgumentError$(index));
if (index >= receiver.length || index < 0)
throw $.$$throw($.RangeError$value(index));
return receiver[index];
},
$isString: true,
$eq: function(receiver, a) {
return receiver === a;
}
};
$$._HashMapImpl = {"": "Object;_keys>,_values>,_loadLimit,_numberOfEntries,_numberOfDeleted",
_probeForAdding$1: function(key) {
var t1, t3, hash, numberOfProbes, insertionIndex, existingKey, numberOfProbes0;
if (key == null)
throw $.$$throw($.ArgumentError$(null));
t1 = $.hashCode(key);
t3 = this._keys.length;
if (t1 !== (t1 | 0))
return this._probeForAdding$1$bailout(1, key, t1);
hash = (t1 & t3 - 1) >>> 0;
for (numberOfProbes = 1, insertionIndex = -1; true; numberOfProbes = numberOfProbes0) {
t1 = this._keys;
if (hash < 0 || hash >= t1.length)
throw $.ioore(hash);
existingKey = t1[hash];
if (existingKey == null) {
if (insertionIndex < 0)
return hash;
return insertionIndex;
} else if ($.$$eq(existingKey, key) === true)
return hash;
else if (insertionIndex < 0 && existingKey === $.CONSTANT3)
insertionIndex = hash;
numberOfProbes0 = numberOfProbes + 1;
hash = $._HashMapImpl__nextProbe(hash, numberOfProbes, this._keys.length);
if (hash !== (hash | 0))
return this._probeForAdding$1$bailout(2, key, null, hash, numberOfProbes0, insertionIndex);
}
},
_probeForAdding$1$bailout: function(state0, key, t1, hash, numberOfProbes0, insertionIndex) {
switch (state0) {
case 0:
if (key == null)
throw $.$$throw($.ArgumentError$(null));
t1 = $.hashCode(key);
case 1:
state0 = 0;
hash = $.$$and(t1, this._keys.length - 1);
numberOfProbes = 1;
insertionIndex = -1;
case 2:
var numberOfProbes, existingKey;
L0:
while (true)
switch (state0) {
case 0:
if (!true)
break L0;
t1 = this._keys;
if (hash !== (hash | 0))
throw $.iae(hash);
if (hash < 0 || hash >= t1.length)
throw $.ioore(hash);
existingKey = t1[hash];
if (existingKey == null) {
if (insertionIndex < 0)
return hash;
return insertionIndex;
} else if ($.$$eq(existingKey, key) === true)
return hash;
else if (insertionIndex < 0 && existingKey === $.CONSTANT3)
insertionIndex = hash;
numberOfProbes0 = numberOfProbes + 1;
hash = $._HashMapImpl__nextProbe(hash, numberOfProbes, this._keys.length);
case 2:
state0 = 0;
numberOfProbes = numberOfProbes0;
}
}
},
_probeForLookup$1: function(key) {
var t1, hash, numberOfProbes, existingKey, numberOfProbes0;
if (key == null)
throw $.$$throw($.ArgumentError$(null));
t1 = $.$$and($.hashCode(key), this._keys.length - 1);
if (t1 !== (t1 | 0))
return this._probeForLookup$1$bailout(1, key, t1);
for (hash = t1, numberOfProbes = 1; true; numberOfProbes = numberOfProbes0) {
t1 = this._keys;
if (hash !== (hash | 0))
throw $.iae(hash);
if (hash < 0 || hash >= t1.length)
throw $.ioore(hash);
existingKey = t1[hash];
if (existingKey == null)
return -1;
if ($.$$eq(existingKey, key) === true)
return hash;
numberOfProbes0 = numberOfProbes + 1;
hash = $._HashMapImpl__nextProbe(hash, numberOfProbes, this._keys.length);
}
},
_probeForLookup$1$bailout: function(state0, key, t1) {
var hash, numberOfProbes, existingKey, numberOfProbes0;
for (hash = t1, numberOfProbes = 1; true; numberOfProbes = numberOfProbes0) {
t1 = this._keys;
if (hash !== (hash | 0))
throw $.iae(hash);
if (hash < 0 || hash >= t1.length)
throw $.ioore(hash);
existingKey = t1[hash];
if (existingKey == null)
return -1;
if ($.$$eq(existingKey, key) === true)
return hash;
numberOfProbes0 = numberOfProbes + 1;
hash = $._HashMapImpl__nextProbe(hash, numberOfProbes, this._keys.length);
}
},
_ensureCapacity$0: function() {
var t1, capacity, t2;
t1 = $.$$add(this._numberOfEntries, 1);
if ($.$$ge(t1, this._loadLimit) === true) {
this._grow$1(this._keys.length * 2);
return;
}
capacity = this._keys.length;
if (typeof t1 !== "number")
throw $.iae(t1);
t2 = this._numberOfDeleted;
if (t2 > capacity - t1 - t2)
this._grow$1(capacity);
},
_grow$1: function(newCapacity) {
var capacity, oldKeys, oldValues, i, key, value, newIndex, t1;
capacity = this._keys.length;
this._loadLimit = $.$$tdiv($.$$mul(newCapacity, 3), 4);
oldKeys = this._keys;
oldValues = this._values;
this._keys = $.List_List$fixedLength(newCapacity, null);
this._values = $.List_List$fixedLength(newCapacity, null);
for (i = 0; i < capacity; ++i) {
if (i >= oldKeys.length)
throw $.ioore(i);
key = oldKeys[i];
if (key == null || key === $.CONSTANT3)
continue;
if (i >= oldValues.length)
throw $.ioore(i);
value = oldValues[i];
newIndex = this._probeForAdding$1(key);
t1 = this._keys;
if (newIndex !== (newIndex | 0))
throw $.iae(newIndex);
if (newIndex < 0 || newIndex >= t1.length)
throw $.ioore(newIndex);
t1[newIndex] = key;
t1 = this._values;
if (newIndex >= t1.length)
throw $.ioore(newIndex);
t1[newIndex] = value;
}
this._numberOfDeleted = 0;
},
$indexSet: function(key, value) {
var index, t1;
this._ensureCapacity$0();
index = this._probeForAdding$1(key);
t1 = this._keys;
if (index !== (index | 0))
throw $.iae(index);
if (index < 0 || index >= t1.length)
throw $.ioore(index);
t1 = t1[index];
if (t1 == null || t1 === $.CONSTANT3) {
t1 = this._numberOfEntries;
if (typeof t1 !== "number")
return this.$$indexSet$bailout0(1, key, value, t1, index);
this._numberOfEntries = t1 + 1;
}
t1 = this._keys;
if (index >= t1.length)
throw $.ioore(index);
t1[index] = key;
t1 = this._values;
if (index >= t1.length)
throw $.ioore(index);
t1[index] = value;
},
$$indexSet$bailout0: function(state0, key, value, t1, index) {
switch (state0) {
case 0:
this._ensureCapacity$0();
index = this._probeForAdding$1(key);
t1 = this._keys;
if (index !== (index | 0))
throw $.iae(index);
if (index < 0 || index >= t1.length)
throw $.ioore(index);
t1 = t1[index];
case 1:
if (state0 === 1 || state0 === 0 && (t1 == null || t1 === $.CONSTANT3))
switch (state0) {
case 0:
t1 = this._numberOfEntries;
case 1:
state0 = 0;
this._numberOfEntries = $.$$add(t1, 1);
}
t1 = this._keys;
if (index >= t1.length)
throw $.ioore(index);
t1[index] = key;
t1 = this._values;
if (index >= t1.length)
throw $.ioore(index);
t1[index] = value;
}
},
$index: function(key) {
var index, t1;
index = this._probeForLookup$1(key);
if (typeof index !== "number")
return this.$$index$bailout(1, index);
if (index < 0)
return;
t1 = this._values;
if (index !== (index | 0))
throw $.iae(index);
if (index < 0 || index >= t1.length)
throw $.ioore(index);
return t1[index];
},
$$index$bailout: function(state0, index) {
var t1;
if ($.$$lt(index, 0) === true)
return;
t1 = this._values;
if (index !== (index | 0))
throw $.iae(index);
if (index < 0 || index >= t1.length)
throw $.ioore(index);
return t1[index];
},
remove$1: function(key) {
var index, t1, value;
index = this._probeForLookup$1(key);
if ($.$$ge(index, 0) === true) {
this._numberOfEntries = $.$$sub(this._numberOfEntries, 1);
t1 = this._values;
if (index !== (index | 0))
throw $.iae(index);
if (index < 0 || index >= t1.length)
throw $.ioore(index);
value = t1[index];
t1[index] = null;
t1 = this._keys;
if (index >= t1.length)
throw $.ioore(index);
t1[index] = $.CONSTANT3;
this._numberOfDeleted = this._numberOfDeleted + 1;
return value;
}
return;
},
get$isEmpty: function() {
return $.$$eq(this._numberOfEntries, 0);
},
get$length: function() {
return this._numberOfEntries;
},
forEach$1: function(f) {
var it, t1, t2, t3;
it = $._HashMapImplIndexIterator$(this);
for (; it.moveNext$0() === true;) {
t1 = this._keys;
t2 = it.get$current();
if (t2 !== (t2 | 0))
throw $.iae(t2);
if (t2 < 0 || t2 >= t1.length)
throw $.ioore(t2);
t2 = t1[t2];
t1 = this._values;
t3 = it.get$current();
if (t3 !== (t3 | 0))
throw $.iae(t3);
if (t3 < 0 || t3 >= t1.length)
throw $.ioore(t3);
f.call$2(t2, t1[t3]);
}
},
get$keys: function() {
return $._HashMapImplKeyIterable$(this);
},
get$values: function() {
return $._HashMapImplValueIterable$(this);
},
containsKey$1: function(key) {
return $.$$eq(this._probeForLookup$1(key), -1) !== true;
},
toString$0: function() {
return $.Maps_mapToString(this);
},
_HashMapImpl$0: function() {
this._numberOfEntries = 0;
this._numberOfDeleted = 0;
this._loadLimit = $._HashMapImpl__computeLoadLimit(8);
this._keys = $.List_List$fixedLength(8, null);
this._values = $.List_List$fixedLength(8, null);
},
$isMap: true
};
$$._HashMapImplKeyIterable = {"": "Iterable;_map",
get$iterator: function() {
return $._HashMapImplKeyIterator$(this._map);
}
};
$$._HashMapImplValueIterable = {"": "Iterable;_map",
get$iterator: function() {
return $._HashMapImplValueIterator$(this._map);
}
};
$$._HashMapImplIterator = {"": "Object;",
moveNext$0: function() {
var t1, t2, t4, newIndex, t3, t5;
t1 = this._map;
t2 = $.length(t1.get$_keys());
if (typeof t2 !== "number")
return this.moveNext$0$bailout(1, t2, t1);
t4 = this._index;
if (typeof t4 !== "number")
return this.moveNext$0$bailout(2, t2, t1, t4);
newIndex = t4 + 1;
for (t3 = t1.get$_keys(); newIndex < t2;) {
if (typeof t3 !== "string" && (typeof t3 !== "object" || t3 === null || t3.constructor !== Array && !t3.$isJavaScriptIndexingBehavior))
return this.moveNext$0$bailout(3, t2, t1, t3, newIndex, $.CONSTANT4);
if (newIndex !== (newIndex | 0))
throw $.iae(newIndex);
if (newIndex < 0 || newIndex >= t3.length)
throw $.ioore(newIndex);
t5 = t3[newIndex];
if (!(t5 == null) && !(t5 === $.CONSTANT3)) {
this._current = this._computeCurrentFromIndex$3(newIndex, t3, t1.get$_values());
this._index = newIndex;
return true;
}
++newIndex;
}
this._index = t2;
this._current = null;
return false;
},
moveNext$0$bailout: function(state0, t2, t1, t4, newIndex, t3) {
switch (state0) {
case 0:
t1 = this._map;
t2 = $.length(t1.get$_keys());
case 1:
state0 = 0;
t4 = this._index;
case 2:
state0 = 0;
newIndex = $.$$add(t4, 1);
case 3:
L0:
while (true)
switch (state0) {
case 0:
t3 = $.getInterceptor$JSNumber(newIndex);
if (!(t3.$lt(newIndex, t2) === true))
break L0;
t4 = t1.get$_keys();
case 3:
state0 = 0;
t4 = $.$$index(t4, newIndex);
if (!(t4 == null) && !(t4 === $.CONSTANT3)) {
this._current = this._computeCurrentFromIndex$3(newIndex, t1.get$_keys(), t1.get$_values());
this._index = newIndex;
return true;
}
newIndex = t3.$add(newIndex, 1);
}
this._index = t2;
this._current = null;
return false;
}
},
get$current: function() {
return this._current;
}
};
$$._HashMapImplKeyIterator = {"": "_HashMapImplIterator;_map,_index,_current",
_computeCurrentFromIndex$3: function(index, keys, values) {
return $.$$index(keys, index);
}
};
$$._HashMapImplValueIterator = {"": "_HashMapImplIterator;_map,_index,_current",
_computeCurrentFromIndex$3: function(index, keys, values) {
return $.$$index(values, index);
}
};
$$._HashMapImplIndexIterator = {"": "_HashMapImplIterator;_map,_index,_current",
_computeCurrentFromIndex$3: function(index, keys, values) {
return index;
}
};
$$._DeletedKeySentinel = {"": "Object;"};
$$._KeyValuePair = {"": "Object;key>,value="};
$$._LinkedHashMapImpl = {"": "Object;_list,_map",
$indexSet: function(key, value) {
var t1, t3;
if (this._map.containsKey$1(key) === true) {
t1 = this._map;
if (typeof t1 !== "string" && (typeof t1 !== "object" || t1 === null || t1.constructor !== Array && !t1.$isJavaScriptIndexingBehavior))
return this.$$indexSet$bailout(1, key, value, t1);
if (key !== (key | 0))
throw $.iae(key);
if (key < 0 || key >= t1.length)
throw $.ioore(key);
t1[key].get$element().set$value(value);
} else {
this._list.addLast$1($._KeyValuePair$(key, value));
t1 = this._map;
t3 = this._list.lastEntry$0();
if (typeof t1 !== "object" || t1 === null || (t1.constructor !== Array || !!t1.immutable$list) && !t1.$isJavaScriptIndexingBehavior)
return this.$$indexSet$bailout(2, key, null, t1);
if (key !== (key | 0))
throw $.iae(key);
if (key < 0 || key >= t1.length)
throw $.ioore(key);
t1[key] = t3;
}
},
$$indexSet$bailout: function(state0, key, value, t1) {
switch (state0) {
case 0:
default:
if (state0 === 1 || state0 === 0 && this._map.containsKey$1(key) === true)
switch (state0) {
case 0:
t1 = this._map;
case 1:
state0 = 0;
$.$$index(t1, key).get$element().set$value(value);
}
else
switch (state0) {
case 0:
this._list.addLast$1($._KeyValuePair$(key, value));
t1 = this._map;
case 2:
state0 = 0;
$.$$indexSet(t1, key, this._list.lastEntry$0());
}
}
},
$index: function(key) {
var t1 = $.$$index(this._map, key);
if (t1 == null)
return;
return t1.get$element().get$value();
},
remove$1: function(key) {
var t1 = $.remove(this._map, key);
if (t1 == null)
return;
t1.remove$0();
return t1.get$element().get$value();
},
get$keys: function() {
return $.MappedIterable$(this._list, new $._LinkedHashMapImpl_keys_anon());
},
get$values: function() {
return $.MappedIterable$(this._list, new $._LinkedHashMapImpl_values_anon());
},
forEach$1: function(f) {
this._list.forEach$1(new $._LinkedHashMapImpl_forEach_anon(f));
},
containsKey$1: function(key) {
return this._map.containsKey$1(key);
},
get$length: function() {
return $.length(this._map);
},
get$isEmpty: function() {
return $.$$eq($.length(this), 0);
},
toString$0: function() {
return $.Maps_mapToString(this);
},
_LinkedHashMapImpl$0: function() {
this._map = $.HashMap_HashMap();
this._list = $.DoubleLinkedQueue$();
},
$isMap: true
};
$$.DoubleLinkedQueueEntry = {"": "Object;_previous=,_next=,_element",
_link$2: function(p, n) {
this._next = n;
this._previous = p;
p.set$_next(this);
n.set$_previous(this);
},
prepend$1: function(e) {
$.DoubleLinkedQueueEntry$(e)._link$2(this._previous, this);
},
remove$0: function() {
var t1 = this._next;
this._previous.set$_next(t1);
t1 = this._previous;
this._next.set$_previous(t1);
this._next = null;
this._previous = null;
return this._element;
},
_asNonSentinelEntry$0: function() {
return this;
},
previousEntry$0: function() {
return this._previous._asNonSentinelEntry$0();
},
nextEntry$0: function() {
return this._next._asNonSentinelEntry$0();
},
get$element: function() {
return this._element;
},
DoubleLinkedQueueEntry$1: function(e) {
this._element = e;
}
};
$$._DoubleLinkedQueueEntrySentinel = {"": "DoubleLinkedQueueEntry;_previous,_next,_element",
remove$0: function() {
throw $.$$throw($.StateError$("Empty queue"));
},
_asNonSentinelEntry$0: function() {
return;
},
get$element: function() {
throw $.$$throw($.StateError$("Empty queue"));
},
_DoubleLinkedQueueEntrySentinel$0: function() {
this._link$2(this, this);
}
};
$$.DoubleLinkedQueue = {"": "Iterable;_sentinel",
addLast$1: function(value) {
this._sentinel.prepend$1(value);
},
add$1: function(value) {
this._sentinel.prepend$1(value);
},
removeLast$0: function() {
return this._sentinel._previous.remove$0();
},
removeFirst$0: function() {
return this._sentinel._next.remove$0();
},
remove$1: function(o) {
var entry = this._sentinel.nextEntry$0();
for (; !(entry === this._sentinel);) {
if ($.$$eq(entry.get$element(), o) === true) {
entry.remove$0();
return;
}
entry = entry.get$_next();
}
},
lastEntry$0: function() {
return this._sentinel.previousEntry$0();
},
get$isEmpty: function() {
var t1 = this._sentinel;
return t1._next === t1;
},
get$iterator: function() {
return $._DoubleLinkedQueueIterator$(this._sentinel);
},
toString$0: function() {
return $.Collections_collectionToString(this);
},
DoubleLinkedQueue$0: function() {
this._sentinel = $._DoubleLinkedQueueEntrySentinel$();
},
$isCollection: true,
$isIterable: true
};
$$._DoubleLinkedQueueIterator = {"": "Object;_sentinel,_currentEntry,_current",
moveNext$0: function() {
var t1, t2;
t1 = this._currentEntry;
if (t1 == null)
return false;
this._currentEntry = t1.get$_next();
t1 = this._currentEntry;
t2 = this._sentinel;
if (t1 == null ? t2 == null : t1 === t2) {
this._currentEntry = null;
this._current = null;
this._sentinel = null;
return false;
}
this._current = t1.get$element();
return true;
},
get$current: function() {
return this._current;
}
};
$$.MappedIterable = {"": "Iterable;_iterable,_f",
_f$1: function(arg0) {
return this._f.call$1(arg0);
},
get$iterator: function() {
return $.MappedIterator$($.iterator(this._iterable), this._f);
},
get$length: function() {
return $.length(this._iterable);
},
get$isEmpty: function() {
return $.isEmpty(this._iterable);
}
};
$$.MappedIterator = {"": "Iterator;_liblib$_current,_iterator,_f",
_f$1: function(arg0) {
return this._f.call$1(arg0);
},
moveNext$0: function() {
var t1 = this._iterator;
if (t1.moveNext$0() === true) {
this._liblib$_current = this._f$1(t1.get$current());
return true;
} else {
this._liblib$_current = null;
return false;
}
},
get$current: function() {
return this._liblib$_current;
}
};
$$.WhereIterable = {"": "Iterable;_iterable,_f",
_f$1: function(arg0) {
return this._f.call$1(arg0);
},
get$iterator: function() {
return $.WhereIterator$($.iterator(this._iterable), this._f);
}
};
$$.WhereIterator = {"": "Iterator;_iterator,_f",
_f$1: function(arg0) {
return this._f.call$1(arg0);
},
moveNext$0: function() {
for (var t1 = this._iterator; t1.moveNext$0() === true;)
if (this._f$1(t1.get$current()) === true)
return true;
return false;
},
get$current: function() {
return this._iterator.get$current();
}
};
$$.ListBase = {"": "Collection;",
get$iterator: function() {
return $.ListIterator$(this);
},
forEach$1: function(f) {
var t1, i;
for (t1 = $.getInterceptor$JSStringJSArray(this), i = 0; $.CONSTANT2.$lt(i, t1.get$length(this)); ++i)
f.call$1(this.$index(i));
},
get$isEmpty: function() {
return $.$$eq($.length(this), 0);
},
getRange$2: function(start, length) {
var result, i;
if (typeof length !== "number")
return this.getRange$2$bailout(1, start, length);
result = [];
for (i = 0; i < length; ++i)
result.push(this.$index(start + i));
return result;
},
getRange$2$bailout: function(state0, start, length) {
var result, i;
result = [];
for (i = 0; $.CONSTANT2.$lt(i, length); ++i)
result.push(this.$index(start + i));
return result;
},
mappedBy$1: function(f) {
return $.MappedList$(this, f);
},
toString$0: function() {
return this.get$Collections().collectionToString$1(this);
},
$isList: true,
$isCollection: true,
$isIterable: true
};
$$.UnmodifiableListBase = {"": "ListBase;",
$indexSet: function(index, value) {
throw $.$$throw($.UnsupportedError$("Cannot modify an unmodifiable list"));
},
add$1: function(value) {
throw $.$$throw($.UnsupportedError$("Cannot add to an unmodifiable list"));
},
addLast$1: function(value) {
throw $.$$throw($.UnsupportedError$("Cannot add to an unmodifiable list"));
},
remove$1: function(element) {
throw $.$$throw($.UnsupportedError$("Cannot remove from an unmodifiable list"));
},
removeLast$0: function() {
throw $.$$throw($.UnsupportedError$("Cannot remove from an unmodifiable list"));
}
};
$$.ListIterator = {"": "Object;_liblib$_list,_length,_position,_liblib$_current",
moveNext$0: function() {
var t1, t3, t4, t5, t2;
t1 = this._liblib$_list;
if (typeof t1 !== "string" && (typeof t1 !== "object" || t1 === null || t1.constructor !== Array && !t1.$isJavaScriptIndexingBehavior))
return this.moveNext$0$bailout0(1, t1);
t3 = $.getInterceptor$JSStringJSArray(t1);
t4 = t1.length;
t5 = this._length;
if (typeof t5 !== "number")
return this.moveNext$0$bailout0(3, t1, t3, t4, t5);
if (!(t4 === t5))
throw $.$$throw($.ConcurrentModificationError$(t1));
t2 = this._position;
if (typeof t2 !== "number")
return this.moveNext$0$bailout0(4, t1, t3, null, t5, t2);
++t2;
if (t2 < t5) {
this._position = t2;
if (t2 !== (t2 | 0))
throw $.iae(t2);
if (t2 < 0 || t2 >= t1.length)
throw $.ioore(t2);
this._liblib$_current = t1[t2];
return true;
}
this._liblib$_current = null;
return false;
},
moveNext$0$bailout0: function(state0, t1, t3, t4, t6, t2) {
switch (state0) {
case 0:
t1 = this._liblib$_list;
case 1:
state0 = 0;
t3 = $.getInterceptor$JSStringJSArray(t1);
t4 = t3.get$length(t1);
case 2:
state0 = 0;
t6 = this._length;
case 3:
state0 = 0;
if ($.$$eq(t4, t6) !== true)
throw $.$$throw($.ConcurrentModificationError$(t1));
t2 = this._position;
case 4:
state0 = 0;
t2 = $.$$add(t2, 1);
if ($.$$lt(t2, t6) === true) {
this._position = t2;
this._liblib$_current = t3.$index(t1, t2);
return true;
}
this._liblib$_current = null;
return false;
}
},
get$current: function() {
return this._liblib$_current;
}
};
$$.MappedList = {"": "UnmodifiableListBase;_liblib$_list,_f",
_f$1: function(arg0) {
return this._f.call$1(arg0);
},
$index: function(index) {
var t1 = this._liblib$_list;
if (typeof t1 !== "string" && (typeof t1 !== "object" || t1 === null || t1.constructor !== Array && !t1.$isJavaScriptIndexingBehavior))
return this.$$index$bailout0(1, index, t1);
if (index !== (index | 0))
throw $.iae(index);
if (index < 0 || index >= t1.length)
throw $.ioore(index);
return this._f$1(t1[index]);
},
$$index$bailout0: function(state0, index, t1) {
return this._f$1($.$$index(t1, index));
},
get$length: function() {
return $.length(this._liblib$_list);
}
};
$$._Manager = {"": "Object;nextIsolateId=,currentManagerId=,nextManagerId=,currentContext=,rootContext=,topEventLoop>,fromCommandLine>,isWorker>,supportsWorkers,isolates>,mainManager>,managers>",
get$useWorkers: function() {
return this.supportsWorkers;
},
get$needSerialization: function() {
return this.get$useWorkers();
},
_nativeDetectEnvironment$0: function() {
var t1, t2;
t1 = $.get$globalWindow() == null;
this.isWorker = t1 && $.get$globalPostMessageDefined() === true;
if (this.isWorker !== true)
t2 = !($.get$globalWorker() == null) && !($.get$IsolateNatives_thisScript() == null);
else
t2 = true;
this.supportsWorkers = t2;
this.fromCommandLine = t1 && this.isWorker !== true;
},
_nativeInitWorkerMessageHandler$0: function() {
var $function = function (e) { $.IsolateNatives__processWorkerMessage.call$2(this.mainManager, e); };
$.get$globalThis().onmessage = $function;
$.get$globalThis().dartPrint = function (object) {};
},
maybeCloseWorker$0: function() {
if (this.isWorker === true && $.isEmpty(this.isolates) === true && $.$$eq(this.topEventLoop.get$activeTimerCount(), 0) === true)
this.mainManager.postMessage$1($._serializeMessage($.makeLiteralMap(["command", "close"])));
},
_Manager$0: function() {
this._nativeDetectEnvironment$0();
this.topEventLoop = $._EventLoop$();
this.isolates = $.Map_Map();
this.managers = $.Map_Map();
if (this.isWorker === true) {
this.mainManager = $._MainManagerStub$();
this._nativeInitWorkerMessageHandler$0();
}
}
};
$$._IsolateContext = {"": "Object;id=,ports>,isolateStatics",
eval$1: function(code) {
var old, result;
old = $globalState.get$currentContext();
$globalState.set$currentContext(this);
this._setGlobals$0();
result = null;
try {
result = code.call$0();
} finally {
$globalState.set$currentContext(old);
if (!(old == null))
old._setGlobals$0();
}
return result;
},
_setGlobals$0: function() {
$ = this.isolateStatics;
},
lookup$1: function(portId) {
return $.$$index(this.ports, portId);
},
register$2: function(portId, port) {
if (this.ports.containsKey$1(portId) === true)
throw $.$$throw($.Exception_Exception("Registry: ports must be registered only once."));
$.$$indexSet(this.ports, portId, port);
$.$$indexSet($globalState.get$isolates(), this.id, this);
},
unregister$1: function(portId) {
$.remove(this.ports, portId);
if ($.isEmpty(this.ports) === true)
$.remove($globalState.get$isolates(), this.id);
},
_IsolateContext$0: function() {
var t1, t2;
t1 = $._globalState();
t2 = t1.get$nextIsolateId();
t1.set$nextIsolateId($.$$add(t2, 1));
this.id = t2;
this.ports = $.Map_Map();
this.isolateStatics = new Isolate;
}
};
$$._EventLoop = {"": "Object;events,activeTimerCount=",
enqueue$3: function(isolate, fn, msg) {
$.addLast(this.events, $._IsolateEvent$(isolate, fn, msg));
},
dequeue$0: function() {
var t1 = this.events;
if ($.isEmpty(t1) === true)
return;
return t1.removeFirst$0();
},
checkOpenReceivePortsFromCommandLine$0: function() {
if (!($globalState.get$rootContext() == null) && $globalState.get$isolates().containsKey$1($globalState.get$rootContext().get$id()) === true && $globalState.get$fromCommandLine() === true && $.isEmpty($globalState.get$rootContext().get$ports()) === true)
throw $.$$throw($.Exception_Exception("Program exited with open ReceivePorts."));
},
runIteration$0: function() {
var event = this.dequeue$0();
if (event == null) {
this.checkOpenReceivePortsFromCommandLine$0();
$globalState.maybeCloseWorker$0();
return false;
}
event.process$0();
return true;
},
_runHelper$0: function() {
if (!($.get$globalWindow() == null))
new $._EventLoop__runHelper_next(this).call$0();
else
for (; this.runIteration$0() === true;)
;
},
run$0: function() {
var e, trace, exception, t1;
if ($globalState.get$isWorker() !== true)
this._runHelper$0();
else
try {
this._runHelper$0();
} catch (exception) {
t1 = $.unwrapException(exception);
e = t1;
trace = $.getTraceFromException(exception);
$globalState.get$mainManager().postMessage$1($._serializeMessage($.makeLiteralMap(["command", "error", "msg", $.S(e) + "\n" + $.S(trace)])));
}
}
};
$$._IsolateEvent = {"": "Object;isolate,fn,message>",
process$0: function() {
this.isolate.eval$1(this.fn);
}
};
$$._MainManagerStub = {"": "Object;",
get$id: function() {
return 0;
},
set$id: function(i) {
throw $.$$throw($.UnimplementedError$(null));
},
set$onmessage: function(f) {
throw $.$$throw($.Exception_Exception("onmessage should not be set on MainManagerStub"));
},
postMessage$1: function(msg) {
$.get$globalThis().postMessage(msg);
},
terminate$0: function() {
}
};
$$._BaseSendPort = {"": "Object;_isolateId>",
_checkReplyTo$1: function(replyTo) {
if (!(replyTo == null) && !(typeof replyTo === "object" && replyTo !== null && !!replyTo.$is_NativeJsSendPort) && !(typeof replyTo === "object" && replyTo !== null && !!replyTo.$is_WorkerSendPort) && !(typeof replyTo === "object" && replyTo !== null && !!replyTo.$is_BufferingSendPort))
throw $.$$throw($.Exception_Exception("SendPort.send: Illegal replyTo port type"));
},
call$1: function(message) {
var completer, port;
completer = $.Completer_Completer();
port = $.ReceivePortImpl$();
this.send$2(message, port.toSendPort$0());
port.receive$1(new $._BaseSendPort_call_anon(completer, port));
return completer.get$future();
},
$isFunction: true,
$isSendPort: true
};
$$._NativeJsSendPort = {"": "_BaseSendPort;_receivePort>,_isolateId",
send$2: function(message, replyTo) {
$._waitForPendingPorts([message, replyTo], new $._NativeJsSendPort_send_anon(this, message, replyTo));
},
$eq: function(other) {
if (other == null)
return false;
return typeof other === "object" && other !== null && !!other.$is_NativeJsSendPort && $.$$eq(this._receivePort, other._receivePort) === true;
},
get$hashCode: function() {
return this._receivePort.get$_id();
},
$is_NativeJsSendPort: true,
$isSendPort: true
};
$$._WorkerSendPort = {"": "_BaseSendPort;_workerId>,_receivePortId,_isolateId",
send$2: function(message, replyTo) {
$._waitForPendingPorts([message, replyTo], new $._WorkerSendPort_send_anon(this, message, replyTo));
},
$eq: function(other) {
var t1;
if (other == null)
return false;
if (typeof other === "object" && other !== null && !!other.$is_WorkerSendPort)
t1 = $.$$eq(this._workerId, other._workerId) === true && $.$$eq(this._isolateId, other._isolateId) === true && $.$$eq(this._receivePortId, other._receivePortId) === true;
else
t1 = false;
return t1;
},
get$hashCode: function() {
return $.$$xor($.$$xor($.$$shl(this._workerId, 16), $.$$shl(this._isolateId, 8)), this._receivePortId);
},
$is_WorkerSendPort: true,
$isSendPort: true
};
$$.ReceivePortImpl = {"": "Object;_id>,_callback>",
_callback$2: function(arg0, arg1) {
return this._callback.call$2(arg0, arg1);
},
receive$1: function(onMessage) {
this._callback = onMessage;
},
close$0: function() {
this._callback = null;
$globalState.get$currentContext().unregister$1(this._id);
},
toSendPort$0: function() {
return $._NativeJsSendPort$(this, $globalState.get$currentContext().get$id());
},
ReceivePortImpl$0: function() {
$._globalState().get$currentContext().register$2(this._id, this);
}
};
$$._PendingSendPortFinder = {"": "_MessageTraverser;ports>,_visited",
visitPrimitive$1: function(x) {
},
visitList$1: function(list) {
if (!($.$$index(this._visited, list) == null))
return;
$.$$indexSet(this._visited, list, true);
$.forEach(list, new $._PendingSendPortFinder_visitList_anon(this));
},
visitMap$1: function(map) {
if (!($.$$index(this._visited, map) == null))
return;
$.$$indexSet(this._visited, map, true);
$.forEach(map.get$values(), new $._PendingSendPortFinder_visitMap_anon(this));
},
visitSendPort$1: function(port) {
if (!!port.$is_BufferingSendPort && port._port == null)
this.ports.push(port.get$_futurePort());
},
_PendingSendPortFinder$0: function() {
this._visited = $._JsVisitedMap$();
}
};
$$._JsSerializer = {"": "_Serializer;_nextFreeRefId,_visited",
visitSendPort$1: function(x) {
if (typeof x === "object" && x !== null && !!x.$is_NativeJsSendPort)
return this.visitNativeJsSendPort$1(x);
if (typeof x === "object" && x !== null && !!x.$is_WorkerSendPort)
return ["sendport", x._workerId, x._isolateId, x._receivePortId];
if (typeof x === "object" && x !== null && !!x.$is_BufferingSendPort)
return this.visitBufferingSendPort$1(x);
throw $.$$throw("Illegal underlying port " + $.S(x));
},
visitNativeJsSendPort$1: function(port) {
return ["sendport", $globalState.get$currentManagerId(), port._isolateId, port._receivePort.get$_id()];
},
visitBufferingSendPort$1: function(port) {
var t1 = port._port;
if (!(t1 == null))
return this.visitSendPort$1(t1);
else
throw $.$$throw("internal error: must call _waitForPendingPorts to ensure all ports are resolved at this point.");
},
_JsSerializer$0: function() {
this._visited = $._JsVisitedMap$();
}
};
$$._JsCopier = {"": "_Copier;_visited",
visitSendPort$1: function(x) {
if (typeof x === "object" && x !== null && !!x.$is_NativeJsSendPort)
return this.visitNativeJsSendPort$1(x);
if (typeof x === "object" && x !== null && !!x.$is_WorkerSendPort)
return this.visitWorkerSendPort$1(x);
if (typeof x === "object" && x !== null && !!x.$is_BufferingSendPort)
return this.visitBufferingSendPort$1(x);
throw $.$$throw("Illegal underlying port " + $.S(this.get$p()));
},
visitNativeJsSendPort$1: function(port) {
return $._NativeJsSendPort$(port._receivePort, port._isolateId);
},
visitWorkerSendPort$1: function(port) {
return $._WorkerSendPort$(port._workerId, port._isolateId, port._receivePortId);
},
visitBufferingSendPort$1: function(port) {
var t1 = port._port;
if (!(t1 == null))
return this.visitSendPort$1(t1);
else
throw $.$$throw("internal error: must call _waitForPendingPorts to ensure all ports are resolved at this point.");
},
_JsCopier$0: function() {
this._visited = $._JsVisitedMap$();
}
};
$$._JsDeserializer = {"": "_Deserializer;_deserialized",
deserializeSendPort$1: function(x) {
var t1, managerId, isolateId, receivePortId, receivePort;
t1 = $.getInterceptor$JSStringJSArray(x);
managerId = t1.$index(x, 1);
isolateId = t1.$index(x, 2);
receivePortId = t1.$index(x, 3);
if ($.$$eq(managerId, $globalState.get$currentManagerId()) === true) {
t1 = $.$$index($globalState.get$isolates(), isolateId);
if (t1 == null)
return;
receivePort = t1.lookup$1(receivePortId);
if (receivePort == null)
return;
return $._NativeJsSendPort$(receivePort, isolateId);
} else
return $._WorkerSendPort$(managerId, isolateId, receivePortId);
}
};
$$._JsVisitedMap = {"": "Object;tagged",
$index: function(object) {
return object['__MessageTraverser__attached_info__'];
},
$indexSet: function(object, info) {
$.add(this.tagged, object);
object['__MessageTraverser__attached_info__'] = info;
},
reset$0: function() {
this.tagged = $.List_List(0);
},
cleanup$0: function() {
var t1, i;
t1 = $.length(this.tagged);
if (typeof t1 !== "number")
return this.cleanup$0$bailout(1, t1);
i = 0;
for (; i < t1; ++i)
$.$$index(this.tagged, i)['__MessageTraverser__attached_info__'] = null;
this.tagged = null;
},
cleanup$0$bailout: function(state0, t1) {
var i = 0;
for (; $.CONSTANT2.$lt(i, t1); ++i)
$.$$index(this.tagged, i)['__MessageTraverser__attached_info__'] = null;
this.tagged = null;
}
};
$$._MessageTraverserVisitedMap = {"": "Object;",
$index: function(object) {
return;
},
$indexSet: function(object, info) {
},
reset$0: function() {
},
cleanup$0: function() {
}
};
$$._MessageTraverser = {"": "Object;",
traverse$1: function(x) {
var result, t1;
t1 = x;
if (t1 == null || typeof t1 === "string" || typeof t1 === "number" || typeof t1 === "boolean")
return this.visitPrimitive$1(x);
this._visited.reset$0();
result = null;
try {
result = this._dispatch$1(x);
} finally {
this._visited.cleanup$0();
}
return result;
},
_dispatch$1: function(x) {
if (x == null || typeof x === "string" || typeof x === "number" || typeof x === "boolean")
return this.visitPrimitive$1(x);
if (typeof x === "object" && x !== null && (x.constructor === Array || !!x.$isList))
return this.visitList$1(x);
if (typeof x === "object" && x !== null && !!x.$isMap)
return this.visitMap$1(x);