M
Size: a a a
M
L
function asmjsModule() {
function asmjs(stdlib, env, heap) {
"use asm";
const i32array = new stdlib.Int32Array(heap)
function init(iNumBits) {
iNumBits = iNumBits|0
var iLen = 0, i = 0
iLen = ((iNumBits >> 5) + 1)|0
for(i = 0|0; (i|0) < (iLen|0); i = (i+1)|0)
i32array[i<<2>>2] = 0
}
function add(iStart, iEnd) {
iStart = iStart|0
iEnd = iEnd|0
var iLen = 0, iOffset = 0
iLen = (iEnd - iStart)|0
iOffset = iStart >> 5
if ( (iLen|0) <= 32 ) {
if ( ( (iStart & 31) + iLen|0 ) >= 32 ) {
i32array[ iOffset << 2 >> 2 ] = i32array[ iOffset << 2 >> 2 ] ^ ~((1 << (iStart & 31)) - 1)
i32array[ (iEnd >> 3) >> 2 ] = i32array[ (iEnd >> 3) >> 2 ] ^ ( (1 << ((iEnd & 31))) - 1 )
return
}
i32array[ iOffset << 2 >> 2 ] = i32array[ iOffset << 2 >> 2 ] ^ ( ((1 << iLen) - 1) << iStart )
return
}
i32array[ iOffset << 2 >> 2 ] = i32array[ iOffset << 2 >> 2 ] ^ ~((1 << (iStart & 31)) - 1)
iOffset = (iOffset + 1)|0
for(; (iOffset|0) < (iEnd >> 5); iOffset = (iOffset + 1)|0)
i32array[ iOffset << 2 >> 2 ] = i32array[ iOffset << 2 >> 2 ] ^ -1
i32array[ iOffset << 2 >> 2 ] = i32array[ iOffset << 2 >> 2 ] ^ ( (1 << ((iEnd & 31))) - 1 )
}
function get(iBits) {
iBits = iBits | 0
return ( i32array[ (iBits >> 3) >> 2 ] >> (iBits & 31) ) & 1
}
return { init: init, add: add, get: get }
}
const heap = new ArrayBuffer(1024*1024)
return asmjs( {
Uint8Array: Uint8Array,
Int8Array: Int8Array,
Uint16Array: Uint16Array,
Int16Array: Int16Array,
Uint32Array: Uint32Array,
Int32Array: Int32Array,
Float32Array:Float32Array,
Float64Array:Float64Array,
Math: Math
},
{},
heap
)
}
const module = asmjsModule()
const moduleSegments = asmjsModule()
const SEGMENT_BITS = 10
function binarySimulation(s, q) {
module.init(s.length)
moduleSegments.init((s.length >> SEGMENT_BITS) + 1)
const r = []
for(const v of q) {
switch(v[0]) {
case "I":
let [, start, end] = v
start--
const startSeg = (start >> SEGMENT_BITS) + 1
const endSeg = end >> SEGMENT_BITS
if ( startSeg <= endSeg ) {
moduleSegments.add(startSeg, endSeg)
module.add(start, startSeg << SEGMENT_BITS)
module.add(endSeg << SEGMENT_BITS, end)
break
}
module.add(start, end)
break
case "Q":
const i = v[1] - 1
r.push( '' + (
module.get(i) ^
moduleSegments.get(i >> SEGMENT_BITS) ^
s[i]
) )
break
}
}
return r
}
p
p
NR
M
L
4
function asmjsModule() {
function asmjs(stdlib, env, heap) {
"use asm";
const i32array = new stdlib.Int32Array(heap)
function init(iNumBits) {
iNumBits = iNumBits|0
var iLen = 0, i = 0
iLen = ((iNumBits >> 5) + 1)|0
for(i = 0|0; (i|0) < (iLen|0); i = (i+1)|0)
i32array[i<<2>>2] = 0
}
function add(iStart, iEnd) {
iStart = iStart|0
iEnd = iEnd|0
var iLen = 0, iOffset = 0
iLen = (iEnd - iStart)|0
iOffset = iStart >> 5
if ( (iLen|0) <= 32 ) {
if ( ( (iStart & 31) + iLen|0 ) >= 32 ) {
i32array[ iOffset << 2 >> 2 ] = i32array[ iOffset << 2 >> 2 ] ^ ~((1 << (iStart & 31)) - 1)
i32array[ (iEnd >> 3) >> 2 ] = i32array[ (iEnd >> 3) >> 2 ] ^ ( (1 << ((iEnd & 31))) - 1 )
return
}
i32array[ iOffset << 2 >> 2 ] = i32array[ iOffset << 2 >> 2 ] ^ ( ((1 << iLen) - 1) << iStart )
return
}
i32array[ iOffset << 2 >> 2 ] = i32array[ iOffset << 2 >> 2 ] ^ ~((1 << (iStart & 31)) - 1)
iOffset = (iOffset + 1)|0
for(; (iOffset|0) < (iEnd >> 5); iOffset = (iOffset + 1)|0)
i32array[ iOffset << 2 >> 2 ] = i32array[ iOffset << 2 >> 2 ] ^ -1
i32array[ iOffset << 2 >> 2 ] = i32array[ iOffset << 2 >> 2 ] ^ ( (1 << ((iEnd & 31))) - 1 )
}
function get(iBits) {
iBits = iBits | 0
return ( i32array[ (iBits >> 3) >> 2 ] >> (iBits & 31) ) & 1
}
return { init: init, add: add, get: get }
}
const heap = new ArrayBuffer(1024*1024)
return asmjs( {
Uint8Array: Uint8Array,
Int8Array: Int8Array,
Uint16Array: Uint16Array,
Int16Array: Int16Array,
Uint32Array: Uint32Array,
Int32Array: Int32Array,
Float32Array:Float32Array,
Float64Array:Float64Array,
Math: Math
},
{},
heap
)
}
const module = asmjsModule()
const moduleSegments = asmjsModule()
const SEGMENT_BITS = 10
function binarySimulation(s, q) {
module.init(s.length)
moduleSegments.init((s.length >> SEGMENT_BITS) + 1)
const r = []
for(const v of q) {
switch(v[0]) {
case "I":
let [, start, end] = v
start--
const startSeg = (start >> SEGMENT_BITS) + 1
const endSeg = end >> SEGMENT_BITS
if ( startSeg <= endSeg ) {
moduleSegments.add(startSeg, endSeg)
module.add(start, startSeg << SEGMENT_BITS)
module.add(endSeg << SEGMENT_BITS, end)
break
}
module.add(start, end)
break
case "Q":
const i = v[1] - 1
r.push( '' + (
module.get(i) ^
moduleSegments.get(i >> SEGMENT_BITS) ^
s[i]
) )
break
}
}
return r
}
B
B
B
M
L
L
L
В
p