Showing preview only (2,809K chars total). Download the full file or copy to clipboard to get everything.
Repository: fiatjaf/glua
Branch: master
Commit: 57b64f960779
Files: 7
Total size: 2.7 MB
Directory structure:
gitextract_kyacih07/
├── .gitignore
├── Makefile
├── README.md
├── dist/
│ └── glua.js
├── main.go
├── package.json
└── try.html
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
node_modules
*.swo
*.swp
================================================
FILE: Makefile
================================================
all: dist/glua.js dist/glua.min.js
dist/glua.js: main.go
gopherjs build -o dist/glua.js
dist/glua.min.js: main.go
gopherjs build -m -o dist/glua.min.js
================================================
FILE: README.md
================================================
## glua [](https://www.npmjs.com/package/glua)
`glua` is what happens when you compile https://github.com/J-J-J/goluajit, a Lua VM written in Go (based on https://github.com/yuin/gopher-lua), to Javascript. It works right now and you can use it for most awesomeness. You don't have to know Go or even click on the link above, just use this library in your favorite JS environment.
### example:
```js
const glua = require('glua')
glua.run(`
print(12, 'lala', true)
`) // will print these values
var result
glua.runWithGlobals({
diff: function (a, b) {
return Math.abs(Math.abs(b) - Math.abs(a))
},
saveResult: function (value) {
result = value
}
}, `
local a = 23
local b = 74
local difference = diff(a, b)
saveResult(difference)
`)
console.log('the result is: ', result)
glua.runWithModules({
fooprinter: `
local fooprinter = {}
function fooprinter.print (foo)
print('foo value is: ', foo)
end
return fooprinter
`
}, {
foo: 264857
}, `
local fooprinter = require('fooprinter')
print('printing foo...')
fooprinter.print(foo)
`)
```
### try it now
Visit https://raw.githack.com/fiatjaf/glua/master/try.html and use your console.
## how do I
1. Return multiple values from a JavaScript function?
Return the special object `{_glua_multi: []}` with an array of the multiple values you want your function to return.
2. Get values out from the Lua environment?
Call `.runWithGlobals` passing a function that takes the parameters from Lua and saves them to a JavaScript variable. It works.
================================================
FILE: dist/glua.js
================================================
"use strict";
(function() {
Error.stackTraceLimit = Infinity;
var $global, $module;
if (typeof window !== "undefined") { /* web page */
$global = window;
} else if (typeof self !== "undefined") { /* web worker */
$global = self;
} else if (typeof global !== "undefined") { /* Node.js */
$global = global;
$global.require = require;
} else { /* others (e.g. Nashorn) */
$global = this;
}
if ($global === undefined || $global.Array === undefined) {
throw new Error("no global object found");
}
if (typeof module !== "undefined") {
$module = module;
}
var $packages = {}, $idCounter = 0;
var $keys = function(m) { return m ? Object.keys(m) : []; };
var $flushConsole = function() {};
var $throwRuntimeError; /* set by package "runtime" */
var $throwNilPointerError = function() { $throwRuntimeError("invalid memory address or nil pointer dereference"); };
var $call = function(fn, rcvr, args) { return fn.apply(rcvr, args); };
var $makeFunc = function(fn) { return function() { return $externalize(fn(this, new ($sliceType($jsObjectPtr))($global.Array.prototype.slice.call(arguments, []))), $emptyInterface); }; };
var $unused = function(v) {};
var $mapArray = function(array, f) {
var newArray = new array.constructor(array.length);
for (var i = 0; i < array.length; i++) {
newArray[i] = f(array[i]);
}
return newArray;
};
var $methodVal = function(recv, name) {
var vals = recv.$methodVals || {};
recv.$methodVals = vals; /* noop for primitives */
var f = vals[name];
if (f !== undefined) {
return f;
}
var method = recv[name];
f = function() {
$stackDepthOffset--;
try {
return method.apply(recv, arguments);
} finally {
$stackDepthOffset++;
}
};
vals[name] = f;
return f;
};
var $methodExpr = function(typ, name) {
var method = typ.prototype[name];
if (method.$expr === undefined) {
method.$expr = function() {
$stackDepthOffset--;
try {
if (typ.wrapped) {
arguments[0] = new typ(arguments[0]);
}
return Function.call.apply(method, arguments);
} finally {
$stackDepthOffset++;
}
};
}
return method.$expr;
};
var $ifaceMethodExprs = {};
var $ifaceMethodExpr = function(name) {
var expr = $ifaceMethodExprs["$" + name];
if (expr === undefined) {
expr = $ifaceMethodExprs["$" + name] = function() {
$stackDepthOffset--;
try {
return Function.call.apply(arguments[0][name], arguments);
} finally {
$stackDepthOffset++;
}
};
}
return expr;
};
var $subslice = function(slice, low, high, max) {
if (high === undefined) {
high = slice.$length;
}
if (max === undefined) {
max = slice.$capacity;
}
if (low < 0 || high < low || max < high || high > slice.$capacity || max > slice.$capacity) {
$throwRuntimeError("slice bounds out of range");
}
if (slice === slice.constructor.nil) {
return slice;
}
var s = new slice.constructor(slice.$array);
s.$offset = slice.$offset + low;
s.$length = high - low;
s.$capacity = max - low;
return s;
};
var $substring = function(str, low, high) {
if (low < 0 || high < low || high > str.length) {
$throwRuntimeError("slice bounds out of range");
}
return str.substring(low, high);
};
var $sliceToArray = function(slice) {
if (slice.$array.constructor !== Array) {
return slice.$array.subarray(slice.$offset, slice.$offset + slice.$length);
}
return slice.$array.slice(slice.$offset, slice.$offset + slice.$length);
};
var $decodeRune = function(str, pos) {
var c0 = str.charCodeAt(pos);
if (c0 < 0x80) {
return [c0, 1];
}
if (c0 !== c0 || c0 < 0xC0) {
return [0xFFFD, 1];
}
var c1 = str.charCodeAt(pos + 1);
if (c1 !== c1 || c1 < 0x80 || 0xC0 <= c1) {
return [0xFFFD, 1];
}
if (c0 < 0xE0) {
var r = (c0 & 0x1F) << 6 | (c1 & 0x3F);
if (r <= 0x7F) {
return [0xFFFD, 1];
}
return [r, 2];
}
var c2 = str.charCodeAt(pos + 2);
if (c2 !== c2 || c2 < 0x80 || 0xC0 <= c2) {
return [0xFFFD, 1];
}
if (c0 < 0xF0) {
var r = (c0 & 0x0F) << 12 | (c1 & 0x3F) << 6 | (c2 & 0x3F);
if (r <= 0x7FF) {
return [0xFFFD, 1];
}
if (0xD800 <= r && r <= 0xDFFF) {
return [0xFFFD, 1];
}
return [r, 3];
}
var c3 = str.charCodeAt(pos + 3);
if (c3 !== c3 || c3 < 0x80 || 0xC0 <= c3) {
return [0xFFFD, 1];
}
if (c0 < 0xF8) {
var r = (c0 & 0x07) << 18 | (c1 & 0x3F) << 12 | (c2 & 0x3F) << 6 | (c3 & 0x3F);
if (r <= 0xFFFF || 0x10FFFF < r) {
return [0xFFFD, 1];
}
return [r, 4];
}
return [0xFFFD, 1];
};
var $encodeRune = function(r) {
if (r < 0 || r > 0x10FFFF || (0xD800 <= r && r <= 0xDFFF)) {
r = 0xFFFD;
}
if (r <= 0x7F) {
return String.fromCharCode(r);
}
if (r <= 0x7FF) {
return String.fromCharCode(0xC0 | r >> 6, 0x80 | (r & 0x3F));
}
if (r <= 0xFFFF) {
return String.fromCharCode(0xE0 | r >> 12, 0x80 | (r >> 6 & 0x3F), 0x80 | (r & 0x3F));
}
return String.fromCharCode(0xF0 | r >> 18, 0x80 | (r >> 12 & 0x3F), 0x80 | (r >> 6 & 0x3F), 0x80 | (r & 0x3F));
};
var $stringToBytes = function(str) {
var array = new Uint8Array(str.length);
for (var i = 0; i < str.length; i++) {
array[i] = str.charCodeAt(i);
}
return array;
};
var $bytesToString = function(slice) {
if (slice.$length === 0) {
return "";
}
var str = "";
for (var i = 0; i < slice.$length; i += 10000) {
str += String.fromCharCode.apply(undefined, slice.$array.subarray(slice.$offset + i, slice.$offset + Math.min(slice.$length, i + 10000)));
}
return str;
};
var $stringToRunes = function(str) {
var array = new Int32Array(str.length);
var rune, j = 0;
for (var i = 0; i < str.length; i += rune[1], j++) {
rune = $decodeRune(str, i);
array[j] = rune[0];
}
return array.subarray(0, j);
};
var $runesToString = function(slice) {
if (slice.$length === 0) {
return "";
}
var str = "";
for (var i = 0; i < slice.$length; i++) {
str += $encodeRune(slice.$array[slice.$offset + i]);
}
return str;
};
var $copyString = function(dst, src) {
var n = Math.min(src.length, dst.$length);
for (var i = 0; i < n; i++) {
dst.$array[dst.$offset + i] = src.charCodeAt(i);
}
return n;
};
var $copySlice = function(dst, src) {
var n = Math.min(src.$length, dst.$length);
$copyArray(dst.$array, src.$array, dst.$offset, src.$offset, n, dst.constructor.elem);
return n;
};
var $copyArray = function(dst, src, dstOffset, srcOffset, n, elem) {
if (n === 0 || (dst === src && dstOffset === srcOffset)) {
return;
}
if (src.subarray) {
dst.set(src.subarray(srcOffset, srcOffset + n), dstOffset);
return;
}
switch (elem.kind) {
case $kindArray:
case $kindStruct:
if (dst === src && dstOffset > srcOffset) {
for (var i = n - 1; i >= 0; i--) {
elem.copy(dst[dstOffset + i], src[srcOffset + i]);
}
return;
}
for (var i = 0; i < n; i++) {
elem.copy(dst[dstOffset + i], src[srcOffset + i]);
}
return;
}
if (dst === src && dstOffset > srcOffset) {
for (var i = n - 1; i >= 0; i--) {
dst[dstOffset + i] = src[srcOffset + i];
}
return;
}
for (var i = 0; i < n; i++) {
dst[dstOffset + i] = src[srcOffset + i];
}
};
var $clone = function(src, type) {
var clone = type.zero();
type.copy(clone, src);
return clone;
};
var $pointerOfStructConversion = function(obj, type) {
if(obj.$proxies === undefined) {
obj.$proxies = {};
obj.$proxies[obj.constructor.string] = obj;
}
var proxy = obj.$proxies[type.string];
if (proxy === undefined) {
var properties = {};
for (var i = 0; i < type.elem.fields.length; i++) {
(function(fieldProp) {
properties[fieldProp] = {
get: function() { return obj[fieldProp]; },
set: function(value) { obj[fieldProp] = value; }
};
})(type.elem.fields[i].prop);
}
proxy = Object.create(type.prototype, properties);
proxy.$val = proxy;
obj.$proxies[type.string] = proxy;
proxy.$proxies = obj.$proxies;
}
return proxy;
};
var $append = function(slice) {
return $internalAppend(slice, arguments, 1, arguments.length - 1);
};
var $appendSlice = function(slice, toAppend) {
if (toAppend.constructor === String) {
var bytes = $stringToBytes(toAppend);
return $internalAppend(slice, bytes, 0, bytes.length);
}
return $internalAppend(slice, toAppend.$array, toAppend.$offset, toAppend.$length);
};
var $internalAppend = function(slice, array, offset, length) {
if (length === 0) {
return slice;
}
var newArray = slice.$array;
var newOffset = slice.$offset;
var newLength = slice.$length + length;
var newCapacity = slice.$capacity;
if (newLength > newCapacity) {
newOffset = 0;
newCapacity = Math.max(newLength, slice.$capacity < 1024 ? slice.$capacity * 2 : Math.floor(slice.$capacity * 5 / 4));
if (slice.$array.constructor === Array) {
newArray = slice.$array.slice(slice.$offset, slice.$offset + slice.$length);
newArray.length = newCapacity;
var zero = slice.constructor.elem.zero;
for (var i = slice.$length; i < newCapacity; i++) {
newArray[i] = zero();
}
} else {
newArray = new slice.$array.constructor(newCapacity);
newArray.set(slice.$array.subarray(slice.$offset, slice.$offset + slice.$length));
}
}
$copyArray(newArray, array, newOffset + slice.$length, offset, length, slice.constructor.elem);
var newSlice = new slice.constructor(newArray);
newSlice.$offset = newOffset;
newSlice.$length = newLength;
newSlice.$capacity = newCapacity;
return newSlice;
};
var $equal = function(a, b, type) {
if (type === $jsObjectPtr) {
return a === b;
}
switch (type.kind) {
case $kindComplex64:
case $kindComplex128:
return a.$real === b.$real && a.$imag === b.$imag;
case $kindInt64:
case $kindUint64:
return a.$high === b.$high && a.$low === b.$low;
case $kindArray:
if (a.length !== b.length) {
return false;
}
for (var i = 0; i < a.length; i++) {
if (!$equal(a[i], b[i], type.elem)) {
return false;
}
}
return true;
case $kindStruct:
for (var i = 0; i < type.fields.length; i++) {
var f = type.fields[i];
if (!$equal(a[f.prop], b[f.prop], f.typ)) {
return false;
}
}
return true;
case $kindInterface:
return $interfaceIsEqual(a, b);
default:
return a === b;
}
};
var $interfaceIsEqual = function(a, b) {
if (a === $ifaceNil || b === $ifaceNil) {
return a === b;
}
if (a.constructor !== b.constructor) {
return false;
}
if (a.constructor === $jsObjectPtr) {
return a.object === b.object;
}
if (!a.constructor.comparable) {
$throwRuntimeError("comparing uncomparable type " + a.constructor.string);
}
return $equal(a.$val, b.$val, a.constructor);
};
var $min = Math.min;
var $mod = function(x, y) { return x % y; };
var $parseInt = parseInt;
var $parseFloat = function(f) {
if (f !== undefined && f !== null && f.constructor === Number) {
return f;
}
return parseFloat(f);
};
var $froundBuf = new Float32Array(1);
var $fround = Math.fround || function(f) {
$froundBuf[0] = f;
return $froundBuf[0];
};
var $imul = Math.imul || function(a, b) {
var ah = (a >>> 16) & 0xffff;
var al = a & 0xffff;
var bh = (b >>> 16) & 0xffff;
var bl = b & 0xffff;
return ((al * bl) + (((ah * bl + al * bh) << 16) >>> 0) >> 0);
};
var $floatKey = function(f) {
if (f !== f) {
$idCounter++;
return "NaN$" + $idCounter;
}
return String(f);
};
var $flatten64 = function(x) {
return x.$high * 4294967296 + x.$low;
};
var $shiftLeft64 = function(x, y) {
if (y === 0) {
return x;
}
if (y < 32) {
return new x.constructor(x.$high << y | x.$low >>> (32 - y), (x.$low << y) >>> 0);
}
if (y < 64) {
return new x.constructor(x.$low << (y - 32), 0);
}
return new x.constructor(0, 0);
};
var $shiftRightInt64 = function(x, y) {
if (y === 0) {
return x;
}
if (y < 32) {
return new x.constructor(x.$high >> y, (x.$low >>> y | x.$high << (32 - y)) >>> 0);
}
if (y < 64) {
return new x.constructor(x.$high >> 31, (x.$high >> (y - 32)) >>> 0);
}
if (x.$high < 0) {
return new x.constructor(-1, 4294967295);
}
return new x.constructor(0, 0);
};
var $shiftRightUint64 = function(x, y) {
if (y === 0) {
return x;
}
if (y < 32) {
return new x.constructor(x.$high >>> y, (x.$low >>> y | x.$high << (32 - y)) >>> 0);
}
if (y < 64) {
return new x.constructor(0, x.$high >>> (y - 32));
}
return new x.constructor(0, 0);
};
var $mul64 = function(x, y) {
var high = 0, low = 0;
if ((y.$low & 1) !== 0) {
high = x.$high;
low = x.$low;
}
for (var i = 1; i < 32; i++) {
if ((y.$low & 1<<i) !== 0) {
high += x.$high << i | x.$low >>> (32 - i);
low += (x.$low << i) >>> 0;
}
}
for (var i = 0; i < 32; i++) {
if ((y.$high & 1<<i) !== 0) {
high += x.$low << i;
}
}
return new x.constructor(high, low);
};
var $div64 = function(x, y, returnRemainder) {
if (y.$high === 0 && y.$low === 0) {
$throwRuntimeError("integer divide by zero");
}
var s = 1;
var rs = 1;
var xHigh = x.$high;
var xLow = x.$low;
if (xHigh < 0) {
s = -1;
rs = -1;
xHigh = -xHigh;
if (xLow !== 0) {
xHigh--;
xLow = 4294967296 - xLow;
}
}
var yHigh = y.$high;
var yLow = y.$low;
if (y.$high < 0) {
s *= -1;
yHigh = -yHigh;
if (yLow !== 0) {
yHigh--;
yLow = 4294967296 - yLow;
}
}
var high = 0, low = 0, n = 0;
while (yHigh < 2147483648 && ((xHigh > yHigh) || (xHigh === yHigh && xLow > yLow))) {
yHigh = (yHigh << 1 | yLow >>> 31) >>> 0;
yLow = (yLow << 1) >>> 0;
n++;
}
for (var i = 0; i <= n; i++) {
high = high << 1 | low >>> 31;
low = (low << 1) >>> 0;
if ((xHigh > yHigh) || (xHigh === yHigh && xLow >= yLow)) {
xHigh = xHigh - yHigh;
xLow = xLow - yLow;
if (xLow < 0) {
xHigh--;
xLow += 4294967296;
}
low++;
if (low === 4294967296) {
high++;
low = 0;
}
}
yLow = (yLow >>> 1 | yHigh << (32 - 1)) >>> 0;
yHigh = yHigh >>> 1;
}
if (returnRemainder) {
return new x.constructor(xHigh * rs, xLow * rs);
}
return new x.constructor(high * s, low * s);
};
var $divComplex = function(n, d) {
var ninf = n.$real === Infinity || n.$real === -Infinity || n.$imag === Infinity || n.$imag === -Infinity;
var dinf = d.$real === Infinity || d.$real === -Infinity || d.$imag === Infinity || d.$imag === -Infinity;
var nnan = !ninf && (n.$real !== n.$real || n.$imag !== n.$imag);
var dnan = !dinf && (d.$real !== d.$real || d.$imag !== d.$imag);
if(nnan || dnan) {
return new n.constructor(NaN, NaN);
}
if (ninf && !dinf) {
return new n.constructor(Infinity, Infinity);
}
if (!ninf && dinf) {
return new n.constructor(0, 0);
}
if (d.$real === 0 && d.$imag === 0) {
if (n.$real === 0 && n.$imag === 0) {
return new n.constructor(NaN, NaN);
}
return new n.constructor(Infinity, Infinity);
}
var a = Math.abs(d.$real);
var b = Math.abs(d.$imag);
if (a <= b) {
var ratio = d.$real / d.$imag;
var denom = d.$real * ratio + d.$imag;
return new n.constructor((n.$real * ratio + n.$imag) / denom, (n.$imag * ratio - n.$real) / denom);
}
var ratio = d.$imag / d.$real;
var denom = d.$imag * ratio + d.$real;
return new n.constructor((n.$imag * ratio + n.$real) / denom, (n.$imag - n.$real * ratio) / denom);
};
var $kindBool = 1;
var $kindInt = 2;
var $kindInt8 = 3;
var $kindInt16 = 4;
var $kindInt32 = 5;
var $kindInt64 = 6;
var $kindUint = 7;
var $kindUint8 = 8;
var $kindUint16 = 9;
var $kindUint32 = 10;
var $kindUint64 = 11;
var $kindUintptr = 12;
var $kindFloat32 = 13;
var $kindFloat64 = 14;
var $kindComplex64 = 15;
var $kindComplex128 = 16;
var $kindArray = 17;
var $kindChan = 18;
var $kindFunc = 19;
var $kindInterface = 20;
var $kindMap = 21;
var $kindPtr = 22;
var $kindSlice = 23;
var $kindString = 24;
var $kindStruct = 25;
var $kindUnsafePointer = 26;
var $methodSynthesizers = [];
var $addMethodSynthesizer = function(f) {
if ($methodSynthesizers === null) {
f();
return;
}
$methodSynthesizers.push(f);
};
var $synthesizeMethods = function() {
$methodSynthesizers.forEach(function(f) { f(); });
$methodSynthesizers = null;
};
var $ifaceKeyFor = function(x) {
if (x === $ifaceNil) {
return 'nil';
}
var c = x.constructor;
return c.string + '$' + c.keyFor(x.$val);
};
var $identity = function(x) { return x; };
var $typeIDCounter = 0;
var $idKey = function(x) {
if (x.$id === undefined) {
$idCounter++;
x.$id = $idCounter;
}
return String(x.$id);
};
var $newType = function(size, kind, string, named, pkg, exported, constructor) {
var typ;
switch(kind) {
case $kindBool:
case $kindInt:
case $kindInt8:
case $kindInt16:
case $kindInt32:
case $kindUint:
case $kindUint8:
case $kindUint16:
case $kindUint32:
case $kindUintptr:
case $kindUnsafePointer:
typ = function(v) { this.$val = v; };
typ.wrapped = true;
typ.keyFor = $identity;
break;
case $kindString:
typ = function(v) { this.$val = v; };
typ.wrapped = true;
typ.keyFor = function(x) { return "$" + x; };
break;
case $kindFloat32:
case $kindFloat64:
typ = function(v) { this.$val = v; };
typ.wrapped = true;
typ.keyFor = function(x) { return $floatKey(x); };
break;
case $kindInt64:
typ = function(high, low) {
this.$high = (high + Math.floor(Math.ceil(low) / 4294967296)) >> 0;
this.$low = low >>> 0;
this.$val = this;
};
typ.keyFor = function(x) { return x.$high + "$" + x.$low; };
break;
case $kindUint64:
typ = function(high, low) {
this.$high = (high + Math.floor(Math.ceil(low) / 4294967296)) >>> 0;
this.$low = low >>> 0;
this.$val = this;
};
typ.keyFor = function(x) { return x.$high + "$" + x.$low; };
break;
case $kindComplex64:
typ = function(real, imag) {
this.$real = $fround(real);
this.$imag = $fround(imag);
this.$val = this;
};
typ.keyFor = function(x) { return x.$real + "$" + x.$imag; };
break;
case $kindComplex128:
typ = function(real, imag) {
this.$real = real;
this.$imag = imag;
this.$val = this;
};
typ.keyFor = function(x) { return x.$real + "$" + x.$imag; };
break;
case $kindArray:
typ = function(v) { this.$val = v; };
typ.wrapped = true;
typ.ptr = $newType(4, $kindPtr, "*" + string, false, "", false, function(array) {
this.$get = function() { return array; };
this.$set = function(v) { typ.copy(this, v); };
this.$val = array;
});
typ.init = function(elem, len) {
typ.elem = elem;
typ.len = len;
typ.comparable = elem.comparable;
typ.keyFor = function(x) {
return Array.prototype.join.call($mapArray(x, function(e) {
return String(elem.keyFor(e)).replace(/\\/g, "\\\\").replace(/\$/g, "\\$");
}), "$");
};
typ.copy = function(dst, src) {
$copyArray(dst, src, 0, 0, src.length, elem);
};
typ.ptr.init(typ);
Object.defineProperty(typ.ptr.nil, "nilCheck", { get: $throwNilPointerError });
};
break;
case $kindChan:
typ = function(v) { this.$val = v; };
typ.wrapped = true;
typ.keyFor = $idKey;
typ.init = function(elem, sendOnly, recvOnly) {
typ.elem = elem;
typ.sendOnly = sendOnly;
typ.recvOnly = recvOnly;
};
break;
case $kindFunc:
typ = function(v) { this.$val = v; };
typ.wrapped = true;
typ.init = function(params, results, variadic) {
typ.params = params;
typ.results = results;
typ.variadic = variadic;
typ.comparable = false;
};
break;
case $kindInterface:
typ = { implementedBy: {}, missingMethodFor: {} };
typ.keyFor = $ifaceKeyFor;
typ.init = function(methods) {
typ.methods = methods;
methods.forEach(function(m) {
$ifaceNil[m.prop] = $throwNilPointerError;
});
};
break;
case $kindMap:
typ = function(v) { this.$val = v; };
typ.wrapped = true;
typ.init = function(key, elem) {
typ.key = key;
typ.elem = elem;
typ.comparable = false;
};
break;
case $kindPtr:
typ = constructor || function(getter, setter, target) {
this.$get = getter;
this.$set = setter;
this.$target = target;
this.$val = this;
};
typ.keyFor = $idKey;
typ.init = function(elem) {
typ.elem = elem;
typ.wrapped = (elem.kind === $kindArray);
typ.nil = new typ($throwNilPointerError, $throwNilPointerError);
};
break;
case $kindSlice:
typ = function(array) {
if (array.constructor !== typ.nativeArray) {
array = new typ.nativeArray(array);
}
this.$array = array;
this.$offset = 0;
this.$length = array.length;
this.$capacity = array.length;
this.$val = this;
};
typ.init = function(elem) {
typ.elem = elem;
typ.comparable = false;
typ.nativeArray = $nativeArray(elem.kind);
typ.nil = new typ([]);
};
break;
case $kindStruct:
typ = function(v) { this.$val = v; };
typ.wrapped = true;
typ.ptr = $newType(4, $kindPtr, "*" + string, false, pkg, exported, constructor);
typ.ptr.elem = typ;
typ.ptr.prototype.$get = function() { return this; };
typ.ptr.prototype.$set = function(v) { typ.copy(this, v); };
typ.init = function(pkgPath, fields) {
typ.pkgPath = pkgPath;
typ.fields = fields;
fields.forEach(function(f) {
if (!f.typ.comparable) {
typ.comparable = false;
}
});
typ.keyFor = function(x) {
var val = x.$val;
return $mapArray(fields, function(f) {
return String(f.typ.keyFor(val[f.prop])).replace(/\\/g, "\\\\").replace(/\$/g, "\\$");
}).join("$");
};
typ.copy = function(dst, src) {
for (var i = 0; i < fields.length; i++) {
var f = fields[i];
switch (f.typ.kind) {
case $kindArray:
case $kindStruct:
f.typ.copy(dst[f.prop], src[f.prop]);
continue;
default:
dst[f.prop] = src[f.prop];
continue;
}
}
};
/* nil value */
var properties = {};
fields.forEach(function(f) {
properties[f.prop] = { get: $throwNilPointerError, set: $throwNilPointerError };
});
typ.ptr.nil = Object.create(constructor.prototype, properties);
typ.ptr.nil.$val = typ.ptr.nil;
/* methods for embedded fields */
$addMethodSynthesizer(function() {
var synthesizeMethod = function(target, m, f) {
if (target.prototype[m.prop] !== undefined) { return; }
target.prototype[m.prop] = function() {
var v = this.$val[f.prop];
if (f.typ === $jsObjectPtr) {
v = new $jsObjectPtr(v);
}
if (v.$val === undefined) {
v = new f.typ(v);
}
return v[m.prop].apply(v, arguments);
};
};
fields.forEach(function(f) {
if (f.embedded) {
$methodSet(f.typ).forEach(function(m) {
synthesizeMethod(typ, m, f);
synthesizeMethod(typ.ptr, m, f);
});
$methodSet($ptrType(f.typ)).forEach(function(m) {
synthesizeMethod(typ.ptr, m, f);
});
}
});
});
};
break;
default:
$panic(new $String("invalid kind: " + kind));
}
switch (kind) {
case $kindBool:
case $kindMap:
typ.zero = function() { return false; };
break;
case $kindInt:
case $kindInt8:
case $kindInt16:
case $kindInt32:
case $kindUint:
case $kindUint8 :
case $kindUint16:
case $kindUint32:
case $kindUintptr:
case $kindUnsafePointer:
case $kindFloat32:
case $kindFloat64:
typ.zero = function() { return 0; };
break;
case $kindString:
typ.zero = function() { return ""; };
break;
case $kindInt64:
case $kindUint64:
case $kindComplex64:
case $kindComplex128:
var zero = new typ(0, 0);
typ.zero = function() { return zero; };
break;
case $kindPtr:
case $kindSlice:
typ.zero = function() { return typ.nil; };
break;
case $kindChan:
typ.zero = function() { return $chanNil; };
break;
case $kindFunc:
typ.zero = function() { return $throwNilPointerError; };
break;
case $kindInterface:
typ.zero = function() { return $ifaceNil; };
break;
case $kindArray:
typ.zero = function() {
var arrayClass = $nativeArray(typ.elem.kind);
if (arrayClass !== Array) {
return new arrayClass(typ.len);
}
var array = new Array(typ.len);
for (var i = 0; i < typ.len; i++) {
array[i] = typ.elem.zero();
}
return array;
};
break;
case $kindStruct:
typ.zero = function() { return new typ.ptr(); };
break;
default:
$panic(new $String("invalid kind: " + kind));
}
typ.id = $typeIDCounter;
$typeIDCounter++;
typ.size = size;
typ.kind = kind;
typ.string = string;
typ.named = named;
typ.pkg = pkg;
typ.exported = exported;
typ.methods = [];
typ.methodSetCache = null;
typ.comparable = true;
return typ;
};
var $methodSet = function(typ) {
if (typ.methodSetCache !== null) {
return typ.methodSetCache;
}
var base = {};
var isPtr = (typ.kind === $kindPtr);
if (isPtr && typ.elem.kind === $kindInterface) {
typ.methodSetCache = [];
return [];
}
var current = [{typ: isPtr ? typ.elem : typ, indirect: isPtr}];
var seen = {};
while (current.length > 0) {
var next = [];
var mset = [];
current.forEach(function(e) {
if (seen[e.typ.string]) {
return;
}
seen[e.typ.string] = true;
if (e.typ.named) {
mset = mset.concat(e.typ.methods);
if (e.indirect) {
mset = mset.concat($ptrType(e.typ).methods);
}
}
switch (e.typ.kind) {
case $kindStruct:
e.typ.fields.forEach(function(f) {
if (f.embedded) {
var fTyp = f.typ;
var fIsPtr = (fTyp.kind === $kindPtr);
next.push({typ: fIsPtr ? fTyp.elem : fTyp, indirect: e.indirect || fIsPtr});
}
});
break;
case $kindInterface:
mset = mset.concat(e.typ.methods);
break;
}
});
mset.forEach(function(m) {
if (base[m.name] === undefined) {
base[m.name] = m;
}
});
current = next;
}
typ.methodSetCache = [];
Object.keys(base).sort().forEach(function(name) {
typ.methodSetCache.push(base[name]);
});
return typ.methodSetCache;
};
var $Bool = $newType( 1, $kindBool, "bool", true, "", false, null);
var $Int = $newType( 4, $kindInt, "int", true, "", false, null);
var $Int8 = $newType( 1, $kindInt8, "int8", true, "", false, null);
var $Int16 = $newType( 2, $kindInt16, "int16", true, "", false, null);
var $Int32 = $newType( 4, $kindInt32, "int32", true, "", false, null);
var $Int64 = $newType( 8, $kindInt64, "int64", true, "", false, null);
var $Uint = $newType( 4, $kindUint, "uint", true, "", false, null);
var $Uint8 = $newType( 1, $kindUint8, "uint8", true, "", false, null);
var $Uint16 = $newType( 2, $kindUint16, "uint16", true, "", false, null);
var $Uint32 = $newType( 4, $kindUint32, "uint32", true, "", false, null);
var $Uint64 = $newType( 8, $kindUint64, "uint64", true, "", false, null);
var $Uintptr = $newType( 4, $kindUintptr, "uintptr", true, "", false, null);
var $Float32 = $newType( 4, $kindFloat32, "float32", true, "", false, null);
var $Float64 = $newType( 8, $kindFloat64, "float64", true, "", false, null);
var $Complex64 = $newType( 8, $kindComplex64, "complex64", true, "", false, null);
var $Complex128 = $newType(16, $kindComplex128, "complex128", true, "", false, null);
var $String = $newType( 8, $kindString, "string", true, "", false, null);
var $UnsafePointer = $newType( 4, $kindUnsafePointer, "unsafe.Pointer", true, "", false, null);
var $nativeArray = function(elemKind) {
switch (elemKind) {
case $kindInt:
return Int32Array;
case $kindInt8:
return Int8Array;
case $kindInt16:
return Int16Array;
case $kindInt32:
return Int32Array;
case $kindUint:
return Uint32Array;
case $kindUint8:
return Uint8Array;
case $kindUint16:
return Uint16Array;
case $kindUint32:
return Uint32Array;
case $kindUintptr:
return Uint32Array;
case $kindFloat32:
return Float32Array;
case $kindFloat64:
return Float64Array;
default:
return Array;
}
};
var $toNativeArray = function(elemKind, array) {
var nativeArray = $nativeArray(elemKind);
if (nativeArray === Array) {
return array;
}
return new nativeArray(array);
};
var $arrayTypes = {};
var $arrayType = function(elem, len) {
var typeKey = elem.id + "$" + len;
var typ = $arrayTypes[typeKey];
if (typ === undefined) {
typ = $newType(12, $kindArray, "[" + len + "]" + elem.string, false, "", false, null);
$arrayTypes[typeKey] = typ;
typ.init(elem, len);
}
return typ;
};
var $chanType = function(elem, sendOnly, recvOnly) {
var string = (recvOnly ? "<-" : "") + "chan" + (sendOnly ? "<- " : " ") + elem.string;
var field = sendOnly ? "SendChan" : (recvOnly ? "RecvChan" : "Chan");
var typ = elem[field];
if (typ === undefined) {
typ = $newType(4, $kindChan, string, false, "", false, null);
elem[field] = typ;
typ.init(elem, sendOnly, recvOnly);
}
return typ;
};
var $Chan = function(elem, capacity) {
if (capacity < 0 || capacity > 2147483647) {
$throwRuntimeError("makechan: size out of range");
}
this.$elem = elem;
this.$capacity = capacity;
this.$buffer = [];
this.$sendQueue = [];
this.$recvQueue = [];
this.$closed = false;
};
var $chanNil = new $Chan(null, 0);
$chanNil.$sendQueue = $chanNil.$recvQueue = { length: 0, push: function() {}, shift: function() { return undefined; }, indexOf: function() { return -1; } };
var $funcTypes = {};
var $funcType = function(params, results, variadic) {
var typeKey = $mapArray(params, function(p) { return p.id; }).join(",") + "$" + $mapArray(results, function(r) { return r.id; }).join(",") + "$" + variadic;
var typ = $funcTypes[typeKey];
if (typ === undefined) {
var paramTypes = $mapArray(params, function(p) { return p.string; });
if (variadic) {
paramTypes[paramTypes.length - 1] = "..." + paramTypes[paramTypes.length - 1].substr(2);
}
var string = "func(" + paramTypes.join(", ") + ")";
if (results.length === 1) {
string += " " + results[0].string;
} else if (results.length > 1) {
string += " (" + $mapArray(results, function(r) { return r.string; }).join(", ") + ")";
}
typ = $newType(4, $kindFunc, string, false, "", false, null);
$funcTypes[typeKey] = typ;
typ.init(params, results, variadic);
}
return typ;
};
var $interfaceTypes = {};
var $interfaceType = function(methods) {
var typeKey = $mapArray(methods, function(m) { return m.pkg + "," + m.name + "," + m.typ.id; }).join("$");
var typ = $interfaceTypes[typeKey];
if (typ === undefined) {
var string = "interface {}";
if (methods.length !== 0) {
string = "interface { " + $mapArray(methods, function(m) {
return (m.pkg !== "" ? m.pkg + "." : "") + m.name + m.typ.string.substr(4);
}).join("; ") + " }";
}
typ = $newType(8, $kindInterface, string, false, "", false, null);
$interfaceTypes[typeKey] = typ;
typ.init(methods);
}
return typ;
};
var $emptyInterface = $interfaceType([]);
var $ifaceNil = {};
var $error = $newType(8, $kindInterface, "error", true, "", false, null);
$error.init([{prop: "Error", name: "Error", pkg: "", typ: $funcType([], [$String], false)}]);
var $mapTypes = {};
var $mapType = function(key, elem) {
var typeKey = key.id + "$" + elem.id;
var typ = $mapTypes[typeKey];
if (typ === undefined) {
typ = $newType(4, $kindMap, "map[" + key.string + "]" + elem.string, false, "", false, null);
$mapTypes[typeKey] = typ;
typ.init(key, elem);
}
return typ;
};
var $makeMap = function(keyForFunc, entries) {
var m = {};
for (var i = 0; i < entries.length; i++) {
var e = entries[i];
m[keyForFunc(e.k)] = e;
}
return m;
};
var $ptrType = function(elem) {
var typ = elem.ptr;
if (typ === undefined) {
typ = $newType(4, $kindPtr, "*" + elem.string, false, "", elem.exported, null);
elem.ptr = typ;
typ.init(elem);
}
return typ;
};
var $newDataPointer = function(data, constructor) {
if (constructor.elem.kind === $kindStruct) {
return data;
}
return new constructor(function() { return data; }, function(v) { data = v; });
};
var $indexPtr = function(array, index, constructor) {
array.$ptr = array.$ptr || {};
return array.$ptr[index] || (array.$ptr[index] = new constructor(function() { return array[index]; }, function(v) { array[index] = v; }));
};
var $sliceType = function(elem) {
var typ = elem.slice;
if (typ === undefined) {
typ = $newType(12, $kindSlice, "[]" + elem.string, false, "", false, null);
elem.slice = typ;
typ.init(elem);
}
return typ;
};
var $makeSlice = function(typ, length, capacity) {
capacity = capacity || length;
if (length < 0 || length > 2147483647) {
$throwRuntimeError("makeslice: len out of range");
}
if (capacity < 0 || capacity < length || capacity > 2147483647) {
$throwRuntimeError("makeslice: cap out of range");
}
var array = new typ.nativeArray(capacity);
if (typ.nativeArray === Array) {
for (var i = 0; i < capacity; i++) {
array[i] = typ.elem.zero();
}
}
var slice = new typ(array);
slice.$length = length;
return slice;
};
var $structTypes = {};
var $structType = function(pkgPath, fields) {
var typeKey = $mapArray(fields, function(f) { return f.name + "," + f.typ.id + "," + f.tag; }).join("$");
var typ = $structTypes[typeKey];
if (typ === undefined) {
var string = "struct { " + $mapArray(fields, function(f) {
return f.name + " " + f.typ.string + (f.tag !== "" ? (" \"" + f.tag.replace(/\\/g, "\\\\").replace(/"/g, "\\\"") + "\"") : "");
}).join("; ") + " }";
if (fields.length === 0) {
string = "struct {}";
}
typ = $newType(0, $kindStruct, string, false, "", false, function() {
this.$val = this;
for (var i = 0; i < fields.length; i++) {
var f = fields[i];
var arg = arguments[i];
this[f.prop] = arg !== undefined ? arg : f.typ.zero();
}
});
$structTypes[typeKey] = typ;
typ.init(pkgPath, fields);
}
return typ;
};
var $assertType = function(value, type, returnTuple) {
var isInterface = (type.kind === $kindInterface), ok, missingMethod = "";
if (value === $ifaceNil) {
ok = false;
} else if (!isInterface) {
ok = value.constructor === type;
} else {
var valueTypeString = value.constructor.string;
ok = type.implementedBy[valueTypeString];
if (ok === undefined) {
ok = true;
var valueMethodSet = $methodSet(value.constructor);
var interfaceMethods = type.methods;
for (var i = 0; i < interfaceMethods.length; i++) {
var tm = interfaceMethods[i];
var found = false;
for (var j = 0; j < valueMethodSet.length; j++) {
var vm = valueMethodSet[j];
if (vm.name === tm.name && vm.pkg === tm.pkg && vm.typ === tm.typ) {
found = true;
break;
}
}
if (!found) {
ok = false;
type.missingMethodFor[valueTypeString] = tm.name;
break;
}
}
type.implementedBy[valueTypeString] = ok;
}
if (!ok) {
missingMethod = type.missingMethodFor[valueTypeString];
}
}
if (!ok) {
if (returnTuple) {
return [type.zero(), false];
}
$panic(new $packages["runtime"].TypeAssertionError.ptr(
$packages["runtime"]._type.ptr.nil,
(value === $ifaceNil ? $packages["runtime"]._type.ptr.nil : new $packages["runtime"]._type.ptr(value.constructor.string)),
new $packages["runtime"]._type.ptr(type.string),
missingMethod));
}
if (!isInterface) {
value = value.$val;
}
if (type === $jsObjectPtr) {
value = value.object;
}
return returnTuple ? [value, true] : value;
};
var $stackDepthOffset = 0;
var $getStackDepth = function() {
var err = new Error();
if (err.stack === undefined) {
return undefined;
}
return $stackDepthOffset + err.stack.split("\n").length;
};
var $panicStackDepth = null, $panicValue;
var $callDeferred = function(deferred, jsErr, fromPanic) {
if (!fromPanic && deferred !== null && deferred.index >= $curGoroutine.deferStack.length) {
throw jsErr;
}
if (jsErr !== null) {
var newErr = null;
try {
$curGoroutine.deferStack.push(deferred);
$panic(new $jsErrorPtr(jsErr));
} catch (err) {
newErr = err;
}
$curGoroutine.deferStack.pop();
$callDeferred(deferred, newErr);
return;
}
if ($curGoroutine.asleep) {
return;
}
$stackDepthOffset--;
var outerPanicStackDepth = $panicStackDepth;
var outerPanicValue = $panicValue;
var localPanicValue = $curGoroutine.panicStack.pop();
if (localPanicValue !== undefined) {
$panicStackDepth = $getStackDepth();
$panicValue = localPanicValue;
}
try {
while (true) {
if (deferred === null) {
deferred = $curGoroutine.deferStack[$curGoroutine.deferStack.length - 1];
if (deferred === undefined) {
/* The panic reached the top of the stack. Clear it and throw it as a JavaScript error. */
$panicStackDepth = null;
if (localPanicValue.Object instanceof Error) {
throw localPanicValue.Object;
}
var msg;
if (localPanicValue.constructor === $String) {
msg = localPanicValue.$val;
} else if (localPanicValue.Error !== undefined) {
msg = localPanicValue.Error();
} else if (localPanicValue.String !== undefined) {
msg = localPanicValue.String();
} else {
msg = localPanicValue;
}
throw new Error(msg);
}
}
var call = deferred.pop();
if (call === undefined) {
$curGoroutine.deferStack.pop();
if (localPanicValue !== undefined) {
deferred = null;
continue;
}
return;
}
var r = call[0].apply(call[2], call[1]);
if (r && r.$blk !== undefined) {
deferred.push([r.$blk, [], r]);
if (fromPanic) {
throw null;
}
return;
}
if (localPanicValue !== undefined && $panicStackDepth === null) {
throw null; /* error was recovered */
}
}
} finally {
if (localPanicValue !== undefined) {
if ($panicStackDepth !== null) {
$curGoroutine.panicStack.push(localPanicValue);
}
$panicStackDepth = outerPanicStackDepth;
$panicValue = outerPanicValue;
}
$stackDepthOffset++;
}
};
var $panic = function(value) {
$curGoroutine.panicStack.push(value);
$callDeferred(null, null, true);
};
var $recover = function() {
if ($panicStackDepth === null || ($panicStackDepth !== undefined && $panicStackDepth !== $getStackDepth() - 2)) {
return $ifaceNil;
}
$panicStackDepth = null;
return $panicValue;
};
var $throw = function(err) { throw err; };
var $noGoroutine = { asleep: false, exit: false, deferStack: [], panicStack: [] };
var $curGoroutine = $noGoroutine, $totalGoroutines = 0, $awakeGoroutines = 0, $checkForDeadlock = true;
var $mainFinished = false;
var $go = function(fun, args) {
$totalGoroutines++;
$awakeGoroutines++;
var $goroutine = function() {
try {
$curGoroutine = $goroutine;
var r = fun.apply(undefined, args);
if (r && r.$blk !== undefined) {
fun = function() { return r.$blk(); };
args = [];
return;
}
$goroutine.exit = true;
} catch (err) {
if (!$goroutine.exit) {
throw err;
}
} finally {
$curGoroutine = $noGoroutine;
if ($goroutine.exit) { /* also set by runtime.Goexit() */
$totalGoroutines--;
$goroutine.asleep = true;
}
if ($goroutine.asleep) {
$awakeGoroutines--;
if (!$mainFinished && $awakeGoroutines === 0 && $checkForDeadlock) {
console.error("fatal error: all goroutines are asleep - deadlock!");
if ($global.process !== undefined) {
$global.process.exit(2);
}
}
}
}
};
$goroutine.asleep = false;
$goroutine.exit = false;
$goroutine.deferStack = [];
$goroutine.panicStack = [];
$schedule($goroutine);
};
var $scheduled = [];
var $runScheduled = function() {
try {
var r;
while ((r = $scheduled.shift()) !== undefined) {
r();
}
} finally {
if ($scheduled.length > 0) {
setTimeout($runScheduled, 0);
}
}
};
var $schedule = function(goroutine) {
if (goroutine.asleep) {
goroutine.asleep = false;
$awakeGoroutines++;
}
$scheduled.push(goroutine);
if ($curGoroutine === $noGoroutine) {
$runScheduled();
}
};
var $setTimeout = function(f, t) {
$awakeGoroutines++;
return setTimeout(function() {
$awakeGoroutines--;
f();
}, t);
};
var $block = function() {
if ($curGoroutine === $noGoroutine) {
$throwRuntimeError("cannot block in JavaScript callback, fix by wrapping code in goroutine");
}
$curGoroutine.asleep = true;
};
var $send = function(chan, value) {
if (chan.$closed) {
$throwRuntimeError("send on closed channel");
}
var queuedRecv = chan.$recvQueue.shift();
if (queuedRecv !== undefined) {
queuedRecv([value, true]);
return;
}
if (chan.$buffer.length < chan.$capacity) {
chan.$buffer.push(value);
return;
}
var thisGoroutine = $curGoroutine;
var closedDuringSend;
chan.$sendQueue.push(function(closed) {
closedDuringSend = closed;
$schedule(thisGoroutine);
return value;
});
$block();
return {
$blk: function() {
if (closedDuringSend) {
$throwRuntimeError("send on closed channel");
}
}
};
};
var $recv = function(chan) {
var queuedSend = chan.$sendQueue.shift();
if (queuedSend !== undefined) {
chan.$buffer.push(queuedSend(false));
}
var bufferedValue = chan.$buffer.shift();
if (bufferedValue !== undefined) {
return [bufferedValue, true];
}
if (chan.$closed) {
return [chan.$elem.zero(), false];
}
var thisGoroutine = $curGoroutine;
var f = { $blk: function() { return this.value; } };
var queueEntry = function(v) {
f.value = v;
$schedule(thisGoroutine);
};
chan.$recvQueue.push(queueEntry);
$block();
return f;
};
var $close = function(chan) {
if (chan.$closed) {
$throwRuntimeError("close of closed channel");
}
chan.$closed = true;
while (true) {
var queuedSend = chan.$sendQueue.shift();
if (queuedSend === undefined) {
break;
}
queuedSend(true); /* will panic */
}
while (true) {
var queuedRecv = chan.$recvQueue.shift();
if (queuedRecv === undefined) {
break;
}
queuedRecv([chan.$elem.zero(), false]);
}
};
var $select = function(comms) {
var ready = [];
var selection = -1;
for (var i = 0; i < comms.length; i++) {
var comm = comms[i];
var chan = comm[0];
switch (comm.length) {
case 0: /* default */
selection = i;
break;
case 1: /* recv */
if (chan.$sendQueue.length !== 0 || chan.$buffer.length !== 0 || chan.$closed) {
ready.push(i);
}
break;
case 2: /* send */
if (chan.$closed) {
$throwRuntimeError("send on closed channel");
}
if (chan.$recvQueue.length !== 0 || chan.$buffer.length < chan.$capacity) {
ready.push(i);
}
break;
}
}
if (ready.length !== 0) {
selection = ready[Math.floor(Math.random() * ready.length)];
}
if (selection !== -1) {
var comm = comms[selection];
switch (comm.length) {
case 0: /* default */
return [selection];
case 1: /* recv */
return [selection, $recv(comm[0])];
case 2: /* send */
$send(comm[0], comm[1]);
return [selection];
}
}
var entries = [];
var thisGoroutine = $curGoroutine;
var f = { $blk: function() { return this.selection; } };
var removeFromQueues = function() {
for (var i = 0; i < entries.length; i++) {
var entry = entries[i];
var queue = entry[0];
var index = queue.indexOf(entry[1]);
if (index !== -1) {
queue.splice(index, 1);
}
}
};
for (var i = 0; i < comms.length; i++) {
(function(i) {
var comm = comms[i];
switch (comm.length) {
case 1: /* recv */
var queueEntry = function(value) {
f.selection = [i, value];
removeFromQueues();
$schedule(thisGoroutine);
};
entries.push([comm[0].$recvQueue, queueEntry]);
comm[0].$recvQueue.push(queueEntry);
break;
case 2: /* send */
var queueEntry = function() {
if (comm[0].$closed) {
$throwRuntimeError("send on closed channel");
}
f.selection = [i];
removeFromQueues();
$schedule(thisGoroutine);
return comm[1];
};
entries.push([comm[0].$sendQueue, queueEntry]);
comm[0].$sendQueue.push(queueEntry);
break;
}
})(i);
}
$block();
return f;
};
var $jsObjectPtr, $jsErrorPtr;
var $needsExternalization = function(t) {
switch (t.kind) {
case $kindBool:
case $kindInt:
case $kindInt8:
case $kindInt16:
case $kindInt32:
case $kindUint:
case $kindUint8:
case $kindUint16:
case $kindUint32:
case $kindUintptr:
case $kindFloat32:
case $kindFloat64:
return false;
default:
return t !== $jsObjectPtr;
}
};
var $externalize = function(v, t) {
if (t === $jsObjectPtr) {
return v;
}
switch (t.kind) {
case $kindBool:
case $kindInt:
case $kindInt8:
case $kindInt16:
case $kindInt32:
case $kindUint:
case $kindUint8:
case $kindUint16:
case $kindUint32:
case $kindUintptr:
case $kindFloat32:
case $kindFloat64:
return v;
case $kindInt64:
case $kindUint64:
return $flatten64(v);
case $kindArray:
if ($needsExternalization(t.elem)) {
return $mapArray(v, function(e) { return $externalize(e, t.elem); });
}
return v;
case $kindFunc:
return $externalizeFunction(v, t, false);
case $kindInterface:
if (v === $ifaceNil) {
return null;
}
if (v.constructor === $jsObjectPtr) {
return v.$val.object;
}
return $externalize(v.$val, v.constructor);
case $kindMap:
var m = {};
var keys = $keys(v);
for (var i = 0; i < keys.length; i++) {
var entry = v[keys[i]];
m[$externalize(entry.k, t.key)] = $externalize(entry.v, t.elem);
}
return m;
case $kindPtr:
if (v === t.nil) {
return null;
}
return $externalize(v.$get(), t.elem);
case $kindSlice:
if ($needsExternalization(t.elem)) {
return $mapArray($sliceToArray(v), function(e) { return $externalize(e, t.elem); });
}
return $sliceToArray(v);
case $kindString:
if ($isASCII(v)) {
return v;
}
var s = "", r;
for (var i = 0; i < v.length; i += r[1]) {
r = $decodeRune(v, i);
var c = r[0];
if (c > 0xFFFF) {
var h = Math.floor((c - 0x10000) / 0x400) + 0xD800;
var l = (c - 0x10000) % 0x400 + 0xDC00;
s += String.fromCharCode(h, l);
continue;
}
s += String.fromCharCode(c);
}
return s;
case $kindStruct:
var timePkg = $packages["time"];
if (timePkg !== undefined && v.constructor === timePkg.Time.ptr) {
var milli = $div64(v.UnixNano(), new $Int64(0, 1000000));
return new Date($flatten64(milli));
}
var noJsObject = {};
var searchJsObject = function(v, t) {
if (t === $jsObjectPtr) {
return v;
}
switch (t.kind) {
case $kindPtr:
if (v === t.nil) {
return noJsObject;
}
return searchJsObject(v.$get(), t.elem);
case $kindStruct:
var f = t.fields[0];
return searchJsObject(v[f.prop], f.typ);
case $kindInterface:
return searchJsObject(v.$val, v.constructor);
default:
return noJsObject;
}
};
var o = searchJsObject(v, t);
if (o !== noJsObject) {
return o;
}
o = {};
for (var i = 0; i < t.fields.length; i++) {
var f = t.fields[i];
if (!f.exported) {
continue;
}
o[f.name] = $externalize(v[f.prop], f.typ);
}
return o;
}
$throwRuntimeError("cannot externalize " + t.string);
};
var $externalizeFunction = function(v, t, passThis) {
if (v === $throwNilPointerError) {
return null;
}
if (v.$externalizeWrapper === undefined) {
$checkForDeadlock = false;
v.$externalizeWrapper = function() {
var args = [];
for (var i = 0; i < t.params.length; i++) {
if (t.variadic && i === t.params.length - 1) {
var vt = t.params[i].elem, varargs = [];
for (var j = i; j < arguments.length; j++) {
varargs.push($internalize(arguments[j], vt));
}
args.push(new (t.params[i])(varargs));
break;
}
args.push($internalize(arguments[i], t.params[i]));
}
var result = v.apply(passThis ? this : undefined, args);
switch (t.results.length) {
case 0:
return;
case 1:
return $externalize(result, t.results[0]);
default:
for (var i = 0; i < t.results.length; i++) {
result[i] = $externalize(result[i], t.results[i]);
}
return result;
}
};
}
return v.$externalizeWrapper;
};
var $internalize = function(v, t, recv) {
if (t === $jsObjectPtr) {
return v;
}
if (t === $jsObjectPtr.elem) {
$throwRuntimeError("cannot internalize js.Object, use *js.Object instead");
}
if (v && v.__internal_object__ !== undefined) {
return $assertType(v.__internal_object__, t, false);
}
var timePkg = $packages["time"];
if (timePkg !== undefined && t === timePkg.Time) {
if (!(v !== null && v !== undefined && v.constructor === Date)) {
$throwRuntimeError("cannot internalize time.Time from " + typeof v + ", must be Date");
}
return timePkg.Unix(new $Int64(0, 0), new $Int64(0, v.getTime() * 1000000));
}
switch (t.kind) {
case $kindBool:
return !!v;
case $kindInt:
return parseInt(v);
case $kindInt8:
return parseInt(v) << 24 >> 24;
case $kindInt16:
return parseInt(v) << 16 >> 16;
case $kindInt32:
return parseInt(v) >> 0;
case $kindUint:
return parseInt(v);
case $kindUint8:
return parseInt(v) << 24 >>> 24;
case $kindUint16:
return parseInt(v) << 16 >>> 16;
case $kindUint32:
case $kindUintptr:
return parseInt(v) >>> 0;
case $kindInt64:
case $kindUint64:
return new t(0, v);
case $kindFloat32:
case $kindFloat64:
return parseFloat(v);
case $kindArray:
if (v.length !== t.len) {
$throwRuntimeError("got array with wrong size from JavaScript native");
}
return $mapArray(v, function(e) { return $internalize(e, t.elem); });
case $kindFunc:
return function() {
var args = [];
for (var i = 0; i < t.params.length; i++) {
if (t.variadic && i === t.params.length - 1) {
var vt = t.params[i].elem, varargs = arguments[i];
for (var j = 0; j < varargs.$length; j++) {
args.push($externalize(varargs.$array[varargs.$offset + j], vt));
}
break;
}
args.push($externalize(arguments[i], t.params[i]));
}
var result = v.apply(recv, args);
switch (t.results.length) {
case 0:
return;
case 1:
return $internalize(result, t.results[0]);
default:
for (var i = 0; i < t.results.length; i++) {
result[i] = $internalize(result[i], t.results[i]);
}
return result;
}
};
case $kindInterface:
if (t.methods.length !== 0) {
$throwRuntimeError("cannot internalize " + t.string);
}
if (v === null) {
return $ifaceNil;
}
if (v === undefined) {
return new $jsObjectPtr(undefined);
}
switch (v.constructor) {
case Int8Array:
return new ($sliceType($Int8))(v);
case Int16Array:
return new ($sliceType($Int16))(v);
case Int32Array:
return new ($sliceType($Int))(v);
case Uint8Array:
return new ($sliceType($Uint8))(v);
case Uint16Array:
return new ($sliceType($Uint16))(v);
case Uint32Array:
return new ($sliceType($Uint))(v);
case Float32Array:
return new ($sliceType($Float32))(v);
case Float64Array:
return new ($sliceType($Float64))(v);
case Array:
return $internalize(v, $sliceType($emptyInterface));
case Boolean:
return new $Bool(!!v);
case Date:
if (timePkg === undefined) {
/* time package is not present, internalize as &js.Object{Date} so it can be externalized into original Date. */
return new $jsObjectPtr(v);
}
return new timePkg.Time($internalize(v, timePkg.Time));
case Function:
var funcType = $funcType([$sliceType($emptyInterface)], [$jsObjectPtr], true);
return new funcType($internalize(v, funcType));
case Number:
return new $Float64(parseFloat(v));
case String:
return new $String($internalize(v, $String));
default:
if ($global.Node && v instanceof $global.Node) {
return new $jsObjectPtr(v);
}
var mapType = $mapType($String, $emptyInterface);
return new mapType($internalize(v, mapType));
}
case $kindMap:
var m = {};
var keys = $keys(v);
for (var i = 0; i < keys.length; i++) {
var k = $internalize(keys[i], t.key);
m[t.key.keyFor(k)] = { k: k, v: $internalize(v[keys[i]], t.elem) };
}
return m;
case $kindPtr:
if (t.elem.kind === $kindStruct) {
return $internalize(v, t.elem);
}
case $kindSlice:
return new t($mapArray(v, function(e) { return $internalize(e, t.elem); }));
case $kindString:
v = String(v);
if ($isASCII(v)) {
return v;
}
var s = "";
var i = 0;
while (i < v.length) {
var h = v.charCodeAt(i);
if (0xD800 <= h && h <= 0xDBFF) {
var l = v.charCodeAt(i + 1);
var c = (h - 0xD800) * 0x400 + l - 0xDC00 + 0x10000;
s += $encodeRune(c);
i += 2;
continue;
}
s += $encodeRune(h);
i++;
}
return s;
case $kindStruct:
var noJsObject = {};
var searchJsObject = function(t) {
if (t === $jsObjectPtr) {
return v;
}
if (t === $jsObjectPtr.elem) {
$throwRuntimeError("cannot internalize js.Object, use *js.Object instead");
}
switch (t.kind) {
case $kindPtr:
return searchJsObject(t.elem);
case $kindStruct:
var f = t.fields[0];
var o = searchJsObject(f.typ);
if (o !== noJsObject) {
var n = new t.ptr();
n[f.prop] = o;
return n;
}
return noJsObject;
default:
return noJsObject;
}
};
var o = searchJsObject(t);
if (o !== noJsObject) {
return o;
}
}
$throwRuntimeError("cannot internalize " + t.string);
};
/* $isASCII reports whether string s contains only ASCII characters. */
var $isASCII = function(s) {
for (var i = 0; i < s.length; i++) {
if (s.charCodeAt(i) >= 128) {
return false;
}
}
return true;
};
$packages["github.com/gopherjs/gopherjs/js"] = (function() {
var $pkg = {}, $init, Object, Error, sliceType, ptrType, ptrType$1, MakeFunc, init;
Object = $pkg.Object = $newType(0, $kindStruct, "js.Object", true, "github.com/gopherjs/gopherjs/js", true, function(object_) {
this.$val = this;
if (arguments.length === 0) {
this.object = null;
return;
}
this.object = object_;
});
Error = $pkg.Error = $newType(0, $kindStruct, "js.Error", true, "github.com/gopherjs/gopherjs/js", true, function(Object_) {
this.$val = this;
if (arguments.length === 0) {
this.Object = null;
return;
}
this.Object = Object_;
});
sliceType = $sliceType($emptyInterface);
ptrType = $ptrType(Object);
ptrType$1 = $ptrType(Error);
Object.ptr.prototype.Get = function(key) {
var key, o;
o = this;
return o.object[$externalize(key, $String)];
};
Object.prototype.Get = function(key) { return this.$val.Get(key); };
Object.ptr.prototype.Set = function(key, value) {
var key, o, value;
o = this;
o.object[$externalize(key, $String)] = $externalize(value, $emptyInterface);
};
Object.prototype.Set = function(key, value) { return this.$val.Set(key, value); };
Object.ptr.prototype.Delete = function(key) {
var key, o;
o = this;
delete o.object[$externalize(key, $String)];
};
Object.prototype.Delete = function(key) { return this.$val.Delete(key); };
Object.ptr.prototype.Length = function() {
var o;
o = this;
return $parseInt(o.object.length);
};
Object.prototype.Length = function() { return this.$val.Length(); };
Object.ptr.prototype.Index = function(i) {
var i, o;
o = this;
return o.object[i];
};
Object.prototype.Index = function(i) { return this.$val.Index(i); };
Object.ptr.prototype.SetIndex = function(i, value) {
var i, o, value;
o = this;
o.object[i] = $externalize(value, $emptyInterface);
};
Object.prototype.SetIndex = function(i, value) { return this.$val.SetIndex(i, value); };
Object.ptr.prototype.Call = function(name, args) {
var args, name, o, obj;
o = this;
return (obj = o.object, obj[$externalize(name, $String)].apply(obj, $externalize(args, sliceType)));
};
Object.prototype.Call = function(name, args) { return this.$val.Call(name, args); };
Object.ptr.prototype.Invoke = function(args) {
var args, o;
o = this;
return o.object.apply(undefined, $externalize(args, sliceType));
};
Object.prototype.Invoke = function(args) { return this.$val.Invoke(args); };
Object.ptr.prototype.New = function(args) {
var args, o;
o = this;
return new ($global.Function.prototype.bind.apply(o.object, [undefined].concat($externalize(args, sliceType))));
};
Object.prototype.New = function(args) { return this.$val.New(args); };
Object.ptr.prototype.Bool = function() {
var o;
o = this;
return !!(o.object);
};
Object.prototype.Bool = function() { return this.$val.Bool(); };
Object.ptr.prototype.String = function() {
var o;
o = this;
return $internalize(o.object, $String);
};
Object.prototype.String = function() { return this.$val.String(); };
Object.ptr.prototype.Int = function() {
var o;
o = this;
return $parseInt(o.object) >> 0;
};
Object.prototype.Int = function() { return this.$val.Int(); };
Object.ptr.prototype.Int64 = function() {
var o;
o = this;
return $internalize(o.object, $Int64);
};
Object.prototype.Int64 = function() { return this.$val.Int64(); };
Object.ptr.prototype.Uint64 = function() {
var o;
o = this;
return $internalize(o.object, $Uint64);
};
Object.prototype.Uint64 = function() { return this.$val.Uint64(); };
Object.ptr.prototype.Float = function() {
var o;
o = this;
return $parseFloat(o.object);
};
Object.prototype.Float = function() { return this.$val.Float(); };
Object.ptr.prototype.Interface = function() {
var o;
o = this;
return $internalize(o.object, $emptyInterface);
};
Object.prototype.Interface = function() { return this.$val.Interface(); };
Object.ptr.prototype.Unsafe = function() {
var o;
o = this;
return o.object;
};
Object.prototype.Unsafe = function() { return this.$val.Unsafe(); };
Error.ptr.prototype.Error = function() {
var err;
err = this;
return "JavaScript error: " + $internalize(err.Object.message, $String);
};
Error.prototype.Error = function() { return this.$val.Error(); };
Error.ptr.prototype.Stack = function() {
var err;
err = this;
return $internalize(err.Object.stack, $String);
};
Error.prototype.Stack = function() { return this.$val.Stack(); };
MakeFunc = function(fn) {
var fn;
return $makeFunc(fn);
};
$pkg.MakeFunc = MakeFunc;
init = function() {
var e;
e = new Error.ptr(null);
$unused(e);
};
ptrType.methods = [{prop: "Get", name: "Get", pkg: "", typ: $funcType([$String], [ptrType], false)}, {prop: "Set", name: "Set", pkg: "", typ: $funcType([$String, $emptyInterface], [], false)}, {prop: "Delete", name: "Delete", pkg: "", typ: $funcType([$String], [], false)}, {prop: "Length", name: "Length", pkg: "", typ: $funcType([], [$Int], false)}, {prop: "Index", name: "Index", pkg: "", typ: $funcType([$Int], [ptrType], false)}, {prop: "SetIndex", name: "SetIndex", pkg: "", typ: $funcType([$Int, $emptyInterface], [], false)}, {prop: "Call", name: "Call", pkg: "", typ: $funcType([$String, sliceType], [ptrType], true)}, {prop: "Invoke", name: "Invoke", pkg: "", typ: $funcType([sliceType], [ptrType], true)}, {prop: "New", name: "New", pkg: "", typ: $funcType([sliceType], [ptrType], true)}, {prop: "Bool", name: "Bool", pkg: "", typ: $funcType([], [$Bool], false)}, {prop: "String", name: "String", pkg: "", typ: $funcType([], [$String], false)}, {prop: "Int", name: "Int", pkg: "", typ: $funcType([], [$Int], false)}, {prop: "Int64", name: "Int64", pkg: "", typ: $funcType([], [$Int64], false)}, {prop: "Uint64", name: "Uint64", pkg: "", typ: $funcType([], [$Uint64], false)}, {prop: "Float", name: "Float", pkg: "", typ: $funcType([], [$Float64], false)}, {prop: "Interface", name: "Interface", pkg: "", typ: $funcType([], [$emptyInterface], false)}, {prop: "Unsafe", name: "Unsafe", pkg: "", typ: $funcType([], [$Uintptr], false)}];
ptrType$1.methods = [{prop: "Error", name: "Error", pkg: "", typ: $funcType([], [$String], false)}, {prop: "Stack", name: "Stack", pkg: "", typ: $funcType([], [$String], false)}];
Object.init("github.com/gopherjs/gopherjs/js", [{prop: "object", name: "object", embedded: false, exported: false, typ: ptrType, tag: ""}]);
Error.init("", [{prop: "Object", name: "Object", embedded: true, exported: true, typ: ptrType, tag: ""}]);
$init = function() {
$pkg.$init = function() {};
/* */ var $f, $c = false, $s = 0, $r; if (this !== undefined && this.$blk !== undefined) { $f = this; $c = true; $s = $f.$s; $r = $f.$r; } s: while (true) { switch ($s) { case 0:
init();
/* */ } return; } if ($f === undefined) { $f = { $blk: $init }; } $f.$s = $s; $f.$r = $r; return $f;
};
$pkg.$init = $init;
return $pkg;
})();
$packages["internal/cpu"] = (function() {
var $pkg = {}, $init;
$init = function() {
$pkg.$init = function() {};
/* */ var $f, $c = false, $s = 0, $r; if (this !== undefined && this.$blk !== undefined) { $f = this; $c = true; $s = $f.$s; $r = $f.$r; } s: while (true) { switch ($s) { case 0:
/* */ } return; } if ($f === undefined) { $f = { $blk: $init }; } $f.$s = $s; $f.$r = $r; return $f;
};
$pkg.$init = $init;
return $pkg;
})();
$packages["internal/bytealg"] = (function() {
var $pkg = {}, $init, cpu;
cpu = $packages["internal/cpu"];
$init = function() {
$pkg.$init = function() {};
/* */ var $f, $c = false, $s = 0, $r; if (this !== undefined && this.$blk !== undefined) { $f = this; $c = true; $s = $f.$s; $r = $f.$r; } s: while (true) { switch ($s) { case 0:
$r = cpu.$init(); /* */ $s = 1; case 1: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; }
/* */ } return; } if ($f === undefined) { $f = { $blk: $init }; } $f.$s = $s; $f.$r = $r; return $f;
};
$pkg.$init = $init;
return $pkg;
})();
$packages["runtime/internal/sys"] = (function() {
var $pkg = {}, $init;
$init = function() {
$pkg.$init = function() {};
/* */ var $f, $c = false, $s = 0, $r; if (this !== undefined && this.$blk !== undefined) { $f = this; $c = true; $s = $f.$s; $r = $f.$r; } s: while (true) { switch ($s) { case 0:
/* */ } return; } if ($f === undefined) { $f = { $blk: $init }; } $f.$s = $s; $f.$r = $r; return $f;
};
$pkg.$init = $init;
return $pkg;
})();
$packages["runtime"] = (function() {
var $pkg = {}, $init, js, bytealg, sys, _type, MemStats, TypeAssertionError, errorString, ptrType, arrayType, structType$1, arrayType$1, ptrType$4, init, GOROOT, GC, Goexit, ReadMemStats, SetFinalizer, Stack, KeepAlive, throw$1;
js = $packages["github.com/gopherjs/gopherjs/js"];
bytealg = $packages["internal/bytealg"];
sys = $packages["runtime/internal/sys"];
_type = $pkg._type = $newType(0, $kindStruct, "runtime._type", true, "runtime", false, function(str_) {
this.$val = this;
if (arguments.length === 0) {
this.str = "";
return;
}
this.str = str_;
});
MemStats = $pkg.MemStats = $newType(0, $kindStruct, "runtime.MemStats", true, "runtime", true, function(Alloc_, TotalAlloc_, Sys_, Lookups_, Mallocs_, Frees_, HeapAlloc_, HeapSys_, HeapIdle_, HeapInuse_, HeapReleased_, HeapObjects_, StackInuse_, StackSys_, MSpanInuse_, MSpanSys_, MCacheInuse_, MCacheSys_, BuckHashSys_, GCSys_, OtherSys_, NextGC_, LastGC_, PauseTotalNs_, PauseNs_, PauseEnd_, NumGC_, GCCPUFraction_, EnableGC_, DebugGC_, BySize_) {
this.$val = this;
if (arguments.length === 0) {
this.Alloc = new $Uint64(0, 0);
this.TotalAlloc = new $Uint64(0, 0);
this.Sys = new $Uint64(0, 0);
this.Lookups = new $Uint64(0, 0);
this.Mallocs = new $Uint64(0, 0);
this.Frees = new $Uint64(0, 0);
this.HeapAlloc = new $Uint64(0, 0);
this.HeapSys = new $Uint64(0, 0);
this.HeapIdle = new $Uint64(0, 0);
this.HeapInuse = new $Uint64(0, 0);
this.HeapReleased = new $Uint64(0, 0);
this.HeapObjects = new $Uint64(0, 0);
this.StackInuse = new $Uint64(0, 0);
this.StackSys = new $Uint64(0, 0);
this.MSpanInuse = new $Uint64(0, 0);
this.MSpanSys = new $Uint64(0, 0);
this.MCacheInuse = new $Uint64(0, 0);
this.MCacheSys = new $Uint64(0, 0);
this.BuckHashSys = new $Uint64(0, 0);
this.GCSys = new $Uint64(0, 0);
this.OtherSys = new $Uint64(0, 0);
this.NextGC = new $Uint64(0, 0);
this.LastGC = new $Uint64(0, 0);
this.PauseTotalNs = new $Uint64(0, 0);
this.PauseNs = arrayType.zero();
this.PauseEnd = arrayType.zero();
this.NumGC = 0;
this.GCCPUFraction = 0;
this.EnableGC = false;
this.DebugGC = false;
this.BySize = arrayType$1.zero();
return;
}
this.Alloc = Alloc_;
this.TotalAlloc = TotalAlloc_;
this.Sys = Sys_;
this.Lookups = Lookups_;
this.Mallocs = Mallocs_;
this.Frees = Frees_;
this.HeapAlloc = HeapAlloc_;
this.HeapSys = HeapSys_;
this.HeapIdle = HeapIdle_;
this.HeapInuse = HeapInuse_;
this.HeapReleased = HeapReleased_;
this.HeapObjects = HeapObjects_;
this.StackInuse = StackInuse_;
this.StackSys = StackSys_;
this.MSpanInuse = MSpanInuse_;
this.MSpanSys = MSpanSys_;
this.MCacheInuse = MCacheInuse_;
this.MCacheSys = MCacheSys_;
this.BuckHashSys = BuckHashSys_;
this.GCSys = GCSys_;
this.OtherSys = OtherSys_;
this.NextGC = NextGC_;
this.LastGC = LastGC_;
this.PauseTotalNs = PauseTotalNs_;
this.PauseNs = PauseNs_;
this.PauseEnd = PauseEnd_;
this.NumGC = NumGC_;
this.GCCPUFraction = GCCPUFraction_;
this.EnableGC = EnableGC_;
this.DebugGC = DebugGC_;
this.BySize = BySize_;
});
TypeAssertionError = $pkg.TypeAssertionError = $newType(0, $kindStruct, "runtime.TypeAssertionError", true, "runtime", true, function(_interface_, concrete_, asserted_, missingMethod_) {
this.$val = this;
if (arguments.length === 0) {
this._interface = ptrType.nil;
this.concrete = ptrType.nil;
this.asserted = ptrType.nil;
this.missingMethod = "";
return;
}
this._interface = _interface_;
this.concrete = concrete_;
this.asserted = asserted_;
this.missingMethod = missingMethod_;
});
errorString = $pkg.errorString = $newType(8, $kindString, "runtime.errorString", true, "runtime", false, null);
ptrType = $ptrType(_type);
arrayType = $arrayType($Uint64, 256);
structType$1 = $structType("", [{prop: "Size", name: "Size", embedded: false, exported: true, typ: $Uint32, tag: ""}, {prop: "Mallocs", name: "Mallocs", embedded: false, exported: true, typ: $Uint64, tag: ""}, {prop: "Frees", name: "Frees", embedded: false, exported: true, typ: $Uint64, tag: ""}]);
arrayType$1 = $arrayType(structType$1, 61);
ptrType$4 = $ptrType(TypeAssertionError);
_type.ptr.prototype.string = function() {
var t;
t = this;
return t.str;
};
_type.prototype.string = function() { return this.$val.string(); };
_type.ptr.prototype.pkgpath = function() {
var t;
t = this;
return "";
};
_type.prototype.pkgpath = function() { return this.$val.pkgpath(); };
init = function() {
var e, jsPkg;
jsPkg = $packages[$externalize("github.com/gopherjs/gopherjs/js", $String)];
$jsObjectPtr = jsPkg.Object.ptr;
$jsErrorPtr = jsPkg.Error.ptr;
$throwRuntimeError = throw$1;
e = $ifaceNil;
e = new TypeAssertionError.ptr(ptrType.nil, ptrType.nil, ptrType.nil, "");
$unused(e);
};
GOROOT = function() {
var goroot, process;
process = $global.process;
if (process === undefined) {
return "/";
}
goroot = process.env.GOROOT;
if (!(goroot === undefined)) {
return $internalize(goroot, $String);
}
return "/usr/local/go";
};
$pkg.GOROOT = GOROOT;
GC = function() {
};
$pkg.GC = GC;
Goexit = function() {
$curGoroutine.exit = $externalize(true, $Bool);
$throw(null);
};
$pkg.Goexit = Goexit;
ReadMemStats = function(m) {
var m;
};
$pkg.ReadMemStats = ReadMemStats;
SetFinalizer = function(x, f) {
var f, x;
};
$pkg.SetFinalizer = SetFinalizer;
Stack = function(buf, all) {
var all, buf, s;
s = new ($global.Error)().stack;
if (s === undefined) {
return 0;
}
return $copyString(buf, $internalize(s.substr(($parseInt(s.indexOf($externalize("\n", $String))) >> 0) + 1 >> 0), $String));
};
$pkg.Stack = Stack;
KeepAlive = function(param) {
var param;
};
$pkg.KeepAlive = KeepAlive;
throw$1 = function(s) {
var s;
$panic(new errorString((s)));
};
TypeAssertionError.ptr.prototype.RuntimeError = function() {
};
TypeAssertionError.prototype.RuntimeError = function() { return this.$val.RuntimeError(); };
TypeAssertionError.ptr.prototype.Error = function() {
var as, cs, e, inter, msg;
e = this;
inter = "interface";
if (!(e._interface === ptrType.nil)) {
inter = e._interface.string();
}
as = e.asserted.string();
if (e.concrete === ptrType.nil) {
return "interface conversion: " + inter + " is nil, not " + as;
}
cs = e.concrete.string();
if (e.missingMethod === "") {
msg = "interface conversion: " + inter + " is " + cs + ", not " + as;
if (cs === as) {
if (!(e.concrete.pkgpath() === e.asserted.pkgpath())) {
msg = msg + (" (types from different packages)");
} else {
msg = msg + (" (types from different scopes)");
}
}
return msg;
}
return "interface conversion: " + cs + " is not " + as + ": missing method " + e.missingMethod;
};
TypeAssertionError.prototype.Error = function() { return this.$val.Error(); };
errorString.prototype.RuntimeError = function() {
var e;
e = this.$val;
};
$ptrType(errorString).prototype.RuntimeError = function() { return new errorString(this.$get()).RuntimeError(); };
errorString.prototype.Error = function() {
var e;
e = this.$val;
return "runtime error: " + (e);
};
$ptrType(errorString).prototype.Error = function() { return new errorString(this.$get()).Error(); };
ptrType.methods = [{prop: "string", name: "string", pkg: "runtime", typ: $funcType([], [$String], false)}, {prop: "pkgpath", name: "pkgpath", pkg: "runtime", typ: $funcType([], [$String], false)}];
ptrType$4.methods = [{prop: "RuntimeError", name: "RuntimeError", pkg: "", typ: $funcType([], [], false)}, {prop: "Error", name: "Error", pkg: "", typ: $funcType([], [$String], false)}];
errorString.methods = [{prop: "RuntimeError", name: "RuntimeError", pkg: "", typ: $funcType([], [], false)}, {prop: "Error", name: "Error", pkg: "", typ: $funcType([], [$String], false)}];
_type.init("runtime", [{prop: "str", name: "str", embedded: false, exported: false, typ: $String, tag: ""}]);
MemStats.init("", [{prop: "Alloc", name: "Alloc", embedded: false, exported: true, typ: $Uint64, tag: ""}, {prop: "TotalAlloc", name: "TotalAlloc", embedded: false, exported: true, typ: $Uint64, tag: ""}, {prop: "Sys", name: "Sys", embedded: false, exported: true, typ: $Uint64, tag: ""}, {prop: "Lookups", name: "Lookups", embedded: false, exported: true, typ: $Uint64, tag: ""}, {prop: "Mallocs", name: "Mallocs", embedded: false, exported: true, typ: $Uint64, tag: ""}, {prop: "Frees", name: "Frees", embedded: false, exported: true, typ: $Uint64, tag: ""}, {prop: "HeapAlloc", name: "HeapAlloc", embedded: false, exported: true, typ: $Uint64, tag: ""}, {prop: "HeapSys", name: "HeapSys", embedded: false, exported: true, typ: $Uint64, tag: ""}, {prop: "HeapIdle", name: "HeapIdle", embedded: false, exported: true, typ: $Uint64, tag: ""}, {prop: "HeapInuse", name: "HeapInuse", embedded: false, exported: true, typ: $Uint64, tag: ""}, {prop: "HeapReleased", name: "HeapReleased", embedded: false, exported: true, typ: $Uint64, tag: ""}, {prop: "HeapObjects", name: "HeapObjects", embedded: false, exported: true, typ: $Uint64, tag: ""}, {prop: "StackInuse", name: "StackInuse", embedded: false, exported: true, typ: $Uint64, tag: ""}, {prop: "StackSys", name: "StackSys", embedded: false, exported: true, typ: $Uint64, tag: ""}, {prop: "MSpanInuse", name: "MSpanInuse", embedded: false, exported: true, typ: $Uint64, tag: ""}, {prop: "MSpanSys", name: "MSpanSys", embedded: false, exported: true, typ: $Uint64, tag: ""}, {prop: "MCacheInuse", name: "MCacheInuse", embedded: false, exported: true, typ: $Uint64, tag: ""}, {prop: "MCacheSys", name: "MCacheSys", embedded: false, exported: true, typ: $Uint64, tag: ""}, {prop: "BuckHashSys", name: "BuckHashSys", embedded: false, exported: true, typ: $Uint64, tag: ""}, {prop: "GCSys", name: "GCSys", embedded: false, exported: true, typ: $Uint64, tag: ""}, {prop: "OtherSys", name: "OtherSys", embedded: false, exported: true, typ: $Uint64, tag: ""}, {prop: "NextGC", name: "NextGC", embedded: false, exported: true, typ: $Uint64, tag: ""}, {prop: "LastGC", name: "LastGC", embedded: false, exported: true, typ: $Uint64, tag: ""}, {prop: "PauseTotalNs", name: "PauseTotalNs", embedded: false, exported: true, typ: $Uint64, tag: ""}, {prop: "PauseNs", name: "PauseNs", embedded: false, exported: true, typ: arrayType, tag: ""}, {prop: "PauseEnd", name: "PauseEnd", embedded: false, exported: true, typ: arrayType, tag: ""}, {prop: "NumGC", name: "NumGC", embedded: false, exported: true, typ: $Uint32, tag: ""}, {prop: "GCCPUFraction", name: "GCCPUFraction", embedded: false, exported: true, typ: $Float64, tag: ""}, {prop: "EnableGC", name: "EnableGC", embedded: false, exported: true, typ: $Bool, tag: ""}, {prop: "DebugGC", name: "DebugGC", embedded: false, exported: true, typ: $Bool, tag: ""}, {prop: "BySize", name: "BySize", embedded: false, exported: true, typ: arrayType$1, tag: ""}]);
TypeAssertionError.init("runtime", [{prop: "_interface", name: "_interface", embedded: false, exported: false, typ: ptrType, tag: ""}, {prop: "concrete", name: "concrete", embedded: false, exported: false, typ: ptrType, tag: ""}, {prop: "asserted", name: "asserted", embedded: false, exported: false, typ: ptrType, tag: ""}, {prop: "missingMethod", name: "missingMethod", embedded: false, exported: false, typ: $String, tag: ""}]);
$init = function() {
$pkg.$init = function() {};
/* */ var $f, $c = false, $s = 0, $r; if (this !== undefined && this.$blk !== undefined) { $f = this; $c = true; $s = $f.$s; $r = $f.$r; } s: while (true) { switch ($s) { case 0:
$r = js.$init(); /* */ $s = 1; case 1: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; }
$r = bytealg.$init(); /* */ $s = 2; case 2: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; }
$r = sys.$init(); /* */ $s = 3; case 3: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; }
init();
/* */ } return; } if ($f === undefined) { $f = { $blk: $init }; } $f.$s = $s; $f.$r = $r; return $f;
};
$pkg.$init = $init;
return $pkg;
})();
$packages["errors"] = (function() {
var $pkg = {}, $init, errorString, ptrType, New;
errorString = $pkg.errorString = $newType(0, $kindStruct, "errors.errorString", true, "errors", false, function(s_) {
this.$val = this;
if (arguments.length === 0) {
this.s = "";
return;
}
this.s = s_;
});
ptrType = $ptrType(errorString);
New = function(text) {
var text;
return new errorString.ptr(text);
};
$pkg.New = New;
errorString.ptr.prototype.Error = function() {
var e;
e = this;
return e.s;
};
errorString.prototype.Error = function() { return this.$val.Error(); };
ptrType.methods = [{prop: "Error", name: "Error", pkg: "", typ: $funcType([], [$String], false)}];
errorString.init("errors", [{prop: "s", name: "s", embedded: false, exported: false, typ: $String, tag: ""}]);
$init = function() {
$pkg.$init = function() {};
/* */ var $f, $c = false, $s = 0, $r; if (this !== undefined && this.$blk !== undefined) { $f = this; $c = true; $s = $f.$s; $r = $f.$r; } s: while (true) { switch ($s) { case 0:
/* */ } return; } if ($f === undefined) { $f = { $blk: $init }; } $f.$s = $s; $f.$r = $r; return $f;
};
$pkg.$init = $init;
return $pkg;
})();
$packages["internal/race"] = (function() {
var $pkg = {}, $init, Acquire, Release, ReleaseMerge, Disable, Enable, ReadRange, WriteRange;
Acquire = function(addr) {
var addr;
};
$pkg.Acquire = Acquire;
Release = function(addr) {
var addr;
};
$pkg.Release = Release;
ReleaseMerge = function(addr) {
var addr;
};
$pkg.ReleaseMerge = ReleaseMerge;
Disable = function() {
};
$pkg.Disable = Disable;
Enable = function() {
};
$pkg.Enable = Enable;
ReadRange = function(addr, len) {
var addr, len;
};
$pkg.ReadRange = ReadRange;
WriteRange = function(addr, len) {
var addr, len;
};
$pkg.WriteRange = WriteRange;
$init = function() {
$pkg.$init = function() {};
/* */ var $f, $c = false, $s = 0, $r; if (this !== undefined && this.$blk !== undefined) { $f = this; $c = true; $s = $f.$s; $r = $f.$r; } s: while (true) { switch ($s) { case 0:
/* */ } return; } if ($f === undefined) { $f = { $blk: $init }; } $f.$s = $s; $f.$r = $r; return $f;
};
$pkg.$init = $init;
return $pkg;
})();
$packages["sync/atomic"] = (function() {
var $pkg = {}, $init, js, Value, ptrType, CompareAndSwapInt32, CompareAndSwapUint64, AddInt32, LoadInt32, LoadUint32, LoadUint64, StoreInt32, StoreUint32;
js = $packages["github.com/gopherjs/gopherjs/js"];
Value = $pkg.Value = $newType(0, $kindStruct, "atomic.Value", true, "sync/atomic", true, function(v_) {
this.$val = this;
if (arguments.length === 0) {
this.v = $ifaceNil;
return;
}
this.v = v_;
});
ptrType = $ptrType(Value);
CompareAndSwapInt32 = function(addr, old, new$1) {
var addr, new$1, old;
if (addr.$get() === old) {
addr.$set(new$1);
return true;
}
return false;
};
$pkg.CompareAndSwapInt32 = CompareAndSwapInt32;
CompareAndSwapUint64 = function(addr, old, new$1) {
var addr, new$1, old, x;
if ((x = addr.$get(), (x.$high === old.$high && x.$low === old.$low))) {
addr.$set(new$1);
return true;
}
return false;
};
$pkg.CompareAndSwapUint64 = CompareAndSwapUint64;
AddInt32 = function(addr, delta) {
var addr, delta, new$1;
new$1 = addr.$get() + delta >> 0;
addr.$set(new$1);
return new$1;
};
$pkg.AddInt32 = AddInt32;
LoadInt32 = function(addr) {
var addr;
return addr.$get();
};
$pkg.LoadInt32 = LoadInt32;
LoadUint32 = function(addr) {
var addr;
return addr.$get();
};
$pkg.LoadUint32 = LoadUint32;
LoadUint64 = function(addr) {
var addr;
return addr.$get();
};
$pkg.LoadUint64 = LoadUint64;
StoreInt32 = function(addr, val) {
var addr, val;
addr.$set(val);
};
$pkg.StoreInt32 = StoreInt32;
StoreUint32 = function(addr, val) {
var addr, val;
addr.$set(val);
};
$pkg.StoreUint32 = StoreUint32;
Value.ptr.prototype.Load = function() {
var v, x;
x = $ifaceNil;
v = this;
x = v.v;
return x;
};
Value.prototype.Load = function() { return this.$val.Load(); };
Value.ptr.prototype.Store = function(x) {
var v, x;
v = this;
if ($interfaceIsEqual(x, $ifaceNil)) {
$panic(new $String("sync/atomic: store of nil value into Value"));
}
if (!($interfaceIsEqual(v.v, $ifaceNil)) && !(x.constructor === v.v.constructor)) {
$panic(new $String("sync/atomic: store of inconsistently typed value into Value"));
}
v.v = x;
};
Value.prototype.Store = function(x) { return this.$val.Store(x); };
ptrType.methods = [{prop: "Load", name: "Load", pkg: "", typ: $funcType([], [$emptyInterface], false)}, {prop: "Store", name: "Store", pkg: "", typ: $funcType([$emptyInterface], [], false)}];
Value.init("sync/atomic", [{prop: "v", name: "v", embedded: false, exported: false, typ: $emptyInterface, tag: ""}]);
$init = function() {
$pkg.$init = function() {};
/* */ var $f, $c = false, $s = 0, $r; if (this !== undefined && this.$blk !== undefined) { $f = this; $c = true; $s = $f.$s; $r = $f.$r; } s: while (true) { switch ($s) { case 0:
$r = js.$init(); /* */ $s = 1; case 1: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; }
/* */ } return; } if ($f === undefined) { $f = { $blk: $init }; } $f.$s = $s; $f.$r = $r; return $f;
};
$pkg.$init = $init;
return $pkg;
})();
$packages["sync"] = (function() {
var $pkg = {}, $init, js, race, runtime, atomic, Pool, Mutex, Locker, Once, poolLocalInternal, poolLocal, notifyList, RWMutex, rlocker, ptrType, sliceType, ptrType$1, chanType, sliceType$1, ptrType$6, ptrType$7, sliceType$4, ptrType$8, ptrType$9, funcType, ptrType$16, funcType$2, ptrType$17, arrayType$2, semWaiters, semAwoken, expunged, allPools, runtime_registerPoolCleanup, runtime_SemacquireMutex, runtime_Semrelease, runtime_notifyListCheck, runtime_canSpin, runtime_nanotime, throw$1, poolCleanup, init, indexLocal, init$1, runtime_doSpin;
js = $packages["github.com/gopherjs/gopherjs/js"];
race = $packages["internal/race"];
runtime = $packages["runtime"];
atomic = $packages["sync/atomic"];
Pool = $pkg.Pool = $newType(0, $kindStruct, "sync.Pool", true, "sync", true, function(local_, localSize_, store_, New_) {
this.$val = this;
if (arguments.length === 0) {
this.local = 0;
this.localSize = 0;
this.store = sliceType$4.nil;
this.New = $throwNilPointerError;
return;
}
this.local = local_;
this.localSize = localSize_;
this.store = store_;
this.New = New_;
});
Mutex = $pkg.Mutex = $newType(0, $kindStruct, "sync.Mutex", true, "sync", true, function(state_, sema_) {
this.$val = this;
if (arguments.length === 0) {
this.state = 0;
this.sema = 0;
return;
}
this.state = state_;
this.sema = sema_;
});
Locker = $pkg.Locker = $newType(8, $kindInterface, "sync.Locker", true, "sync", true, null);
Once = $pkg.Once = $newType(0, $kindStruct, "sync.Once", true, "sync", true, function(m_, done_) {
this.$val = this;
if (arguments.length === 0) {
this.m = new Mutex.ptr(0, 0);
this.done = 0;
return;
}
this.m = m_;
this.done = done_;
});
poolLocalInternal = $pkg.poolLocalInternal = $newType(0, $kindStruct, "sync.poolLocalInternal", true, "sync", false, function(private$0_, shared_, Mutex_) {
this.$val = this;
if (arguments.length === 0) {
this.private$0 = $ifaceNil;
this.shared = sliceType$4.nil;
this.Mutex = new Mutex.ptr(0, 0);
return;
}
this.private$0 = private$0_;
this.shared = shared_;
this.Mutex = Mutex_;
});
poolLocal = $pkg.poolLocal = $newType(0, $kindStruct, "sync.poolLocal", true, "sync", false, function(poolLocalInternal_, pad_) {
this.$val = this;
if (arguments.length === 0) {
this.poolLocalInternal = new poolLocalInternal.ptr($ifaceNil, sliceType$4.nil, new Mutex.ptr(0, 0));
this.pad = arrayType$2.zero();
return;
}
this.poolLocalInternal = poolLocalInternal_;
this.pad = pad_;
});
notifyList = $pkg.notifyList = $newType(0, $kindStruct, "sync.notifyList", true, "sync", false, function(wait_, notify_, lock_, head_, tail_) {
this.$val = this;
if (arguments.length === 0) {
this.wait = 0;
this.notify = 0;
this.lock = 0;
this.head = 0;
this.tail = 0;
return;
}
this.wait = wait_;
this.notify = notify_;
this.lock = lock_;
this.head = head_;
this.tail = tail_;
});
RWMutex = $pkg.RWMutex = $newType(0, $kindStruct, "sync.RWMutex", true, "sync", true, function(w_, writerSem_, readerSem_, readerCount_, readerWait_) {
this.$val = this;
if (arguments.length === 0) {
this.w = new Mutex.ptr(0, 0);
this.writerSem = 0;
this.readerSem = 0;
this.readerCount = 0;
this.readerWait = 0;
return;
}
this.w = w_;
this.writerSem = writerSem_;
this.readerSem = readerSem_;
this.readerCount = readerCount_;
this.readerWait = readerWait_;
});
rlocker = $pkg.rlocker = $newType(0, $kindStruct, "sync.rlocker", true, "sync", false, function(w_, writerSem_, readerSem_, readerCount_, readerWait_) {
this.$val = this;
if (arguments.length === 0) {
this.w = new Mutex.ptr(0, 0);
this.writerSem = 0;
this.readerSem = 0;
this.readerCount = 0;
this.readerWait = 0;
return;
}
this.w = w_;
this.writerSem = writerSem_;
this.readerSem = readerSem_;
this.readerCount = readerCount_;
this.readerWait = readerWait_;
});
ptrType = $ptrType(Pool);
sliceType = $sliceType(ptrType);
ptrType$1 = $ptrType($Uint32);
chanType = $chanType($Bool, false, false);
sliceType$1 = $sliceType(chanType);
ptrType$6 = $ptrType($Int32);
ptrType$7 = $ptrType(poolLocal);
sliceType$4 = $sliceType($emptyInterface);
ptrType$8 = $ptrType(rlocker);
ptrType$9 = $ptrType(RWMutex);
funcType = $funcType([], [$emptyInterface], false);
ptrType$16 = $ptrType(Mutex);
funcType$2 = $funcType([], [], false);
ptrType$17 = $ptrType(Once);
arrayType$2 = $arrayType($Uint8, 100);
Pool.ptr.prototype.Get = function() {
var _r, p, x, x$1, x$2, $s, $r;
/* */ $s = 0; var $f, $c = false; if (this !== undefined && this.$blk !== undefined) { $f = this; $c = true; _r = $f._r; p = $f.p; x = $f.x; x$1 = $f.x$1; x$2 = $f.x$2; $s = $f.$s; $r = $f.$r; } s: while (true) { switch ($s) { case 0:
p = this;
/* */ if (p.store.$length === 0) { $s = 1; continue; }
/* */ $s = 2; continue;
/* if (p.store.$length === 0) { */ case 1:
/* */ if (!(p.New === $throwNilPointerError)) { $s = 3; continue; }
/* */ $s = 4; continue;
/* if (!(p.New === $throwNilPointerError)) { */ case 3:
_r = p.New(); /* */ $s = 5; case 5: if($c) { $c = false; _r = _r.$blk(); } if (_r && _r.$blk !== undefined) { break s; }
$s = -1; return _r;
/* } */ case 4:
$s = -1; return $ifaceNil;
/* } */ case 2:
x$2 = (x = p.store, x$1 = p.store.$length - 1 >> 0, ((x$1 < 0 || x$1 >= x.$length) ? ($throwRuntimeError("index out of range"), undefined) : x.$array[x.$offset + x$1]));
p.store = $subslice(p.store, 0, (p.store.$length - 1 >> 0));
$s = -1; return x$2;
/* */ } return; } if ($f === undefined) { $f = { $blk: Pool.ptr.prototype.Get }; } $f._r = _r; $f.p = p; $f.x = x; $f.x$1 = x$1; $f.x$2 = x$2; $f.$s = $s; $f.$r = $r; return $f;
};
Pool.prototype.Get = function() { return this.$val.Get(); };
Pool.ptr.prototype.Put = function(x) {
var p, x;
p = this;
if ($interfaceIsEqual(x, $ifaceNil)) {
return;
}
p.store = $append(p.store, x);
};
Pool.prototype.Put = function(x) { return this.$val.Put(x); };
runtime_registerPoolCleanup = function(cleanup) {
var cleanup;
};
runtime_SemacquireMutex = function(s, lifo) {
var _entry, _entry$1, _entry$2, _entry$3, _entry$4, _key, _key$1, _key$2, _r, ch, lifo, s, $s, $r;
/* */ $s = 0; var $f, $c = false; if (this !== undefined && this.$blk !== undefined) { $f = this; $c = true; _entry = $f._entry; _entry$1 = $f._entry$1; _entry$2 = $f._entry$2; _entry$3 = $f._entry$3; _entry$4 = $f._entry$4; _key = $f._key; _key$1 = $f._key$1; _key$2 = $f._key$2; _r = $f._r; ch = $f.ch; lifo = $f.lifo; s = $f.s; $s = $f.$s; $r = $f.$r; } s: while (true) { switch ($s) { case 0:
/* */ if (((s.$get() - (_entry = semAwoken[ptrType$1.keyFor(s)], _entry !== undefined ? _entry.v : 0) >>> 0)) === 0) { $s = 1; continue; }
/* */ $s = 2; continue;
/* if (((s.$get() - (_entry = semAwoken[ptrType$1.keyFor(s)], _entry !== undefined ? _entry.v : 0) >>> 0)) === 0) { */ case 1:
ch = new $Chan($Bool, 0);
if (lifo) {
_key = s; (semWaiters || $throwRuntimeError("assignment to entry in nil map"))[ptrType$1.keyFor(_key)] = { k: _key, v: $appendSlice(new sliceType$1([ch]), (_entry$1 = semWaiters[ptrType$1.keyFor(s)], _entry$1 !== undefined ? _entry$1.v : sliceType$1.nil)) };
} else {
_key$1 = s; (semWaiters || $throwRuntimeError("assignment to entry in nil map"))[ptrType$1.keyFor(_key$1)] = { k: _key$1, v: $append((_entry$2 = semWaiters[ptrType$1.keyFor(s)], _entry$2 !== undefined ? _entry$2.v : sliceType$1.nil), ch) };
}
_r = $recv(ch); /* */ $s = 3; case 3: if($c) { $c = false; _r = _r.$blk(); } if (_r && _r.$blk !== undefined) { break s; }
_r[0];
_key$2 = s; (semAwoken || $throwRuntimeError("assignment to entry in nil map"))[ptrType$1.keyFor(_key$2)] = { k: _key$2, v: (_entry$3 = semAwoken[ptrType$1.keyFor(s)], _entry$3 !== undefined ? _entry$3.v : 0) - (1) >>> 0 };
if ((_entry$4 = semAwoken[ptrType$1.keyFor(s)], _entry$4 !== undefined ? _entry$4.v : 0) === 0) {
delete semAwoken[ptrType$1.keyFor(s)];
}
/* } */ case 2:
s.$set(s.$get() - (1) >>> 0);
$s = -1; return;
/* */ } return; } if ($f === undefined) { $f = { $blk: runtime_SemacquireMutex }; } $f._entry = _entry; $f._entry$1 = _entry$1; $f._entry$2 = _entry$2; $f._entry$3 = _entry$3; $f._entry$4 = _entry$4; $f._key = _key; $f._key$1 = _key$1; $f._key$2 = _key$2; $f._r = _r; $f.ch = ch; $f.lifo = lifo; $f.s = s; $f.$s = $s; $f.$r = $r; return $f;
};
runtime_Semrelease = function(s, handoff) {
var _entry, _entry$1, _key, _key$1, ch, handoff, s, w, $s, $r;
/* */ $s = 0; var $f, $c = false; if (this !== undefined && this.$blk !== undefined) { $f = this; $c = true; _entry = $f._entry; _entry$1 = $f._entry$1; _key = $f._key; _key$1 = $f._key$1; ch = $f.ch; handoff = $f.handoff; s = $f.s; w = $f.w; $s = $f.$s; $r = $f.$r; } s: while (true) { switch ($s) { case 0:
s.$set(s.$get() + (1) >>> 0);
w = (_entry = semWaiters[ptrType$1.keyFor(s)], _entry !== undefined ? _entry.v : sliceType$1.nil);
if (w.$length === 0) {
$s = -1; return;
}
ch = (0 >= w.$length ? ($throwRuntimeError("index out of range"), undefined) : w.$array[w.$offset + 0]);
w = $subslice(w, 1);
_key = s; (semWaiters || $throwRuntimeError("assignment to entry in nil map"))[ptrType$1.keyFor(_key)] = { k: _key, v: w };
if (w.$length === 0) {
delete semWaiters[ptrType$1.keyFor(s)];
}
_key$1 = s; (semAwoken || $throwRuntimeError("assignment to entry in nil map"))[ptrType$1.keyFor(_key$1)] = { k: _key$1, v: (_entry$1 = semAwoken[ptrType$1.keyFor(s)], _entry$1 !== undefined ? _entry$1.v : 0) + (1) >>> 0 };
$r = $send(ch, true); /* */ $s = 1; case 1: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; }
$s = -1; return;
/* */ } return; } if ($f === undefined) { $f = { $blk: runtime_Semrelease }; } $f._entry = _entry; $f._entry$1 = _entry$1; $f._key = _key; $f._key$1 = _key$1; $f.ch = ch; $f.handoff = handoff; $f.s = s; $f.w = w; $f.$s = $s; $f.$r = $r; return $f;
};
runtime_notifyListCheck = function(size) {
var size;
};
runtime_canSpin = function(i) {
var i;
return false;
};
runtime_nanotime = function() {
return $mul64($internalize(new ($global.Date)().getTime(), $Int64), new $Int64(0, 1000000));
};
throw$1 = function(s) {
var s;
$throwRuntimeError($externalize(s, $String));
};
Mutex.ptr.prototype.Lock = function() {
var awoke, delta, iter, m, new$1, old, queueLifo, starving, waitStartTime, x, x$1, $s, $r;
/* */ $s = 0; var $f, $c = false; if (this !== undefined && this.$blk !== undefined) { $f = this; $c = true; awoke = $f.awoke; delta = $f.delta; iter = $f.iter; m = $f.m; new$1 = $f.new$1; old = $f.old; queueLifo = $f.queueLifo; starving = $f.starving; waitStartTime = $f.waitStartTime; x = $f.x; x$1 = $f.x$1; $s = $f.$s; $r = $f.$r; } s: while (true) { switch ($s) { case 0:
m = this;
if (atomic.CompareAndSwapInt32((m.$ptr_state || (m.$ptr_state = new ptrType$6(function() { return this.$target.state; }, function($v) { this.$target.state = $v; }, m))), 0, 1)) {
if (false) {
race.Acquire((m));
}
$s = -1; return;
}
waitStartTime = new $Int64(0, 0);
starving = false;
awoke = false;
iter = 0;
old = m.state;
/* while (true) { */ case 1:
/* */ if (((old & 5) === 1) && runtime_canSpin(iter)) { $s = 3; continue; }
/* */ $s = 4; continue;
/* if (((old & 5) === 1) && runtime_canSpin(iter)) { */ case 3:
if (!awoke && ((old & 2) === 0) && !(((old >> 3 >> 0) === 0)) && atomic.CompareAndSwapInt32((m.$ptr_state || (m.$ptr_state = new ptrType$6(function() { return this.$target.state; }, function($v) { this.$target.state = $v; }, m))), old, old | 2)) {
awoke = true;
}
runtime_doSpin();
iter = iter + (1) >> 0;
old = m.state;
/* continue; */ $s = 1; continue;
/* } */ case 4:
new$1 = old;
if ((old & 4) === 0) {
new$1 = new$1 | (1);
}
if (!(((old & 5) === 0))) {
new$1 = new$1 + (8) >> 0;
}
if (starving && !(((old & 1) === 0))) {
new$1 = new$1 | (4);
}
if (awoke) {
if ((new$1 & 2) === 0) {
throw$1("sync: inconsistent mutex state");
}
new$1 = (new$1 & ~(2)) >> 0;
}
/* */ if (atomic.CompareAndSwapInt32((m.$ptr_state || (m.$ptr_state = new ptrType$6(function() { return this.$target.state; }, function($v) { this.$target.state = $v; }, m))), old, new$1)) { $s = 5; continue; }
/* */ $s = 6; continue;
/* if (atomic.CompareAndSwapInt32((m.$ptr_state || (m.$ptr_state = new ptrType$6(function() { return this.$target.state; }, function($v) { this.$target.state = $v; }, m))), old, new$1)) { */ case 5:
if ((old & 5) === 0) {
/* break; */ $s = 2; continue;
}
queueLifo = !((waitStartTime.$high === 0 && waitStartTime.$low === 0));
if ((waitStartTime.$high === 0 && waitStartTime.$low === 0)) {
waitStartTime = runtime_nanotime();
}
$r = runtime_SemacquireMutex((m.$ptr_sema || (m.$ptr_sema = new ptrType$1(function() { return this.$target.sema; }, function($v) { this.$target.sema = $v; }, m))), queueLifo); /* */ $s = 8; case 8: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; }
starving = starving || (x = (x$1 = runtime_nanotime(), new $Int64(x$1.$high - waitStartTime.$high, x$1.$low - waitStartTime.$low)), (x.$high > 0 || (x.$high === 0 && x.$low > 1000000)));
old = m.state;
if (!(((old & 4) === 0))) {
if (!(((old & 3) === 0)) || ((old >> 3 >> 0) === 0)) {
throw$1("sync: inconsistent mutex state");
}
delta = -7;
if (!starving || ((old >> 3 >> 0) === 1)) {
delta = delta - (4) >> 0;
}
atomic.AddInt32((m.$ptr_state || (m.$ptr_state = new ptrType$6(function() { return this.$target.state; }, function($v) { this.$target.state = $v; }, m))), delta);
/* break; */ $s = 2; continue;
}
awoke = true;
iter = 0;
$s = 7; continue;
/* } else { */ case 6:
old = m.state;
/* } */ case 7:
/* } */ $s = 1; continue; case 2:
if (false) {
race.Acquire((m));
}
$s = -1; return;
/* */ } return; } if ($f === undefined) { $f = { $blk: Mutex.ptr.prototype.Lock }; } $f.awoke = awoke; $f.delta = delta; $f.iter = iter; $f.m = m; $f.new$1 = new$1; $f.old = old; $f.queueLifo = queueLifo; $f.starving = starving; $f.waitStartTime = waitStartTime; $f.x = x; $f.x$1 = x$1; $f.$s = $s; $f.$r = $r; return $f;
};
Mutex.prototype.Lock = function() { return this.$val.Lock(); };
Mutex.ptr.prototype.Unlock = function() {
var m, new$1, old, $s, $r;
/* */ $s = 0; var $f, $c = false; if (this !== undefined && this.$blk !== undefined) { $f = this; $c = true; m = $f.m; new$1 = $f.new$1; old = $f.old; $s = $f.$s; $r = $f.$r; } s: while (true) { switch ($s) { case 0:
m = this;
if (false) {
$unused(m.state);
race.Release((m));
}
new$1 = atomic.AddInt32((m.$ptr_state || (m.$ptr_state = new ptrType$6(function() { return this.$target.state; }, function($v) { this.$target.state = $v; }, m))), -1);
if ((((new$1 + 1 >> 0)) & 1) === 0) {
throw$1("sync: unlock of unlocked mutex");
}
/* */ if ((new$1 & 4) === 0) { $s = 1; continue; }
/* */ $s = 2; continue;
/* if ((new$1 & 4) === 0) { */ case 1:
old = new$1;
/* while (true) { */ case 4:
if (((old >> 3 >> 0) === 0) || !(((old & 7) === 0))) {
$s = -1; return;
}
new$1 = ((old - 8 >> 0)) | 2;
/* */ if (atomic.CompareAndSwapInt32((m.$ptr_state || (m.$ptr_state = new ptrType$6(function() { return this.$target.state; }, function($v) { this.$target.state = $v; }, m))), old, new$1)) { $s = 6; continue; }
/* */ $s = 7; continue;
/* if (atomic.CompareAndSwapInt32((m.$ptr_state || (m.$ptr_state = new ptrType$6(function() { return this.$target.state; }, function($v) { this.$target.state = $v; }, m))), old, new$1)) { */ case 6:
$r = runtime_Semrelease((m.$ptr_sema || (m.$ptr_sema = new ptrType$1(function() { return this.$target.sema; }, function($v) { this.$target.sema = $v; }, m))), false); /* */ $s = 8; case 8: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; }
$s = -1; return;
/* } */ case 7:
old = m.state;
/* } */ $s = 4; continue; case 5:
$s = 3; continue;
/* } else { */ case 2:
$r = runtime_Semrelease((m.$ptr_sema || (m.$ptr_sema = new ptrType$1(function() { return this.$target.sema; }, function($v) { this.$target.sema = $v; }, m))), true); /* */ $s = 9; case 9: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; }
/* } */ case 3:
$s = -1; return;
/* */ } return; } if ($f === undefined) { $f = { $blk: Mutex.ptr.prototype.Unlock }; } $f.m = m; $f.new$1 = new$1; $f.old = old; $f.$s = $s; $f.$r = $r; return $f;
};
Mutex.prototype.Unlock = function() { return this.$val.Unlock(); };
Once.ptr.prototype.Do = function(f) {
var f, o, $s, $deferred, $r;
/* */ $s = 0; var $f, $c = false; if (this !== undefined && this.$blk !== undefined) { $f = this; $c = true; f = $f.f; o = $f.o; $s = $f.$s; $deferred = $f.$deferred; $r = $f.$r; } var $err = null; try { s: while (true) { switch ($s) { case 0: $deferred = []; $deferred.index = $curGoroutine.deferStack.length; $curGoroutine.deferStack.push($deferred);
o = this;
if (atomic.LoadUint32((o.$ptr_done || (o.$ptr_done = new ptrType$1(function() { return this.$target.done; }, function($v) { this.$target.done = $v; }, o)))) === 1) {
$s = -1; return;
}
$r = o.m.Lock(); /* */ $s = 1; case 1: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; }
$deferred.push([$methodVal(o.m, "Unlock"), []]);
/* */ if (o.done === 0) { $s = 2; continue; }
/* */ $s = 3; continue;
/* if (o.done === 0) { */ case 2:
$deferred.push([atomic.StoreUint32, [(o.$ptr_done || (o.$ptr_done = new ptrType$1(function() { return this.$target.done; }, function($v) { this.$target.done = $v; }, o))), 1]]);
$r = f(); /* */ $s = 4; case 4: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; }
/* } */ case 3:
$s = -1; return;
/* */ } return; } } catch(err) { $err = err; $s = -1; } finally { $callDeferred($deferred, $err); if($curGoroutine.asleep) { if ($f === undefined) { $f = { $blk: Once.ptr.prototype.Do }; } $f.f = f; $f.o = o; $f.$s = $s; $f.$deferred = $deferred; $f.$r = $r; return $f; } }
};
Once.prototype.Do = function(f) { return this.$val.Do(f); };
poolCleanup = function() {
var _i, _i$1, _ref, _ref$1, i, i$1, j, l, p, x;
_ref = allPools;
_i = 0;
while (true) {
if (!(_i < _ref.$length)) { break; }
i = _i;
p = ((_i < 0 || _i >= _ref.$length) ? ($throwRuntimeError("index out of range"), undefined) : _ref.$array[_ref.$offset + _i]);
((i < 0 || i >= allPools.$length) ? ($throwRuntimeError("index out of range"), undefined) : allPools.$array[allPools.$offset + i] = ptrType.nil);
i$1 = 0;
while (true) {
if (!(i$1 < ((p.localSize >> 0)))) { break; }
l = indexLocal(p.local, i$1);
l.poolLocalInternal.private$0 = $ifaceNil;
_ref$1 = l.poolLocalInternal.shared;
_i$1 = 0;
while (true) {
if (!(_i$1 < _ref$1.$length)) { break; }
j = _i$1;
(x = l.poolLocalInternal.shared, ((j < 0 || j >= x.$length) ? ($throwRuntimeError("index out of range"), undefined) : x.$array[x.$offset + j] = $ifaceNil));
_i$1++;
}
l.poolLocalInternal.shared = sliceType$4.nil;
i$1 = i$1 + (1) >> 0;
}
p.local = 0;
p.localSize = 0;
_i++;
}
allPools = new sliceType([]);
};
init = function() {
runtime_registerPoolCleanup(poolCleanup);
};
indexLocal = function(l, i) {
var i, l, lp;
lp = (((l) + ($imul(((i >>> 0)), 128) >>> 0) >>> 0));
return ($pointerOfStructConversion(lp, ptrType$7));
};
init$1 = function() {
var n;
n = new notifyList.ptr(0, 0, 0, 0, 0);
runtime_notifyListCheck(20);
};
runtime_doSpin = function() {
$throwRuntimeError("native function not implemented: sync.runtime_doSpin");
};
RWMutex.ptr.prototype.RLock = function() {
var rw, $s, $r;
/* */ $s = 0; var $f, $c = false; if (this !== undefined && this.$blk !== undefined) { $f = this; $c = true; rw = $f.rw; $s = $f.$s; $r = $f.$r; } s: while (true) { switch ($s) { case 0:
rw = this;
if (false) {
$unused(rw.w.state);
race.Disable();
}
/* */ if (atomic.AddInt32((rw.$ptr_readerCount || (rw.$ptr_readerCount = new ptrType$6(function() { return this.$target.readerCount; }, function($v) { this.$target.readerCount = $v; }, rw))), 1) < 0) { $s = 1; continue; }
/* */ $s = 2; continue;
/* if (atomic.AddInt32((rw.$ptr_readerCount || (rw.$ptr_readerCount = new ptrType$6(function() { return this.$target.readerCount; }, function($v) { this.$target.readerCount = $v; }, rw))), 1) < 0) { */ case 1:
$r = runtime_SemacquireMutex((rw.$ptr_readerSem || (rw.$ptr_readerSem = new ptrType$1(function() { return this.$target.readerSem; }, function($v) { this.$target.readerSem = $v; }, rw))), false); /* */ $s = 3; case 3: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; }
/* } */ case 2:
if (false) {
race.Enable();
race.Acquire(((rw.$ptr_readerSem || (rw.$ptr_readerSem = new ptrType$1(function() { return this.$target.readerSem; }, function($v) { this.$target.readerSem = $v; }, rw)))));
}
$s = -1; return;
/* */ } return; } if ($f === undefined) { $f = { $blk: RWMutex.ptr.prototype.RLock }; } $f.rw = rw; $f.$s = $s; $f.$r = $r; return $f;
};
RWMutex.prototype.RLock = function() { return this.$val.RLock(); };
RWMutex.ptr.prototype.RUnlock = function() {
var r, rw, $s, $r;
/* */ $s = 0; var $f, $c = false; if (this !== undefined && this.$blk !== undefined) { $f = this; $c = true; r = $f.r; rw = $f.rw; $s = $f.$s; $r = $f.$r; } s: while (true) { switch ($s) { case 0:
rw = this;
if (false) {
$unused(rw.w.state);
race.ReleaseMerge(((rw.$ptr_writerSem || (rw.$ptr_writerSem = new ptrType$1(function() { return this.$target.writerSem; }, function($v) { this.$target.writerSem = $v; }, rw)))));
race.Disable();
}
r = atomic.AddInt32((rw.$ptr_readerCount || (rw.$ptr_readerCount = new ptrType$6(function() { return this.$target.readerCount; }, function($v) { this.$target.readerCount = $v; }, rw))), -1);
/* */ if (r < 0) { $s = 1; continue; }
/* */ $s = 2; continue;
/* if (r < 0) { */ case 1:
if (((r + 1 >> 0) === 0) || ((r + 1 >> 0) === -1073741824)) {
race.Enable();
throw$1("sync: RUnlock of unlocked RWMutex");
}
/* */ if (atomic.AddInt32((rw.$ptr_readerWait || (rw.$ptr_readerWait = new ptrType$6(function() { return this.$target.readerWait; }, function($v) { this.$target.readerWait = $v; }, rw))), -1) === 0) { $s = 3; continue; }
/* */ $s = 4; continue;
/* if (atomic.AddInt32((rw.$ptr_readerWait || (rw.$ptr_readerWait = new ptrType$6(function() { return this.$target.readerWait; }, function($v) { this.$target.readerWait = $v; }, rw))), -1) === 0) { */ case 3:
$r = runtime_Semrelease((rw.$ptr_writerSem || (rw.$ptr_writerSem = new ptrType$1(function() { return this.$target.writerSem; }, function($v) { this.$target.writerSem = $v; }, rw))), false); /* */ $s = 5; case 5: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; }
/* } */ case 4:
/* } */ case 2:
if (false) {
race.Enable();
}
$s = -1; return;
/* */ } return; } if ($f === undefined) { $f = { $blk: RWMutex.ptr.prototype.RUnlock }; } $f.r = r; $f.rw = rw; $f.$s = $s; $f.$r = $r; return $f;
};
RWMutex.prototype.RUnlock = function() { return this.$val.RUnlock(); };
RWMutex.ptr.prototype.Lock = function() {
var r, rw, $s, $r;
/* */ $s = 0; var $f, $c = false; if (this !== undefined && this.$blk !== undefined) { $f = this; $c = true; r = $f.r; rw = $f.rw; $s = $f.$s; $r = $f.$r; } s: while (true) { switch ($s) { case 0:
rw = this;
if (false) {
$unused(rw.w.state);
race.Disable();
}
$r = rw.w.Lock(); /* */ $s = 1; case 1: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; }
r = atomic.AddInt32((rw.$ptr_readerCount || (rw.$ptr_readerCount = new ptrType$6(function() { return this.$target.readerCount; }, function($v) { this.$target.readerCount = $v; }, rw))), -1073741824) + 1073741824 >> 0;
/* */ if (!((r === 0)) && !((atomic.AddInt32((rw.$ptr_readerWait || (rw.$ptr_readerWait = new ptrType$6(function() { return this.$target.readerWait; }, function($v) { this.$target.readerWait = $v; }, rw))), r) === 0))) { $s = 2; continue; }
/* */ $s = 3; continue;
/* if (!((r === 0)) && !((atomic.AddInt32((rw.$ptr_readerWait || (rw.$ptr_readerWait = new ptrType$6(function() { return this.$target.readerWait; }, function($v) { this.$target.readerWait = $v; }, rw))), r) === 0))) { */ case 2:
$r = runtime_SemacquireMutex((rw.$ptr_writerSem || (rw.$ptr_writerSem = new ptrType$1(function() { return this.$target.writerSem; }, function($v) { this.$target.writerSem = $v; }, rw))), false); /* */ $s = 4; case 4: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; }
/* } */ case 3:
if (false) {
race.Enable();
race.Acquire(((rw.$ptr_readerSem || (rw.$ptr_readerSem = new ptrType$1(function() { return this.$target.readerSem; }, function($v) { this.$target.readerSem = $v; }, rw)))));
race.Acquire(((rw.$ptr_writerSem || (rw.$ptr_writerSem = new ptrType$1(function() { return this.$target.writerSem; }, function($v) { this.$target.writerSem = $v; }, rw)))));
}
$s = -1; return;
/* */ } return; } if ($f === undefined) { $f = { $blk: RWMutex.ptr.prototype.Lock }; } $f.r = r; $f.rw = rw; $f.$s = $s; $f.$r = $r; return $f;
};
RWMutex.prototype.Lock = function() { return this.$val.Lock(); };
RWMutex.ptr.prototype.Unlock = function() {
var i, r, rw, $s, $r;
/* */ $s = 0; var $f, $c = false; if (this !== undefined && this.$blk !== undefined) { $f = this; $c = true; i = $f.i; r = $f.r; rw = $f.rw; $s = $f.$s; $r = $f.$r; } s: while (true) { switch ($s) { case 0:
rw = this;
if (false) {
$unused(rw.w.state);
race.Release(((rw.$ptr_readerSem || (rw.$ptr_readerSem = new ptrType$1(function() { return this.$target.readerSem; }, function($v) { this.$target.readerSem = $v; }, rw)))));
race.Disable();
}
r = atomic.AddInt32((rw.$ptr_readerCount || (rw.$ptr_readerCount = new ptrType$6(function() { return this.$target.readerCount; }, function($v) { this.$target.readerCount = $v; }, rw))), 1073741824);
if (r >= 1073741824) {
race.Enable();
throw$1("sync: Unlock of unlocked RWMutex");
}
i = 0;
/* while (true) { */ case 1:
/* if (!(i < ((r >> 0)))) { break; } */ if(!(i < ((r >> 0)))) { $s = 2; continue; }
$r = runtime_Semrelease((rw.$ptr_readerSem || (rw.$ptr_readerSem = new ptrType$1(function() { return this.$target.readerSem; }, function($v) { this.$target.readerSem = $v; }, rw))), false); /* */ $s = 3; case 3: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; }
i = i + (1) >> 0;
/* } */ $s = 1; continue; case 2:
$r = rw.w.Unlock(); /* */ $s = 4; case 4: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; }
if (false) {
race.Enable();
}
$s = -1; return;
/* */ } return; } if ($f === undefined) { $f = { $blk: RWMutex.ptr.prototype.Unlock }; } $f.i = i; $f.r = r; $f.rw = rw; $f.$s = $s; $f.$r = $r; return $f;
};
RWMutex.prototype.Unlock = function() { return this.$val.Unlock(); };
RWMutex.ptr.prototype.RLocker = function() {
var rw;
rw = this;
return ($pointerOfStructConversion(rw, ptrType$8));
};
RWMutex.prototype.RLocker = function() { return this.$val.RLocker(); };
rlocker.ptr.prototype.Lock = function() {
var r, $s, $r;
/* */ $s = 0; var $f, $c = false; if (this !== undefined && this.$blk !== undefined) { $f = this; $c = true; r = $f.r; $s = $f.$s; $r = $f.$r; } s: while (true) { switch ($s) { case 0:
r = this;
$r = ($pointerOfStructConversion(r, ptrType$9)).RLock(); /* */ $s = 1; case 1: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; }
$s = -1; return;
/* */ } return; } if ($f === undefined) { $f = { $blk: rlocker.ptr.prototype.Lock }; } $f.r = r; $f.$s = $s; $f.$r = $r; return $f;
};
rlocker.prototype.Lock = function() { return this.$val.Lock(); };
rlocker.ptr.prototype.Unlock = function() {
var r, $s, $r;
/* */ $s = 0; var $f, $c = false; if (this !== undefined && this.$blk !== undefined) { $f = this; $c = true; r = $f.r; $s = $f.$s; $r = $f.$r; } s: while (true) { switch ($s) { case 0:
r = this;
$r = ($pointerOfStructConversion(r, ptrType$9)).RUnlock(); /* */ $s = 1; case 1: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; }
$s = -1; return;
/* */ } return; } if ($f === undefined) { $f = { $blk: rlocker.ptr.prototype.Unlock }; } $f.r = r; $f.$s = $s; $f.$r = $r; return $f;
};
rlocker.prototype.Unlock = function() { return this.$val.Unlock(); };
ptrType.methods = [{prop: "Get", name: "Get", pkg: "", typ: $funcType([], [$emptyInterface], false)}, {prop: "Put", name: "Put", pkg: "", typ: $funcType([$emptyInterface], [], false)}, {prop: "getSlow", name: "getSlow", pkg: "sync", typ: $funcType([], [$emptyInterface], false)}, {prop: "pin", name: "pin", pkg: "sync", typ: $funcType([], [ptrType$7], false)}, {prop: "pinSlow", name: "pinSlow", pkg: "sync", typ: $funcType([], [ptrType$7], false)}];
ptrType$16.methods = [{prop: "Lock", name: "Lock", pkg: "", typ: $funcType([], [], false)}, {prop: "Unlock", name: "Unlock", pkg: "", typ: $funcType([], [], false)}];
ptrType$17.methods = [{prop: "Do", name: "Do", pkg: "", typ: $funcType([funcType$2], [], false)}];
ptrType$9.methods = [{prop: "RLock", name: "RLock", pkg: "", typ: $funcType([], [], false)}, {prop: "RUnlock", name: "RUnlock", pkg: "", typ: $funcType([], [], false)}, {prop: "Lock", name: "Lock", pkg: "", typ: $funcType([], [], false)}, {prop: "Unlock", name: "Unlock", pkg: "", typ: $funcType([], [], false)}, {prop: "RLocker", name: "RLocker", pkg: "", typ: $funcType([], [Locker], false)}];
ptrType$8.methods = [{prop: "Lock", name: "Lock", pkg: "", typ: $funcType([], [], false)}, {prop: "Unlock", name: "Unlock", pkg: "", typ: $funcType([], [], false)}];
Pool.init("sync", [{prop: "local", name: "local", embedded: false, exported: false, typ: $UnsafePointer, tag: ""}, {prop: "localSize", name: "localSize", embedded: false, exported: false, typ: $Uintptr, tag: ""}, {prop: "store", name: "store", embedded: false, exported: false, typ: sliceType$4, tag: ""}, {prop: "New", name: "New", embedded: false, exported: true, typ: funcType, tag: ""}]);
Mutex.init("sync", [{prop: "state", name: "state", embedded: false, exported: false, typ: $Int32, tag: ""}, {prop: "sema", name: "sema", embedded: false, exported: false, typ: $Uint32, tag: ""}]);
Locker.init([{prop: "Lock", name: "Lock", pkg: "", typ: $funcType([], [], false)}, {prop: "Unlock", name: "Unlock", pkg: "", typ: $funcType([], [], false)}]);
Once.init("sync", [{prop: "m", name: "m", embedded: false, exported: false, typ: Mutex, tag: ""}, {prop: "done", name: "done", embedded: false, exported: false, typ: $Uint32, tag: ""}]);
poolLocalInternal.init("sync", [{prop: "private$0", name: "private", embedded: false, exported: false, typ: $emptyInterface, tag: ""}, {prop: "shared", name: "shared", embedded: false, exported: false, typ: sliceType$4, tag: ""}, {prop: "Mutex", name: "Mutex", embedded: true, exported: true, typ: Mutex, tag: ""}]);
poolLocal.init("sync", [{prop: "poolLocalInternal", name: "poolLocalInternal", embedded: true, exported: false, typ: poolLocalInternal, tag: ""}, {prop: "pad", name: "pad", embedded: false, exported: false, typ: arrayType$2, tag: ""}]);
notifyList.init("sync", [{prop: "wait", name: "wait", embedded: false, exported: false, typ: $Uint32, tag: ""}, {prop: "notify", name: "notify", embedded: false, exported: false, typ: $Uint32, tag: ""}, {prop: "lock", name: "lock", embedded: false, exported: false, typ: $Uintptr, tag: ""}, {prop: "head", name: "head", embedded: false, exported: false, typ: $UnsafePointer, tag: ""}, {prop: "tail", name: "tail", embedded: false, exported: false, typ: $UnsafePointer, tag: ""}]);
RWMutex.init("sync", [{prop: "w", name: "w", embedded: false, exported: false, typ: Mutex, tag: ""}, {prop: "writerSem", name: "writerSem", embedded: false, exported: false, typ: $Uint32, tag: ""}, {prop: "readerSem", name: "readerSem", embedded: false, exported: false, typ: $Uint32, tag: ""}, {prop: "readerCount", name: "readerCount", embedded: false, exported: false, typ: $Int32, tag: ""}, {prop: "readerWait", name: "readerWait", embedded: false, exported: false, typ: $Int32, tag: ""}]);
rlocker.init("sync", [{prop: "w", name: "w", embedded: false, exported: false, typ: Mutex, tag: ""}, {prop: "writerSem", name: "writerSem", embedded: false, exported: false, typ: $Uint32, tag: ""}, {prop: "readerSem", name: "readerSem", embedded: false, exported: false, typ: $Uint32, tag: ""}, {prop: "readerCount", name: "readerCount", embedded: false, exported: false, typ: $Int32, tag: ""}, {prop: "readerWait", name: "readerWait", embedded: false, exported: false, typ: $Int32, tag: ""}]);
$init = function() {
$pkg.$init = function() {};
/* */ var $f, $c = false, $s = 0, $r; if (this !== undefined && this.$blk !== undefined) { $f = this; $c = true; $s = $f.$s; $r = $f.$r; } s: while (true) { switch ($s) { case 0:
$r = js.$init(); /* */ $s = 1; case 1: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; }
$r = race.$init(); /* */ $s = 2; case 2: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; }
$r = runtime.$init(); /* */ $s = 3; case 3: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; }
$r = atomic.$init(); /* */ $s = 4; case 4: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; }
allPools = sliceType.nil;
semWaiters = {};
semAwoken = {};
expunged = (new Uint8Array(8));
init();
init$1();
/* */ } return; } if ($f === undefined) { $f = { $blk: $init }; } $f.$s = $s; $f.$r = $r; return $f;
};
$pkg.$init = $init;
return $pkg;
})();
$packages["io"] = (function() {
var $pkg = {}, $init, errors, sync, atomic, Reader, Writer, Closer, ReadCloser, WriteCloser, ReaderFrom, WriterTo, RuneScanner, stringWriter, LimitedReader, sliceType, ptrType$1, errWhence, errOffset, WriteString, ReadAtLeast, ReadFull, Copy, copyBuffer;
errors = $packages["errors"];
sync = $packages["sync"];
atomic = $packages["sync/atomic"];
Reader = $pkg.Reader = $newType(8, $kindInterface, "io.Reader", true, "io", true, null);
Writer = $pkg.Writer = $newType(8, $kindInterface, "io.Writer", true, "io", true, null);
Closer = $pkg.Closer = $newType(8, $kindInterface, "io.Closer", true, "io", true, null);
ReadCloser = $pkg.ReadCloser = $newType(8, $kindInterface, "io.ReadCloser", true, "io", true, null);
WriteCloser = $pkg.WriteCloser = $newType(8, $kindInterface, "io.WriteCloser", true, "io", true, null);
ReaderFrom = $pkg.ReaderFrom = $newType(8, $kindInterface, "io.ReaderFrom", true, "io", true, null);
WriterTo = $pkg.WriterTo = $newType(8, $kindInterface, "io.WriterTo", true, "io", true, null);
RuneScanner = $pkg.RuneScanner = $newType(8, $kindInterface, "io.RuneScanner", true, "io", true, null);
stringWriter = $pkg.stringWriter = $newType(8, $kindInterface, "io.stringWriter", true, "io", false, null);
LimitedReader = $pkg.LimitedReader = $newType(0, $kindStruct, "io.LimitedReader", true, "io", true, function(R_, N_) {
this.$val = this;
if (arguments.length === 0) {
this.R = $ifaceNil;
this.N = new $Int64(0, 0);
return;
}
this.R = R_;
this.N = N_;
});
sliceType = $sliceType($Uint8);
ptrType$1 = $ptrType(LimitedReader);
WriteString = function(w, s) {
var _r, _r$1, _tuple, _tuple$1, _tuple$2, err, n, ok, s, sw, w, $s, $r;
/* */ $s = 0; var $f, $c = false; if (this !== undefined && this.$blk !== undefined) { $f = this; $c = true; _r = $f._r; _r$1 = $f._r$1; _tuple = $f._tuple; _tuple$1 = $f._tuple$1; _tuple$2 = $f._tuple$2; err = $f.err; n = $f.n; ok = $f.ok; s = $f.s; sw = $f.sw; w = $f.w; $s = $f.$s; $r = $f.$r; } s: while (true) { switch ($s) { case 0:
n = 0;
err = $ifaceNil;
_tuple = $assertType(w, stringWriter, true);
sw = _tuple[0];
ok = _tuple[1];
/* */ if (ok) { $s = 1; continue; }
/* */ $s = 2; continue;
/* if (ok) { */ case 1:
_r = sw.WriteString(s); /* */ $s = 3; case 3: if($c) { $c = false; _r = _r.$blk(); } if (_r && _r.$blk !== undefined) { break s; }
_tuple$1 = _r;
n = _tuple$1[0];
err = _tuple$1[1];
$s = -1; return [n, err];
/* } */ case 2:
_r$1 = w.Write((new sliceType($stringToBytes(s)))); /* */ $s = 4; case 4: if($c) { $c = false; _r$1 = _r$1.$blk(); } if (_r$1 && _r$1.$blk !== undefined) { break s; }
_tuple$2 = _r$1;
n = _tuple$2[0];
err = _tuple$2[1];
$s = -1; return [n, err];
/* */ } return; } if ($f === undefined) { $f = { $blk: WriteString }; } $f._r = _r; $f._r$1 = _r$1; $f._tuple = _tuple; $f._tuple$1 = _tuple$1; $f._tuple$2 = _tuple$2; $f.err = err; $f.n = n; $f.ok = ok; $f.s = s; $f.sw = sw; $f.w = w; $f.$s = $s; $f.$r = $r; return $f;
};
$pkg.WriteString = WriteString;
ReadAtLeast = function(r, buf, min) {
var _r, _tmp, _tmp$1, _tuple, buf, err, min, n, nn, r, $s, $r;
/* */ $s = 0; var $f, $c = false; if (this !== undefined && this.$blk !== undefined) { $f = this; $c = true; _r = $f._r; _tmp = $f._tmp; _tmp$1 = $f._tmp$1; _tuple = $f._tuple; buf = $f.buf; err = $f.err; min = $f.min; n = $f.n; nn = $f.nn; r = $f.r; $s = $f.$s; $r = $f.$r; } s: while (true) { switch ($s) { case 0:
n = 0;
err = $ifaceNil;
if (buf.$length < min) {
_tmp = 0;
_tmp$1 = $pkg.ErrShortBuffer;
n = _tmp;
err = _tmp$1;
$s = -1; return [n, err];
}
/* while (true) { */ case 1:
/* if (!(n < min && $interfaceIsEqual(err, $ifaceNil))) { break; } */ if(!(n < min && $interfaceIsEqual(err, $ifaceNil))) { $s = 2; continue; }
nn = 0;
_r = r.Read($subslice(buf, n)); /* */ $s = 3; case 3: if($c) { $c = false; _r = _r.$blk(); } if (_r && _r.$blk !== undefined) { break s; }
_tuple = _r;
nn = _tuple[0];
err = _tuple[1];
n = n + (nn) >> 0;
/* } */ $s = 1; continue; case 2:
if (n >= min) {
err = $ifaceNil;
} else if (n > 0 && $interfaceIsEqual(err, $pkg.EOF)) {
err = $pkg.ErrUnexpectedEOF;
}
$s = -1; return [n, err];
/* */ } return; } if ($f === undefined) { $f = { $blk: ReadAtLeast }; } $f._r = _r; $f._tmp = _tmp; $f._tmp$1 = _tmp$1; $f._tuple = _tuple; $f.buf = buf; $f.err = err; $f.min = min; $f.n = n; $f.nn = nn; $f.r = r; $f.$s = $s; $f.$r = $r; return $f;
};
$pkg.ReadAtLeast = ReadAtLeast;
ReadFull = function(r, buf) {
var _r, _tuple, buf, err, n, r, $s, $r;
/* */ $s = 0; var $f, $c = false; if (this !== undefined && this.$blk !== undefined) { $f = this; $c = true; _r = $f._r; _tuple = $f._tuple; buf = $f.buf; err = $f.err; n = $f.n; r = $f.r; $s = $f.$s; $r = $f.$r; } s: while (true) { switch ($s) { case 0:
n = 0;
err = $ifaceNil;
_r = ReadAtLeast(r, buf, buf.$length); /* */ $s = 1; case 1: if($c) { $c = false; _r = _r.$blk(); } if (_r && _r.$blk !== undefined) { break s; }
_tuple = _r;
n = _tuple[0];
err = _tuple[1];
$s = -1; return [n, err];
/* */ } return; } if ($f === undefined) { $f = { $blk: ReadFull }; } $f._r = _r; $f._tuple = _tuple; $f.buf = buf; $f.err = err; $f.n = n; $f.r = r; $f.$s = $s; $f.$r = $r; return $f;
};
$pkg.ReadFull = ReadFull;
Copy = function(dst, src) {
var _r, _tuple, dst, err, src, written, $s, $r;
/* */ $s = 0; var $f, $c = false; if (this !== undefined && this.$blk !== undefined) { $f = this; $c = true; _r = $f._r; _tuple = $f._tuple; dst = $f.dst; err = $f.err; src = $f.src; written = $f.written; $s = $f.$s; $r = $f.$r; } s: while (true) { switch ($s) { case 0:
written = new $Int64(0, 0);
err = $ifaceNil;
_r = copyBuffer(dst, src, sliceType.nil); /* */ $s = 1; case 1: if($c) { $c = false; _r = _r.$blk(); } if (_r && _r.$blk !== undefined) { break s; }
_tuple = _r;
written = _tuple[0];
err = _tuple[1];
$s = -1; return [written, err];
/* */ } return; } if ($f === undefined) { $f = { $blk: Copy }; } $f._r = _r; $f._tuple = _tuple; $f.dst = dst; $f.err = err; $f.src = src; $f.written = written; $f.$s = $s; $f.$r = $r; return $f;
};
$pkg.Copy = Copy;
copyBuffer = function(dst, src, buf) {
var _r, _r$1, _r$2, _r$3, _tmp, _tmp$1, _tuple, _tuple$1, _tuple$2, _tuple$3, _tuple$4, _tuple$5, _tuple$6, buf, dst, er, err, ew, l, nr, nw, ok, ok$1, ok$2, rt, size, src, written, wt, x, x$1, x$2, x$3, x$4, $s, $r;
/* */ $s = 0; var $f, $c = false; if (this !== undefined && this.$blk !== undefined) { $f = this; $c = true; _r = $f._r; _r$1 = $f._r$1; _r$2 = $f._r$2; _r$3 = $f._r$3; _tmp = $f._tmp; _tmp$1 = $f._tmp$1; _tuple = $f._tuple; _tuple$1 = $f._tuple$1; _tuple$2 = $f._tuple$2; _tuple$3 = $f._tuple$3; _tuple$4 = $f._tuple$4; _tuple$5 = $f._tuple$5; _tuple$6 = $f._tuple$6; buf = $f.buf; dst = $f.dst; er = $f.er; err = $f.err; ew = $f.ew; l = $f.l; nr = $f.nr; nw = $f.nw; ok = $f.ok; ok$1 = $f.ok$1; ok$2 = $f.ok$2; rt = $f.rt; size = $f.size; src = $f.src; written = $f.written; wt = $f.wt; x = $f.x; x$1 = $f.x$1; x$2 = $f.x$2; x$3 = $f.x$3; x$4 = $f.x$4; $s = $f.$s; $r = $f.$r; } s: while (true) { switch ($s) { case 0:
written = new $Int64(0, 0);
err = $ifaceNil;
_tuple = $assertType(src, WriterTo, true);
wt = _tuple[0];
ok = _tuple[1];
/* */ if (ok) { $s = 1; continue; }
/* */ $s = 2; continue;
/* if (ok) { */ case 1:
_r = wt.WriteTo(dst); /* */ $s = 3; case 3: if($c) { $c = false; _r = _r.$blk(); } if (_r && _r.$blk !== undefined) { break s; }
_tuple$1 = _r;
written = _tuple$1[0];
err = _tuple$1[1];
$s = -1; return [written, err];
/* } */ case 2:
_tuple$2 = $assertType(dst, ReaderFrom, true);
rt = _tuple$2[0];
ok$1 = _tuple$2[1];
/* */ if (ok$1) { $s = 4; continue; }
/* */ $s = 5; continue;
/* if (ok$1) { */ case 4:
_r$1 = rt.ReadFrom(src); /* */ $s = 6; case 6: if($c) { $c = false; _r$1 = _r$1.$blk(); } if (_r$1 && _r$1.$blk !== undefined) { break s; }
_tuple$3 = _r$1;
written = _tuple$3[0];
err = _tuple$3[1];
$s = -1; return [written, err];
/* } */ case 5:
if (buf === sliceType.nil) {
size = 32768;
_tuple$4 = $assertType(src, ptrType$1, true);
l = _tuple$4[0];
ok$2 = _tuple$4[1];
if (ok$2 && (x = (new $Int64(0, size)), x$1 = l.N, (x.$high > x$1.$high || (x.$high === x$1.$high && x.$low > x$1.$low)))) {
if ((x$2 = l.N, (x$2.$high < 0 || (x$2.$high === 0 && x$2.$low < 1)))) {
size = 1;
} else {
size = (((x$3 = l.N, x$3.$low + ((x$3.$high >> 31) * 4294967296)) >> 0));
}
}
buf = $makeSlice(sliceType, size);
}
/* while (true) { */ case 7:
_r$2 = src.Read(buf); /* */ $s = 9; case 9: if($c) { $c = false; _r$2 = _r$2.$blk(); } if (_r$2 && _r$2.$blk !== undefined) { break s; }
_tuple$5 = _r$2;
nr = _tuple$5[0];
er = _tuple$5[1];
/* */ if (nr > 0) { $s = 10; continue; }
/* */ $s = 11; continue;
/* if (nr > 0) { */ case 10:
_r$3 = dst.Write($subslice(buf, 0, nr)); /* */ $s = 12; case 12: if($c) { $c = false; _r$3 = _r$3.$blk(); } if (_r$3 && _r$3.$blk !== undefined) { break s; }
_tuple$6 = _r$3;
nw = _tuple$6[0];
ew = _tuple$6[1];
if (nw > 0) {
written = (x$4 = (new $Int64(0, nw)), new $Int64(written.$high + x$4.$high, written.$low + x$4.$low));
}
if (!($interfaceIsEqual(ew, $ifaceNil))) {
err = ew;
/* break; */ $s = 8; continue;
}
if (!((nr === nw))) {
err = $pkg.ErrShortWrite;
/* break; */ $s = 8; continue;
}
/* } */ case 11:
if (!($interfaceIsEqual(er, $ifaceNil))) {
if (!($interfaceIsEqual(er, $pkg.EOF))) {
err = er;
}
/* break; */ $s = 8; continue;
}
/* } */ $s = 7; continue; case 8:
_tmp = written;
_tmp$1 = err;
written = _tmp;
err = _tmp$1;
$s = -1; return [written, err];
/* */ } return; } if ($f === undefined) { $f = { $blk: copyBuffer }; } $f._r = _r; $f._r$1 = _r$1; $f._r$2 = _r$2; $f._r$3 = _r$3; $f._tmp = _tmp; $f._tmp$1 = _tmp$1; $f._tuple = _tuple; $f._tuple$1 = _tuple$1; $f._tuple$2 = _tuple$2; $f._tuple$3 = _tuple$3; $f._tuple$4 = _tuple$4; $f._tuple$5 = _tuple$5; $f._tuple$6 = _tuple$6; $f.buf = buf; $f.dst = dst; $f.er = er; $f.err = err; $f.ew = ew; $f.l = l; $f.nr = nr; $f.nw = nw; $f.ok = ok; $f.ok$1 = ok$1; $f.ok$2 = ok$2; $f.rt = rt; $f.size = size; $f.src = src; $f.written = written; $f.wt = wt; $f.x = x; $f.x$1 = x$1; $f.x$2 = x$2; $f.x$3 = x$3; $f.x$4 = x$4; $f.$s = $s; $f.$r = $r; return $f;
};
LimitedReader.ptr.prototype.Read = function(p) {
var _r, _tmp, _tmp$1, _tuple, err, l, n, p, x, x$1, x$2, x$3, x$4, $s, $r;
/* */ $s = 0; var $f, $c = false; if (this !== undefined && this.$blk !== undefined) { $f = this; $c = true; _r = $f._r; _tmp = $f._tmp; _tmp$1 = $f._tmp$1; _tuple = $f._tuple; err = $f.err; l = $f.l; n = $f.n; p = $f.p; x = $f.x; x$1 = $f.x$1; x$2 = $f.x$2; x$3 = $f.x$3; x$4 = $f.x$4; $s = $f.$s; $r = $f.$r; } s: while (true) { switch ($s) { case 0:
n = 0;
err = $ifaceNil;
l = this;
if ((x = l.N, (x.$high < 0 || (x.$high === 0 && x.$low <= 0)))) {
_tmp = 0;
_tmp$1 = $pkg.EOF;
n = _tmp;
err = _tmp$1;
$s = -1; return [n, err];
}
if ((x$1 = (new $Int64(0, p.$length)), x$2 = l.N, (x$1.$high > x$2.$high || (x$1.$high === x$2.$high && x$1.$low > x$2.$low)))) {
p = $subslice(p, 0, $flatten64(l.N));
}
_r = l.R.Read(p); /* */ $s = 1; case 1: if($c) { $c = false; _r = _r.$blk(); } if (_r && _r.$blk !== undefined) { break s; }
_tuple = _r;
n = _tuple[0];
err = _tuple[1];
l.N = (x$3 = l.N, x$4 = (new $Int64(0, n)), new $Int64(x$3.$high - x$4.$high, x$3.$low - x$4.$low));
$s = -1; return [n, err];
/* */ } return; } if ($f === undefined) { $f = { $blk: LimitedReader.ptr.prototype.Read }; } $f._r = _r; $f._tmp = _tmp; $f._tmp$1 = _tmp$1; $f._tuple = _tuple; $f.err = err; $f.l = l; $f.n = n; $f.p = p; $f.x = x; $f.x$1 = x$1; $f.x$2 = x$2; $f.x$3 = x$3; $f.x$4 = x$4; $f.$s = $s; $f.$r = $r; return $f;
};
LimitedReader.prototype.Read = function(p) { return this.$val.Read(p); };
ptrType$1.methods = [{prop: "Read", name: "Read", pkg: "", typ: $funcType([sliceType], [$Int, $error], false)}];
Reader.init([{prop: "Read", name: "Read", pkg: "", typ: $funcType([sliceType], [$Int, $error], false)}]);
Writer.init([{prop: "Write", name: "Write", pkg: "", typ: $funcType([sliceType], [$Int, $error], false)}]);
Closer.init([{prop: "Close", name: "Close", pkg: "", typ: $funcType([], [$error], false)}]);
ReadCloser.init([{prop: "Close", name: "Close", pkg: "", typ: $funcType([], [$error], false)}, {prop: "Read", name: "Read", pkg: "", typ: $funcType([sliceType], [$Int, $error], false)}]);
WriteCloser.init([{prop: "Close", name: "Close", pkg: "", typ: $funcType([], [$error], false)}, {prop: "Write", name: "Write", pkg: "", typ: $funcType([sliceType], [$Int, $error], false)}]);
ReaderFrom.init([{prop: "ReadFrom", name: "ReadFrom", pkg: "", typ: $funcType([Reader], [$Int64, $error], false)}]);
WriterTo.init([{prop: "WriteTo", name: "WriteTo", pkg: "", typ: $funcType([Writer], [$Int64, $error], false)}]);
RuneScanner.init([{prop: "ReadRune", name: "ReadRune", pkg: "", typ: $funcType([], [$Int32, $Int, $error], false)}, {prop: "UnreadRune", name: "UnreadRune", pkg: "", typ: $funcType([], [$error], false)}]);
stringWriter.init([{prop: "WriteString", name: "WriteString", pkg: "", typ: $funcType([$String], [$Int, $error], false)}]);
LimitedReader.init("", [{prop: "R", name: "R", embedded: false, exported: true, typ: Reader, tag: ""}, {prop: "N", name: "N", embedded: false, exported: true, typ: $Int64, tag: ""}]);
$init = function() {
$pkg.$init = function() {};
/* */ var $f, $c = false, $s = 0, $r; if (this !== undefined && this.$blk !== undefined) { $f = this; $c = true; $s = $f.$s; $r = $f.$r; } s: while (true) { switch ($s) { case 0:
$r = errors.$init(); /* */ $s = 1; case 1: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; }
$r = sync.$init(); /* */ $s = 2; case 2: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; }
$r = atomic.$init(); /* */ $s = 3; case 3: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; }
$pkg.ErrShortWrite = errors.New("short write");
$pkg.ErrShortBuffer = errors.New("short buffer");
$pkg.EOF = errors.New("EOF");
$pkg.ErrUnexpectedEOF = errors.New("unexpected EOF");
$pkg.ErrNoProgress = errors.New("multiple Read calls return no data or error");
errWhence = errors.New("Seek: invalid whence");
errOffset = errors.New("Seek: invalid offset");
$pkg.ErrClosedPipe = errors.New("io: read/write on closed pipe");
/* */ } return; } if ($f === undefined) { $f = { $blk: $init }; } $f.$s = $s; $f.$r = $r; return $f;
};
$pkg.$init = $init;
return $pkg;
})();
$packages["unicode"] = (function() {
var $pkg = {}, $init, RangeTable, Range16, Range32, CaseRange, d, arrayType, sliceType, sliceType$1, sliceType$3, _White_Space, _CaseRanges, to, IsSpace, is16, is32, isExcludingLatin, To, ToUpper, ToLower;
RangeTable = $pkg.RangeTable = $newType(0, $kindStruct, "unicode.RangeTable", true, "unicode", true, function(R16_, R32_, LatinOffset_) {
this.$val = this;
if (arguments.length === 0) {
this.R16 = sliceType.nil;
this.R32 = sliceType$1.nil;
this.LatinOffset = 0;
return;
}
this.R16 = R16_;
this.R32 = R32_;
this.LatinOffset = LatinOffset_;
});
Range16 = $pkg.Range16 = $newType(0, $kindStruct, "unicode.Range16", true, "unicode", true, function(Lo_, Hi_, Stride_) {
this.$val = this;
if (arguments.length === 0) {
this.Lo = 0;
this.Hi = 0;
this.Stride = 0;
return;
}
this.Lo = Lo_;
this.Hi = Hi_;
this.Stride = Stride_;
});
Range32 = $pkg.Range32 = $newType(0, $kindStruct, "unicode.Range32", true, "unicode", true, function(Lo_, Hi_, Stride_) {
this.$val = this;
if (arguments.length === 0) {
this.Lo = 0;
this.Hi = 0;
this.Stride = 0;
return;
}
this.Lo = Lo_;
this.Hi = Hi_;
this.Stride = Stride_;
});
CaseRange = $pkg.CaseRange = $newType(0, $kindStruct, "unicode.CaseRange", true, "unicode", true, function(Lo_, Hi_, Delta_) {
this.$val = this;
if (arguments.length === 0) {
this.Lo = 0;
this.Hi = 0;
this.Delta = arrayType.zero();
return;
}
this.Lo = Lo_;
this.Hi = Hi_;
this.Delta = Delta_;
});
d = $pkg.d = $newType(12, $kindArray, "unicode.d", true, "unicode", false, null);
arrayType = $arrayType($Int32, 3);
sliceType = $sliceType(Range16);
sliceType$1 = $sliceType(Range32);
sliceType$3 = $sliceType(CaseRange);
to = function(_case, r, caseRange) {
var _case, _q, _tmp, _tmp$1, _tmp$2, _tmp$3, _tmp$4, _tmp$5, _tmp$6, _tmp$7, caseRange, cr, delta, foundMapping, hi, lo, m, mappedRune, r, x;
mappedRune = 0;
foundMapping = false;
if (_case < 0 || 3 <= _case) {
_tmp = 65533;
_tmp$1 = false;
mappedRune = _tmp;
foundMapping = _tmp$1;
return [mappedRune, foundMapping];
}
lo = 0;
hi = caseRange.$length;
while (true) {
if (!(lo < hi)) { break; }
m = lo + (_q = ((hi - lo >> 0)) / 2, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero")) >> 0;
cr = ((m < 0 || m >= caseRange.$length) ? ($throwRuntimeError("index out of range"), undefined) : caseRange.$array[caseRange.$offset + m]);
if (((cr.Lo >> 0)) <= r && r <= ((cr.Hi >> 0))) {
delta = ((x = cr.Delta, ((_case < 0 || _case >= x.length) ? ($throwRuntimeError("index out of range"), undefined) : x[_case])));
if (delta > 1114111) {
_tmp$2 = ((cr.Lo >> 0)) + ((((((r - ((cr.Lo >> 0)) >> 0)) & ~1) >> 0) | (((_case & 1) >> 0)))) >> 0;
_tmp$3 = true;
mappedRune = _tmp$2;
foundMapping = _tmp$3;
return [mappedRune, foundMapping];
}
_tmp$4 = r + delta >> 0;
_tmp$5 = true;
mappedRune = _tmp$4;
foundMapping = _tmp$5;
return [mappedRune, foundMapping];
}
if (r < ((cr.Lo >> 0))) {
hi = m;
} else {
lo = m + 1 >> 0;
}
}
_tmp$6 = r;
_tmp$7 = false;
mappedRune = _tmp$6;
foundMapping = _tmp$7;
return [mappedRune, foundMapping];
};
IsSpace = function(r) {
var _1, r;
if (((r >>> 0)) <= 255) {
_1 = r;
if ((_1 === (9)) || (_1 === (10)) || (_1 === (11)) || (_1 === (12)) || (_1 === (13)) || (_1 === (32)) || (_1 === (133)) || (_1 === (160))) {
return true;
}
return false;
}
return isExcludingLatin($pkg.White_Space, r);
};
$pkg.IsSpace = IsSpace;
is16 = function(ranges, r) {
var _i, _q, _r, _r$1, _ref, hi, i, lo, m, r, range_, range_$1, ranges;
if (ranges.$length <= 18 || r <= 255) {
_ref = ranges;
_i = 0;
while (true) {
if (!(_i < _ref.$length)) { break; }
i = _i;
range_ = ((i < 0 || i >= ranges.$length) ? ($throwRuntimeError("index out of range"), undefined) : ranges.$array[ranges.$offset + i]);
if (r < range_.Lo) {
return false;
}
if (r <= range_.Hi) {
return (range_.Stride === 1) || ((_r = ((r - range_.Lo << 16 >>> 16)) % range_.Stride, _r === _r ? _r : $throwRuntimeError("integer divide by zero")) === 0);
}
_i++;
}
return false;
}
lo = 0;
hi = ranges.$length;
while (true) {
if (!(lo < hi)) { break; }
m = lo + (_q = ((hi - lo >> 0)) / 2, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero")) >> 0;
range_$1 = ((m < 0 || m >= ranges.$length) ? ($throwRuntimeError("index out of range"), undefined) : ranges.$array[ranges.$offset + m]);
if (range_$1.Lo <= r && r <= range_$1.Hi) {
return (range_$1.Stride === 1) || ((_r$1 = ((r - range_$1.Lo << 16 >>> 16)) % range_$1.Stride, _r$1 === _r$1 ? _r$1 : $throwRuntimeError("integer divide by zero")) === 0);
}
if (r < range_$1.Lo) {
hi = m;
} else {
lo = m + 1 >> 0;
}
}
return false;
};
is32 = function(ranges, r) {
var _i, _q, _r, _r$1, _ref, hi, i, lo, m, r, range_, range_$1, ranges;
if (ranges.$length <= 18) {
_ref = ranges;
_i = 0;
while (true) {
if (!(_i < _ref.$length)) { break; }
i = _i;
range_ = ((i < 0 || i >= ranges.$length) ? ($throwRuntimeError("index out of range"), undefined) : ranges.$array[ranges.$offset + i]);
if (r < range_.Lo) {
return false;
}
if (r <= range_.Hi) {
return (range_.Stride === 1) || ((_r = ((r - range_.Lo >>> 0)) % range_.Stride, _r === _r ? _r : $throwRuntimeError("integer divide by zero")) === 0);
}
_i++;
}
return false;
}
lo = 0;
hi = ranges.$length;
while (true) {
if (!(lo < hi)) { break; }
m = lo + (_q = ((hi - lo >> 0)) / 2, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero")) >> 0;
range_$1 = $clone(((m < 0 || m >= ranges.$length) ? ($throwRuntimeError("index out of range"), undefined) : ranges.$array[ranges.$offset + m]), Range32);
if (range_$1.Lo <= r && r <= range_$1.Hi) {
return (range_$1.Stride === 1) || ((_r$1 = ((r - range_$1.Lo >>> 0)) % range_$1.Stride, _r$1 === _r$1 ? _r$1 : $throwRuntimeError("integer divide by zero")) === 0);
}
if (r < range_$1.Lo) {
hi = m;
} else {
lo = m + 1 >> 0;
}
}
return false;
};
isExcludingLatin = function(rangeTab, r) {
var off, r, r16, r32, rangeTab, x;
r16 = rangeTab.R16;
off = rangeTab.LatinOffset;
if (r16.$length > off && r <= (((x = r16.$length - 1 >> 0, ((x < 0 || x >= r16.$length) ? ($throwRuntimeError("index out of range"), undefined) : r16.$array[r16.$offset + x])).Hi >> 0))) {
return is16($subslice(r16, off), ((r << 16 >>> 16)));
}
r32 = rangeTab.R32;
if (r32.$length > 0 && r >= (((0 >= r32.$length ? ($throwRuntimeError("index out of range"), undefined) : r32.$array[r32.$offset + 0]).Lo >> 0))) {
return is32(r32, ((r >>> 0)));
}
return false;
};
To = function(_case, r) {
var _case, _tuple, r;
_tuple = to(_case, r, $pkg.CaseRanges);
r = _tuple[0];
return r;
};
$pkg.To = To;
ToUpper = function(r) {
var r;
if (r <= 127) {
if (97 <= r && r <= 122) {
r = r - (32) >> 0;
}
return r;
}
return To(0, r);
};
$pkg.ToUpper = ToUpper;
ToLower = function(r) {
var r;
if (r <= 127) {
if (65 <= r && r <= 90) {
r = r + (32) >> 0;
}
return r;
}
return To(1, r);
};
$pkg.ToLower = ToLower;
RangeTable.init("", [{prop: "R16", name: "R16", embedded: false, exported: true, typ: sliceType, tag: ""}, {prop: "R32", name: "R32", embedded: false, exported: true, typ: sliceType$1, tag: ""}, {prop: "LatinOffset", name: "LatinOffset", embedded: false, exported: true, typ: $Int, tag: ""}]);
Range16.init("", [{prop: "Lo", name: "Lo", embedded: false, exported: true, typ: $Uint16, tag: ""}, {prop: "Hi", name: "Hi", embedded: false, exported: true, typ: $Uint16, tag: ""}, {prop: "Stride", name: "Stride", embedded: false, exported: true, typ: $Uint16, tag: ""}]);
Range32.init("", [{prop: "Lo", name: "Lo", embedded: false, exported: true, typ: $Uint32, tag: ""}, {prop: "Hi", name: "Hi", embedded: false, exported: true, typ: $Uint32, tag: ""}, {prop: "Stride", name: "Stride", embedded: false, exported: true, typ: $Uint32, tag: ""}]);
CaseRange.init("", [{prop: "Lo", name: "Lo", embedded: false, exported: true, typ: $Uint32, tag: ""}, {prop: "Hi", name: "Hi", embedded: false, exported: true, typ: $Uint32, tag: ""}, {prop: "Delta", name: "Delta", embedded: false, exported: true, typ: d, tag: ""}]);
d.init($Int32, 3);
$init = function() {
$pkg.$init = function() {};
/* */ var $f, $c = false, $s = 0, $r; if (this !== undefined && this.$blk !== undefined) { $f = this; $c = true; $s = $f.$s; $r = $f.$r; } s: while (true) { switch ($s) { case 0:
_White_Space = new RangeTable.ptr(new sliceType([new Range16.ptr(9, 13, 1), new Range16.ptr(32, 32, 1), new Range16.ptr(133, 133, 1), new Range16.ptr(160, 160, 1), new Range16.ptr(5760, 5760, 1), new Range16.ptr(8192, 8202, 1), new Range16.ptr(8232, 8233, 1), new Range16.ptr(8239, 8239, 1), new Range16.ptr(8287, 8287, 1), new Range16.ptr(12288, 12288, 1)]), sliceType$1.nil, 4);
$pkg.White_Space = _White_Space;
_CaseRanges = new sliceType$3([new CaseRange.ptr(65, 90, $toNativeArray($kindInt32, [0, 32, 0])), new CaseRange.ptr(97, 122, $toNativeArray($kindInt32, [-32, 0, -32])), new CaseRange.ptr(181, 181, $toNativeArray($kindInt32, [743, 0, 743])), new CaseRange.ptr(192, 214, $toNativeArray($kindInt32, [0, 32, 0])), new CaseRange.ptr(216, 222, $toNativeArray($kindInt32, [0, 32, 0])), new CaseRange.ptr(224, 246, $toNativeArray($kindInt32, [-32, 0, -32])), new CaseRange.ptr(248, 254, $toNativeArray($kindInt32, [-32, 0, -32])), new CaseRange.ptr(255, 255, $toNativeArray($kindInt32, [121, 0, 121])), new CaseRange.ptr(256, 303, $toNativeArray($kindInt32, [1114112, 1114112, 1114112])), new CaseRange.ptr(304, 304, $toNativeArray($kindInt32, [0, -199, 0])), new CaseRange.ptr(305, 305, $toNativeArray($kindInt32, [-232, 0, -232])), new CaseRange.ptr(306, 311, $toNativeArray($kindInt32, [1114112, 1114112, 1114112])), new CaseRange.ptr(313, 328, $toNativeArray($kindInt32, [1114112, 1114112, 1114112])), new CaseRange.ptr(330, 375, $toNativeArray($kindInt32, [1114112, 1114112, 1114112])), new CaseRange.ptr(376, 376, $toNativeArray($kindInt32, [0, -121, 0])), new CaseRange.ptr(377, 382, $toNativeArray($kindInt32, [1114112, 1114112, 1114112])), new CaseRange.ptr(383, 383, $toNativeArray($kindInt32, [-300, 0, -300])), new CaseRange.ptr(384, 384, $toNativeArray($kindInt32, [195, 0, 195])), new CaseRange.ptr(385, 385, $toNativeArray($kindInt32, [0, 210, 0])), new CaseRange.ptr(386, 389, $toNativeArray($kindInt32, [1114112, 1114112, 1114112])), new CaseRange.ptr(390, 390, $toNativeArray($kindInt32, [0, 206, 0])), new CaseRange.ptr(391, 392, $toNativeArray($kindInt32, [1114112, 1114112, 1114112])), new CaseRange.ptr(393, 394, $toNativeArray($kindInt32, [0, 205, 0])), new CaseRange.ptr(395, 396, $toNativeArray($kindInt32, [1114112, 1114112, 1114112])), new CaseRange.ptr(398, 398, $toNativeArray($kindInt32, [0, 79, 0])), new CaseRange.ptr(399, 399, $toNativeArray($kindInt32, [0, 202, 0])), new CaseRange.ptr(400, 400, $toNativeArray($kindInt32, [0, 203, 0])), new CaseRange.ptr(401, 402, $toNativeArray($kindInt32, [1114112, 1114112, 1114112])), new CaseRange.ptr(403, 403, $toNativeArray($kindInt32, [0, 205, 0])), new CaseRange.ptr(404, 404, $toNativeArray($kindInt32, [0, 207, 0])), new CaseRange.ptr(405, 405, $toNativeArray($kindInt32, [97, 0, 97])), new CaseRange.ptr(406, 406, $toNativeArray($kindInt32, [0, 211, 0])), new CaseRange.ptr(407, 407, $toNativeArray($kindInt32, [0, 209, 0])), new CaseRange.ptr(408, 409, $toNativeArray($kindInt32, [1114112, 1114112, 1114112])), new CaseRange.ptr(410, 410, $toNativeArray($kindInt32, [163, 0, 163])), new CaseRange.ptr(412, 412, $toNativeArray($kindInt32, [0, 211, 0])), new CaseRange.ptr(413, 413, $toNativeArray($kindInt32, [0, 213, 0])), new CaseRange.ptr(414, 414, $toNativeArray($kindInt32, [130, 0, 130])), new CaseRange.ptr(415, 415, $toNativeArray($kindInt32, [0, 214, 0])), new CaseRange.ptr(416, 421, $toNativeArray($kindInt32, [1114112, 1114112, 1114112])), new CaseRange.ptr(422, 422, $toNativeArray($kindInt32, [0, 218, 0])), new CaseRange.ptr(423, 424, $toNativeArray($kindInt32, [1114112, 1114112, 1114112])), new CaseRange.ptr(425, 425, $toNativeArray($kindInt32, [0, 218, 0])), new CaseRange.ptr(428, 429, $toNativeArray($kindInt32, [1114112, 1114112, 1114112])), new CaseRange.ptr(430, 430, $toNativeArray($kindInt32, [0, 218, 0])), new CaseRange.ptr(431, 432, $toNativeArray($kindInt32, [1114112, 1114112, 1114112])), new CaseRange.ptr(433, 434, $toNativeArray($kindInt32, [0, 217, 0])), new CaseRange.ptr(435, 438, $toNativeArray($kindInt32, [1114112, 1114112, 1114112])), new CaseRange.ptr(439, 439, $toNativeArray($kindInt32, [0, 219, 0])), new CaseRange.ptr(440, 441, $toNativeArray($kindInt32, [1114112, 1114112, 1114112])), new CaseRange.ptr(444, 445, $toNativeArray($kindInt32, [1114112, 1114112, 1114112])), new CaseRange.ptr(447, 447, $toNativeArray($kindInt32, [56, 0, 56])), new CaseRange.ptr(452, 452, $toNativeArray($kindInt32, [0, 2, 1])), new CaseRange.ptr(453, 453, $toNativeArray($kindInt32, [-1, 1, 0])), new CaseRange.ptr(454, 454, $toNativeArray($kindInt32, [-2, 0, -1])), new CaseRange.ptr(455, 455, $toNativeArray($kindInt32, [0, 2, 1])), new CaseRange.ptr(456, 456, $toNativeArray($kindInt32, [-1, 1, 0])), new CaseRange.ptr(457, 457, $toNativeArray($kindInt32, [-2, 0, -1])), new CaseRange.ptr(458, 458, $toNativeArray($kindInt32, [0, 2, 1])), new CaseRange.ptr(459, 459, $toNativeArray($kindInt32, [-1, 1, 0])), new CaseRange.ptr(460, 460, $toNativeArray($kindInt32, [-2, 0, -1])), new CaseRange.ptr(461, 476, $toNativeArray($kindInt32, [1114112, 1114112, 1114112])), new CaseRange.ptr(477, 477, $toNativeArray($kindInt32, [-79, 0, -79])), new CaseRange.ptr(478, 495, $toNativeArray($kindInt32, [1114112, 1114112, 1114112])), new CaseRange.ptr(497, 497, $toNativeArray($kindInt32, [0, 2, 1])), new CaseRange.ptr(498, 498, $toNativeArray($kindInt32, [-1, 1, 0])), new CaseRange.ptr(499, 499, $toNativeArray($kindInt32, [-2, 0, -1])), new CaseRange.ptr(500, 501, $toNativeArray($kindInt32, [1114112, 1114112, 1114112])), new CaseRange.ptr(502, 502, $toNativeArray($kindInt32, [0, -97, 0])), new CaseRange.ptr(503, 503, $toNativeArray($kindInt32, [0, -56, 0])), new CaseRange.ptr(504, 543, $toNativeArray($kindInt32, [1114112, 1114112, 1114112])), new CaseRange.ptr(544, 544, $toNativeArray($kindInt32, [0, -130, 0])), new CaseRange.ptr(546, 563, $toNativeArray($kindInt32, [1114112, 1114112, 1114112])), new CaseRange.ptr(570, 570, $toNativeArray($kindInt32, [0, 10795, 0])), new CaseRange.ptr(571, 572, $toNativeArray($kindInt32, [1114112, 1114112, 1114112])), new CaseRange.ptr(573, 573, $toNativeArray($kindInt32, [0, -163, 0])), new CaseRange.ptr(574, 574, $toNativeArray($kindInt32, [0, 10792, 0])), new CaseRange.ptr(575, 576, $toNativeArray($kindInt32, [10815, 0, 10815])), new CaseRange.ptr(577, 578, $toNativeArray($kindInt32, [1114112, 1114112, 1114112])), new CaseRange.ptr(579, 579, $toNativeArray($kindInt32, [0, -195, 0])), new CaseRange.ptr(580, 580, $toNativeArray($kindInt32, [0, 69, 0])), new CaseRange.ptr(581, 581, $toNativeArray($kindInt32, [0, 71, 0])), new CaseRange.ptr(582, 591, $toNativeArray($kindInt32, [1114112, 1114112, 1114112])), new CaseRange.ptr(592, 592, $toNativeArray($kindInt32, [10783, 0, 10783])), new CaseRange.ptr(593, 593, $toNativeArray($kindInt32, [10780, 0, 10780])), new CaseRange.ptr(594, 594, $toNativeArray($kindInt32, [10782, 0, 10782])), new CaseRange.ptr(595, 595, $toNativeArray($kindInt32, [-210, 0, -210])), new CaseRange.ptr(596, 596, $toNativeArray($kindInt32, [-206, 0, -206])), new CaseRange.ptr(598, 599, $toNativeArray($kindInt32, [-205, 0, -205])), new CaseRange.ptr(601, 601, $toNativeArray($kindInt32, [-202, 0, -202])), new CaseRange.ptr(603, 603, $toNativeArray($kindInt32, [-203, 0, -203])), new CaseRange.ptr(604, 604, $toNativeArray($kindInt32, [42319, 0, 42319])), new CaseRange.ptr(608, 608, $toNativeArray($kindInt32, [-205, 0, -205])), new CaseRange.ptr(609, 609, $toNativeArray($kindInt32, [42315, 0, 42315])), new CaseRange.ptr(611, 611, $toNativeArray($kindInt32, [-207, 0, -207])), new CaseRange.ptr(613, 613, $toNativeArray($kindInt32, [42280, 0, 42280])), new CaseRange.ptr(614, 614, $toNativeArray($kindInt32, [42308, 0, 42308])), new CaseRange.ptr(616, 616, $toNativeArray($kindInt32, [-209, 0, -209])), new CaseRange.ptr(617, 617, $toNativeArray($kindInt32, [-211, 0, -211])), new CaseRange.ptr(618, 618, $toNativeArray($kindInt32, [42308, 0, 42308])), new CaseRange.ptr(619, 619, $toNativeArray($kindInt32, [10743, 0, 10743])), new CaseRange.ptr(620, 620, $toNativeArray($kindInt32, [42305, 0, 42305])), new CaseRange.ptr(623, 623, $toNativeArray($kindInt32, [-211, 0, -211])), new CaseRange.ptr(625, 625, $toNativeArray($kindInt32, [10749, 0, 10749])), new CaseRange.ptr(626, 626, $toNativeArray($kindInt32, [-213, 0, -213])), new CaseRange.ptr(629, 629, $toNativeArray($kindInt32, [-214, 0, -214])), new CaseRange.ptr(637, 637, $toNativeArray($kindInt32, [10727, 0, 10727])), new CaseRange.ptr(640, 640, $toNativeArray($kindInt32, [-218, 0, -218])), new CaseRange.ptr(643, 643, $toNativeArray($kindInt32, [-218, 0, -218])), new CaseRange.ptr(647, 647, $toNativeArray($kindInt32, [42282, 0, 42282])), new CaseRange.ptr(648, 648, $toNativeArray($kindInt32, [-218, 0, -218])), new CaseRange.ptr(649, 649, $toNativeArray($kindInt32, [-69, 0, -69])), new CaseRange.ptr(650, 651, $toNativeArray($kindInt32, [-217, 0, -217])), new CaseRange.ptr(652, 652, $toNativeArray($kindInt32, [-71, 0, -71])), new CaseRange.ptr(658, 658, $toNativeArray($kindInt32, [-219, 0, -219])), new CaseRange.ptr(669, 669, $toNativeArray($kindInt32, [42261, 0, 42261])), new CaseRange.ptr(670, 670, $toNativeArray($kindInt32, [42258, 0, 42258])), new CaseRange.ptr(837, 837, $toNativeArray($kindInt32, [84, 0, 84])), new CaseRange.ptr(880, 883, $toNativeArray($kindInt32, [1114112, 1114112, 1114112])), new CaseRange.ptr(886, 887, $toNativeArray($kindInt32, [1114112, 1114112, 1114112])), new CaseRange.ptr(891, 893, $toNativeArray($kindInt32, [130, 0, 130])), new CaseRange.ptr(895, 895, $toNativeArray($kindInt32, [0, 116, 0])), new CaseRange.ptr(902, 902, $toNativeArray($kindInt32, [0, 38, 0])), new CaseRange.ptr(904, 906, $toNativeArray($kindInt32, [0, 37, 0])), new CaseRange.ptr(908, 908, $toNativeArray($kindInt32, [0, 64, 0])), new CaseRange.ptr(910, 911, $toNativeArray($kindInt32, [0, 63, 0])), new CaseRange.ptr(913, 929, $toNativeArray($kindInt32, [0, 32, 0])), new CaseRange.ptr(931, 939, $toNativeArray($kindInt32, [0, 32, 0])), new CaseRange.ptr(940, 940, $toNativeArray($kindInt32, [-38, 0, -38])), new CaseRange.ptr(941, 943, $toNativeArray($kindInt32, [-37, 0, -37])), new CaseRange.ptr(945, 961, $toNativeArray($kindInt32, [-32, 0, -32])), new CaseRange.ptr(962, 962, $toNativeArray($kindInt32, [-31, 0, -31])), new CaseRange.ptr(963, 971, $toNativeArray($kindInt32, [-32, 0, -32])), new CaseRange.ptr(972, 972, $toNativeArray($kindInt32, [-64, 0, -64])), new CaseRange.ptr(973, 974, $toNativeArray($kindInt32, [-63, 0, -63])), new CaseRange.ptr(975, 975, $toNativeArray($kindInt32, [0, 8, 0])), new CaseRange.ptr(976, 976, $toNativeArray($kindInt32, [-62, 0, -62])), new CaseRange.ptr(977, 977, $toNativeArray($kindInt32, [-57, 0, -57])), new CaseRange.ptr(981, 981, $toNativeArray($kindInt32, [-47, 0, -47])), new CaseRange.ptr(982, 982, $toNativeArray($kindInt32, [-54, 0, -54])), new CaseRange.ptr(983, 983, $toNativeArray($kindInt32, [-8, 0, -8])), new CaseRange.ptr(984, 1007, $toNativeArray($kindInt32, [1114112, 1114112, 1114112])), new CaseRange.ptr(1008, 1008, $toNativeArray($kindInt32, [-86, 0, -86])), new CaseRange.ptr(1009, 1009, $toNativeArray($kindInt32, [-80, 0, -80])), new CaseRange.ptr(1010, 1010, $toNativeArray($kindInt32, [7, 0, 7])), new CaseRange.ptr(1011, 1011, $toNativeArray($kindInt32, [-116, 0, -116])), new CaseRange.ptr(1012, 1012, $toNativeArray($kindInt32, [0, -60, 0])), new CaseRange.ptr(1013, 1013, $toNativeArray($kindInt32, [-96, 0, -96])), new CaseRange.ptr(1015, 1016, $toNativeArray($kindInt32, [1114112, 1114112, 1114112])), new CaseRange.ptr(1017, 1017, $toNativeArray($kindInt32, [0, -7, 0])), new CaseRange.ptr(1018, 1019, $toNativeArray($kindInt32, [1114112, 1114112, 1114112])), new CaseRange.ptr(1021, 1023, $toNativeArray($kindInt32, [0, -130, 0])), new CaseRange.ptr(1024, 1039, $toNativeArray($kindInt32, [0, 80, 0])), new CaseRange.ptr(1040, 1071, $toNativeArray($kindInt32, [0, 32, 0])), new CaseRange.ptr(1072, 1103, $toNativeArray($kindInt32, [-32, 0, -32])), new CaseRange.ptr(1104, 1119, $toNativeArray($kindInt32, [-80, 0, -80])), new CaseRange.ptr(1120, 1153, $toNativeArray($kindInt32, [1114112, 1114112, 1114112])), new CaseRange.ptr(1162, 1215, $toNativeArray($kindInt32, [1114112, 1114112, 1114112])), new CaseRange.ptr(1216, 1216, $toNativeArray($kindInt32, [0, 15, 0])), new CaseRange.ptr(1217, 1230, $toNativeArray($kindInt32, [1114112, 1114112, 1114112])), new CaseRange.ptr(1231, 1231, $toNativeArray($kindInt32, [-15, 0, -15])), new CaseRange.ptr(1232, 1327, $toNativeArray($kindInt32, [1114112, 1114112, 1114112])), new CaseRange.ptr(1329, 1366, $toNativeArray($kindInt32, [0, 48, 0])), new CaseRange.ptr(1377, 1414, $toNativeArray($kindInt32, [-48, 0, -48])), new CaseRange.ptr(4256, 4293, $toNativeArray($kindInt32, [0, 7264, 0])), new CaseRange.ptr(4295, 4295, $toNativeArray($kindInt32, [0, 7264, 0])), new CaseRange.ptr(4301, 4301, $toNativeArray($kindInt32, [0, 7264, 0])), new CaseRange.ptr(5024, 5103, $toNativeArray($kindInt32, [0, 38864, 0])), new CaseRange.ptr(5104, 5109, $toNativeArray($kindInt32, [0, 8, 0])), new CaseRange.ptr(5112, 5117, $toNativeArray($kindInt32, [-8, 0, -8])), new CaseRange.ptr(7296, 7296, $toNativeArray($kindInt32, [-6254, 0, -6254])), new CaseRange.ptr(7297, 7297, $toNativeArray($kindInt32, [-6253, 0, -6253])), new CaseRange.ptr(7298, 7298, $toNativeArray($kindInt32, [-6244, 0, -6244])), new CaseRange.ptr(7299, 7300, $toNativeArray($kindInt32, [-6242, 0, -6242])), new CaseRange.ptr(7301, 7301, $toNativeArray($kindInt32, [-6243, 0, -6243])), new CaseRange.ptr(7302, 7302, $toNativeArray($kindInt32, [-6236, 0, -6236])), new CaseRange.ptr(7303, 7303, $toNativeArray($kindInt32, [-6181, 0, -6181])), new CaseRange.ptr(7304, 7304, $toNativeArray($kindInt32, [35266, 0, 35266])), new CaseRange.ptr(7545, 7545, $toNativeArray($kindInt32, [35332, 0, 35332])), new CaseRange.ptr(7549, 7549, $toNativeArray($kindInt32, [3814, 0, 3814])), new CaseRange.ptr(7680, 7829, $toNativeArray($kindInt32, [1114112, 1114112, 1114112])), new CaseRange.ptr(7835, 7835, $toNativeArray($kindInt32, [-59, 0, -59])), new CaseRange.ptr(7838, 7838, $toNativeArray($kindInt32, [0, -7615, 0])), new CaseRange.ptr(7840, 7935, $toNativeArray($kindInt32, [1114112, 1114112, 1114112])), new CaseRange.ptr(7936, 7943, $toNativeArray($kindInt32, [8, 0, 8])), new CaseRange.ptr(7944, 7951, $toNativeArray($kindInt32, [0, -8, 0])), new CaseRange.ptr(7952, 7957, $toNativeArray($kindInt32, [8, 0, 8])), new CaseRange.ptr(7960, 7965, $toNativeArray($kindInt32, [0, -8, 0])), new CaseRange.ptr(7968, 7975, $toNativeArray($kindInt32, [8, 0, 8])), new CaseRange.ptr(7976, 7983, $toNativeArray($kindInt32, [0, -8, 0])), new CaseRange.ptr(7984, 7991, $toNativeArray($kindInt32, [8, 0, 8])), new CaseRange.ptr(7992, 7999, $toNativeArray($kindInt32, [0, -8, 0])), new CaseRange.ptr(8000, 8005, $toNativeArray($kindInt32, [8, 0, 8])), new CaseRange.ptr(8008, 8013, $toNativeArray($kindInt32, [0, -8, 0])), new CaseRange.ptr(8017, 8017, $toNativeArray($kindInt32, [8, 0, 8])), new CaseRange.ptr(8019, 8019, $toNativeArray($kindInt32, [8, 0, 8])), new CaseRange.ptr(8021, 8021, $toNativeArray($kindInt32, [8, 0, 8])), new CaseRange.ptr(8023, 8023, $toNativeArray($kindInt32, [8, 0, 8])), new CaseRange.ptr(8025, 8025, $toNativeArray($kindInt32, [0, -8, 0])), new CaseRange.ptr(8027, 8027, $toNativeArray($kindInt32, [0, -8, 0])), new CaseRange.ptr(8029, 8029, $toNativeArray($kindInt32, [0, -8, 0])), new CaseRange.ptr(8031, 8031, $toNativeArray($kindInt32, [0, -8, 0])), new CaseRange.ptr(8032, 8039, $toNativeArray($kindInt32, [8, 0, 8])), new CaseRange.ptr(8040, 8047, $toNativeArray($kindInt32, [0, -8, 0])), new CaseRange.ptr(8048, 8049, $toNativeArray($kindInt32, [74, 0, 74])), new CaseRange.ptr(8050, 8053, $toNativeArray($kindInt32, [86, 0, 86])), new CaseRange.ptr(8054, 8055, $toNativeArray($kindInt32, [100, 0, 100])), new CaseRange.ptr(8056, 8057, $toNativeArray($kindInt32, [128, 0, 128])), new CaseRange.ptr(8058, 8059, $toNativeArray($kindInt32, [112, 0, 112])), new CaseRange.ptr(8060, 8061, $toNativeArray($kindInt32, [126, 0, 126])), new CaseRange.ptr(8064, 8071, $toNativeArray($kindInt32, [8, 0, 8])), new CaseRange.ptr(8072, 8079, $toNativeArray($kindInt32, [0, -8, 0])), new CaseRange.ptr(8080, 8087, $toNativeArray($kindInt32, [8, 0, 8])), new CaseRange.ptr(8088, 8095, $toNativeArray($kindInt32, [0, -8, 0])), new CaseRange.ptr(8096, 8103, $toNativeArray($kindInt32, [8, 0, 8])), new CaseRange.ptr(8104, 8111, $toNativeArray($kindInt32, [0, -8, 0])), new CaseRange.ptr(8112, 8113, $toNativeArray($kindInt32, [8, 0, 8])), new CaseRange.ptr(8115, 8115, $toNativeArray($kindInt32, [9, 0, 9])), new CaseRange.ptr(8120, 8121, $toNativeArray($kindInt32, [0, -8, 0])), new CaseRange.ptr(8122, 8123, $toNativeArray($kindInt32, [0, -74, 0])), new CaseRange.ptr(8124, 8124, $toNativeArray($kindInt32, [0, -9, 0])), new CaseRange.ptr(8126, 8126, $toNativeArray($kindInt32, [-7205, 0, -7205])), new CaseRange.ptr(8131, 8131, $toNativeArray($kindInt32, [9, 0, 9])), new CaseRange.ptr(8136, 8139, $toNativeArray($kindInt32, [0, -86, 0])), new CaseRange.ptr(8140, 8140, $toNativeArray($kindInt32, [0, -9, 0])), new CaseRange.ptr(8144, 8145, $toNativeArray($kindInt32, [8, 0, 8])), new CaseRange.ptr(8152, 8153, $toNativeArray($kindInt32, [0, -8, 0])), new CaseRange.ptr(8154, 8155, $toNativeArray($kindInt32, [0, -100, 0])), new CaseRange.ptr(8160, 8161, $toNativeArray($kindInt32, [8, 0, 8])), new CaseRange.ptr(8165, 8165, $toNativeArray($kindInt32, [7, 0, 7])), new CaseRange.ptr(8168, 8169, $toNativeArray($kindInt32, [0, -8, 0])), new CaseRange.ptr(8170, 8171, $toNativeArray($kindInt32, [0, -112, 0])), new CaseRange.ptr(8172, 8172, $toNativeArray($kindInt32, [0, -7, 0])), new CaseRange.ptr(8179, 8179, $toNativeArray($kindInt32, [9, 0, 9])), new CaseRange.ptr(8184, 8185, $toNativeArray($kindInt32, [0, -128, 0])), new CaseRange.ptr(8186, 8187, $toNativeArray($kindInt32, [0, -126, 0])), new CaseRange.ptr(8188, 8188, $toNativeArray($kindInt32, [0, -9, 0])), new CaseRange.ptr(8486, 8486, $toNativeArray($kindInt32, [0, -7517, 0])), new CaseRange.ptr(8490, 8490, $toNativeArray($kindInt32, [0, -8383, 0])), new CaseRange.ptr(8491, 8491, $toNativeArray($kindInt32, [0, -8262, 0])), new CaseRange.ptr(8498, 8498, $toNativeArray($kindInt32, [0, 28, 0])), new CaseRange.ptr(8526, 8526, $toNativeArray($kindInt32, [-28, 0, -28])), new CaseRange.ptr(8544, 8559, $toNativeArray($kindInt32, [0, 16, 0])), new CaseRange.ptr(8560, 8575, $toNativeArray($kindInt32, [-16, 0, -16])), new CaseRange.ptr(8579, 8580, $toNativeArray($kindInt32, [1114112, 1114112, 1114112])), new CaseRange.ptr(9398, 9423, $toNativeArray($kindInt32, [0, 26, 0])), new CaseRange.ptr(9424, 9449, $toNativeArray($kindInt32, [-26, 0, -26])), new CaseRange.ptr(11264, 11310, $toNativeArray($kindInt32, [0, 48, 0])), new CaseRange.ptr(11312, 11358, $toNativeArray($kindInt32, [-48, 0, -48])), new CaseRange.ptr(11360, 11361, $toNativeArray($kindInt32, [1114112, 1114112, 1114112])), new CaseRange.ptr(11362, 11362, $toNativeArray($kindInt32, [0, -10743, 0])), new CaseRange.ptr(11363, 11363, $toNativeArray($kindInt32, [0, -3814, 0])), new CaseRange.ptr(11364, 11364, $toNativeArray($kindInt32, [0, -10727, 0])), new CaseRange.ptr(11365, 11365, $toNativeArray($kindInt32, [-10795, 0, -10795])), new CaseRange.ptr(11366, 11366, $toNativeArray($kindInt32, [-10792, 0, -10792])), new CaseRange.ptr(11367, 11372, $toNativeArray($kindInt32, [1114112, 1114112, 1114112])), new CaseRange.ptr(11373, 11373, $toNativeArray($kindInt32, [0, -10780, 0])), new CaseRange.ptr(11374, 11374, $toNativeArray($kindInt32, [0, -10749, 0])), new CaseRange.ptr(11375, 11375, $toNativeArray($kindInt32, [0, -10783, 0])), new CaseRange.ptr(11376, 11376, $toNativeArray($kindInt32, [0, -10782, 0])), new CaseRange.ptr(11378, 11379, $toNativeArray($kindInt32, [1114112, 1114112, 1114112])), new CaseRange.ptr(11381, 11382, $toNativeArray($kindInt32, [1114112, 1114112, 1114112])), new CaseRange.ptr(11390, 11391, $toNativeArray($kindInt32, [0, -10815, 0])), new CaseRange.ptr(11392, 11491, $toNativeArray($kindInt32, [1114112, 1114112, 1114112])), new CaseRange.ptr(11499, 11502, $toNativeArray($kindInt32, [1114112, 1114112, 1114112])), new CaseRange.ptr(11506, 11507, $toNativeArray($kindInt32, [1114112, 1114112, 1114112])), new CaseRange.ptr(11520, 11557, $toNativeArray($kindInt32, [-7264, 0, -7264])), new CaseRange.ptr(11559, 11559, $toNativeArray($kindInt32, [-7264, 0, -7264])), new CaseRange.ptr(11565, 11565, $toNativeArray($kindInt32, [-7264, 0, -7264])), new CaseRange.ptr(42560, 42605, $toNativeArray($kindInt32, [1114112, 1114112, 1114112])), new CaseRange.ptr(42624, 42651, $toNativeArray($kindInt32, [1114112, 1114112, 1114112])), new CaseRange.ptr(42786, 42799, $toNativeArray($kindInt32, [1114112, 1114112, 1114112])), new CaseRange.ptr(42802, 42863, $toNativeArray($kindInt32, [1114112, 1114112, 1114112])), new CaseRange.ptr(42873, 42876, $toNativeArray($kindInt32, [1114112, 1114112, 1114112])), new CaseRange.ptr(42877, 42877, $toNativeArray($kindInt32, [0, -35332, 0])), new CaseRange.ptr(42878, 42887, $toNativeArray($kindInt32, [1114112, 1114112, 1114112])), new CaseRange.ptr(42891, 42892, $toNativeArray($kindInt32, [1114112, 1114112, 1114112])), new CaseRange.ptr(42893, 42893, $toNativeArray($kindInt32, [0, -42280, 0])), new CaseRange.ptr(42896, 42899, $toNativeArray($kindInt32, [1114112, 1114112, 1114112])), new CaseRange.ptr(42902, 42921, $toNativeArray($kindInt32, [1114112, 1114112, 1114112])), new CaseRange.ptr(42922, 42922, $toNativeArray($kindInt32, [0, -42308, 0])), new CaseRange.ptr(42923, 42923, $toNativeArray($kindInt32, [0, -42319, 0])), new CaseRange.ptr(42924, 42924, $toNativeArray($kindInt32, [0, -42315, 0])), new CaseRange.ptr(42925, 42925, $toNativeArray($kindInt32, [0, -42305, 0])), new CaseRange.ptr(42926, 42926, $toNativeArray($kindInt32, [0, -42308, 0])), new CaseRange.ptr(42928, 42928, $toNativeArray($kindInt32, [0, -42258, 0])), new CaseRange.ptr(42929, 42929, $toNativeArray($kindInt32, [0, -42282, 0])), new CaseRange.ptr(42930, 42930, $toNativeArray($kindInt32, [0, -42261, 0])), new CaseRange.ptr(42931, 42931, $toNativeArray($kindInt32, [0, 928, 0])), new CaseRange.ptr(42932, 42935, $toNativeArray($kindInt32, [1114112, 1114112, 1114112])), new CaseRange.ptr(43859, 43859, $toNativeArray($kindInt32, [-928, 0, -928])), new CaseRange.ptr(43888, 43967, $toNativeArray($kindInt32, [-38864, 0, -38864])), new CaseRange.ptr(65313, 65338, $toNativeArray($kindInt32, [0, 32, 0])), new CaseRange.ptr(65345, 65370, $toNativeArray($kindInt32, [-32, 0, -32])), new CaseRange.ptr(66560, 66599, $toNativeArray($kindInt32, [0, 40, 0])), new CaseRange.ptr(66600, 66639, $toNativeArray($kindInt32, [-40, 0, -40])), new CaseRange.ptr(66736, 66771, $toNativeArray($kindInt32, [0, 40, 0])), new CaseRange.ptr(66776, 66811, $toNativeArray($kindInt32, [-40, 0, -40])), new CaseRange.ptr(68736, 68786, $toNativeArray($kindInt32, [0, 64, 0])), new CaseRange.ptr(68800, 68850, $toNativeArray($kindInt32, [-64, 0, -64])), new CaseRange.ptr(71840, 71871, $toNativeArray($kindInt32, [0, 32, 0])), new CaseRange.ptr(71872, 71903, $toNativeArray($kindInt32, [-32, 0, -32])), new CaseRange.ptr(125184, 125217, $toNativeArray($kindInt32, [0, 34, 0])), new CaseRange.ptr(125218, 125251, $toNativeArray($kindInt32, [-34, 0, -34]))]);
$pkg.CaseRanges = _CaseRanges;
/* */ } return; } if ($f === undefined) { $f = { $blk: $init }; } $f.$s = $s; $f.$r = $r; return $f;
};
$pkg.$init = $init;
return $pkg;
})();
$packages["unicode/utf8"] = (function() {
var $pkg = {}, $init, acceptRange, first, acceptRanges, FullRune, DecodeRune, DecodeRuneInString, DecodeLastRuneInString, RuneLen, EncodeRune, RuneCount, RuneCountInString, RuneStart, ValidString, ValidRune;
acceptRange = $pkg.acceptRange = $newType(0, $kindStruct, "utf8.acceptRange", true, "unicode/utf8", false, function(lo_, hi_) {
this.$val = this;
if (arguments.length === 0) {
this.lo = 0;
this.hi = 0;
return;
}
this.lo = lo_;
this.hi = hi_;
});
FullRune = function(p) {
var accept, n, p, x, x$1, x$2;
n = p.$length;
if (n === 0) {
return false;
}
x$1 = (x = (0 >= p.$length ? ($throwRuntimeError("index out of range"), undefined) : p.$array[p.$offset + 0]), ((x < 0 || x >= first.length) ? ($throwRuntimeError("index out of range"), undefined) : first[x]));
if (n >= ((((x$1 & 7) >>> 0) >> 0))) {
return true;
}
accept = $clone((x$2 = x$1 >>> 4 << 24 >>> 24, ((x$2 < 0 || x$2 >= acceptRanges.length) ? ($throwRuntimeError("index out of range"), undefined) : acceptRanges[x$2])), acceptRange);
if (n > 1 && ((1 >= p.$length ? ($throwRuntimeError("index out of range"), undefined) : p.$array[p.$offset + 1]) < accept.lo || accept.hi < (1 >= p.$length ? ($throwRuntimeError("index out of range"), undefined) : p.$array[p.$offset + 1]))) {
return true;
} else if (n > 2 && ((2 >= p.$length ? ($throwRuntimeError("index out of range"), undefined) : p.$array[p.$offset + 2]) < 128 || 191 < (2 >= p.$length ? ($throwRuntimeError("index out of range"), undefined) : p.$array[p.$offset + 2]))) {
return true;
}
return false;
};
$pkg.FullRune = FullRune;
DecodeRune = function(p) {
var _tmp, _tmp$1, _tmp$10, _tmp$11, _tmp$12, _tmp$13, _tmp$14, _tmp$15, _tmp$16, _tmp$17, _tmp$2, _tmp$3, _tmp$4, _tmp$5, _tmp$6, _tmp$7, _tmp$8, _tmp$9, accept, b1, b2, b3, mask, n, p, p0, r, size, sz, x, x$1;
r = 0;
size = 0;
n = p.$length;
if (n < 1) {
_tmp = 65533;
_tmp$1 = 0;
r = _tmp;
size = _tmp$1;
return [r, size];
}
p0 = (0 >= p.$length ? ($throwRuntimeError("index out of range"), undefined) : p.$array[p.$offset + 0]);
x = ((p0 < 0 || p0 >= first.length) ? ($throwRuntimeError("index out of range"), undefined) : first[p0]);
if (x >= 240) {
mask = (((x >> 0)) << 31 >> 0) >> 31 >> 0;
_tmp$2 = (((((0 >= p.$length ? ($throwRuntimeError("index out of range"), undefined) : p.$array[p.$offset + 0]) >> 0)) & ~mask) >> 0) | (65533 & mask);
_tmp$3 = 1;
r = _tmp$2;
size = _tmp$3;
return [r, size];
}
sz = (x & 7) >>> 0;
accept = $clone((x$1 = x >>> 4 << 24 >>> 24, ((x$1 < 0 || x$1 >= acceptRanges.length) ? ($throwRuntimeError("index out of range"), undefined) : acceptRanges[x$1])), acceptRange);
if (n < ((sz >> 0))) {
_tmp$4 = 65533;
_tmp$5 = 1;
r = _tmp$4;
size = _tmp$5;
return [r, size];
}
b1 = (1 >= p.$length ? ($throwRuntimeError("index out of range"), undefined) : p.$array[p.$offset + 1]);
if (b1 < accept.lo || accept.hi < b1) {
_tmp$6 = 65533;
_tmp$7 = 1;
r = _tmp$6;
size = _tmp$7;
return [r, size];
}
if (sz === 2) {
_tmp$8 = (((((p0 & 31) >>> 0) >> 0)) << 6 >> 0) | ((((b1 & 63) >>> 0) >> 0));
_tmp$9 = 2;
r = _tmp$8;
size = _tmp$9;
return [r, size];
}
b2 = (2 >= p.$length ? ($throwRuntimeError("index out of range"), undefined) : p.$array[p.$offset + 2]);
if (b2 < 128 || 191 < b2) {
_tmp$10 = 65533;
_tmp$11 = 1;
r = _tmp$10;
size = _tmp$11;
return [r, size];
}
if (sz === 3) {
_tmp$12 = ((((((p0 & 15) >>> 0) >> 0)) << 12 >> 0) | (((((b1 & 63) >>> 0) >> 0)) << 6 >> 0)) | ((((b2 & 63) >>> 0) >> 0));
_tmp$13 = 3;
r = _tmp$12;
size = _tmp$13;
return [r, size];
}
b3 = (3 >= p.$length ? ($throwRuntimeError("index out of range"), undefined) : p.$array[p.$offset + 3]);
if (b3 < 128 || 191 < b3) {
_tmp$14 = 65533;
_tmp$15 = 1;
r = _tmp$14;
size = _tmp$15;
return [r, size];
}
_tmp$16 = (((((((p0 & 7) >>> 0) >> 0)) << 18 >> 0) | (((((b1 & 63) >>> 0) >> 0)) << 12 >> 0)) | (((((b2 & 63) >>> 0) >> 0)) << 6 >> 0)) | ((((b3 & 63) >>> 0) >> 0));
_tmp$17 = 4;
r = _tmp$16;
size = _tmp$17;
return [r, size];
};
$pkg.DecodeRune = DecodeRune;
DecodeRuneInString = function(s) {
var _tmp, _tmp$1, _tmp$10, _tmp$11, _tmp$12, _tmp$13, _tmp$14, _tmp$15, _tmp$16, _tmp$17, _tmp$2, _tmp$3, _tmp$4, _tmp$5, _tmp$6, _tmp$7, _tmp$8, _tmp$9, accept, mask, n, r, s, s0, s1, s2, s3, size, sz, x, x$1;
r = 0;
size = 0;
n = s.length;
if (n < 1) {
_tmp = 65533;
_tmp$1 = 0;
r = _tmp;
size = _tmp$1;
return [r, size];
}
s0 = s.charCodeAt(0);
x = ((s0 < 0 || s0 >= first.length) ? ($throwRuntimeError("index out of range"), undefined) : first[s0]);
if (x >= 240) {
mask = (((x >> 0)) << 31 >> 0) >> 31 >> 0;
_tmp$2 = ((((s.charCodeAt(0) >> 0)) & ~mask) >> 0) | (65533 & mask);
_tmp$3 = 1;
r = _tmp$2;
size = _tmp$3;
return [r, size];
}
sz = (x & 7) >>> 0;
accept = $clone((x$1 = x >>> 4 << 24 >>> 24, ((x$1 < 0 || x$1 >= acceptRanges.length) ? ($throwRuntimeError("index out of range"), undefined) : acceptRanges[x$1])), acceptRange);
if (n < ((sz >> 0))) {
_tmp$4 = 65533;
_tmp$5 = 1;
r = _tmp$4;
size = _tmp$5;
return [r, size];
}
s1 = s.charCodeAt(1);
if (s1 < accept.lo || accept.hi < s1) {
_tmp$6 = 65533;
_tmp$7 = 1;
r = _tmp$6;
size = _tmp$7;
return [r, size];
}
if (sz === 2) {
_tmp$8 = (((((s0 & 31) >>> 0) >> 0)) << 6 >> 0) | ((((s1 & 63) >>> 0) >> 0));
_tmp$9 = 2;
r = _tmp$8;
size = _tmp$9;
return [r, size];
}
s2 = s.charCodeAt(2);
if (s2 < 128 || 191 < s2) {
_tmp$10 = 65533;
_tmp$11 = 1;
r = _tmp$10;
size = _tmp$11;
return [r, size];
}
if (sz === 3) {
_tmp$12 = ((((((s0 & 15) >>> 0) >> 0)) << 12 >> 0) | (((((s1 & 63) >>> 0) >> 0)) << 6 >> 0)) | ((((s2 & 63) >>> 0) >> 0));
_tmp$13 = 3;
r = _tmp$12;
size = _tmp$13;
return [r, size];
}
s3 = s.charCodeAt(3);
if (s3 < 128 || 191 < s3) {
_tmp$14 = 65533;
_tmp$15 = 1;
r = _tmp$14;
size = _tmp$15;
return [r, size];
}
_tmp$16 = (((((((s0 & 7) >>> 0) >> 0)) << 18 >> 0) | (((((s1 & 63) >>> 0) >> 0)) << 12 >> 0)) | (((((s2 & 63) >>> 0) >> 0)) << 6 >> 0)) | ((((s3 & 63) >>> 0) >> 0));
_tmp$17 = 4;
r = _tmp$16;
size = _tmp$17;
return [r, size];
};
$pkg.DecodeRuneInString = DecodeRuneInString;
DecodeLastRuneInString = function(s) {
var _tmp, _tmp$1, _tmp$2, _tmp$3, _tmp$4, _tmp$5, _tmp$6, _tmp$7, _tuple, end, lim, r, s, size, start;
r = 0;
size = 0;
end = s.length;
if (end === 0) {
_tmp = 65533;
_tmp$1 = 0;
r = _tmp;
size = _tmp$1;
return [r, size];
}
start = end - 1 >> 0;
r = ((s.charCodeAt(start) >> 0));
if (r < 128) {
_tmp$2 = r;
_tmp$3 = 1;
r = _tmp$2;
size = _tmp$3;
return [r, size];
}
lim = end - 4 >> 0;
if (lim < 0) {
lim = 0;
}
start = start - (1) >> 0;
while (true) {
if (!(start >= lim)) { break; }
if (RuneStart(s.charCodeAt(start))) {
break;
}
start = start - (1) >> 0;
}
if (start < 0) {
start = 0;
}
_tuple = DecodeRuneInString($substring(s, start, end));
r = _tuple[0];
size = _tuple[1];
if (!(((start + size >> 0) === end))) {
_tmp$4 = 65533;
_tmp$5 = 1;
r = _tmp$4;
size = _tmp$5;
return [r, size];
}
_tmp$6 = r;
_tmp$7 = size;
r = _tmp$6;
size = _tmp$7;
return [r, size];
};
$pkg.DecodeLastRuneInString = DecodeLastRuneInString;
RuneLen = function(r) {
var r;
if (r < 0) {
return -1;
} else if (r <= 127) {
return 1;
} else if (r <= 2047) {
return 2;
} else if (55296 <= r && r <= 57343) {
return -1;
} else if (r <= 65535) {
return 3;
} else if (r <= 1114111) {
return 4;
}
return -1;
};
$pkg.RuneLen = RuneLen;
EncodeRune = function(p, r) {
var i, p, r;
i = ((r >>> 0));
if (i <= 127) {
(0 >= p.$length ? ($throwRuntimeError("index out of range"), undefined) : p.$array[p.$offset + 0] = ((r << 24 >>> 24)));
return 1;
} else if (i <= 2047) {
$unused((1 >= p.$length ? ($throwRuntimeError("index out of range"), undefined) : p.$array[p.$offset + 1]));
(0 >= p.$length ? ($throwRuntimeError("index out of range"), undefined) : p.$array[p.$offset + 0] = ((192 | (((r >> 6 >> 0) << 24 >>> 24))) >>> 0));
(1 >= p.$length ? ($throwRuntimeError("index out of range"), undefined) : p.$array[p.$offset + 1] = ((128 | ((((r << 24 >>> 24)) & 63) >>> 0)) >>> 0));
return 2;
} else if ((i > 1114111) || (55296 <= i && i <= 57343)) {
r = 65533;
$unused((2 >= p.$length ? ($throwRuntimeError("index out of range"), undefined) : p.$array[p.$offset + 2]));
(0 >= p.$length ? ($throwRuntimeError("index out of range"), undefined) : p.$array[p.$offset + 0] = ((224 | (((r >> 12 >> 0) << 24 >>> 24))) >>> 0));
(1 >= p.$length ? ($throwRuntimeError("index out of range"), undefined) : p.$array[p.$offset + 1] = ((128 | (((((r >> 6 >> 0) << 24 >>> 24)) & 63) >>> 0)) >>> 0));
(2 >= p.$length ? ($throwRuntimeError("index out of range"), undefined) : p.$array[p.$offset + 2] = ((128 | ((((r << 24 >>> 24)) & 63) >>> 0)) >>> 0));
return 3;
} else if (i <= 65535) {
$unused((2 >= p.$length ? ($throwRuntimeError("index out of range"), undefined) : p.$array[p.$offset + 2]));
(0 >= p.$length ? ($throwRuntimeError("index out of range"), undefined) : p.$array[p.$offset + 0] = ((224 | (((r >> 12 >> 0) << 24 >>> 24))) >>> 0));
(1 >= p.$length ? ($throwRuntimeError("index out of range"), undefined) : p.$array[p.$offset + 1] = ((128 | (((((r >> 6 >> 0) << 24 >>> 24)) & 63) >>> 0)) >>> 0));
(2 >= p.$length ? ($throwRuntimeError("index out of range"), undefined) : p.$array[p.$offset + 2] = ((128 | ((((r << 24 >>> 24)) & 63) >>> 0)) >>> 0));
return 3;
} else {
$unused((3 >= p.$length ? ($throwRuntimeError("index out of range"), undefined) : p.$array[p.$offset + 3]));
(0 >= p.$length ? ($throwRuntimeError("index out of range"), undefined) : p.$array[p.$offset + 0] = ((240 | (((r >> 18 >> 0) << 24 >>> 24))) >>> 0));
(1 >= p.$length ? ($throwRuntimeError("index out of range"), undefined) : p.$array[p.$offset + 1] = ((128 | (((((r >> 12 >> 0) << 24 >>> 24)) & 63) >>> 0)) >>> 0));
(2 >= p.$length ? ($throwRuntimeError("index out of range"), undefined) : p.$array[p.$offset + 2] = ((128 | (((((r >> 6 >> 0) << 24 >>> 24)) & 63) >>> 0)) >>> 0));
(3 >= p.$length ? ($throwRuntimeError("index out of range"), undefined) : p.$array[p.$offset + 3] = ((128 | ((((r << 24 >>> 24)) & 63) >>> 0)) >>> 0));
return 4;
}
};
$pkg.EncodeRune = EncodeRune;
RuneCount = function(p) {
var accept, c, c$1, c$2, c$3, i, n, np, p, size, x, x$1, x$2, x$3, x$4;
np = p.$length;
n = 0;
i = 0;
while (true) {
if (!(i < np)) { break; }
n = n + (1) >> 0;
c = ((i < 0 || i >= p.$length) ? ($throwRuntimeError("index out of range"), undefined) : p.$array[p.$offset + i]);
if (c < 128) {
i = i + (1) >> 0;
continue;
}
x = ((c < 0 || c >= first.length) ? ($throwRuntimeError("index out of range"), undefined) : first[c]);
if (x === 241) {
i = i + (1) >> 0;
continue;
}
size = ((((x & 7) >>> 0) >> 0));
if ((i + size >> 0) > np) {
i = i + (1) >> 0;
continue;
}
accept = $clone((x$1 = x >>> 4 << 24 >>> 24, ((x$1 < 0 || x$1 >= acceptRanges.length) ? ($throwRuntimeError("index out of range"), undefined) : acceptRanges[x$1])), acceptRange);
c$1 = (x$2 = i + 1 >> 0, ((x$2 < 0 || x$2 >= p.$length) ? ($throwRuntimeError("index out of range"), undefined) : p.$array[p.$offset + x$2]));
if (c$1 < accept.lo || accept.hi < c$1) {
size = 1;
} else if (size === 2) {
} else {
c$2 = (x$3 = i + 2 >> 0, ((x$3 < 0 || x$3 >= p.$length) ? ($throwRuntimeError("index out of range"), undefined) : p.$array[p.$offset + x$3]));
if (c$2 < 128 || 191 < c$2) {
size = 1;
} else if (size === 3) {
} else {
c$3 = (x$4 = i + 3 >> 0, ((x$4 < 0 || x$4 >= p.$length) ? ($throwRuntimeError("index out of range"), undefined) : p.$array[p.$offset + x$4]));
if (c$3 < 128 || 191 < c$3) {
size = 1;
}
}
}
i = i + (size) >> 0;
}
return n;
};
$pkg.RuneCount = RuneCount;
RuneCountInString = function(s) {
var accept, c, c$1, c$2, c$3, i, n, ns, s, size, x, x$1;
n = 0;
ns = s.length;
i = 0;
while (true) {
if (!(i < ns)) { break; }
c = s.charCodeAt(i);
if (c < 128) {
i = i + (1) >> 0;
n = n + (1) >> 0;
continue;
}
x = ((c < 0 || c >= first.length) ? ($throwRuntimeError("index out of range"), undefined) : first[c]);
if (x === 241) {
i = i + (1) >> 0;
n = n + (1) >> 0;
continue;
}
size = ((((x & 7) >>> 0) >> 0));
if ((i + size >> 0) > ns) {
i = i + (1) >> 0;
n = n + (1) >> 0;
continue;
}
accept = $clone((x$1 = x >>> 4 << 24 >>> 24, ((x$1 < 0 || x$1 >= acceptRanges.length) ? ($throwRuntimeError("index out of range"), undefined) : acceptRanges[x$1])), acceptRange);
c$1 = s.charCodeAt((i + 1 >> 0));
if (c$1 < accept.lo || accept.hi < c$1) {
size = 1;
} else if (size === 2) {
} else {
c$2 = s.charCodeAt((i + 2 >> 0));
if (c$2 < 128 || 191 < c$2) {
size = 1;
} else if (size === 3) {
} else {
c$3 = s.charCodeAt((i + 3 >> 0));
if (c$3 < 128 || 191 < c$3) {
size = 1;
}
}
}
i = i + (size) >> 0;
n = n + (1) >> 0;
}
n = n;
return n;
};
$pkg.RuneCountInString = RuneCountInString;
RuneStart = function(b) {
var b;
return !((((b & 192) >>> 0) === 128));
};
$pkg.RuneStart = RuneStart;
ValidString = function(s) {
var accept, c, c$1, c$2, i, n, s, si, size, x, x$1;
n = s.length;
i = 0;
while (true) {
if (!(i < n)) { break; }
si = s.charCodeAt(i);
if (si < 128) {
i = i + (1) >> 0;
continue;
}
x = ((si < 0 || si >= first.length) ? ($throwRuntimeError("index out of range"), undefined) : first[si]);
if (x === 241) {
return false;
}
size = ((((x & 7) >>> 0) >> 0));
if ((i + size >> 0) > n) {
return false;
}
accept = $clone((x$1 = x >>> 4 << 24 >>> 24, ((x$1 < 0 || x$1 >= acceptRanges.length) ? ($throwRuntimeError("index out of range"), undefined) : acceptRanges[x$1])), acceptRange);
c = s.charCodeAt((i + 1 >> 0));
if (c < accept.lo || accept.hi < c) {
return false;
} else if (size === 2) {
} else {
c$1 = s.charCodeAt((i + 2 >> 0));
if (c$1 < 128 || 191 < c$1) {
return false;
} else if (size === 3) {
} else {
c$2 = s.charCodeAt((i + 3 >> 0));
if (c$2 < 128 || 191 < c$2) {
return false;
}
}
}
i = i + (size) >> 0;
}
return true;
};
$pkg.ValidString = ValidString;
ValidRune = function(r) {
var r;
if (0 <= r && r < 55296) {
return true;
} else if (57343 < r && r <= 1114111) {
return true;
}
return false;
};
$pkg.ValidRune = ValidRune;
acceptRange.init("unicode/utf8", [{prop: "lo", name: "lo", embedded: false, exported: false, typ: $Uint8, tag: ""}, {prop: "hi", name: "hi", embedded: false, exported: false, typ: $Uint8, tag: ""}]);
$init = function() {
$pkg.$init = function() {};
/* */ var $f, $c = false, $s = 0, $r; if (this !== undefined && this.$blk !== undefined) { $f = this; $c = true; $s = $f.$s; $r = $f.$r; } s: while (true) { switch ($s) { case 0:
first = $toNativeArray($kindUint8, [240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 241, 241, 241, 241, 241, 241, 241, 241, 241, 241, 241, 241, 241, 241, 241, 241, 241, 241, 241, 241, 241, 241, 241, 241, 241, 241, 241, 241, 241, 241, 241, 241, 241, 241, 241, 241, 241, 241, 241, 241, 241, 241, 241, 241, 241, 241, 241, 241, 241, 241, 241, 241, 241, 241, 241, 241, 241, 241, 241, 241, 241, 241, 241, 241, 241, 241, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 19, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 35, 3, 3, 52, 4, 4, 4, 68, 241, 241, 241, 241, 241, 241, 241, 241, 241, 241, 241]);
acceptRanges = $toNativeArray($kindStruct, [new acceptRange.ptr(128, 191), new acceptRange.ptr(160, 191), new acceptRange.ptr(128, 159), new acceptRange.ptr(144, 191), new acceptRange.ptr(128, 143)]);
/* */ } return; } if ($f === undefined) { $f = { $blk: $init }; } $f.$s = $s; $f.$r = $r; return $f;
};
$pkg.$init = $init;
return $pkg;
})();
$packages["bytes"] = (function() {
var $pkg = {}, $init, errors, bytealg, io, unicode, utf8, Buffer, readOp, ptrType, sliceType, arrayType, errNegativeRead, IndexByte, makeSlice;
errors = $packages["errors"];
bytealg = $packages["internal/bytealg"];
io = $packages["io"];
unicode = $packages["unicode"];
utf8 = $packages["unicode/utf8"];
Buffer = $pkg.Buffer = $newType(0, $kindStruct, "bytes.Buffer", true, "bytes", true, function(buf_, off_, bootstrap_, lastRead_) {
this.$val = this;
if (arguments.length === 0) {
this.buf = sliceType.nil;
this.off = 0;
this.bootstrap = arrayType.zero();
this.lastRead = 0;
return;
}
this.buf = buf_;
this.off = off_;
this.bootstrap = bootstrap_;
this.lastRead = lastRead_;
});
readOp = $pkg.readOp = $newType(1, $kindInt8, "bytes.readOp", true, "bytes", false, null);
ptrType = $ptrType(Buffer);
sliceType = $sliceType($Uint8);
arrayType = $arrayType($Uint8, 64);
IndexByte = function(s, c) {
var _i, _ref, b, c, i, s;
_ref = s;
_i = 0;
while (true) {
if (!(_i < _ref.$length)) { break; }
i = _i;
b = ((_i < 0 || _i >= _ref.$length) ? ($throwRuntimeError("index out of range"), undefined) : _ref.$array[_ref.$offset + _i]);
if (b === c) {
return i;
}
_i++;
}
return -1;
};
$pkg.IndexByte = IndexByte;
Buffer.ptr.prototype.Bytes = function() {
var b;
b = this;
return $subslice(b.buf, b.off);
};
Buffer.prototype.Bytes = function() { return this.$val.Bytes(); };
Buffer.ptr.prototype.String = function() {
var b;
b = this;
if (b === ptrType.nil) {
return "<nil>";
}
return ($bytesToString($subslice(b.buf, b.off)));
};
Buffer.prototype.String = function() { return this.$val.String(); };
Buffer.ptr.prototype.empty = function() {
var b;
b = this;
return b.buf.$length <= b.off;
};
Buffer.prototype.empty = function() { return this.$val.empty(); };
Buffer.ptr.prototype.Len = function() {
var b;
b = this;
return b.buf.$length - b.off >> 0;
};
Buffer.prototype.Len = function() { return this.$val.Len(); };
Buffer.ptr.prototype.Cap = function() {
var b;
b = this;
return b.buf.$capacity;
};
Buffer.prototype.Cap = function() { return this.$val.Cap(); };
Buffer.ptr.prototype.Truncate = function(n) {
var b, n;
b = this;
if (n === 0) {
b.Reset();
return;
}
b.lastRead = 0;
if (n < 0 || n > b.Len()) {
$panic(new $String("bytes.Buffer: truncation out of range"));
}
b.buf = $subslice(b.buf, 0, (b.off + n >> 0));
};
Buffer.prototype.Truncate = function(n) { return this.$val.Truncate(n); };
Buffer.ptr.prototype.Reset = function() {
var b;
b = this;
b.buf = $subslice(b.buf, 0, 0);
b.off = 0;
b.lastRead = 0;
};
Buffer.prototype.Reset = function() { return this.$val.Reset(); };
Buffer.ptr.prototype.tryGrowByReslice = function(n) {
var b, l, n;
b = this;
l = b.buf.$length;
if (n <= (b.buf.$capacity - l >> 0)) {
b.buf = $subslice(b.buf, 0, (l + n >> 0));
return [l, true];
}
return [0, false];
};
Buffer.prototype.tryGrowByReslice = function(n) { return this.$val.tryGrowByReslice(n); };
Buffer.ptr.prototype.grow = function(n) {
var _q, _tuple, b, buf, c, i, m, n, ok;
b = this;
m = b.Len();
if ((m === 0) && !((b.off === 0))) {
b.Reset();
}
_tuple = b.tryGrowByReslice(n);
i = _tuple[0];
ok = _tuple[1];
if (ok) {
return i;
}
if (b.buf === sliceType.nil && n <= 64) {
b.buf = $subslice(new sliceType(b.bootstrap), 0, n);
return 0;
}
c = b.buf.$capacity;
if (n <= ((_q = c / 2, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero")) - m >> 0)) {
$copySlice(b.buf, $subslice(b.buf, b.off));
} else if (c > ((2147483647 - c >> 0) - n >> 0)) {
$panic($pkg.ErrTooLarge);
} else {
buf = makeSlice(($imul(2, c)) + n >> 0);
$copySlice(buf, $subslice(b.buf, b.off));
b.buf = buf;
}
b.off = 0;
b.buf = $subslice(b.buf, 0, (m + n >> 0));
return m;
};
Buffer.prototype.grow = function(n) { return this.$val.grow(n); };
Buffer.ptr.prototype.Grow = function(n) {
var b, m, n;
b = this;
if (n < 0) {
$panic(new $String("bytes.Buffer.Grow: negative count"));
}
m = b.grow(n);
b.buf = $subslice(b.buf, 0, m);
};
Buffer.prototype.Grow = function(n) { return this.$val.Grow(n); };
Buffer.ptr.prototype.Write = function(p) {
var _tmp, _tmp$1, _tuple, b, err, m, n, ok, p;
n = 0;
err = $ifaceNil;
b = this;
b.lastRead = 0;
_tuple = b.tryGrowByReslice(p.$length);
m = _tuple[0];
ok = _tuple[1];
if (!ok) {
m = b.grow(p.$length);
}
_tmp = $copySlice($subslice(b.buf, m), p);
_tmp$1 = $ifaceNil;
n = _tmp;
err = _tmp$1;
return [n, err];
};
Buffer.prototype.Write = function(p) { return this.$val.Write(p); };
Buffer.ptr.prototype.WriteString = function(s) {
var _tmp, _tmp$1, _tuple, b, err, m, n, ok, s;
n = 0;
err = $ifaceNil;
b = this;
b.lastRead = 0;
_tuple = b.tryGrowByReslice(s.length);
m = _tuple[0];
ok = _tuple[1];
if (!ok) {
m = b.grow(s.length);
}
_tmp = $copyString($subslice(b.buf, m), s);
_tmp$1 = $ifaceNil;
n = _tmp;
err = _tmp$1;
return [n, err];
};
Buffer.prototype.WriteString = function(s) { return this.$val.WriteString(s); };
Buffer.ptr.prototype.ReadFrom = function(r) {
var _r, _tmp, _tmp$1, _tmp$2, _tmp$3, _tuple, b, e, err, i, m, n, r, x, $s, $r;
/* */ $s = 0; var $f, $c = false; if (this !== undefined && this.$blk !== undefined) { $f = this; $c = true; _r = $f._r; _tmp = $f._tmp; _tmp$1 = $f._tmp$1; _tmp$2 = $f._tmp$2; _tmp$3 = $f._tmp$3; _tuple = $f._tuple; b = $f.b; e = $f.e; err = $f.err; i = $f.i; m = $f.m; n = $f.n; r = $f.r; x = $f.x; $s = $f.$s; $r = $f.$r; } s: while (true) { switch ($s) { case 0:
n = new $Int64(0, 0);
err = $ifaceNil;
b = this;
b.lastRead = 0;
/* while (true) { */ case 1:
i = b.grow(512);
b.buf = $subslice(b.buf, 0, i);
_r = r.Read($subslice(b.buf, i, b.buf.$capacity)); /* */ $s = 3; case 3: if($c) { $c = false; _r = _r.$blk(); } if (_r && _r.$blk !== undefined) { break s; }
_tuple = _r;
m = _tuple[0];
e = _tuple[1];
if (m < 0) {
$panic(errNegativeRead);
}
b.buf = $subslice(b.buf, 0, (i + m >> 0));
n = (x = (new $Int64(0, m)), new $Int64(n.$high + x.$high, n.$low + x.$low));
if ($interfaceIsEqual(e, io.EOF)) {
_tmp = n;
_tmp$1 = $ifaceNil;
n = _tmp;
err = _tmp$1;
$s = -1; return [n, err];
}
if (!($interfaceIsEqual(e, $ifaceNil))) {
_tmp$2 = n;
_tmp$3 = e;
n = _tmp$2;
err = _tmp$3;
$s = -1; return [n, err];
}
/* } */ $s = 1; continue; case 2:
$s = -1; return [n, err];
/* */ } return; } if ($f === undefined) { $f = { $blk: Buffer.ptr.prototype.ReadFrom }; } $f._r = _r; $f._tmp = _tmp; $f._tmp$1 = _tmp$1; $f._tmp$2 = _tmp$2; $f._tmp$3 = _tmp$3; $f._tuple = _tuple; $f.b = b; $f.e = e; $f.err = err; $f.i = i; $f.m = m; $f.n = n; $f.r = r; $f.x = x; $f.$s = $s; $f.$r = $r; return $f;
};
Buffer.prototype.ReadFrom = function(r) { return this.$val.ReadFrom(r); };
makeSlice = function(n) {
var n, $deferred;
/* */ var $err = null; try { $deferred = []; $deferred.index = $curGoroutine.deferStack.length; $curGoroutine.deferStack.push($deferred);
$deferred.push([(function() {
if (!($interfaceIsEqual($recover(), $ifaceNil))) {
$panic($pkg.ErrTooLarge);
}
}), []]);
return $makeSlice(sliceType, n);
/* */ } catch(err) { $err = err; return sliceType.nil; } finally { $callDeferred($deferred, $err); }
};
Buffer.ptr.prototype.WriteTo = function(w) {
var _r, _tmp, _tmp$1, _tmp$2, _tmp$3, _tmp$4, _tmp$5, _tuple, b, e, err, m, n, nBytes, w, $s, $r;
/* */ $s = 0; var $f, $c = false; if (this !== undefined && this.$blk !== undefined) { $f = this; $c = true; _r = $f._r; _tmp = $f._tmp; _tmp$1 = $f._tmp$1; _tmp$2 = $f._tmp$2; _tmp$3 = $f._tmp$3; _tmp$4 = $f._tmp$4; _tmp$5 = $f._tmp$5; _tuple = $f._tuple; b = $f.b; e = $f.e; err = $f.err; m = $f.m; n = $f.n; nBytes = $f.nBytes; w = $f.w; $s = $f.$s; $r = $f.$r; } s: while (true) { switch ($s) { case 0:
n = new $Int64(0, 0);
err = $ifaceNil;
b = this;
b.lastRead = 0;
nBytes = b.Len();
/* */ if (nBytes > 0) { $s = 1; continue; }
/* */ $s = 2; continue;
/* if (nBytes > 0) { */ case 1:
_r = w.Write($subslice(b.buf, b.off)); /* */ $s = 3; case 3: if($c) { $c = false; _r = _r.$blk(); } if (_r && _r.$blk !== undefined) { break s; }
_tuple = _r;
m = _tuple[0];
e = _tuple[1];
if (m > nBytes) {
$panic(new $String("bytes.Buffer.WriteTo: invalid Write count"));
}
b.off = b.off + (m) >> 0;
n = (new $Int64(0, m));
if (!($interfaceIsEqual(e, $ifaceNil))) {
_tmp = n;
_tmp$1 = e;
n = _tmp;
err = _tmp$1;
$s = -1; return [n, err];
}
if (!((m === nBytes))) {
_tmp$2 = n;
_tmp$3 = io.ErrShortWrite;
n = _tmp$2;
err = _tmp$3;
$s = -1; return [n, err];
}
/* } */ case 2:
b.Reset();
_tmp$4 = n;
_tmp$5 = $ifaceNil;
n = _tmp$4;
err = _tmp$5;
$s = -1; return [n, err];
/* */ } return; } if ($f === undefined) { $f = { $blk: Buffer.ptr.prototype.WriteTo }; } $f._r = _r; $f._tmp = _tmp; $f._tmp$1 = _tmp$1; $f._tmp$2 = _tmp$2; $f._tmp$3 = _tmp$3; $f._tmp$4 = _tmp$4; $f._tmp$5 = _tmp$5; $f._tuple = _tuple; $f.b = b; $f.e = e; $f.err = err; $f.m = m; $f.n = n; $f.nBytes = nBytes; $f.w = w; $f.$s = $s; $f.$r = $r; return $f;
};
Buffer.prototype.WriteTo = function(w) { return this.$val.WriteTo(w); };
Buffer.ptr.prototype.WriteByte = function(c) {
var _tuple, b, c, m, ok, x;
b = this;
b.lastRead = 0;
_tuple = b.tryGrowByReslice(1);
m = _tuple[0];
ok = _tuple[1];
if (!ok) {
m = b.grow(1);
}
(x = b.buf, ((m < 0 || m >= x.$length) ? ($throwRuntimeError("index out of range"), undefined) : x.$array[x.$offset + m] = c));
return $ifaceNil;
};
Buffer.prototype.WriteByte = function(c) { return this.$val.WriteByte(c); };
Buffer.ptr.prototype.WriteRune = function(r) {
var _tmp, _tmp$1, _tmp$2, _tmp$3, _tuple, b, err, m, n, ok, r;
n = 0;
err = $ifaceNil;
b = this;
if (r < 128) {
b.WriteByte(((r << 24 >>> 24)));
_tmp = 1;
_tmp$1 = $ifaceNil;
n = _tmp;
err = _tmp$1;
return [n, err];
}
b.lastRead = 0;
_tuple = b.tryGrowByReslice(4);
m = _tuple[0];
ok = _tuple[1];
if (!ok) {
m = b.grow(4);
}
n = utf8.EncodeRune($subslice(b.buf, m, (m + 4 >> 0)), r);
b.buf = $subslice(b.buf, 0, (m + n >> 0));
_tmp$2 = n;
_tmp$3 = $ifaceNil;
n = _tmp$2;
err = _tmp$3;
return [n, err];
};
Buffer.prototype.WriteRune = function(r) { return this.$val.WriteRune(r); };
Buffer.ptr.prototype.Read = function(p) {
var _tmp, _tmp$1, _tmp$2, _tmp$3, _tmp$4, _tmp$5, b, err, n, p;
n = 0;
err = $ifaceNil;
b = this;
b.lastRead = 0;
if (b.empty()) {
b.Reset();
if (p.$length === 0) {
_tmp = 0;
_tmp$1 = $ifaceNil;
n = _tmp;
err = _tmp$1;
return [n, err];
}
_tmp$2 = 0;
_tmp$3 = io.EOF;
n = _tmp$2;
err = _tmp$3;
return [n, err];
}
n = $copySlice(p, $subslice(b.buf, b.off));
b.off = b.off + (n) >> 0;
if (n > 0) {
b.lastRead = -1;
}
_tmp$4 = n;
_tmp$5 = $ifaceNil;
n = _tmp$4;
err = _tmp$5;
return [n, err];
};
Buffer.prototype.Read = function(p) { return this.$val.Read(p); };
Buffer.ptr.prototype.Next = function(n) {
var b, data, m, n;
b = this;
b.lastRead = 0;
m = b.Len();
if (n > m) {
n = m;
}
data = $subslice(b.buf, b.off, (b.off + n >> 0));
b.off = b.off + (n) >> 0;
if (n > 0) {
b.lastRead = -1;
}
return data;
};
Buffer.prototype.Next = function(n) { return this.$val.Next(n); };
Buffer.ptr.prototype.ReadByte = function() {
var b, c, x, x$1;
b = this;
if (b.empty()) {
b.Reset();
return [0, io.EOF];
}
c = (x = b.buf, x$1 = b.off, ((x$1 < 0 || x$1 >= x.$length) ? ($throwRuntimeError("index out of range"), undefined) : x.$array[x.$offset + x$1]));
b.off = b.off + (1) >> 0;
b.lastRead = -1;
return [c, $ifaceNil];
};
Buffer.prototype.ReadByte = function() { return this.$val.ReadByte(); };
Buffer.ptr.prototype.ReadRune = function() {
var _tmp, _tmp$1, _tmp$2, _tmp$3, _tmp$4, _tmp$5, _tmp$6, _tmp$7, _tmp$8, _tuple, b, c, err, n, r, size, x, x$1;
r = 0;
size = 0;
err = $ifaceNil;
b = this;
if (b.empty()) {
b.Reset();
_tmp = 0;
_tmp$1 = 0;
_tmp$2 = io.EOF;
r = _tmp;
size = _tmp$1;
err = _tmp$2;
return [r, size, err];
}
c = (x = b.buf, x$1 = b.off, ((x$1 < 0 || x$1 >= x.$length) ? ($throwRuntimeError("index out of range"), undefined) : x.$array[x.$offset + x$1]));
if (c < 128) {
b.off = b.off + (1) >> 0;
b.lastRead = 1;
_tmp$3 = ((c >> 0));
_tmp$4 = 1;
_tmp$5 = $ifaceNil;
r = _tmp$3;
size = _tmp$4;
err = _tmp$5;
return [r, size, err];
}
_tuple = utf8.DecodeRune($subslice(b.buf, b.off));
r = _tuple[0];
n = _tuple[1];
b.off = b.off + (n) >> 0;
b.lastRead = ((n << 24 >> 24));
_tmp$6 = r;
_tmp$7 = n;
_tmp$8 = $ifaceNil;
r = _tmp$6;
size = _tmp$7;
err = _tmp$8;
return [r, size, err];
};
Buffer.prototype.ReadRune = function() { return this.$val.ReadRune(); };
Buffer.ptr.prototype.UnreadRune = function() {
var b;
b = this;
if (b.lastRead <= 0) {
return errors.New("bytes.Buffer: UnreadRune: previous operation was not a successful ReadRune");
}
if (b.off >= ((b.lastRead >> 0))) {
b.off = b.off - (((b.lastRead >> 0))) >> 0;
}
b.lastRead = 0;
return $ifaceNil;
};
Buffer.prototype.UnreadRune = function() { return this.$val.UnreadRune(); };
Buffer.ptr.prototype.UnreadByte = function() {
var b;
b = this;
if (b.lastRead === 0) {
return errors.New("bytes.Buffer: UnreadByte: previous operation was not a successful read");
}
b.lastRead = 0;
if (b.off > 0) {
b.off = b.off - (1) >> 0;
}
return $ifaceNil;
};
Buffer.prototype.UnreadByte = function() { return this.$val.UnreadByte(); };
Buffer.ptr.prototype.ReadBytes = function(delim) {
var _tmp, _tmp$1, _tuple, b, delim, err, line, slice;
line = sliceType.nil;
err = $ifaceNil;
b = this;
_tuple = b.readSlice(delim);
slice = _tuple[0];
err = _tuple[1];
line = $appendSlice(line, slice);
_tmp = line;
_tmp$1 = err;
line = _tmp;
err = _tmp$1;
return [line, err];
};
Buffer.prototype.ReadBytes = function(delim) { return this.$val.ReadBytes(delim); };
Buffer.ptr.prototype.readSlice = function(delim) {
var _tmp, _tmp$1, b, delim, end, err, i, line;
line = sliceType.nil;
err = $ifaceNil;
b = this;
i = IndexByte($subslice(b.buf, b.off), delim);
end = (b.off + i >> 0) + 1 >> 0;
if (i < 0) {
end = b.buf.$length;
err = io.EOF;
}
line = $subslice(b.buf, b.off, end);
b.off = end;
b.lastRead = -1;
_tmp = line;
_tmp$1 = err;
line = _tmp;
err = _tmp$1;
return [line, err];
};
Buffer.prototype.readSlice = function(delim) { return this.$val.readSlice(delim); };
Buffer.ptr.prototype.ReadString = function(delim) {
var _tmp, _tmp$1, _tuple, b, delim, err, line, slice;
line = "";
err = $ifaceNil;
b = this;
_tuple = b.readSlice(delim);
slice = _tuple[0];
err = _tuple[1];
_tmp = ($bytesToString(slice));
_tmp$1 = err;
line = _tmp;
err = _tmp$1;
return [line, err];
};
Buffer.prototype.ReadString = function(delim) { return this.$val.ReadString(delim); };
ptrType.methods = [{prop: "Bytes", name: "Bytes", pkg: "", typ: $funcType([], [sliceType], false)}, {prop: "String", name: "String", pkg: "", typ: $funcType([], [$String], false)}, {prop: "empty", name: "empty", pkg: "bytes", typ: $funcType([], [$Bool], false)}, {prop: "Len", name: "Len", pkg: "", typ: $funcType([], [$Int], false)}, {prop: "Cap", name: "Cap", pkg: "", typ: $funcType([], [$Int], false)}, {prop: "Truncate", name: "Truncate", pkg: "", typ: $funcType([$Int], [], false)}, {prop: "Reset", name: "Reset", pkg: "", typ: $funcType([], [], false)}, {prop: "tryGrowByReslice", name: "tryGrowByReslice", pkg: "bytes", typ: $funcType([$Int], [$Int, $Bool], false)}, {prop: "grow", name: "grow", pkg: "bytes", typ: $funcType([$Int], [$Int], false)}, {prop: "Grow", name: "Grow", pkg: "", typ: $funcType([$Int], [], false)}, {prop: "Write", name: "Write", pkg: "", typ: $funcType([sliceType], [$Int, $error], false)}, {prop: "WriteString", name: "WriteString", pkg: "", typ: $funcType([$String], [$Int, $error], false)}, {prop: "ReadFrom", name: "ReadFrom", pkg: "", typ: $funcType([io.Reader], [$Int64, $error], false)}, {prop: "WriteTo", name: "WriteTo", pkg: "", typ: $funcType([io.Writer], [$Int64, $error], false)}, {prop: "WriteByte", name: "WriteByte", pkg: "", typ: $funcType([$Uint8], [$error], false)}, {prop: "WriteRune", name: "WriteRune", pkg: "", typ: $funcType([$Int32]
gitextract_kyacih07/ ├── .gitignore ├── Makefile ├── README.md ├── dist/ │ └── glua.js ├── main.go ├── package.json └── try.html
SYMBOL INDEX (3 symbols across 1 files)
FILE: main.go
function main (line 8) | func main() {
function lvalueFromInterface (line 63) | func lvalueFromInterface(L *lua.LState, value interface{}) lua.LValue {
function lvalueToInterface (line 122) | func lvalueToInterface(lvalue lua.LValue) interface{} {
Condensed preview — 7 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (2,994K chars).
[
{
"path": ".gitignore",
"chars": 25,
"preview": "node_modules\n*.swo\n*.swp\n"
},
{
"path": "Makefile",
"chars": 156,
"preview": "all: dist/glua.js dist/glua.min.js\n\ndist/glua.js: main.go\n\tgopherjs build -o dist/glua.js\n\ndist/glua.min.js: main.go\n\tgo"
},
{
"path": "README.md",
"chars": 1588,
"preview": "## glua [](https://www.npmjs.com/package/glua)\n\n`glua` is what happen"
},
{
"path": "dist/glua.js",
"chars": 2801094,
"preview": "\"use strict\";\n(function() {\n\nError.stackTraceLimit = Infinity;\n\nvar $global, $module;\nif (typeof window !== \"undefined\")"
},
{
"path": "main.go",
"chars": 4025,
"preview": "package main\n\nimport (\n\tlua \"github.com/J-J-J/goluajit\"\n\t\"github.com/gopherjs/gopherjs/js\"\n)\n\nfunc main() {\n\trun := func"
},
{
"path": "package.json",
"chars": 466,
"preview": "{\n \"name\": \"glua\",\n \"version\": \"1.0.2\",\n \"description\": \"Full-featured Lua VM for nodejs and the browser. Based on gi"
},
{
"path": "try.html",
"chars": 695,
"preview": "<!doctype html>\n\n<title>glua playground</title>\n\n<center>open your console for all the action.</center>\n<center><a href="
}
]
About this extraction
This page contains the full source code of the fiatjaf/glua GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 7 files (2.7 MB), approximately 702.3k tokens, and a symbol index with 3 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.