/* * Minified version of SqueakJS VM (incl. CodeParadise adaptations and plugins) * SqueakJS VM: Copyright (c) 2013-2020 Vanessa Freudenberg * CodeParadise: https://github.com/ErikOnBike/CodeParadise */ "use strict";var require$$0$4=require("os"),require$$0$3=require("fs"),require$$2$1=require("process"),require$$1$1=require("path"),require$$0$2=require("events"),require$$1=require("https"),require$$2=require("http"),require$$3=require("net"),require$$4=require("tls"),require$$0$1=require("crypto"),require$$6=require("url"),require$$0=require("stream"),commonjsGlobal="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},node_app={},permessageDeflate,hasRequiredPermessageDeflate,constants,hasRequiredConstants;function requirePermessageDeflate(){return hasRequiredPermessageDeflate?permessageDeflate:(hasRequiredPermessageDeflate=1,permessageDeflate={extensionName:"PerMessageDeflate"})}function requireConstants(){return hasRequiredConstants?constants:(hasRequiredConstants=1,constants={BINARY_TYPES:["nodebuffer","arraybuffer","fragments"],GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),EMPTY_BUFFER:Buffer.alloc(0),NOOP:()=>{}})}var bufferUtil={exports:{}},hasRequiredBufferUtil;function requireBufferUtil(){if(hasRequiredBufferUtil)return bufferUtil.exports;hasRequiredBufferUtil=1;const{EMPTY_BUFFER}=requireConstants();function concat(list,totalLength){if(0===list.length)return EMPTY_BUFFER;if(1===list.length)return list[0];const target=Buffer.allocUnsafe(totalLength);let offset=0;for(let i=0;i!0}return validation.isValidStatusCode=code=>code>=1e3&&code<=1013&&1004!==code&&1005!==code&&1006!==code||code>=3e3&&code<=4999,validation}function requireReceiver(){if(hasRequiredReceiver)return receiver;hasRequiredReceiver=1;const{Writable}=require$$0,PerMessageDeflate=requirePermessageDeflate(),{BINARY_TYPES,EMPTY_BUFFER,kStatusCode,kWebSocket}=requireConstants(),{concat,toArrayBuffer,unmask}=requireBufferUtil(),{isValidStatusCode,isValidUTF8}=requireValidation();function error(ErrorCtor,message,prefix,statusCode){const err=new ErrorCtor(prefix?`Invalid WebSocket frame: ${message}`:message);return Error.captureStackTrace(err,error),err[kStatusCode]=statusCode,err}return receiver=class Receiver extends Writable{constructor(binaryType,extensions,maxPayload){super(),this._binaryType=binaryType||BINARY_TYPES[0],this[kWebSocket]=void 0,this._extensions=extensions||{},this._maxPayload=0|maxPayload,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._state=0,this._loop=!1}_write(chunk,encoding,cb){if(8===this._opcode&&0==this._state)return cb();this._bufferedBytes+=chunk.length,this._buffers.push(chunk),this.startLoop(cb)}consume(n){if(this._bufferedBytes-=n,n===this._buffers[0].length)return this._buffers.shift();if(n=buf.length?dst.set(this._buffers.shift(),offset):(dst.set(new Uint8Array(buf.buffer,buf.byteOffset,n),offset),this._buffers[0]=buf.slice(n)),n-=buf.length}while(n>0);return dst}startLoop(cb){let err;this._loop=!0;do{switch(this._state){case 0:err=this.getInfo();break;case 1:err=this.getPayloadLength16();break;case 2:err=this.getPayloadLength64();break;case 3:this.getMask();break;case 4:err=this.getData(cb);break;default:return void(this._loop=!1)}}while(this._loop);cb(err)}getInfo(){if(this._bufferedBytes<2)return void(this._loop=!1);const buf=this.consume(2);if(0!=(48&buf[0]))return this._loop=!1,error(RangeError,"RSV2 and RSV3 must be clear",!0,1002);const compressed=64==(64&buf[0]);if(compressed&&!this._extensions[PerMessageDeflate.extensionName])return this._loop=!1,error(RangeError,"RSV1 must be clear",!0,1002);if(this._fin=128==(128&buf[0]),this._opcode=15&buf[0],this._payloadLength=127&buf[1],0===this._opcode){if(compressed)return this._loop=!1,error(RangeError,"RSV1 must be clear",!0,1002);if(!this._fragmented)return this._loop=!1,error(RangeError,"invalid opcode 0",!0,1002);this._opcode=this._fragmented}else if(1===this._opcode||2===this._opcode){if(this._fragmented)return this._loop=!1,error(RangeError,`invalid opcode ${this._opcode}`,!0,1002);this._compressed=compressed}else{if(!(this._opcode>7&&this._opcode<11))return this._loop=!1,error(RangeError,`invalid opcode ${this._opcode}`,!0,1002);if(!this._fin)return this._loop=!1,error(RangeError,"FIN must be set",!0,1002);if(compressed)return this._loop=!1,error(RangeError,"RSV1 must be clear",!0,1002);if(this._payloadLength>125)return this._loop=!1,error(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002)}if(this._fin||this._fragmented||(this._fragmented=this._opcode),this._masked=128==(128&buf[1]),126===this._payloadLength)this._state=1;else{if(127!==this._payloadLength)return this.haveLength();this._state=2}}getPayloadLength16(){if(!(this._bufferedBytes<2))return this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength();this._loop=!1}getPayloadLength64(){if(this._bufferedBytes<8)return void(this._loop=!1);const buf=this.consume(8),num=buf.readUInt32BE(0);return num>Math.pow(2,21)-1?(this._loop=!1,error(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009)):(this._payloadLength=num*Math.pow(2,32)+buf.readUInt32BE(4),this.haveLength())}haveLength(){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0))return this._loop=!1,error(RangeError,"Max payload size exceeded",!1,1009);this._masked?this._state=3:this._state=4}getMask(){this._bufferedBytes<4?this._loop=!1:(this._mask=this.consume(4),this._state=4)}getData(cb){let data=EMPTY_BUFFER;if(this._payloadLength){if(this._bufferedBytes7?this.controlMessage(data):this._compressed?(this._state=5,void this.decompress(data,cb)):(data.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(data)),this.dataMessage())}decompress(data,cb){this._extensions[PerMessageDeflate.extensionName].decompress(data,this._fin,((err,buf)=>{if(err)return cb(err);if(buf.length){if(this._messageLength+=buf.length,this._messageLength>this._maxPayload&&this._maxPayload>0)return cb(error(RangeError,"Max payload size exceeded",!1,1009));this._fragments.push(buf)}const er=this.dataMessage();if(er)return cb(er);this.startLoop(cb)}))}dataMessage(){if(this._fin){const messageLength=this._messageLength,fragments=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],2===this._opcode){let data;data="nodebuffer"===this._binaryType?concat(fragments,messageLength):"arraybuffer"===this._binaryType?toArrayBuffer(concat(fragments,messageLength)):fragments,this.emit("message",data)}else{const buf=concat(fragments,messageLength);if(!isValidUTF8(buf))return this._loop=!1,error(Error,"invalid UTF-8 sequence",!0,1007);this.emit("message",buf.toString())}}this._state=0}controlMessage(data){if(8===this._opcode)if(this._loop=!1,0===data.length)this.emit("conclude",1005,""),this.end();else{if(1===data.length)return error(RangeError,"invalid payload length 1",!0,1002);{const code=data.readUInt16BE(0);if(!isValidStatusCode(code))return error(RangeError,`invalid status code ${code}`,!0,1002);const buf=data.slice(2);if(!isValidUTF8(buf))return error(Error,"invalid UTF-8 sequence",!0,1007);this.emit("conclude",code,buf.toString()),this.end()}}else 9===this._opcode?this.emit("ping",data):this.emit("pong",data);this._state=0}}}function requireSender(){if(hasRequiredSender)return sender;hasRequiredSender=1;const{randomFillSync}=require$$0$1,PerMessageDeflate=requirePermessageDeflate(),{EMPTY_BUFFER}=requireConstants(),{isValidStatusCode}=requireValidation(),{mask:applyMask,toBuffer}=requireBufferUtil(),mask=Buffer.alloc(4);class Sender{constructor(socket,extensions){this._extensions=extensions||{},this._socket=socket,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._deflating=!1,this._queue=[]}static frame(data,options){const merge=options.mask&&options.readOnly;let offset=options.mask?6:2,payloadLength=data.length;data.length>=65536?(offset+=8,payloadLength=127):data.length>125&&(offset+=2,payloadLength=126);const target=Buffer.allocUnsafe(merge?data.length+offset:offset);return target[0]=options.fin?128|options.opcode:options.opcode,options.rsv1&&(target[0]|=64),target[1]=payloadLength,126===payloadLength?target.writeUInt16BE(data.length,2):127===payloadLength&&(target.writeUInt32BE(0,2),target.writeUInt32BE(data.length,6)),options.mask?(randomFillSync(mask,0,4),target[1]|=128,target[offset-4]=mask[0],target[offset-3]=mask[1],target[offset-2]=mask[2],target[offset-1]=mask[3],merge?(applyMask(data,mask,target,offset,data.length),[target]):(applyMask(data,mask,data,0,data.length),[target,data])):[target,data]}close(code,data,mask,cb){let buf;if(void 0===code)buf=EMPTY_BUFFER;else{if("number"!=typeof code||!isValidStatusCode(code))throw new TypeError("First argument must be a valid error code number");void 0===data||""===data?(buf=Buffer.allocUnsafe(2),buf.writeUInt16BE(code,0)):(buf=Buffer.allocUnsafe(2+Buffer.byteLength(data)),buf.writeUInt16BE(code,0),buf.write(data,2))}this._deflating?this.enqueue([this.doClose,buf,mask,cb]):this.doClose(buf,mask,cb)}doClose(data,mask,cb){this.sendFrame(Sender.frame(data,{fin:!0,rsv1:!1,opcode:8,mask,readOnly:!1}),cb)}ping(data,mask,cb){const buf=toBuffer(data);this._deflating?this.enqueue([this.doPing,buf,mask,toBuffer.readOnly,cb]):this.doPing(buf,mask,toBuffer.readOnly,cb)}doPing(data,mask,readOnly,cb){this.sendFrame(Sender.frame(data,{fin:!0,rsv1:!1,opcode:9,mask,readOnly}),cb)}pong(data,mask,cb){const buf=toBuffer(data);this._deflating?this.enqueue([this.doPong,buf,mask,toBuffer.readOnly,cb]):this.doPong(buf,mask,toBuffer.readOnly,cb)}doPong(data,mask,readOnly,cb){this.sendFrame(Sender.frame(data,{fin:!0,rsv1:!1,opcode:10,mask,readOnly}),cb)}send(data,options,cb){const buf=toBuffer(data),perMessageDeflate=this._extensions[PerMessageDeflate.extensionName];let opcode=options.binary?2:1,rsv1=options.compress;if(this._firstFragment?(this._firstFragment=!1,rsv1&&perMessageDeflate&&(rsv1=buf.length>=perMessageDeflate._threshold),this._compress=rsv1):(rsv1=!1,opcode=0),options.fin&&(this._firstFragment=!0),perMessageDeflate){const opts={fin:options.fin,rsv1,opcode,mask:options.mask,readOnly:toBuffer.readOnly};this._deflating?this.enqueue([this.dispatch,buf,this._compress,opts,cb]):this.dispatch(buf,this._compress,opts,cb)}else this.sendFrame(Sender.frame(buf,{fin:options.fin,rsv1:!1,opcode,mask:options.mask,readOnly:toBuffer.readOnly}),cb)}dispatch(data,compress,options,cb){if(!compress)return void this.sendFrame(Sender.frame(data,options),cb);const perMessageDeflate=this._extensions[PerMessageDeflate.extensionName];this._deflating=!0,perMessageDeflate.compress(data,options.fin,((_,buf)=>{this._deflating=!1,options.readOnly=!1,this.sendFrame(Sender.frame(buf,options),cb),this.dequeue()}))}dequeue(){for(;!this._deflating&&this._queue.length;){const params=this._queue.shift();this._bufferedBytes-=params[1].length,Reflect.apply(params[0],this,params.slice(1))}}enqueue(params){this._bufferedBytes+=params[1].length,this._queue.push(params)}sendFrame(list,cb){2===list.length?(this._socket.cork(),this._socket.write(list[0]),this._socket.write(list[1],cb),this._socket.uncork()):this._socket.write(list[0],cb)}}return sender=Sender}function requireEventTarget(){if(hasRequiredEventTarget)return eventTarget;hasRequiredEventTarget=1;class Event{constructor(type,target){this.target=target,this.type=type}}class MessageEvent extends Event{constructor(data,target){super("message",target),this.data=data}}class CloseEvent extends Event{constructor(code,reason,target){super("close",target),this.wasClean=target._closeFrameReceived&&target._closeFrameSent,this.reason=reason,this.code=code}}class OpenEvent extends Event{constructor(target){super("open",target)}}class ErrorEvent extends Event{constructor(error,target){super("error",target),this.message=error.message,this.error=error}}return eventTarget={addEventListener(method,listener){function onMessage(data){listener.call(this,new MessageEvent(data,this))}function onClose(code,message){listener.call(this,new CloseEvent(code,message,this))}function onError(error){listener.call(this,new ErrorEvent(error,this))}function onOpen(){listener.call(this,new OpenEvent(this))}"function"==typeof listener&&("message"===method?(onMessage._listener=listener,this.on(method,onMessage)):"close"===method?(onClose._listener=listener,this.on(method,onClose)):"error"===method?(onError._listener=listener,this.on(method,onError)):"open"===method?(onOpen._listener=listener,this.on(method,onOpen)):this.on(method,listener))},removeEventListener(method,listener){const listeners=this.listeners(method);for(let i=0;i{let configurations=extensions[extension];return Array.isArray(configurations)||(configurations=[configurations]),configurations.map((params=>[extension].concat(Object.keys(params).map((k=>{let values=params[k];return Array.isArray(values)||(values=[values]),values.map((v=>!0===v?k:`${k}=${v}`)).join("; ")}))).join("; "))).join(", ")})).join(", ")},parse:function(header){const offers=Object.create(null);if(void 0===header||""===header)return offers;let extensionName,paramName,params=Object.create(null),mustUnescape=!1,isEscaping=!1,inQuotes=!1,start=-1,end=-1,i=0;for(;i0&&socket.unshift(head),socket.on("close",socketOnClose),socket.on("data",socketOnData),socket.on("end",socketOnEnd),socket.on("error",socketOnError),this.readyState=WebSocket.OPEN,this.emit("open")}emitClose(){this.readyState=WebSocket.CLOSED,this._socket?(this._extensions[PerMessageDeflate.extensionName]&&this._extensions[PerMessageDeflate.extensionName].cleanup(),this._receiver.removeAllListeners(),this.emit("close",this._closeCode,this._closeMessage)):this.emit("close",this._closeCode,this._closeMessage)}close(code,data){if(this.readyState!==WebSocket.CLOSED){if(this.readyState===WebSocket.CONNECTING){const msg="WebSocket was closed before the connection was established";return abortHandshake(this,this._req,msg)}this.readyState!==WebSocket.CLOSING?(this.readyState=WebSocket.CLOSING,this._sender.close(code,data,!this._isServer,(err=>{err||(this._closeFrameSent=!0,this._closeFrameReceived&&this._socket.end())})),this._closeTimer=setTimeout(this._socket.destroy.bind(this._socket),3e4)):this._closeFrameSent&&this._closeFrameReceived&&this._socket.end()}}ping(data,mask,cb){if(this.readyState===WebSocket.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");"function"==typeof data?(cb=data,data=mask=void 0):"function"==typeof mask&&(cb=mask,mask=void 0),"number"==typeof data&&(data=data.toString()),this.readyState===WebSocket.OPEN?(void 0===mask&&(mask=!this._isServer),this._sender.ping(data||EMPTY_BUFFER,mask,cb)):sendAfterClose(this,data,cb)}pong(data,mask,cb){if(this.readyState===WebSocket.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");"function"==typeof data?(cb=data,data=mask=void 0):"function"==typeof mask&&(cb=mask,mask=void 0),"number"==typeof data&&(data=data.toString()),this.readyState===WebSocket.OPEN?(void 0===mask&&(mask=!this._isServer),this._sender.pong(data||EMPTY_BUFFER,mask,cb)):sendAfterClose(this,data,cb)}send(data,options,cb){if(this.readyState===WebSocket.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if("function"==typeof options&&(cb=options,options={}),"number"==typeof data&&(data=data.toString()),this.readyState!==WebSocket.OPEN)return void sendAfterClose(this,data,cb);const opts={binary:"string"!=typeof data,mask:!this._isServer,compress:!0,fin:!0,...options};this._extensions[PerMessageDeflate.extensionName]||(opts.compress=!1),this._sender.send(data||EMPTY_BUFFER,opts,cb)}terminate(){if(this.readyState!==WebSocket.CLOSED){if(this.readyState===WebSocket.CONNECTING){const msg="WebSocket was closed before the connection was established";return abortHandshake(this,this._req,msg)}this._socket&&(this.readyState=WebSocket.CLOSING,this._socket.destroy())}}}function initAsClient(websocket,address,protocols,options){const opts={protocolVersion:protocolVersions[1],maxPayload:104857600,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...options,createConnection:void 0,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:void 0,auth:void 0,host:void 0,path:void 0,port:void 0};if(!protocolVersions.includes(opts.protocolVersion))throw new RangeError(`Unsupported protocol version: ${opts.protocolVersion} (supported versions: ${protocolVersions.join(", ")})`);let parsedUrl;address instanceof URL?(parsedUrl=address,websocket.url=address.href):(parsedUrl=new URL(address),websocket.url=address);const isUnixSocket="ws+unix:"===parsedUrl.protocol;if(!(parsedUrl.host||isUnixSocket&&parsedUrl.pathname))throw new Error(`Invalid URL: ${websocket.url}`);const isSecure="wss:"===parsedUrl.protocol||"https:"===parsedUrl.protocol,defaultPort=isSecure?443:80,key=randomBytes(16).toString("base64"),get=isSecure?https.get:http.get;let perMessageDeflate;if(opts.createConnection=isSecure?tlsConnect:netConnect,opts.defaultPort=opts.defaultPort||defaultPort,opts.port=parsedUrl.port||defaultPort,opts.host=parsedUrl.hostname.startsWith("[")?parsedUrl.hostname.slice(1,-1):parsedUrl.hostname,opts.headers={"Sec-WebSocket-Version":opts.protocolVersion,"Sec-WebSocket-Key":key,Connection:"Upgrade",Upgrade:"websocket",...opts.headers},opts.path=parsedUrl.pathname+parsedUrl.search,opts.timeout=opts.handshakeTimeout,opts.perMessageDeflate&&(perMessageDeflate=new PerMessageDeflate(!0!==opts.perMessageDeflate?opts.perMessageDeflate:{},!1,opts.maxPayload),opts.headers["Sec-WebSocket-Extensions"]=format({[PerMessageDeflate.extensionName]:perMessageDeflate.offer()})),protocols&&(opts.headers["Sec-WebSocket-Protocol"]=protocols),opts.origin&&(opts.protocolVersion<13?opts.headers["Sec-WebSocket-Origin"]=opts.origin:opts.headers.Origin=opts.origin),(parsedUrl.username||parsedUrl.password)&&(opts.auth=`${parsedUrl.username}:${parsedUrl.password}`),isUnixSocket){const parts=opts.path.split(":");opts.socketPath=parts[0],opts.path=parts[1]}let req=websocket._req=get(opts);opts.timeout&&req.on("timeout",(()=>{abortHandshake(websocket,req,"Opening handshake has timed out")})),req.on("error",(err=>{websocket._req.aborted||(req=websocket._req=null,websocket.readyState=WebSocket.CLOSING,websocket.emit("error",err),websocket.emitClose())})),req.on("response",(res=>{const location=res.headers.location,statusCode=res.statusCode;if(location&&opts.followRedirects&&statusCode>=300&&statusCode<400){if(++websocket._redirects>opts.maxRedirects)return void abortHandshake(websocket,req,"Maximum redirects exceeded");req.abort();const addr=new URL(location,address);initAsClient(websocket,addr,protocols,options)}else websocket.emit("unexpected-response",req,res)||abortHandshake(websocket,req,`Unexpected server response: ${res.statusCode}`)})),req.on("upgrade",((res,socket,head)=>{if(websocket.emit("upgrade",res),websocket.readyState!==WebSocket.CONNECTING)return;req=websocket._req=null;const digest=createHash("sha1").update(key+GUID).digest("base64");if(res.headers["sec-websocket-accept"]!==digest)return void abortHandshake(websocket,socket,"Invalid Sec-WebSocket-Accept header");const serverProt=res.headers["sec-websocket-protocol"],protList=(protocols||"").split(/, */);let protError;if(!protocols&&serverProt?protError="Server sent a subprotocol but none was requested":protocols&&!serverProt?protError="Server sent no subprotocol":serverProt&&!protList.includes(serverProt)&&(protError="Server sent an invalid subprotocol"),protError)abortHandshake(websocket,socket,protError);else{if(serverProt&&(websocket.protocol=serverProt),perMessageDeflate)try{const extensions=parse(res.headers["sec-websocket-extensions"]);extensions[PerMessageDeflate.extensionName]&&(perMessageDeflate.accept(extensions[PerMessageDeflate.extensionName]),websocket._extensions[PerMessageDeflate.extensionName]=perMessageDeflate)}catch(err){return void abortHandshake(websocket,socket,"Invalid Sec-WebSocket-Extensions header")}websocket.setSocket(socket,head,opts.maxPayload)}}))}function netConnect(options){return options.path=options.socketPath,net.connect(options)}function tlsConnect(options){return options.path=void 0,options.servername||""===options.servername||(options.servername=options.host),tls.connect(options)}function abortHandshake(websocket,stream,message){websocket.readyState=WebSocket.CLOSING;const err=new Error(message);Error.captureStackTrace(err,abortHandshake),stream.setHeader?(stream.abort(),stream.once("abort",websocket.emitClose.bind(websocket)),websocket.emit("error",err)):(stream.destroy(err),stream.once("error",websocket.emit.bind(websocket,"error")),stream.once("close",websocket.emitClose.bind(websocket)))}function sendAfterClose(websocket,data,cb){if(data){const length=toBuffer(data).length;websocket._socket?websocket._sender._bufferedBytes+=length:websocket._bufferedAmount+=length}if(cb){cb(new Error(`WebSocket is not open: readyState ${websocket.readyState} (${readyStates[websocket.readyState]})`))}}function receiverOnConclude(code,reason){const websocket=this[kWebSocket];websocket._socket.removeListener("data",socketOnData),websocket._socket.resume(),websocket._closeFrameReceived=!0,websocket._closeMessage=reason,websocket._closeCode=code,1005===code?websocket.close():websocket.close(code,reason)}function receiverOnDrain(){this[kWebSocket]._socket.resume()}function receiverOnError(err){const websocket=this[kWebSocket];websocket._socket.removeListener("data",socketOnData),websocket.readyState=WebSocket.CLOSING,websocket._closeCode=err[kStatusCode],websocket.emit("error",err),websocket._socket.destroy()}function receiverOnFinish(){this[kWebSocket].emitClose()}function receiverOnMessage(data){this[kWebSocket].emit("message",data)}function receiverOnPing(data){const websocket=this[kWebSocket];websocket.pong(data,!websocket._isServer,NOOP),websocket.emit("ping",data)}function receiverOnPong(data){this[kWebSocket].emit("pong",data)}function socketOnClose(){const websocket=this[kWebSocket];this.removeListener("close",socketOnClose),this.removeListener("end",socketOnEnd),websocket.readyState=WebSocket.CLOSING,websocket._socket.read(),websocket._receiver.end(),this.removeListener("data",socketOnData),this[kWebSocket]=void 0,clearTimeout(websocket._closeTimer),websocket._receiver._writableState.finished||websocket._receiver._writableState.errorEmitted?websocket.emitClose():(websocket._receiver.on("error",receiverOnFinish),websocket._receiver.on("finish",receiverOnFinish))}function socketOnData(chunk){this[kWebSocket]._receiver.write(chunk)||this.pause()}function socketOnEnd(){const websocket=this[kWebSocket];websocket.readyState=WebSocket.CLOSING,websocket._receiver.end(),this.end()}function socketOnError(){const websocket=this[kWebSocket];this.removeListener("error",socketOnError),this.on("error",NOOP),websocket&&(websocket.readyState=WebSocket.CLOSING,this.destroy())}return readyStates.forEach(((readyState,i)=>{WebSocket[readyState]=i})),["open","error","close","message"].forEach((method=>{Object.defineProperty(WebSocket.prototype,`on${method}`,{get(){const listeners=this.listeners(method);for(let i=0;i>2]|=message[index]<>2]|=code<>2]|=(192|code>>6)<>2]|=(128|63&code)<=57344?(blocks[i>>2]|=(224|code>>12)<>2]|=(128|code>>6&63)<>2]|=(128|63&code)<>2]|=(240|code>>18)<>2]|=(128|code>>12&63)<>2]|=(128|code>>6&63)<>2]|=(128|63&code)<=64?(this.block=blocks[16],this.start=i-64,this.hash(),this.hashed=!0):this.start=i}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this}},Sha1.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var blocks=this.blocks,i=this.lastByteIndex;blocks[16]=this.block,blocks[i>>2]|=EXTRA[3&i],this.block=blocks[16],i>=56&&(this.hashed||this.hash(),blocks[0]=this.block,blocks[16]=blocks[1]=blocks[2]=blocks[3]=blocks[4]=blocks[5]=blocks[6]=blocks[7]=blocks[8]=blocks[9]=blocks[10]=blocks[11]=blocks[12]=blocks[13]=blocks[14]=blocks[15]=0),blocks[14]=this.hBytes<<3|this.bytes>>>29,blocks[15]=this.bytes<<3,this.hash()}},Sha1.prototype.hash=function(){var j,t,a=this.h0,b=this.h1,c=this.h2,d=this.h3,e=this.h4,blocks=this.blocks;for(j=16;j<80;++j)t=blocks[j-3]^blocks[j-8]^blocks[j-14]^blocks[j-16],blocks[j]=t<<1|t>>>31;for(j=0;j<20;j+=5)a=(t=(b=(t=(c=(t=(d=(t=(e=(t=a<<5|a>>>27)+(b&c|~b&d)+e+1518500249+blocks[j]<<0)<<5|e>>>27)+(a&(b=b<<30|b>>>2)|~a&c)+d+1518500249+blocks[j+1]<<0)<<5|d>>>27)+(e&(a=a<<30|a>>>2)|~e&b)+c+1518500249+blocks[j+2]<<0)<<5|c>>>27)+(d&(e=e<<30|e>>>2)|~d&a)+b+1518500249+blocks[j+3]<<0)<<5|b>>>27)+(c&(d=d<<30|d>>>2)|~c&e)+a+1518500249+blocks[j+4]<<0,c=c<<30|c>>>2;for(;j<40;j+=5)a=(t=(b=(t=(c=(t=(d=(t=(e=(t=a<<5|a>>>27)+(b^c^d)+e+1859775393+blocks[j]<<0)<<5|e>>>27)+(a^(b=b<<30|b>>>2)^c)+d+1859775393+blocks[j+1]<<0)<<5|d>>>27)+(e^(a=a<<30|a>>>2)^b)+c+1859775393+blocks[j+2]<<0)<<5|c>>>27)+(d^(e=e<<30|e>>>2)^a)+b+1859775393+blocks[j+3]<<0)<<5|b>>>27)+(c^(d=d<<30|d>>>2)^e)+a+1859775393+blocks[j+4]<<0,c=c<<30|c>>>2;for(;j<60;j+=5)a=(t=(b=(t=(c=(t=(d=(t=(e=(t=a<<5|a>>>27)+(b&c|b&d|c&d)+e-1894007588+blocks[j]<<0)<<5|e>>>27)+(a&(b=b<<30|b>>>2)|a&c|b&c)+d-1894007588+blocks[j+1]<<0)<<5|d>>>27)+(e&(a=a<<30|a>>>2)|e&b|a&b)+c-1894007588+blocks[j+2]<<0)<<5|c>>>27)+(d&(e=e<<30|e>>>2)|d&a|e&a)+b-1894007588+blocks[j+3]<<0)<<5|b>>>27)+(c&(d=d<<30|d>>>2)|c&e|d&e)+a-1894007588+blocks[j+4]<<0,c=c<<30|c>>>2;for(;j<80;j+=5)a=(t=(b=(t=(c=(t=(d=(t=(e=(t=a<<5|a>>>27)+(b^c^d)+e-899497514+blocks[j]<<0)<<5|e>>>27)+(a^(b=b<<30|b>>>2)^c)+d-899497514+blocks[j+1]<<0)<<5|d>>>27)+(e^(a=a<<30|a>>>2)^b)+c-899497514+blocks[j+2]<<0)<<5|c>>>27)+(d^(e=e<<30|e>>>2)^a)+b-899497514+blocks[j+3]<<0)<<5|b>>>27)+(c^(d=d<<30|d>>>2)^e)+a-899497514+blocks[j+4]<<0,c=c<<30|c>>>2;this.h0=this.h0+a<<0,this.h1=this.h1+b<<0,this.h2=this.h2+c<<0,this.h3=this.h3+d<<0,this.h4=this.h4+e<<0},Sha1.prototype.hex=function(){this.finalize();var h0=this.h0,h1=this.h1,h2=this.h2,h3=this.h3,h4=this.h4;return HEX_CHARS[h0>>28&15]+HEX_CHARS[h0>>24&15]+HEX_CHARS[h0>>20&15]+HEX_CHARS[h0>>16&15]+HEX_CHARS[h0>>12&15]+HEX_CHARS[h0>>8&15]+HEX_CHARS[h0>>4&15]+HEX_CHARS[15&h0]+HEX_CHARS[h1>>28&15]+HEX_CHARS[h1>>24&15]+HEX_CHARS[h1>>20&15]+HEX_CHARS[h1>>16&15]+HEX_CHARS[h1>>12&15]+HEX_CHARS[h1>>8&15]+HEX_CHARS[h1>>4&15]+HEX_CHARS[15&h1]+HEX_CHARS[h2>>28&15]+HEX_CHARS[h2>>24&15]+HEX_CHARS[h2>>20&15]+HEX_CHARS[h2>>16&15]+HEX_CHARS[h2>>12&15]+HEX_CHARS[h2>>8&15]+HEX_CHARS[h2>>4&15]+HEX_CHARS[15&h2]+HEX_CHARS[h3>>28&15]+HEX_CHARS[h3>>24&15]+HEX_CHARS[h3>>20&15]+HEX_CHARS[h3>>16&15]+HEX_CHARS[h3>>12&15]+HEX_CHARS[h3>>8&15]+HEX_CHARS[h3>>4&15]+HEX_CHARS[15&h3]+HEX_CHARS[h4>>28&15]+HEX_CHARS[h4>>24&15]+HEX_CHARS[h4>>20&15]+HEX_CHARS[h4>>16&15]+HEX_CHARS[h4>>12&15]+HEX_CHARS[h4>>8&15]+HEX_CHARS[h4>>4&15]+HEX_CHARS[15&h4]},Sha1.prototype.toString=Sha1.prototype.hex,Sha1.prototype.digest=function(){this.finalize();var h0=this.h0,h1=this.h1,h2=this.h2,h3=this.h3,h4=this.h4;return[h0>>24&255,h0>>16&255,h0>>8&255,255&h0,h1>>24&255,h1>>16&255,h1>>8&255,255&h1,h2>>24&255,h2>>16&255,h2>>8&255,255&h2,h3>>24&255,h3>>16&255,h3>>8&255,255&h3,h4>>24&255,h4>>16&255,h4>>8&255,255&h4]},Sha1.prototype.array=Sha1.prototype.digest,Sha1.prototype.arrayBuffer=function(){this.finalize();var buffer=new ArrayBuffer(20),dataView=new DataView(buffer);return dataView.setUint32(0,this.h0),dataView.setUint32(4,this.h1),dataView.setUint32(8,this.h2),dataView.setUint32(12,this.h3),dataView.setUint32(16,this.h4),buffer};var exports=createMethod();COMMON_JS?module.exports=exports:root.sha1=exports})()}(sha1)),sha1.exports}var globals={},hasRequiredGlobals;function requireGlobals(){if(hasRequiredGlobals)return globals;if(hasRequiredGlobals=1,self.Squeak||(self.Squeak={}),!Squeak.Settings){var settings;try{if((settings=self.localStorage)["squeak-foo:"]="bar","bar"!==settings["squeak-foo:"])throw Error();delete settings["squeak-foo:"]}catch(e){settings={}}Squeak.Settings=settings}return Object.extend||(Object.extend=function(obj){for(var i=1;i4292870144?4294967296*(hi>>0)+lo:[hi,lo]}})),vm}var vm_object={},hasRequiredVm_object;function requireVm_object(){return hasRequiredVm_object||(hasRequiredVm_object=1,Object.subclass("Squeak.Object","initialization",{initInstanceOf:function(aClass,indexableSize,hash,nilObj){this.sqClass=aClass,this.hash=hash;var instSpec=aClass.pointers[Squeak.Class_format],instSize=(instSpec>>1&63)+(instSpec>>10&192)-1;this._format=instSpec>>7&15,this._format<8?6!=this._format?instSize+indexableSize>0&&(this.pointers=this.fillArray(instSize+indexableSize,nilObj)):indexableSize>0&&(aClass.isFloatClass?(this.isFloat=!0,this.float=0):this.words=new Uint32Array(indexableSize)):indexableSize>0&&(this.bytes=new Uint8Array(indexableSize))},initAsClone:function(original,hash){this.sqClass=original.sqClass,this.hash=hash,this._format=original._format,original.isFloat?(this.isFloat=original.isFloat,this.float=original.float):(original.pointers&&(this.pointers=original.pointers.slice(0)),original.words&&(this.words=new Uint32Array(original.words)),original.bytes&&(this.bytes=new Uint8Array(original.bytes)))},initFromImage:function(oop,cls,fmt,hsh){this.oop=oop,this.sqClass=cls,this._format=fmt,this.hash=hsh},classNameFromImage:function(oopMap,rawBits){var name=oopMap[rawBits[this.oop][Squeak.Class_name]];if(name&&name._format>=8&&name._format<12){var bits=rawBits[name.oop],bytes=name.decodeBytes(bits.length,bits,0,3&name._format);return Squeak.bytesAsString(bytes)}return"Class"},renameFromImage:function(oopMap,rawBits,ccArray){var classObj=this.sqClass<32?oopMap[ccArray[this.sqClass-1]]:oopMap[this.sqClass];if(!classObj)return this;var instProto=classObj.instProto||classObj.classInstProto(classObj.classNameFromImage(oopMap,rawBits));if(!instProto)return this;var renamedObj=new instProto;return renamedObj.oop=this.oop,renamedObj.sqClass=this.sqClass,renamedObj._format=this._format,renamedObj.hash=this.hash,renamedObj},installFromImage:function(oopMap,rawBits,ccArray,floatClass,littleEndian,nativeFloats){var ccInt=this.sqClass;this.sqClass=ccInt>0&&ccInt<32?oopMap[ccArray[ccInt-1]]:oopMap[ccInt];var bits=rawBits[this.oop],nWords=bits.length;if(this._format<5){if(nWords>0){var oops=bits;this.pointers=this.decodePointers(nWords,oops,oopMap)}}else if(this._format>=12){var numLits=this.decodeWords(1,bits,littleEndian)[0]>>10&255;oops=this.decodeWords(numLits+1,bits,littleEndian);this.pointers=this.decodePointers(numLits+1,oops,oopMap),this.bytes=this.decodeBytes(nWords-(numLits+1),bits,numLits+1,3&this._format)}else this._format>=8?nWords>0&&(this.bytes=this.decodeBytes(nWords,bits,0,3&this._format)):this.sqClass==floatClass?(this.isFloat=!0,this.float=this.decodeFloat(bits,littleEndian,nativeFloats)):nWords>0&&(this.words=this.decodeWords(nWords,bits,littleEndian));this.mark=!1},decodePointers:function(nWords,theBits,oopMap){for(var ptrs=new Array(nWords),i=0;i>1:oopMap[oop]||42424242}return ptrs},decodeWords:function(nWords,theBits,littleEndian){for(var data=new DataView(theBits.buffer,theBits.byteOffset),words=new Uint32Array(nWords),i=0;i=8&&fmt<=11},isWordsOrBytes:function(){var fmt=this._format;return 6==fmt||fmt>=8&&fmt<=11},isPointers:function(){return this._format<=4},isWeak:function(){return 4===this._format},isMethod:function(){return this._format>=12},sameFormats:function(a,b){return a<8?a===b:(12&a)==(12&b)},sameFormatAs:function(obj){return this.sameFormats(this._format,obj._format)}},"printing",{toString:function(){return this.sqInstName()},bytesAsString:function(){return this.bytes?Squeak.bytesAsString(this.bytes):""},bytesAsNumberString:function(negative){if(!this.bytes)return"";for(var hex="0123456789ABCDEF",digits=[],value=0,i=this.bytes.length-1;i>=0;i--)digits.push(hex[this.bytes[i]>>4]),digits.push(hex[15&this.bytes[i]]),value=256*value+this.bytes[i];var sign=negative?"-":"",approx=value>9007199254740991?"≈":"";return sign+"16r"+digits.join("")+" ("+approx+sign+value+"L)"},assnKeyAsString:function(){return this.pointers[Squeak.Assn_key].bytesAsString()},slotNameAt:function(index){var instSize=this.instSize();return index<=instSize?this.sqClass.allInstVarNames()[index-1]||"ivar"+(index-1):(index-instSize).toString()},sqInstName:function(){if(this.isNil)return"nil";if(this.isTrue)return"true";if(this.isFalse)return"false";if(this.isFloat){var str=this.float.toString();return/\./.test(str)||(str+=".0"),str}var className=this.sqClass.className();if(/ /.test(className))return"the "+className;switch(className){case"String":case"ByteString":return"'"+this.bytesAsString()+"'";case"Symbol":case"ByteSymbol":return"#"+this.bytesAsString();case"Point":return this.pointers.join("@");case"Rectangle":return this.pointers.join(" corner: ");case"Association":case"ReadOnlyVariableBinding":return this.pointers.join("->");case"LargePositiveInteger":return this.bytesAsNumberString(!1);case"LargeNegativeInteger":return this.bytesAsNumberString(!0);case"Character":var unicode=this.pointers?this.pointers[0]:this.hash;return"$"+String.fromCharCode(unicode)+" ("+unicode.toString()+")";case"CompiledMethod":return this.methodAsString();case"CompiledBlock":return"[] in "+this.blockOuterCode().sqInstName()}return/^[aeiou]/i.test(className)?"an"+className:"a"+className}},"accessing",{pointersSize:function(){return this.pointers?this.pointers.length:0},bytesSize:function(){return this.bytes?this.bytes.length:0},wordsSize:function(){return this.isFloat?2:this.words?this.words.length:0},instSize:function(){var fmt=this._format;return fmt>4||2===fmt?0:fmt<2?this.pointersSize():this.sqClass.classInstSize()},indexableSize:function(primHandler){var fmt=this._format;return fmt<2?-1:3===fmt&&primHandler.vm.isContext(this)&&!primHandler.allowAccessBeyondSP?this.pointers[Squeak.Context_stackPointer]:fmt<6?this.pointersSize()-this.instSize():fmt<8?this.wordsSize():fmt<12?this.bytesSize():this.bytesSize()+4*this.pointersSize()},floatData:function(){var buffer=new ArrayBuffer(8),data=new DataView(buffer);return data.setFloat64(0,this.float,!1),data},wordsAsFloat32Array:function(){return this.float32Array||this.words&&(this.float32Array=new Float32Array(this.words.buffer))},wordsAsFloat64Array:function(){return this.float64Array||this.words&&(this.float64Array=new Float64Array(this.words.buffer))},wordsAsInt32Array:function(){return this.int32Array||this.words&&(this.int32Array=new Int32Array(this.words.buffer))},wordsAsInt16Array:function(){return this.int16Array||this.words&&(this.int16Array=new Int16Array(this.words.buffer))},wordsAsUint16Array:function(){return this.uint16Array||this.words&&(this.uint16Array=new Uint16Array(this.words.buffer))},wordsAsUint8Array:function(){return this.uint8Array||this.words&&(this.uint8Array=new Uint8Array(this.words.buffer))},wordsOrBytes:function(){return this.words?this.words:this.uint32Array?this.uint32Array:this.bytes?this.uint32Array=new Uint32Array(this.bytes.buffer,0,this.bytes.length>>>2):null},setAddr:function(addr){var words=this.snapshotSize();return this.oop=addr+4*words.header,addr+4*(words.header+words.body)},snapshotSize:function(){var nWords=this.isFloat?2:this.words?this.words.length:this.pointers?this.pointers.length:0;return this.bytes&&(nWords+=this.bytes.length+3>>>2),{header:++nWords>63?2:this.sqClass.isCompact?0:1,body:nWords}},addr:function(){return this.oop-4*this.snapshotSize().header},totalBytes:function(){var words=this.snapshotSize();return 4*(words.header+words.body)},writeTo:function(data,pos,image){this.bytes&&(this._format|=3&-this.bytes.length);var beforePos=pos,size=this.snapshotSize(),formatAndHash=(15&this._format)<<8|(4095&this.hash)<<17;switch(size.header){case 2:data.setUint32(pos,size.body<<2|Squeak.HeaderTypeSizeAndClass),pos+=4,data.setUint32(pos,this.sqClass.oop|Squeak.HeaderTypeSizeAndClass),pos+=4,data.setUint32(pos,formatAndHash|Squeak.HeaderTypeSizeAndClass),pos+=4;break;case 1:data.setUint32(pos,this.sqClass.oop|Squeak.HeaderTypeClass),pos+=4,data.setUint32(pos,formatAndHash|size.body<<2|Squeak.HeaderTypeClass),pos+=4;break;case 0:var classIndex=image.compactClasses.indexOf(this.sqClass)+1;data.setUint32(pos,formatAndHash|classIndex<<12|size.body<<2|Squeak.HeaderTypeShort),pos+=4}if(this.isFloat)data.setFloat64(pos,this.float),pos+=8;else if(this.words)for(var i=0;i>7&15},classInstSize:function(){var spec=this.pointers[Squeak.Class_format];return(spec>>10&192)+(spec>>1&63)-1},classInstIsBytes:function(){var fmt=this.classInstFormat();return fmt>=8&&fmt<=11},classInstIsPointers:function(){return this.classInstFormat()<=4},instVarNames:function(){for(var index=3;index<=4;index++){var varNames=this.pointers[index].pointers;if(varNames&&varNames.length&&varNames[0].bytes)return varNames.map((function(each){return each.bytesAsString()}))}return[]},allInstVarNames:function(){var superclass=this.superclass();return superclass.isNil?this.instVarNames():superclass.allInstVarNames().concat(this.instVarNames())},superclass:function(){return this.pointers[0]},className:function(){if(!this.pointers)return"_NOTACLASS_";for(var nameIdx=6;nameIdx<=7;nameIdx++){if((name=this.pointers[nameIdx])&&name.bytes)return name.bytesAsString()}for(var clsIndex=3;clsIndex<=6;clsIndex++){var cls=this.pointers[clsIndex];if(cls&&cls.pointers)for(nameIdx=6;nameIdx<=7;nameIdx++){var name;if((name=cls.pointers[nameIdx])&&name.bytes)return name.bytesAsString()+" class"}}return"_SOMECLASS_"},defaultInst:function(){return Squeak.Object},classInstProto:function(className){if(this.instProto)return this.instProto;var proto=this.defaultInst();try{className||(className=this.className());var safeName=className.replace(/[^A-Za-z0-9]/g,"_");safeName="UndefinedObject"===safeName?"nil":"True"===safeName?"true_":"False"===safeName?"false_":(/^[AEIOU]/.test(safeName)?"an":"a")+safeName,(proto=new Function("return function "+safeName+"() {};")()).prototype=this.defaultInst().prototype}catch(e){}return Object.defineProperty(this,"instProto",{value:proto}),proto}},"as method",{methodSignFlag:function(){return!1},methodNumLits:function(){return this.pointers[0]>>9&255},methodNumArgs:function(){return this.pointers[0]>>24&15},methodPrimitiveIndex:function(){var primBits=805306879&this.pointers[0];return primBits>511?(511&primBits)+(primBits>>19):primBits},methodClassForSuper:function(){return this.pointers[this.methodNumLits()].pointers[Squeak.Assn_value]},methodNeedsLargeFrame:function(){return(131072&this.pointers[0])>0},methodAddPointers:function(headerAndLits){this.pointers=headerAndLits},methodTempCount:function(){return this.pointers[0]>>18&63},methodGetLiteral:function(zeroBasedIndex){return this.pointers[1+zeroBasedIndex]},methodGetSelector:function(zeroBasedIndex){return this.pointers[1+zeroBasedIndex]},methodAsString:function(){return"aCompiledMethod"}},"as context",{contextHome:function(){return this.contextIsBlock()?this.pointers[Squeak.BlockContext_home]:this},contextIsBlock:function(){return"number"==typeof this.pointers[Squeak.BlockContext_argumentCount]},contextMethod:function(){return this.contextHome().pointers[Squeak.Context_method]},contextSender:function(){return this.pointers[Squeak.Context_sender]},contextSizeWithStack:function(vm){if(vm&&vm.activeContext===this)return vm.sp+1;var sp=this.pointers[Squeak.Context_stackPointer];return Squeak.Context_tempFrameStart+("number"==typeof sp?sp:0)}})),vm_object}var vm_object_spur={},hasRequiredVm_object_spur;function requireVm_object_spur(){return hasRequiredVm_object_spur||(hasRequiredVm_object_spur=1,Squeak.Object.subclass("Squeak.ObjectSpur","initialization",{initInstanceOf:function(aClass,indexableSize,hash,nilObj){this.sqClass=aClass,this.hash=hash;var instSpec=aClass.pointers[Squeak.Class_format],instSize=65535&instSpec,format=instSpec>>16&31;this._format=format,format<12?format<10?instSize+indexableSize>0&&(this.pointers=this.fillArray(instSize+indexableSize,nilObj)):indexableSize>0&&(aClass.isFloatClass?(this.isFloat=!0,this.float=0):this.words=new Uint32Array(indexableSize)):indexableSize>0&&(this.bytes=new Uint8Array(indexableSize))},installFromImage:function(oopMap,rawBits,classTable,floatClass,littleEndian,getCharacter,is64Bit){var classID=this.sqClass;if(classID<32)throw Error("Invalid class ID: "+classID);if(this.sqClass=classTable[classID],!this.sqClass)throw Error("Class ID not in class table: "+classID);var bits=rawBits[this.oop],nWords=bits.length;switch(this._format){case 0:case 1:case 2:case 3:case 4:case 5:if(nWords>0){var oops=bits;this.pointers=this.decodePointers(nWords,oops,oopMap,getCharacter,is64Bit)}break;case 11:nWords--,this._format=10;case 10:this.sqClass===floatClass?(this.isFloat=!0,this.float=this.decodeFloat(bits,littleEndian,!0)):nWords>0&&(this.words=this.decodeWords(nWords,bits,littleEndian));break;case 12:case 13:throw Error("16 bit arrays not supported yet");case 20:case 21:case 22:case 23:nWords--,this._format-=4;case 16:case 17:case 18:case 19:nWords>0&&(this.bytes=this.decodeBytes(nWords,bits,0,3&this._format));break;case 28:case 29:case 30:case 31:nWords--,this._format-=4;case 24:case 25:case 26:case 27:var intHeader=this.decodeWords(1,bits,littleEndian)[0]>>(is64Bit?3:1),numLits=32767&intHeader,ptrWords=(oops=is64Bit?this.decodeWords64(numLits+1,bits,littleEndian):this.decodeWords(numLits+1,bits,littleEndian),is64Bit?2*(numLits+1):numLits+1);this.pointers=this.decodePointers(numLits+1,oops,oopMap,getCharacter,is64Bit),this.bytes=this.decodeBytes(nWords-ptrWords,bits,ptrWords,3&this._format),is64Bit&&(this.pointers[0]=2147483648&bits[1]|intHeader);break;default:throw Error("Unknown object format: "+this._format)}this.mark=!1},decodeWords64:function(nWords,theBits,littleEndian){for(var words=new Array(nWords),i=0;i=0?oop<=8589934591:oop>=-8589934592)?oop/4>>1:is64Bit.makeLargeFromSmall((oop-(oop>>>0))/4294967296>>>0,oop>>>0):oop>>1;else if(2==(3&oop)){if(oop<0||oop>8589934591)throw Error("Large Immediate Characters not implemented yet");ptrs[i]=getCharacter(oop>>>(is64Bit?3:2))}else if(is64Bit&&4==(7&oop))ptrs[i]=this.decodeSmallFloat((oop-(oop>>>0))/4294967296>>>0,oop>>>0,is64Bit);else if(ptrs[i]=oopMap[oop]||42424242,42424242===ptrs[i])debugger}return ptrs},decodeSmallFloat:function(hi,lo,is64Bit){var newHi=0,newLo=0,sign=(8&lo)<<28;return 0==(hi|4294967280&lo)?newHi=sign:(newHi=939524096+(hi>>>4)|sign,newLo=lo>>>4|(15&hi)<<28),is64Bit.makeFloat(new Uint32Array([newLo,newHi]))},overhead64:function(bits){var overhead=0,words32=0,words64=0;if(this._format<=5)overhead=-2&bits.length;else if(this._format>=24){var oddOops=1==(1&(overhead=(bits[0]>>3&32767)+1)),oddBytes=this._format>=28;oddOops&&(overhead+=oddBytes?1:-1),words64=bits.length/2,words32=bits.length-overhead}else words64=(words32=bits.length)/2;return{bytes:4*overhead,sizeHeader:words32>=255&&words64<255}},initInstanceOfChar:function(charClass,unicode){this.oop=unicode<<2|2,this.sqClass=charClass,this.hash=unicode,this._format=7,this.mark=!0},initInstanceOfFloat:function(floatClass,bits){this.sqClass=floatClass,this.hash=0,this._format=10,this.isFloat=!0,this.float=this.decodeFloat(bits,!0,!0)},initInstanceOfLargeInt:function(largeIntClass,size){this.sqClass=largeIntClass,this.hash=0,this._format=16,this.bytes=new Uint8Array(size)},classNameFromImage:function(oopMap,rawBits){var name=oopMap[rawBits[this.oop][Squeak.Class_name]];if(name&&name._format>=16&&name._format<24){var bits=rawBits[name.oop],bytes=name.decodeBytes(bits.length,bits,0,7&name._format);return Squeak.bytesAsString(bytes)}return"Class"},renameFromImage:function(oopMap,rawBits,classTable){var classObj=classTable[this.sqClass];if(!classObj)return this;var instProto=classObj.instProto||classObj.classInstProto(classObj.classNameFromImage(oopMap,rawBits));if(!instProto)return this;var renamedObj=new instProto;return renamedObj.oop=this.oop,renamedObj.sqClass=this.sqClass,renamedObj._format=this._format,renamedObj.hash=this.hash,renamedObj}},"accessing",{instSize:function(){return this._format<2?this.pointersSize():this.sqClass.classInstSize()},indexableSize:function(primHandler){var fmt=this._format;return fmt<2?-1:3===fmt&&primHandler.vm.isContext(this)?this.pointers[Squeak.Context_stackPointer]:fmt<6?this.pointersSize()-this.instSize():fmt<12?this.wordsSize():fmt<16?this.shortsSize():fmt<24?this.bytesSize():4*this.pointersSize()+this.bytesSize()},snapshotSize:function(){var nWords=this.isFloat?2:this.words?this.words.length:this.pointers?this.pointers.length:0;this.bytes&&(nWords+=this.bytes.length+3>>>2);var extraHeader=nWords>=255?2:0;return nWords+=1&nWords,(nWords+=2)<4&&(nWords=4),{header:extraHeader,body:nWords}},writeTo:function(data,pos,littleEndian,objToOop){var nWords=this.isFloat?2:this.words?this.words.length:this.pointers?this.pointers.length:0;this.bytes&&(nWords+=this.bytes.length+3>>>2,this._format|=3&-this.bytes.length);var beforePos=pos,formatAndClass=this._format<<24|4194303&this.sqClass.hash,sizeAndHash=nWords<<24|4194303&this.hash;if(nWords>=255&&(data.setUint32(pos,nWords,littleEndian),pos+=4,sizeAndHash=255<<24|4194303&this.hash,data.setUint32(pos,sizeAndHash,littleEndian),pos+=4),data.setUint32(pos,formatAndClass,littleEndian),pos+=4,data.setUint32(pos,sizeAndHash,littleEndian),pos+=4,this.isFloat)data.setFloat64(pos,this.float,littleEndian),pos+=8;else if(this.words)for(var i=0;i=24){var mask=this.methodSignFlag()?2147483648:0,taggedHeader=this.pointers[0]<<1|1|mask;data.setUint32(pos,taggedHeader,littleEndian),pos+=4,startIndex=1}for(i=startIndex;i=16&&fmt<=23},isPointers:function(){return this._format<=6},isWords:function(){return 10===this._format},isWordsOrBytes:function(){var fmt=this._format;return 10===fmt||fmt>=16&&fmt<=23},isWeak:function(){return 4===this._format},isMethod:function(){return this._format>=24},sameFormats:function(a,b){return a<16?a===b:(248&a)==(248&b)}},"as class",{defaultInst:function(){return Squeak.ObjectSpur},classInstFormat:function(){return this.pointers[Squeak.Class_format]>>16&31},classInstSize:function(){return 65535&this.pointers[Squeak.Class_format]},classInstIsBytes:function(){var fmt=this.classInstFormat();return fmt>=16&&fmt<=23},classInstIsPointers:function(){return this.classInstFormat()<=6},classByteSizeOfInstance:function(nElements){var format=this.classInstFormat(),nWords=this.classInstSize();return nWords+=format<9?nElements:format>=16?(nElements+3)/4|0:format>=12?(nElements+1)/2|0:format>=10?nElements:2*nElements,nWords+=1&nWords,(nWords+=nWords>=255?4:2)<4&&(nWords=4),4*nWords}},"as compiled block",{blockOuterCode:function(){return this.pointers[this.pointers.length-1]}},"as method",{methodSignFlag:function(){return this.pointers[0]<0},methodNumLits:function(){return 32767&this.pointers[0]},methodPrimitiveIndex:function(){return 0==(65536&this.pointers[0])?0:this.bytes[1]+256*this.bytes[2]},methodAsString:function(){var cls=this.pointers[this.pointers.length-1].pointers[Squeak.ClassBinding_value],selector=this.pointers[this.pointers.length-2];return selector.pointers&&(selector=selector.pointers[Squeak.AdditionalMethodState_selector]),cls.className()+">>"+selector.bytesAsString()}})),vm_object_spur}var vm_image={},hasRequiredVm_image;function requireVm_image(){return hasRequiredVm_image||(hasRequiredVm_image=1,Object.subclass("Squeak.Image","about",{about:function(){}},"initializing",{initialize:function(name){this.headRoom=1e8,this.totalMemory=0,this.headerFlags=0,this.name=name,this.gcCount=0,this.gcMilliseconds=0,this.pgcCount=0,this.pgcMilliseconds=0,this.gcTenured=0,this.allocationCount=0,this.oldSpaceCount=0,this.youngSpaceCount=0,this.newSpaceCount=0,this.hasNewInstances={}},readFromBuffer:function(arraybuffer,thenDo,progressDo){console.log("squeak: reading "+this.name+" ("+arraybuffer.byteLength+" bytes)"),this.startupTime=Date.now();for(var data=new DataView(arraybuffer),littleEndian=!1,pos=0,readWord32=function(){var int=data.getUint32(pos,littleEndian);return pos+=4,int},readWord=readWord32,wordSize=4,readBits=function(nWords,isPointers){if(isPointers){for(var oops=[];oops.length=0);)if(littleEndian||(fileHeaderSize+=512),fileHeaderSize>512)throw Error("bad image version");this.version=version;var nativeFloats=0!=(1&version);this.hasClosures=!([6501,6502,68e3].indexOf(version)>=0),this.isSpur=0!=(16&version);var is64Bit=version>=68e3;if(is64Bit&&!this.isSpur)throw Error("64 bit non-spur images not supported yet");is64Bit&&(readWord=function(){var lo=data.getUint32(pos,!0),hi=data.getUint32(pos+4,!0);return pos+=8,Squeak.word64FromUint32(hi,lo)},wordSize=8),this.is64Bit=is64Bit,console.log(`squeak: Image Spur: ${this.isSpur} is64Bit: ${is64Bit} hasClosures: ${this.hasClosures} version: ${version}`);var imageHeaderSize=readWord32(),objectMemorySize=readWord(),oldBaseAddr=readWord(),specialObjectsOopInt=readWord(),lastHash=readWord32();is64Bit&&readWord32();var savedWindowSize=readWord();this.headerFlags=readWord(),this.savedHeaderWords=[lastHash,savedWindowSize,this.headerFlags];for(var i=0;i<4;i++)this.savedHeaderWords.push(readWord32());var prevObj,firstSegSize=readWord(),oopMap={},rawBits={},headerSize=fileHeaderSize+imageHeaderSize;if(pos=headerSize,this.isSpur){this.oldSpaceBytes=firstSegSize-16;for(var segmentEnd=pos+firstSegSize,addressOffset=0,classPages=null,skippedBytes=0,oopAdjust={};pos>>24;255===size&&(size=formatAndClass,formatAndClass=readWord32(),sizeAndHash=readWord32());oop=addressOffset+pos-8-headerSize;var classID=4194303&formatAndClass;hash=4194303&sizeAndHash,bits=readBits(size,(format=formatAndClass>>>24&31)<10&&classID>0);if(pos+=is64Bit?8*(size<1?1-size:0):4*(size<2?2-size:1&size),classID>=32){if((object=new Squeak.ObjectSpur).initFromImage(oop,classID,format,hash),prevObj&&(prevObj.nextObject=object),this.oldSpaceCount++,prevObj=object,oopMap[oldBaseAddr+oop]=object,rawBits[oop]=bits,oopAdjust[oop]=skippedBytes,is64Bit){var overhead=object.overhead64(bits);skippedBytes+=overhead.bytes,overhead.sizeHeader&&(oopAdjust[oop]-=8,skippedBytes-=8)}}else skippedBytes+=pos-objPos,16!==classID||classPages||(classPages=bits),classID&&(oopMap[oldBaseAddr+oop]=bits)}if(pos!==segmentEnd-16)throw Error("invalid segment");var deltaWords=readWord32(),deltaWordsHi=readWord32(),segmentBytes=readWord32();if(readWord32(),0!==segmentBytes){var deltaBytes=4278190080&deltaWordsHi?4*(16777215&deltaWords):0;segmentEnd+=segmentBytes,addressOffset+=deltaBytes,skippedBytes+=16+deltaBytes,this.oldSpaceBytes+=deltaBytes+segmentBytes}}this.oldSpaceBytes-=skippedBytes,this.firstOldObject=oopMap[oldBaseAddr],this.lastOldObject=object,this.lastOldObject.nextObject=null}else{for(;pos>>2,classInt=readWord(),header=readWord();break;case Squeak.HeaderTypeClass:classInt=header-Squeak.HeaderTypeClass,nWords=(header=readWord())>>>2&63;break;case Squeak.HeaderTypeShort:nWords=header>>>2&63,classInt=header>>>12&31;break;case Squeak.HeaderTypeFree:throw Error("Unexpected free block")}nWords--;var format,object,oop=pos-4-headerSize,hash=header>>>17&4095,bits=readBits(nWords,(format=header>>>8&15)<5);(object=new Squeak.Object).initFromImage(oop,classInt,format,hash),classInt<32&&(object.hash|=268435456),prevObj&&(prevObj.nextObject=object),this.oldSpaceCount++,prevObj=object,oopMap[oldBaseAddr+oop]=object,rawBits[oop]=bits}this.firstOldObject=oopMap[oldBaseAddr+4],this.lastOldObject=object,this.lastOldObject.nextObject=null,this.oldSpaceBytes=objectMemorySize}this.totalMemory=this.oldSpaceBytes+this.headRoom,this.totalMemory=1e6*Math.ceil(this.totalMemory/1e6);var _splObs=oopMap[specialObjectsOopInt],cc=this.isSpur?this.spurClassTable(oopMap,rawBits,classPages,_splObs):rawBits[oopMap[rawBits[_splObs.oop][Squeak.splOb_CompactClasses]].oop],renamedObj=null;for(object=this.firstOldObject,prevObj=null;object;)prevObj=renamedObj,renamedObj=object.renameFromImage(oopMap,rawBits,cc),prevObj?prevObj.nextObject=renamedObj:this.firstOldObject=renamedObj,oopMap[oldBaseAddr+object.oop]=renamedObj,object=object.nextObject;this.lastOldObject=renamedObj,this.lastOldObject.nextObject=null;var splObs=oopMap[specialObjectsOopInt],compactClasses=rawBits[oopMap[rawBits[splObs.oop][Squeak.splOb_CompactClasses]].oop],floatClass=oopMap[rawBits[splObs.oop][Squeak.splOb_ClassFloat]];this.isSpur&&(this.initImmediateClasses(oopMap,rawBits,splObs),compactClasses=this.spurClassTable(oopMap,rawBits,classPages,splObs),nativeFloats=this.getCharacter.bind(this),this.initSpurOverrides());var obj=this.firstOldObject,done=0;floatClass.hash=34;var mapSomeObjects=function(){if(obj){for(var stop=done+(this.oldSpaceCount/20|0);obj&&done268435455;if(hadCompactHeader!==!!obj.sqClass.isCompact){var isCompact=0===obj.snapshotSize().header;hadCompactHeader!==isCompact&&(adjust+=isCompact?-4:4)}obj.hash&=268435455,obj.oop+=adjust,obj=obj.nextObject}this.oldSpaceBytes+=adjust}},fixCompiledMethods:function(){if(!(this.version>=6502))for(var obj=this.firstOldObject,compiledMethodClass=this.specialObjectsArray.pointers[Squeak.splOb_ClassCompiledMethod];obj;)obj.isMethod()&&(obj.sqClass=compiledMethodClass),obj=obj.nextObject},fixSkippedOops:function(oopAdjust){for(var obj=this.firstOldObject;obj;)obj.oop-=oopAdjust[obj.oop],obj=obj.nextObject;if((obj=this.lastOldObject).addr()+obj.totalBytes()!==this.oldSpaceBytes)throw Error("image size doesn't match object sizes")},fixPCs:function(){for(var clsMethodContext=this.specialObjectsArray.pointers[Squeak.splOb_ClassMethodContext],pc=Squeak.Context_instructionPointer,method=Squeak.Context_method,clsBlockClosure=this.specialObjectsArray.pointers[Squeak.splOb_ClassBlockClosure],startpc=Squeak.Closure_startpc,outerContext=Squeak.Closure_outerContext,obj=this.firstOldObject;obj;)obj.sqClass===clsMethodContext?obj.pointers[pc]-=4*obj.pointers[method].pointers.length:obj.sqClass===clsBlockClosure&&(obj.pointers[startpc]-=4*obj.pointers[outerContext].pointers[method].pointers.length),obj=obj.nextObject},ensureFullBlockClosureClass:function(splObs,compactClasses){splObs.pointers[Squeak.splOb_ClassFullBlockClosure].isNil&&compactClasses[38]&&(splObs.pointers[Squeak.splOb_ClassFullBlockClosure]=compactClasses[38])}},"garbage collection - full",{fullGC:function(reason){this.vm.addMessage("fullGC: "+reason);var start=Date.now(),previousNew=this.newSpaceCount,previousOld=this.oldSpaceCount,newObjects=this.markReachableObjects();this.removeUnmarkedOldObjects(),this.appendToOldObjects(newObjects),this.finalizeWeakReferences(),this.allocationCount+=this.newSpaceCount,this.newSpaceCount=0,this.youngSpaceCount=0,this.hasNewInstances={},this.gcCount++,this.gcMilliseconds+=Date.now()-start;var delta=previousOld-this.oldSpaceCount,survivingNew=newObjects.length,survivingOld=this.oldSpaceCount-survivingNew,gcedNew=previousNew-survivingNew,gcedOld=previousOld-survivingOld;return console.log("Full GC ("+reason+"): "+(Date.now()-start)+" ms; before: "+previousOld.toLocaleString()+" old objects; allocated "+previousNew.toLocaleString()+" new; surviving "+survivingOld.toLocaleString()+" old; tenuring "+survivingNew.toLocaleString()+" new; gc'ed "+gcedOld.toLocaleString()+" old and "+gcedNew.toLocaleString()+" new; total now: "+this.oldSpaceCount.toLocaleString()+" ("+(delta>0?"+":"")+delta.toLocaleString()+", "+this.oldSpaceBytes.toLocaleString()+" bytes)"),newObjects.length>0?newObjects[0]:null},gcRoots:function(){return this.vm.storeContextRegisters(),[this.specialObjectsArray,this.vm.activeContext]},markReachableObjects:function(){var todo=this.gcRoots(),newObjects=[];for(this.weakObjects=[];todo.length>0;){var object=todo.pop();if(!object.mark){object.oop<0&&newObjects.push(object),object.mark=!0,object.sqClass.mark||todo.push(object.sqClass);var body=object.pointers;if(body){var n=body.length;if(object.isWeak()&&(n=object.sqClass.classInstSize(),this.weakObjects.push(object)),this.vm.isContext(object))for(var i=n=object.contextSizeWithStack();i=2)){var list=weakObj.pointers[Squeak.WeakFinalizerItem_list];if(list.sqClass==this.vm.specialObjects[Squeak.splOb_ClassWeakFinalizer]){var items=list.pointers[Squeak.WeakFinalizationList_first];weakObj.pointers[Squeak.WeakFinalizerItem_next]=items,list.pointers[Squeak.WeakFinalizationList_first]=weakObj}}}this.vm.pendingFinalizationSignals>0&&this.vm.forceInterruptCheck()}},"garbage collection - partial",{partialGC:function(reason){this.vm.addMessage("partialGC: "+reason);var start=Date.now(),previous=this.newSpaceCount,young=this.findYoungObjects();return this.appendToYoungSpace(young),this.finalizeWeakReferences(),this.cleanupYoungSpace(young),this.allocationCount+=this.newSpaceCount-young.length,this.youngSpaceCount=young.length,this.newSpaceCount=this.youngSpaceCount,this.pgcCount++,this.pgcMilliseconds+=Date.now()-start,console.log("Partial GC ("+reason+"): "+(Date.now()-start)+" ms, found "+this.youngRootsCount.toLocaleString()+" roots in "+this.oldSpaceCount.toLocaleString()+" old, kept "+this.youngSpaceCount.toLocaleString()+" young ("+(previous-this.youngSpaceCount).toLocaleString()+" gc'ed)"),young[0]},youngRoots:function(){for(var roots=this.gcRoots().filter((function(obj){return obj.oop<0})),object=this.firstOldObject;object;){if(object.dirty){for(var body=object.pointers,dirty=!1,i=0;i0;){var object=todo.pop();if(!object.mark){newObjects.push(object),object.mark=!0,object.sqClass.oop<0&&todo.push(object.sqClass);var body=object.pointers;if(body){var n=body.length;if(object.isWeak()&&(n=object.sqClass.classInstSize(),this.weakObjects.push(object)),this.vm.isContext(object))for(var i=n=object.contextSizeWithStack();i0?firstYoungObject=this.partialGC("become"):this.vm.storeContextRegisters();for(var mutations={},i=0;i0?0:this.youngSpaceCount;return this.newSpaceCount<=limit?null:(obj.oop<0&&this.fullGC(reason),this.partialGC(reason))},nextObjectWithGCFor:function(obj,clsObj){return this.hasNewInstances[clsObj.oop]?this.nextObjectWithGC("instance of "+clsObj.className(),obj):null},allInstancesOf:function(clsObj){for(var obj=this.firstOldObject,result=[];obj;)obj.sqClass===clsObj&&result.push(obj),obj=obj.nextObject||this.nextObjectWithGCFor(obj,clsObj);return result},writeToBuffer:function(){var data=new DataView(new ArrayBuffer(64+this.oldSpaceBytes)),pos=0,writeWord=function(word){data.setUint32(pos,word),pos+=4};for(writeWord(this.formatVersion()),writeWord(64),writeWord(this.oldSpaceBytes),writeWord(this.firstOldObject.addr()),writeWord(this.objectToOop(this.specialObjectsArray)),writeWord(this.lastHash),writeWord(52429400);pos<64;)writeWord(0);for(var obj=this.firstOldObject,n=0;obj;)pos=obj.writeTo(data,pos,this),obj=obj.nextObject,n++;if(pos!==data.byteLength)throw Error("wrong image size");if(n!==this.oldSpaceCount)throw Error("wrong object count");return data.buffer},objectToOop:function(obj){if("number"==typeof obj)return obj<<1|1;if(obj.oop<0)throw Error("temporary oop");return obj.oop},bytesLeft:function(){return this.totalMemory-this.oldSpaceBytes},formatVersion:function(){return this.isSpur?6521:this.hasClosures?6504:6502},segmentVersion:function(){var dnuFirstWord=this.isSpur?"seod":"does";return this.formatVersion()|dnuFirstWord.charCodeAt(0)<<24},storeImageSegment:function(segmentWordArray,outPointerArray,arrayOfRoots){var segment=new DataView(segmentWordArray.words.buffer),pos=0,outPointers=outPointerArray.pointers,outPos=0;segment.setUint32(pos,this.segmentVersion()),pos+=4,this.fullGC("storeImageSegment"),arrayOfRoots.mark=!0;for(var i=0;i=outPointers.length)return 0;oop=2147483652+4*outPos,outPointers[outPos++]=object}else{if(pos+object.totalBytes()>segment.byteLength)return 0;oop=pos+4*(object.snapshotSize().header+1),pos=object.writeTo(segment,pos,this),todo.push(object)}segmentOops[object.oop]=oop}return oop}function cleanUp(){for(var obj=this.firstOldObject;obj;)obj.mark=!1,obj=obj.nextObject;return this.weakObjects=null,!1}for(addToSegment=addToSegment.bind(this),cleanUp=cleanUp.bind(this),addToSegment(arrayOfRoots);todo.length>0;){var obj=todo.shift(),oop=segmentOops[obj.oop],headerSize=obj.snapshotSize().header,objBody=obj.pointers;if(headerSize>0){var classOop=addToSegment(obj.sqClass);if(!classOop)return cleanUp();var headerType=1===headerSize?Squeak.HeaderTypeClass:Squeak.HeaderTypeSizeAndClass;segment.setUint32(oop-8,classOop|headerType)}if(objBody)for(i=0;i>>2,classInt=readWord(),header=readWord();break;case Squeak.HeaderTypeClass:classInt=header-Squeak.HeaderTypeClass,nWords=(header=readWord())>>>2&63;break;case Squeak.HeaderTypeShort:nWords=header>>>2&63,classInt=header>>>12&31;break;case Squeak.HeaderTypeFree:throw Error("Unexpected free block")}nWords--;var oop=pos,format=header>>>8&15,hash=header>>>17&4095,bits=readBits(nWords,format),object=new Squeak.Object;object.initFromImage(oop+oopOffset,classInt,format,hash),prevObj.nextObject=object,this.oldSpaceCount++,prevObj=object,oopMap[oop]=object,rawBits[oop+oopOffset]=bits}object.nextObject=endMarker;for(var i=0;i0&&classIndex<1024&&(classes[classIndex]=knownClass)}return classes[3]=classes[1],this.classTable=classes,this.classTableIndex=1024,classes},enterIntoClassTable:function(newClass){for(var index=this.classTableIndex,table=this.classTable;index<=4194303;){if(!table[index])return table[index]=newClass,newClass.hash=index,this.classTableIndex=index,index;index++}return console.error("class table full?"),null},initImmediateClasses:function(oopMap,rawBits,splObs){var special=rawBits[splObs.oop];this.characterClass=oopMap[special[Squeak.splOb_ClassCharacter]],this.floatClass=oopMap[special[Squeak.splOb_ClassFloat]],this.largePosIntClass=oopMap[special[Squeak.splOb_ClassLargePositiveInteger]],this.largeNegIntClass=oopMap[special[Squeak.splOb_ClassLargeNegativeInteger]],this.characterClass.classInstProto("Character"),this.floatClass.classInstProto("Float"),this.largePosIntClass.classInstProto("LargePositiveInteger"),this.largeNegIntClass.classInstProto("LargeNegativeInteger"),this.characterTable={}},getCharacter:function(unicode){var char=this.characterTable[unicode];return char||((char=new this.characterClass.instProto).initInstanceOfChar(this.characterClass,unicode),this.characterTable[unicode]=char),char},instantiateFloat:function(bits){var float=new this.floatClass.instProto;return this.registerObjectSpur(float),this.hasNewInstances[this.floatClass.oop]=!0,float.initInstanceOfFloat(this.floatClass,bits),float},instantiateLargeFromSmall:function(hi,lo){lo=hi<<29|lo>>>3;var negative=(hi>>=3)<0;negative&&(hi=-hi,0!==(lo=-lo)&&hi--);var size=0===hi?4:hi<=255?5:hi<=65535?6:hi<=16777215?7:8,largeIntClass=negative?this.largeNegIntClass:this.largePosIntClass,largeInt=new largeIntClass.instProto;this.registerObjectSpur(largeInt),this.hasNewInstances[largeIntClass.oop]=!0,largeInt.initInstanceOfLargeInt(largeIntClass,size);for(var bytes=largeInt.bytes,i=0;i<4;i++)bytes[i]=255&lo,lo>>=8;for(i=4;i>=8;return largeInt},ensureClassesInTable:function(){for(var obj=this.firstOldObject,maxIndex=1024;obj;){var cls=obj.sqClass;if(0===cls.hash&&this.enterIntoClassTable(cls),cls.hash>maxIndex&&(maxIndex=cls.hash),this.classTable[cls.hash]!==cls)throw Error("Class not in class table");obj=obj.nextObject}return 1+(maxIndex>>10)},classTableBytes:function(numPages){return 4*(4108+1028*numPages)},writeFreeLists:function(data,pos,littleEndian,oopOffset){return data.setUint32(pos,167772178,littleEndian),pos+=4,data.setUint32(pos,536870912,littleEndian),pos+=4,pos+=128},writeClassTable:function(data,pos,littleEndian,objToOop,numPages){data.setUint32(pos,4104,littleEndian),pos+=4,data.setUint32(pos,4278190080,littleEndian),pos+=4,data.setUint32(pos,33554448,littleEndian),pos+=4,data.setUint32(pos,4278190080,littleEndian),pos+=4;for(var p=0;p=32||classObj.oop<0)&&(console.warn("freeing class index "+classID+" "+classObj.className()),classObj=null,delete this.classTable[classID])}classObj&&data.setUint32(pos,objToOop(classObj),littleEndian),pos+=4,classID++}}return pos},writeToBufferSpur:function(){var numPages=this.ensureClassesInTable(),hiddenSize=136+this.classTableBytes(numPages),data=new DataView(new ArrayBuffer(64+hiddenSize+this.oldSpaceBytes+16)),start=Date.now(),pos=0;function writeWord(word){data.setUint32(pos,word,true),pos+=4}function objToOop(obj){if("number"==typeof obj)return obj<<1|1;if(7===obj._format){if(obj.hash!==obj.oop>>2||2!=(3&obj.oop))throw Error("Bad immediate char");return obj.oop}if(obj.oop<0)throw Error("temporary oop");return obj.oop<48?obj.oop:obj.oop+hiddenSize}for(writeWord(this.formatVersion()),writeWord(64),writeWord(hiddenSize+this.oldSpaceBytes+16),writeWord(this.firstOldObject.addr()),writeWord(objToOop(this.specialObjectsArray)),this.savedHeaderWords.forEach(writeWord),writeWord(hiddenSize+this.oldSpaceBytes+16);pos<64;)writeWord(0);var obj=this.firstOldObject,n=0;for(pos=obj.writeTo(data,pos,true,objToOop),obj=obj.nextObject,n++,pos=obj.writeTo(data,pos,true,objToOop),obj=obj.nextObject,n++,pos=obj.writeTo(data,pos,true,objToOop),obj=obj.nextObject,n++,pos=this.writeFreeLists(data,pos,true,objToOop),pos=this.writeClassTable(data,pos,true,objToOop,numPages);obj;)pos=obj.writeTo(data,pos,true,objToOop),obj=obj.nextObject,n++;if(writeWord(1241513987),writeWord(8388608),writeWord(0),writeWord(0),pos!==data.byteLength)throw Error("wrong image size");if(n!==this.oldSpaceCount)throw Error("wrong object count");var time=Date.now()-start;return console.log("Wrote "+n+" objects in "+time+" ms, image size "+pos+" bytes"),data.buffer},storeImageSegmentSpur:function(segmentWordArray,outPointerArray,arrayOfRoots){return this.vm.warnOnce("not implemented for Spur yet: primitive 98 (primitiveStoreImageSegment)"),!1},loadImageSegmentSpur:function(segmentWordArray,outPointerArray){return this.vm.warnOnce("not implemented for Spur yet: primitive 99 (primitiveLoadImageSegment)"),null}})),vm_image}var vm_interpreter={},hasRequiredVm_interpreter;function requireVm_interpreter(){return hasRequiredVm_interpreter||(hasRequiredVm_interpreter=1,Object.subclass("Squeak.Interpreter","initialization",{initialize:function(image,display,options){console.log("squeak: initializing interpreter "+Squeak.vmVersion+" ("+Squeak.vmDate+")"),this.Squeak=Squeak,this.image=image,this.image.vm=this,this.options=options||{},this.primHandler=new Squeak.Primitives(this,display),this.loadImageState(),this.initVMState(),this.loadInitialContext(),this.hackImage(),this.initCompiler(),console.log("squeak: ready")},loadImageState:function(){this.specialObjects=this.image.specialObjectsArray.pointers,this.specialSelectors=this.specialObjects[Squeak.splOb_SpecialSelectors].pointers,this.nilObj=this.specialObjects[Squeak.splOb_NilObject],this.falseObj=this.specialObjects[Squeak.splOb_FalseObject],this.trueObj=this.specialObjects[Squeak.splOb_TrueObject],this.hasClosures=this.image.hasClosures,this.getGlobals=this.globalsGetter(),this.hasClosures||this.findMethod("UnixFileDirectory class>>pathNameDelimiter")||(this.primHandler.emulateMac=!0),6501==this.image.version&&(this.primHandler.reverseDisplay=!0)},initVMState:function(){this.byteCodeCount=0,this.sendCount=0,this.interruptCheckCounter=0,this.interruptCheckCounterFeedBackReset=1e3,this.interruptChecksEveryNms=3,this.lowSpaceThreshold=1e6,this.signalLowSpace=!1,this.nextPollTick=0,this.nextWakeupTick=0,this.lastTick=0,this.interruptKeycode=2094,this.interruptPending=!1,this.pendingFinalizationSignals=0,this.freeContexts=this.nilObj,this.freeLargeContexts=this.nilObj,this.reclaimableContextCount=0,this.nRecycledContexts=0,this.nAllocatedContexts=0,this.methodCacheSize=1024,this.methodCacheMask=this.methodCacheSize-1,this.methodCacheRandomish=0,this.methodCache=[];for(var i=0;i>wordSize",literal:{index:1,old:8,hack:4},enabled:!0},{method:"ReleaseBuilder class>>prepareEnvironment",bytecode:{pc:28,old:216,hack:135},enabled:opts.includes("wizard=false")},{method:"Latin1Environment class>>systemConverterClass",bytecode:{pc:53,old:69,hack:73},enabled:!this.image.isSpur},{method:"Latin1Environment class>>systemConverterClass",bytecode:{pc:38,old:22,hack:19},enabled:this.image.isSpur&&sista},{method:"Latin1Environment class>>systemConverterClass",bytecode:{pc:50,old:68,hack:72},enabled:this.image.isSpur&&!sista}].forEach((function(each){try{var m=each.enabled&&this.findMethod(each.method);if(m){var prim=each.primitive,byte=each.bytecode,lit=each.literal,hacked=!0;prim?m.pointers[0]|=prim:byte&&m.bytes[byte.pc]===byte.old?m.bytes[byte.pc]=byte.hack:byte&&m.bytes[byte.pc]===byte.hack?hacked=!1:lit&&m.pointers[lit.index].pointers[1]===lit.old?m.pointers[lit.index].pointers[1]=lit.hack:lit&&m.pointers[lit.index].pointers[1]===lit.hack?hacked=!1:(hacked=!1,console.warn("Not hacking "+each.method)),hacked&&console.warn("Hacking "+each.method)}}catch(error){console.error("Failed to hack "+each.method+" with error "+error)}}),this)}},"interpreting",{interpretOne:function(singleStep){if(!this.method.compiled){if(this.method.methodSignFlag())return this.interpretOneSistaWithExtensions(singleStep,0,0);var b,b2,Squeak=this.Squeak;switch(this.byteCodeCount++,b=this.nextByte()){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9:case 10:case 11:case 12:case 13:case 14:case 15:return void this.push(this.receiver.pointers[15&b]);case 16:case 17:case 18:case 19:case 20:case 21:case 22:case 23:case 24:case 25:case 26:case 27:case 28:case 29:case 30:case 31:return void this.push(this.homeContext.pointers[Squeak.Context_tempFrameStart+(15&b)]);case 32:case 33:case 34:case 35:case 36:case 37:case 38:case 39:case 40:case 41:case 42:case 43:case 44:case 45:case 46:case 47:case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:case 58:case 59:case 60:case 61:case 62:case 63:return void this.push(this.method.methodGetLiteral(31&b));case 64:case 65:case 66:case 67:case 68:case 69:case 70:case 71:case 72:case 73:case 74:case 75:case 76:case 77:case 78:case 79:case 80:case 81:case 82:case 83:case 84:case 85:case 86:case 87:case 88:case 89:case 90:case 91:case 92:case 93:case 94:case 95:return void this.push(this.method.methodGetLiteral(31&b).pointers[Squeak.Assn_value]);case 96:case 97:case 98:case 99:case 100:case 101:case 102:case 103:return this.receiver.dirty=!0,void(this.receiver.pointers[7&b]=this.pop());case 104:case 105:case 106:case 107:case 108:case 109:case 110:case 111:return void(this.homeContext.pointers[Squeak.Context_tempFrameStart+(7&b)]=this.pop());case 112:return void this.push(this.receiver);case 113:return void this.push(this.trueObj);case 114:return void this.push(this.falseObj);case 115:return void this.push(this.nilObj);case 116:return void this.push(-1);case 117:return void this.push(0);case 118:return void this.push(1);case 119:return void this.push(2);case 120:return void this.doReturn(this.receiver);case 121:return void this.doReturn(this.trueObj);case 122:return void this.doReturn(this.falseObj);case 123:return void this.doReturn(this.nilObj);case 124:return void this.doReturn(this.pop());case 125:return void this.doReturn(this.pop(),this.activeContext.pointers[Squeak.BlockContext_caller]);case 126:case 127:return void this.nono();case 128:return void this.extendedPush(this.nextByte());case 129:return void this.extendedStore(this.nextByte());case 130:return void this.extendedStorePop(this.nextByte());case 131:return b2=this.nextByte(),void this.send(this.method.methodGetSelector(31&b2),b2>>5,!1);case 132:return void this.doubleExtendedDoAnything(this.nextByte());case 133:return b2=this.nextByte(),void this.send(this.method.methodGetSelector(31&b2),b2>>5,!0);case 134:return b2=this.nextByte(),void this.send(this.method.methodGetSelector(63&b2),b2>>6,!1);case 135:return void this.pop();case 136:return void this.push(this.top());case 137:return void this.push(this.exportThisContext());case 138:return void this.pushNewArray(this.nextByte());case 139:return void this.callPrimBytecode(129);case 140:return b2=this.nextByte(),void this.push(this.homeContext.pointers[Squeak.Context_tempFrameStart+this.nextByte()].pointers[b2]);case 141:return b2=this.nextByte(),(vec=this.homeContext.pointers[Squeak.Context_tempFrameStart+this.nextByte()]).pointers[b2]=this.top(),void(vec.dirty=!0);case 142:var vec;return b2=this.nextByte(),(vec=this.homeContext.pointers[Squeak.Context_tempFrameStart+this.nextByte()]).pointers[b2]=this.pop(),void(vec.dirty=!0);case 143:return void this.pushClosureCopy();case 144:case 145:case 146:case 147:case 148:case 149:case 150:case 151:return void(this.pc+=1+(7&b));case 152:case 153:case 154:case 155:case 156:case 157:case 158:case 159:return void this.jumpIfFalse(1+(7&b));case 160:case 161:case 162:case 163:case 164:case 165:case 166:case 167:return b2=this.nextByte(),this.pc+=256*((7&b)-4)+b2,void((7&b)<4&&this.interruptCheckCounter--<=0&&this.checkForInterrupts());case 168:case 169:case 170:case 171:return void this.jumpIfTrue(256*(3&b)+this.nextByte());case 172:case 173:case 174:case 175:return void this.jumpIfFalse(256*(3&b)+this.nextByte());case 176:return this.success=!0,this.resultIsFloat=!1,void(this.pop2AndPushNumResult(this.stackIntOrFloat(1)+this.stackIntOrFloat(0))||this.sendSpecial(15&b));case 177:return this.success=!0,this.resultIsFloat=!1,void(this.pop2AndPushNumResult(this.stackIntOrFloat(1)-this.stackIntOrFloat(0))||this.sendSpecial(15&b));case 178:return this.success=!0,void(this.pop2AndPushBoolResult(this.stackIntOrFloat(1)this.stackIntOrFloat(0))||this.sendSpecial(15&b));case 180:return this.success=!0,void(this.pop2AndPushBoolResult(this.stackIntOrFloat(1)<=this.stackIntOrFloat(0))||this.sendSpecial(15&b));case 181:return this.success=!0,void(this.pop2AndPushBoolResult(this.stackIntOrFloat(1)>=this.stackIntOrFloat(0))||this.sendSpecial(15&b));case 182:return this.success=!0,void(this.pop2AndPushBoolResult(this.stackIntOrFloat(1)===this.stackIntOrFloat(0))||this.sendSpecial(15&b));case 183:return this.success=!0,void(this.pop2AndPushBoolResult(this.stackIntOrFloat(1)!==this.stackIntOrFloat(0))||this.sendSpecial(15&b));case 184:return this.success=!0,this.resultIsFloat=!1,void(this.pop2AndPushNumResult(this.stackIntOrFloat(1)*this.stackIntOrFloat(0))||this.sendSpecial(15&b));case 185:return this.success=!0,void(this.pop2AndPushIntResult(this.quickDivide(this.stackInteger(1),this.stackInteger(0)))||this.sendSpecial(15&b));case 186:return this.success=!0,void(this.pop2AndPushIntResult(this.mod(this.stackInteger(1),this.stackInteger(0)))||this.sendSpecial(15&b));case 187:return this.success=!0,void(this.primHandler.primitiveMakePoint(1,!0)||this.sendSpecial(15&b));case 188:return this.success=!0,void(this.pop2AndPushIntResult(this.safeShift(this.stackInteger(1),this.stackInteger(0)))||this.sendSpecial(15&b));case 189:return this.success=!0,void(this.pop2AndPushIntResult(this.div(this.stackInteger(1),this.stackInteger(0)))||this.sendSpecial(15&b));case 190:return this.success=!0,void(this.pop2AndPushIntResult(this.stackInteger(1)&this.stackInteger(0))||this.sendSpecial(15&b));case 191:return this.success=!0,void(this.pop2AndPushIntResult(this.stackInteger(1)|this.stackInteger(0))||this.sendSpecial(15&b));case 192:case 193:case 194:case 195:case 196:case 197:case 198:case 199:case 200:case 201:case 202:case 203:case 204:case 205:case 206:case 207:return void(this.primHandler.quickSendOther(this.receiver,15&b)||this.sendSpecial(16+(15&b)));case 208:case 209:case 210:case 211:case 212:case 213:case 214:case 215:case 216:case 217:case 218:case 219:case 220:case 221:case 222:case 223:return void this.send(this.method.methodGetSelector(15&b),0,!1);case 224:case 225:case 226:case 227:case 228:case 229:case 230:case 231:case 232:case 233:case 234:case 235:case 236:case 237:case 238:case 239:return void this.send(this.method.methodGetSelector(15&b),1,!1);case 240:case 241:case 242:case 243:case 244:case 245:case 246:case 247:case 248:case 249:case 250:case 251:case 252:case 253:case 254:case 255:return void this.send(this.method.methodGetSelector(15&b),2,!1)}throw Error("not a bytecode: "+b)}if(singleStep){if(!this.compiler.enableSingleStepping(this.method))return this.method.compiled=null,this.interpretOne(singleStep);this.breakNow()}this.method.compiled(this)},interpretOneSistaWithExtensions:function(singleStep,extA,extB){var b,b2,Squeak=this.Squeak;switch(this.byteCodeCount++,b=this.nextByte()){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9:case 10:case 11:case 12:case 13:case 14:case 15:return void this.push(this.receiver.pointers[15&b]);case 16:case 17:case 18:case 19:case 20:case 21:case 22:case 23:case 24:case 25:case 26:case 27:case 28:case 29:case 30:case 31:return void this.push(this.method.methodGetLiteral(15&b).pointers[Squeak.Assn_value]);case 32:case 33:case 34:case 35:case 36:case 37:case 38:case 39:case 40:case 41:case 42:case 43:case 44:case 45:case 46:case 47:case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:case 58:case 59:case 60:case 61:case 62:case 63:return void this.push(this.method.methodGetLiteral(31&b));case 64:case 65:case 66:case 67:case 68:case 69:case 70:case 71:return void this.push(this.homeContext.pointers[Squeak.Context_tempFrameStart+(7&b)]);case 72:case 73:case 74:case 75:return void this.push(this.homeContext.pointers[Squeak.Context_tempFrameStart+(3&b)+8]);case 76:return void this.push(this.receiver);case 77:return void this.push(this.trueObj);case 78:return void this.push(this.falseObj);case 79:return void this.push(this.nilObj);case 80:return void this.push(0);case 81:return void this.push(1);case 82:return 0==extB?void this.push(this.exportThisContext()):void this.nono();case 83:return void this.push(this.top());case 84:case 85:case 86:case 87:case 217:case 218:case 219:case 220:case 221:case 222:case 223:case 230:case 236:case 246:case 247:case 254:case 255:return void this.nono();case 88:return void this.doReturn(this.receiver);case 89:return void this.doReturn(this.trueObj);case 90:return void this.doReturn(this.falseObj);case 91:return void this.doReturn(this.nilObj);case 92:return void this.doReturn(this.pop());case 93:return void this.doReturn(this.nilObj,this.activeContext.pointers[Squeak.BlockContext_caller]);case 94:return 0==extA?void this.doReturn(this.pop(),this.activeContext.pointers[Squeak.BlockContext_caller]):void this.nono();case 95:return;case 96:return this.success=!0,this.resultIsFloat=!1,void(this.pop2AndPushNumResult(this.stackIntOrFloat(1)+this.stackIntOrFloat(0))||this.sendSpecial(15&b));case 97:return this.success=!0,this.resultIsFloat=!1,void(this.pop2AndPushNumResult(this.stackIntOrFloat(1)-this.stackIntOrFloat(0))||this.sendSpecial(15&b));case 98:return this.success=!0,void(this.pop2AndPushBoolResult(this.stackIntOrFloat(1)this.stackIntOrFloat(0))||this.sendSpecial(15&b));case 100:return this.success=!0,void(this.pop2AndPushBoolResult(this.stackIntOrFloat(1)<=this.stackIntOrFloat(0))||this.sendSpecial(15&b));case 101:return this.success=!0,void(this.pop2AndPushBoolResult(this.stackIntOrFloat(1)>=this.stackIntOrFloat(0))||this.sendSpecial(15&b));case 102:return this.success=!0,void(this.pop2AndPushBoolResult(this.stackIntOrFloat(1)===this.stackIntOrFloat(0))||this.sendSpecial(15&b));case 103:return this.success=!0,void(this.pop2AndPushBoolResult(this.stackIntOrFloat(1)!==this.stackIntOrFloat(0))||this.sendSpecial(15&b));case 104:return this.success=!0,this.resultIsFloat=!1,void(this.pop2AndPushNumResult(this.stackIntOrFloat(1)*this.stackIntOrFloat(0))||this.sendSpecial(15&b));case 105:return this.success=!0,void(this.pop2AndPushIntResult(this.quickDivide(this.stackInteger(1),this.stackInteger(0)))||this.sendSpecial(15&b));case 106:return this.success=!0,void(this.pop2AndPushIntResult(this.mod(this.stackInteger(1),this.stackInteger(0)))||this.sendSpecial(15&b));case 107:return this.success=!0,void(this.primHandler.primitiveMakePoint(1,!0)||this.sendSpecial(15&b));case 108:return this.success=!0,void(this.pop2AndPushIntResult(this.safeShift(this.stackInteger(1),this.stackInteger(0)))||this.sendSpecial(15&b));case 109:return this.success=!0,void(this.pop2AndPushIntResult(this.div(this.stackInteger(1),this.stackInteger(0)))||this.sendSpecial(15&b));case 110:return this.success=!0,void(this.pop2AndPushIntResult(this.stackInteger(1)&this.stackInteger(0))||this.sendSpecial(15&b));case 111:return this.success=!0,void(this.pop2AndPushIntResult(this.stackInteger(1)|this.stackInteger(0))||this.sendSpecial(15&b));case 112:case 113:case 114:case 115:case 116:case 117:case 118:case 119:case 120:case 121:case 122:case 123:case 124:case 125:case 126:case 127:return void(this.primHandler.quickSendOther(this.receiver,15&b)||this.sendSpecial(16+(15&b)));case 128:case 129:case 130:case 131:case 132:case 133:case 134:case 135:case 136:case 137:case 138:case 139:case 140:case 141:case 142:case 143:return void this.send(this.method.methodGetSelector(15&b),0,!1);case 144:case 145:case 146:case 147:case 148:case 149:case 150:case 151:case 152:case 153:case 154:case 155:case 156:case 157:case 158:case 159:return void this.send(this.method.methodGetSelector(15&b),1,!1);case 160:case 161:case 162:case 163:case 164:case 165:case 166:case 167:case 168:case 169:case 170:case 171:case 172:case 173:case 174:case 175:return void this.send(this.method.methodGetSelector(15&b),2,!1);case 176:case 177:case 178:case 179:case 180:case 181:case 182:case 183:return void(this.pc+=1+(7&b));case 184:case 185:case 186:case 187:case 188:case 189:case 190:case 191:return void this.jumpIfTrue(1+(7&b));case 192:case 193:case 194:case 195:case 196:case 197:case 198:case 199:return void this.jumpIfFalse(1+(7&b));case 200:case 201:case 202:case 203:case 204:case 205:case 206:case 207:return this.receiver.dirty=!0,void(this.receiver.pointers[7&b]=this.pop());case 208:case 209:case 210:case 211:case 212:case 213:case 214:case 215:return void(this.homeContext.pointers[Squeak.Context_tempFrameStart+(7&b)]=this.pop());case 216:return void this.pop();case 224:return b2=this.nextByte(),void this.interpretOneSistaWithExtensions(singleStep,(extA<<8)+b2,extB);case 225:return b2=this.nextByte(),void this.interpretOneSistaWithExtensions(singleStep,extA,(extB<<8)+(b2<128?b2:b2-256));case 226:return b2=this.nextByte(),void this.push(this.receiver.pointers[b2+(extA<<8)]);case 227:return b2=this.nextByte(),void this.push(this.method.methodGetLiteral(b2+(extA<<8)).pointers[Squeak.Assn_value]);case 228:return b2=this.nextByte(),void this.push(this.method.methodGetLiteral(b2+(extA<<8)));case 229:return b2=this.nextByte(),void this.push(this.homeContext.pointers[Squeak.Context_tempFrameStart+b2]);case 231:return void this.pushNewArray(this.nextByte());case 232:return b2=this.nextByte(),void this.push(b2+(extB<<8));case 233:return b2=this.nextByte(),void this.push(this.image.getCharacter(b2+(extB<<8)));case 234:return b2=this.nextByte(),void this.send(this.method.methodGetSelector((b2>>3)+(extA<<5)),(7&b2)+(extB<<3),!1);case 235:b2=this.nextByte();var literal=this.method.methodGetSelector((b2>>3)+(extA<<5));return extB>=64?void this.sendSuperDirected(literal,(7&b2)+((63&extB)<<3)):void this.send(literal,(7&b2)+(extB<<3),!0);case 237:var offset=this.nextByte()+(extB<<8);return this.pc+=offset,void(offset<0&&this.interruptCheckCounter--<=0&&this.checkForInterrupts());case 238:return void this.jumpIfTrue(this.nextByte()+(extB<<8));case 239:return void this.jumpIfFalse(this.nextByte()+(extB<<8));case 240:return this.receiver.dirty=!0,void(this.receiver.pointers[this.nextByte()+(extA<<8)]=this.pop());case 241:return(assoc=this.method.methodGetLiteral(this.nextByte()+(extA<<8))).dirty=!0,void(assoc.pointers[Squeak.Assn_value]=this.pop());case 242:return void(this.homeContext.pointers[Squeak.Context_tempFrameStart+this.nextByte()]=this.pop());case 243:return this.receiver.dirty=!0,void(this.receiver.pointers[this.nextByte()+(extA<<8)]=this.top());case 244:var assoc;return(assoc=this.method.methodGetLiteral(this.nextByte()+(extA<<8))).dirty=!0,void(assoc.pointers[Squeak.Assn_value]=this.top());case 245:return void(this.homeContext.pointers[Squeak.Context_tempFrameStart+this.nextByte()]=this.top());case 248:return void this.callPrimBytecode(245);case 249:return void this.pushFullClosure(extA);case 250:return void this.pushClosureCopyExtended(extA,extB);case 251:return b2=this.nextByte(),void this.push(this.homeContext.pointers[Squeak.Context_tempFrameStart+this.nextByte()].pointers[b2]);case 252:return b2=this.nextByte(),(vec=this.homeContext.pointers[Squeak.Context_tempFrameStart+this.nextByte()]).pointers[b2]=this.top(),void(vec.dirty=!0);case 253:var vec;return b2=this.nextByte(),(vec=this.homeContext.pointers[Squeak.Context_tempFrameStart+this.nextByte()]).pointers[b2]=this.pop(),void(vec.dirty=!0)}throw Error("not a bytecode: "+b)},interpret:function(forMilliseconds,thenDo){if(this.frozen)return"frozen";for(this.isIdle=!1,this.breakOutOfInterpreter=!1,this.breakAfter(forMilliseconds||500);!1===this.breakOutOfInterpreter;)this.method.compiled?this.method.compiled(this):this.interpretOne();if("function"==typeof this.breakOutOfInterpreter)return this.breakOutOfInterpreter(thenDo);var result="break"==this.breakOutOfInterpreter?"break":this.isIdle?this.nextWakeupTick?Math.max(1,this.nextWakeupTick-this.primHandler.millisecondClockValue()):"sleep":0;return thenDo&&thenDo(result),result},goIdle:function(){var hadTimer=0!==this.nextWakeupTick;this.forceInterruptCheck(),this.checkForInterrupts();var hasTimer=0!==this.nextWakeupTick;this.isIdle=hasTimer||!hadTimer,this.breakOut()},freeze:function(frozenDo){var continueFunc;this.frozen=!0,this.breakOutOfInterpreter=function(thenDo){if(!thenDo)throw Error("need function to restart interpreter");return continueFunc=thenDo,"frozen"}.bind(this);var unfreeze=function(){if(this.frozen=!1,!continueFunc)throw Error("no continue function");continueFunc(0)}.bind(this);return frozenDo&&self.setTimeout((function(){frozenDo(unfreeze)}),0),unfreeze},breakOut:function(){this.breakOutOfInterpreter=this.breakOutOfInterpreter||!0},nextByte:function(){return this.method.bytes[this.pc++]},nono:function(){throw Error("Oh No!")},forceInterruptCheck:function(){this.interruptCheckCounter=-1e3},checkForInterrupts:function(){var now=this.primHandler.millisecondClockValue();(now-100&&(now-this.lastTick=this.nextWakeupTick&&(this.nextWakeupTick=0,(sema=this.specialObjects[Squeak.splOb_TheTimerSemaphore]).isNil||this.primHandler.synchronousSignal(sema));if(this.pendingFinalizationSignals>0){var sema=this.specialObjects[Squeak.splOb_TheFinalizationSemaphore];this.pendingFinalizationSignals=0,sema.isNil||this.primHandler.synchronousSignal(sema)}this.primHandler.semaphoresToSignal.length>0&&this.primHandler.signalExternalSemaphores(),this.method.compiled||this.compileIfPossible(this.method),now>=this.breakOutTick&&this.breakOut()},extendedPush:function(nextByte){var lobits=63&nextByte;switch(nextByte>>6){case 0:this.push(this.receiver.pointers[lobits]);break;case 1:this.push(this.homeContext.pointers[Squeak.Context_tempFrameStart+lobits]);break;case 2:this.push(this.method.methodGetLiteral(lobits));break;case 3:this.push(this.method.methodGetLiteral(lobits).pointers[Squeak.Assn_value])}},extendedStore:function(nextByte){var lobits=63&nextByte;switch(nextByte>>6){case 0:this.receiver.dirty=!0,this.receiver.pointers[lobits]=this.top();break;case 1:this.homeContext.pointers[Squeak.Context_tempFrameStart+lobits]=this.top();break;case 2:this.nono();break;case 3:var assoc=this.method.methodGetLiteral(lobits);assoc.dirty=!0,assoc.pointers[Squeak.Assn_value]=this.top()}},extendedStorePop:function(nextByte){var lobits=63&nextByte;switch(nextByte>>6){case 0:this.receiver.dirty=!0,this.receiver.pointers[lobits]=this.pop();break;case 1:this.homeContext.pointers[Squeak.Context_tempFrameStart+lobits]=this.pop();break;case 2:this.nono();break;case 3:var assoc=this.method.methodGetLiteral(lobits);assoc.dirty=!0,assoc.pointers[Squeak.Assn_value]=this.pop()}},doubleExtendedDoAnything:function(byte2){var byte3=this.nextByte();switch(byte2>>5){case 0:this.send(this.method.methodGetSelector(byte3),31&byte2,!1);break;case 1:this.send(this.method.methodGetSelector(byte3),31&byte2,!0);break;case 2:this.push(this.receiver.pointers[byte3]);break;case 3:this.push(this.method.methodGetLiteral(byte3));break;case 4:this.push(this.method.methodGetLiteral(byte3).pointers[Squeak.Assn_value]);break;case 5:this.receiver.dirty=!0,this.receiver.pointers[byte3]=this.top();break;case 6:this.receiver.dirty=!0,this.receiver.pointers[byte3]=this.pop();break;case 7:var assoc=this.method.methodGetLiteral(byte3);assoc.dirty=!0,assoc.pointers[Squeak.Assn_value]=this.top()}},jumpIfTrue:function(delta){var top=this.pop();top.isTrue?this.pc+=delta:top.isFalse||(this.push(top),this.send(this.specialObjects[Squeak.splOb_SelectorMustBeBoolean],0,!1))},jumpIfFalse:function(delta){var top=this.pop();top.isFalse?this.pc+=delta:top.isTrue||(this.push(top),this.send(this.specialObjects[Squeak.splOb_SelectorMustBeBoolean],0,!1))},sendSpecial:function(lobits){this.send(this.specialSelectors[2*lobits],this.specialSelectors[2*lobits+1],!1)},callPrimBytecode:function(extendedStoreBytecode){this.pc+=2,this.primFailCode&&(this.method.bytes[this.pc]===extendedStoreBytecode&&this.stackTopPut(this.getErrorObjectFromPrimFailCode()),this.primFailCode=0)},getErrorObjectFromPrimFailCode:function(){var primErrTable=this.specialObjects[Squeak.splOb_PrimErrTableIndex];if(primErrTable&&primErrTable.pointers){var errorObject=primErrTable.pointers[this.primFailCode-1];if(errorObject)return errorObject}return this.primFailCode}},"closures",{pushNewArray:function(nextByte){var popValues=nextByte>127,count=127&nextByte,array=this.instantiateClass(this.specialObjects[Squeak.splOb_ClassArray],count);if(popValues){for(var i=0;i>4,blockSize=256*this.nextByte()+this.nextByte(),initialPC=this.encodeSqueakPC(this.pc,this.method),closure=this.newClosure(numArgs,initialPC,numCopied);if(closure.pointers[Squeak.Closure_outerContext]=this.activeContext,this.reclaimableContextCount=0,numCopied>0){for(var i=0;i>3&7)+8*this.div(extA,16),blockSize=byteB+(extB<<8),initialPC=this.encodeSqueakPC(this.pc,this.method),closure=this.newClosure(numArgs,initialPC,numCopied);if(closure.pointers[Squeak.Closure_outerContext]=this.activeContext,this.reclaimableContextCount=0,numCopied>0){for(var i=0;i>6&1)?this.vm.nilObj:this.activeContext;var compiledBlock=this.method.methodGetLiteral(literalIndex),closure=this.newFullClosure(context,numCopied,compiledBlock);if(1==(byteB>>7&1))throw Error("on-stack receiver not yet supported");if(closure.pointers[Squeak.ClosureFull_receiver]=this.receiver,this.reclaimableContextCount=0,numCopied>0){for(var i=0;i>"+selector.bytesAsString())}return this.popNandPush(argCount,dnuMsg),this.findSelectorInClass(dnuSel,1,startingClass)},lookupSelectorInDict:function(mDict,messageSelector){for(var dictSize=mDict.pointersSize(),index=(dictSize-Squeak.MethodDict_selectorStart-1&messageSelector.hash)+Squeak.MethodDict_selectorStart,hasWrapped=!1;;){var nextSelector=mDict.pointers[index];if(nextSelector===messageSelector)return mDict.pointers[Squeak.MethodDict_array].pointers[index-Squeak.MethodDict_selectorStart];if(nextSelector.isNil)return this.nilObj;if(++index===dictSize){if(hasWrapped)return this.nilObj;index=Squeak.MethodDict_selectorStart,hasWrapped=!0}}},executeNewMethod:function(newRcvr,newMethod,argumentCount,primitiveIndex,optClass,optSel){if(this.sendCount++,newMethod===this.breakOnMethod&&this.breakNow("executing method "+this.printMethod(newMethod,optClass,optSel)),this.logSends){for(var indent=" ",ctx=this.activeContext;!ctx.isNil;)indent+="| ",ctx=ctx.pointers[Squeak.Context_sender];var args=this.activeContext.pointers.slice(this.sp+1-argumentCount,this.sp+1);console.log(this.sendCount+indent+this.printMethod(newMethod,optClass,optSel,args))}if(this.breakOnContextChanged&&(this.breakOnContextChanged=!1,this.breakNow()),!(primitiveIndex>0&&this.tryPrimitive(primitiveIndex,argumentCount,newMethod))){var newContext=this.allocateOrRecycleContext(newMethod.methodNeedsLargeFrame()),tempCount=newMethod.methodTempCount(),newSP=Squeak.Context_tempFrameStart+tempCount-1;if(newContext.pointers[Squeak.Context_method]=newMethod,newContext.pointers[Squeak.BlockContext_initialIP]=this.nilObj,newContext.pointers[Squeak.Context_sender]=this.activeContext,this.arrayCopy(this.activeContext.pointers,this.sp-argumentCount,newContext.pointers,Squeak.Context_tempFrameStart-1,argumentCount+1),this.arrayFill(newContext.pointers,Squeak.Context_tempFrameStart+argumentCount,Squeak.Context_tempFrameStart+tempCount,this.nilObj),this.popN(argumentCount+1),this.reclaimableContextCount++,this.storeContextRegisters(),this.activeContext=newContext,this.activeContext.dirty=!0,this.homeContext=newContext,this.method=newMethod,this.pc=0,this.sp=newSP,this.receiver=newContext.pointers[Squeak.Context_receiver],this.receiver!==newRcvr)throw Error("receivers don't match");newMethod.compiled||this.compileIfPossible(newMethod,optClass,optSel),this.interruptCheckCounter--<=0&&this.checkForInterrupts()}},compileIfPossible(newMethod,optClass,optSel){!newMethod.compiled&&this.compiler&&this.compiler.compile(newMethod,optClass,optSel)},doReturn:function(returnValue,targetContext){if(!targetContext){var ctx=this.homeContext;if(this.hasClosures)for(var closure;!(closure=ctx.pointers[Squeak.Context_closure]).isNil;)ctx=closure.pointers[Squeak.Closure_outerContext];targetContext=ctx.pointers[Squeak.Context_sender]}if(targetContext.isNil||targetContext.pointers[Squeak.Context_instructionPointer].isNil)return this.cannotReturn(returnValue);for(var nextContext,thisContext=this.activeContext.pointers[Squeak.Context_sender];thisContext!==targetContext;){if(thisContext.isNil)return this.cannotReturn(returnValue);if(this.isUnwindMarked(thisContext))return this.aboutToReturnThrough(returnValue,thisContext);thisContext=thisContext.pointers[Squeak.Context_sender]}for(thisContext=this.activeContext;thisContext!==targetContext;)this.breakOnContextReturned===thisContext&&(this.breakOnContextReturned=null,this.breakNow()),nextContext=thisContext.pointers[Squeak.Context_sender],thisContext.pointers[Squeak.Context_sender]=this.nilObj,thisContext.pointers[Squeak.Context_instructionPointer]=this.nilObj,this.reclaimableContextCount>0&&(this.reclaimableContextCount--,this.recycleIfPossible(thisContext)),thisContext=nextContext;this.activeContext=thisContext,this.activeContext.dirty=!0,this.fetchContextRegisters(this.activeContext),this.push(returnValue),this.breakOnContextChanged&&(this.breakOnContextChanged=!1,this.breakNow())},aboutToReturnThrough:function(resultObj,aContext){this.push(this.exportThisContext()),this.push(resultObj),this.push(aContext);var aboutToReturnSel=this.specialObjects[Squeak.splOb_SelectorAboutToReturn];this.send(aboutToReturnSel,2)},cannotReturn:function(resultObj){this.push(this.exportThisContext()),this.push(resultObj);var cannotReturnSel=this.specialObjects[Squeak.splOb_SelectorCannotReturn];this.send(cannotReturnSel,1)},tryPrimitive:function(primIndex,argCount,newMethod){if(primIndex>255&&primIndex<520){if(primIndex>=264)return this.popNandPush(1,this.top().pointers[primIndex-264]),!0;switch(primIndex){case 256:return!0;case 257:return this.popNandPush(1,this.trueObj),!0;case 258:return this.popNandPush(1,this.falseObj),!0;case 259:return this.popNandPush(1,this.nilObj),!0}return this.popNandPush(1,primIndex-261),!0}var sp=this.sp,context=this.activeContext,success=this.primHandler.doPrimitive(primIndex,argCount,newMethod);return success&&this.sp!==sp-argCount&&context===this.activeContext&&117!==primIndex&&118!==primIndex&&218!==primIndex&&!this.frozen&&this.warnOnce("stack unbalanced after primitive "+primIndex,"error"),success},createActualMessage:function(selector,argCount,cls){var message=this.instantiateClass(this.specialObjects[Squeak.splOb_ClassMessage],0),argArray=this.instantiateClass(this.specialObjects[Squeak.splOb_ClassArray],argCount);return this.arrayCopy(this.activeContext.pointers,this.sp-argCount+1,argArray.pointers,0,argCount),message.pointers[Squeak.Message_selector]=selector,message.pointers[Squeak.Message_arguments]=argArray,message.pointers.length>Squeak.Message_lookupClass&&(message.pointers[Squeak.Message_lookupClass]=cls),message},primitivePerform:function(argCount){var selector=this.stackValue(argCount-1),rcvr=this.stackValue(argCount),trueArgCount=argCount-1,entry=this.findSelectorInClass(selector,trueArgCount,this.getClass(rcvr),argCount);if(entry.selector===selector){if(entry.argCount!==trueArgCount)return!1;var stack=this.activeContext.pointers,selectorIndex=this.sp-trueArgCount;this.arrayCopy(stack,selectorIndex+1,stack,selectorIndex,trueArgCount),this.sp--}else rcvr=this.stackValue(entry.argCount);return this.executeNewMethod(rcvr,entry.method,entry.argCount,entry.primIndex,entry.mClass,selector),!0},primitivePerformWithArgs:function(argCount,supered){var rcvrPos=supered?3:2,rcvr=this.stackValue(rcvrPos),selector=this.stackValue(rcvrPos-1),args=this.stackValue(rcvrPos-2);if(args.sqClass!==this.specialObjects[Squeak.splOb_ClassArray])return!1;var lookupClass=supered?this.top():this.getClass(rcvr);if(supered)for(var cls=this.getClass(rcvr);cls!==lookupClass;)if((cls=cls.pointers[Squeak.Class_superclass]).isNil)return!1;var trueArgCount=args.pointersSize(),entry=this.findSelectorInClass(selector,trueArgCount,lookupClass,argCount);if(entry.selector===selector){if(entry.argCount!==trueArgCount)return!1;var stack=this.activeContext.pointers,selectorIndex=this.sp-(argCount-1);stack[selectorIndex-1]=rcvr,this.arrayCopy(args.pointers,0,stack,selectorIndex,trueArgCount),this.sp+=trueArgCount-argCount}else rcvr=this.stackValue(entry.argCount);return this.executeNewMethod(rcvr,entry.method,entry.argCount,entry.primIndex,entry.mClass,selector),!0},primitiveInvokeObjectAsMethod:function(argCount,method){for(var orgArgs=this.instantiateClass(this.specialObjects[Squeak.splOb_ClassArray],argCount),i=0;i=0;i--)value=256*value+bytes[i];if(num.sqClass===this.specialObjects[Squeak.splOb_ClassLargePositiveInteger])return value;if(num.sqClass===this.specialObjects[Squeak.splOb_ClassLargeNegativeInteger])return-value}return this.success=!1,0},pop2AndPushIntResult:function(intResult){return!(!this.success||!this.canBeSmallInt(intResult))&&(this.popNandPush(2,intResult),!0)},pop2AndPushNumResult:function(numResult){if(this.success){if(this.resultIsFloat)return this.popNandPush(2,this.primHandler.makeFloat(numResult)),!0;if(numResult>=Squeak.MinSmallInt&&numResult<=Squeak.MaxSmallInt)return this.popNandPush(2,numResult),!0;if(numResult>=-4294967295&&numResult<=4294967295){var negative=numResult<0,unsigned=negative?-numResult:numResult,lgIntClass=negative?Squeak.splOb_ClassLargeNegativeInteger:Squeak.splOb_ClassLargePositiveInteger,lgIntObj=this.instantiateClass(this.specialObjects[lgIntClass],4),bytes=lgIntObj.bytes;return bytes[0]=255&unsigned,bytes[1]=unsigned>>8&255,bytes[2]=unsigned>>16&255,bytes[3]=unsigned>>24&255,this.popNandPush(2,lgIntObj),!0}}return!1},pop2AndPushBoolResult:function(boolResult){return!!this.success&&(this.popNandPush(2,boolResult?this.trueObj:this.falseObj),!0)}},"numbers",{getClass:function(obj){return this.isSmallInt(obj)?this.specialObjects[Squeak.splOb_ClassInteger]:obj.sqClass},canBeSmallInt:function(anInt){return anInt>=Squeak.MinSmallInt&&anInt<=Squeak.MaxSmallInt},isSmallInt:function(object){return"number"==typeof object},checkSmallInt:function(maybeSmallInt){return"number"==typeof maybeSmallInt?maybeSmallInt:(this.success=!1,1)},quickDivide:function(rcvr,arg){if(0===arg)return Squeak.NonSmallInt;var result=rcvr/arg|0;return result*arg===rcvr?result:Squeak.NonSmallInt},div:function(rcvr,arg){return 0===arg?Squeak.NonSmallInt:Math.floor(rcvr/arg)},mod:function(rcvr,arg){return 0===arg?Squeak.NonSmallInt:rcvr-Math.floor(rcvr/arg)*arg},safeShift:function(smallInt,shiftCount){if(shiftCount<0)return shiftCount<-31?smallInt<0?-1:0:smallInt>>-shiftCount;if(shiftCount>31)return 0===smallInt?0:Squeak.NonSmallInt;var shifted=smallInt<>shiftCount!==smallInt?Squeak.NonSmallInt:shifted}},"utils",{isContext:function(obj){return obj.sqClass===this.specialObjects[Squeak.splOb_ClassMethodContext]||obj.sqClass===this.specialObjects[Squeak.splOb_ClassBlockContext]},isMethodContext:function(obj){return obj.sqClass===this.specialObjects[Squeak.splOb_ClassMethodContext]},instantiateClass:function(aClass,indexableSize){return this.image.instantiateClass(aClass,indexableSize,this.nilObj)},arrayFill:function(array,fromIndex,toIndex,value){for(var i=fromIndex;i=0;i--)dest[destPos+i]=src[srcPos+i];else for(i=0;i0){var increase=prompt&&prompt("Out of memory, "+Math.ceil(this.image.totalMemory/1e6)+" MB used.\nEnter additional MB, or 0 to signal low space in image","0");if(increase){var bytes=1e6*parseInt(increase,10);this.image.totalMemory+=bytes,this.signalLowSpaceIfNecessary(this.image.bytesLeft())}else{console.warn("squeak: low memory ("+bytesLeft+"/"+this.image.totalMemory+" bytes left), signaling low space"),this.signalLowSpace=!0,this.lowSpaceThreshold=0,this.specialObjects[Squeak.splOb_ProcessSignalingLowSpace].isNil&&(this.specialObjects[Squeak.splOb_ProcessSignalingLowSpace]=this.primHandler.activeProcess()),this.forceInterruptCheck()}}}},"debugging",{addMessage:function(message){return this.messages[message]?++this.messages[message]:this.messages[message]=1},warnOnce:function(message,what){if(1==this.addMessage(message))return console[what||"warn"](message),!0},printMethod:function(aMethod,optContext,optSel,optArgs){if(aMethod.sqClass!=this.specialObjects[Squeak.splOb_ClassCompiledMethod])return this.printMethod(aMethod.blockOuterCode(),optContext,optSel,optArgs);var found;if(optSel){var printed=optContext.className()+">>",selector=optSel.bytesAsString();if(optArgs&&optArgs.length)for(var parts=selector.replace(/(:[a-zA-Z])/g,": $1").split(" :"),i=0;i0&&(printed+=" "),printed+=parts[i]+" "+optArgs[i];else printed+=selector;return printed}return aMethod||(aMethod=this.activeContext.contextMethod()),this.allMethodsDo((function(classObj,methodObj,selectorObj){if(methodObj===aMethod)return found=classObj.className()+">>"+selectorObj.bytesAsString()})),found||(optContext?"("+optContext.pointers[Squeak.Context_receiver]+")>>?":"?>>?")},allInstancesOf:function(classObj,callback){"string"==typeof classObj&&(classObj=this.globalNamed(classObj));for(var instances=[],inst=this.image.someInstanceOf(classObj);inst;)callback?callback(inst):instances.push(inst),inst=this.image.nextInstanceAfter(inst);return instances},globalNamed:function(name){return this.allGlobalsDo((function(nameObj,globalObj){if(nameObj.bytesAsString()===name)return globalObj}))},allGlobalsDo:function(callback){for(var globals=this.getGlobals(),i=0;i=9)for(var clsAndMeta=[globalObj,globalObj.sqClass],c=0;c0;)contexts.push(ctx),ctx=ctx.pointers[Squeak.Context_sender];contexts.length>limit+200&&(ctx.isNil||contexts.push("..."),contexts=contexts.slice(0,limit).concat(["..."]).concat(contexts.slice(-200)));var stack=[],i=contexts.length,indents="";for(indent&&this.logSends&&(indents=Array((""+this.sendCount).length+2).join(" "));i-- >0;){if((ctx=contexts[i]).pointers){var block="",method=ctx.pointers[Squeak.Context_method];"number"==typeof method?(method=ctx.pointers[Squeak.BlockContext_home].pointers[Squeak.Context_method],block="[] in "):ctx.pointers[Squeak.Context_closure].isNil||(block="[] in ");var line=block+this.printMethod(method,ctx);indent&&(line=indents+line),stack.push(line+"\n"),indent&&(indents+=indent)}else stack.push("...\n")}return stack.join("")},findMethod:function(classAndMethodString){var found,className=classAndMethodString.split(">>")[0],methodName=classAndMethodString.split(">>")[1];return this.allMethodsDo((function(classObj,methodObj,selectorObj){if(methodName.length==selectorObj.bytesSize()&&methodName==selectorObj.bytesAsString()&&className==classObj.className())return found=methodObj})),found},breakAfter:function(ms){this.breakOutTick=this.primHandler.millisecondClockValue()+ms},breakNow:function(msg){msg&&console.log("Break: "+msg),this.breakOutOfInterpreter="break"},breakOn:function(classAndMethodString){return this.breakOnMethod=classAndMethodString&&this.findMethod(classAndMethodString)},breakOnReturnFromThisContext:function(){this.breakOnContextChanged=!1,this.breakOnContextReturned=this.activeContext},breakOnSendOrReturn:function(){this.breakOnContextChanged=!0,this.breakOnContextReturned=null},printContext:function(ctx,maxWidth){if(!this.isContext(ctx))return"NOT A CONTEXT: "+printObj(ctx);function printObj(obj){var value="number"==typeof obj||"object"==typeof obj?obj.sqInstName():"<"+obj+">";return(value=JSON.stringify(value).slice(1,-1)).length>maxWidth-3&&(value=value.slice(0,maxWidth-3)+"..."),value}maxWidth||(maxWidth=72);for(var isBlock="number"==typeof ctx.pointers[Squeak.BlockContext_argumentCount],closure=ctx.pointers[Squeak.Context_closure],isClosure=!isBlock&&!closure.isNil,homeCtx=isBlock?ctx.pointers[Squeak.BlockContext_home]:ctx,tempCount=isClosure?closure.pointers[Squeak.Closure_numArgs]:homeCtx.pointers[Squeak.Context_method].methodTempCount(),stackBottom=this.decodeSqueakSP(0),stackTop=homeCtx.contextSizeWithStack(this)-1,firstTemp=stackBottom+1,lastTemp=firstTemp+tempCount-1,lastArg=firstTemp+homeCtx.pointers[Squeak.Context_method].methodNumArgs()-1,stack="",i=stackBottom;i<=stackTop;i++){var label="";i===stackBottom?label="=rcvr":(i<=lastTemp&&(label="=tmp"+(i-firstTemp)),i<=lastArg&&(label+="/arg"+(i-firstTemp))),stack+="\nctx["+i+"]"+label+": "+printObj(homeCtx.pointers[i])}if(isBlock){stack+="\n";var nArgs=ctx.pointers[Squeak.BlockContext_argumentCount],firstArg=this.decodeSqueakSP(1),sp=(lastArg=firstArg+nArgs,ctx===this.activeContext?this.sp:ctx.pointers[Squeak.Context_stackPointer]);sp");for(i=firstArg;i<=sp;i++){label="";i=0;priority--)for(var process=lists[priority].pointers[Squeak.LinkedList_firstLink];!process.isNil;)result+="\n------------------------------------------",result+="\nRunnable: "+this.printProcess(process),process=process.pointers[Squeak.Link_nextLink];for(var semaClass=this.specialObjects[Squeak.splOb_ClassSemaphore],sema=this.image.someInstanceOf(semaClass),waiting=[];sema;){for(process=sema.pointers[Squeak.LinkedList_firstLink];!process.isNil;)waiting.push(process),process=process.pointers[Squeak.Link_nextLink];sema=this.image.nextInstanceAfter(sema)}waiting.sort((function(a,b){return b.pointers[Squeak.Proc_priority]-a.pointers[Squeak.Proc_priority]}));for(var i=0;i ",this.pc),this.activeContext.pointers.slice(0,this.sp+1))},willSendOrReturn:function(){var byte=this.method.bytes[this.pc];if(this.method.methodSignFlag()){if(96<=byte&&byte<=127)selectorObj=this.specialSelectors[2*(byte-96)];else if(128<=byte&&byte<=175)selectorObj=this.method.methodGetSelector(15&byte);else if(234==byte||235==byte)this.method.methodGetSelector(this.method.bytes[this.pc+1]>>3);else if(88<=byte&&byte<=94)return!0}else{if(byte>=120&&byte<=125)return!0;if(byte<131||200==byte)return!1;if(byte>=176)return!0;if(byte<=134){var litIndex;if(132===byte){if(this.method.bytes[this.pc+1]>>5>1)return!1;litIndex=this.method.bytes[this.pc+2]}else litIndex=this.method.bytes[this.pc+1]&(134===byte?63:31);var selectorObj=this.method.methodGetLiteral(litIndex);if("blockCopy:"!==selectorObj.bytesAsString())return!0}}return!1},nextSendSelector:function(){var selectorObj,byte=this.method.bytes[this.pc];if(this.method.methodSignFlag())if(96<=byte&&byte<=127)selectorObj=this.specialSelectors[2*(byte-96)];else if(128<=byte&&byte<=175)selectorObj=this.method.methodGetSelector(15&byte);else{if(234!=byte&&235!=byte)return null;this.method.methodGetSelector(this.method.bytes[this.pc+1]>>3)}else{if(byte<131||200==byte)return null;if(byte>=208)selectorObj=this.method.methodGetLiteral(15&byte);else if(byte>=176)selectorObj=this.specialSelectors[2*(byte-176)];else if(byte<=134){var litIndex;if(132===byte){if(this.method.bytes[this.pc+1]>>5>1)return null;litIndex=this.method.bytes[this.pc+2]}else litIndex=this.method.bytes[this.pc+1]&(134===byte?63:31);selectorObj=this.method.methodGetLiteral(litIndex)}}if(selectorObj){var selector=selectorObj.bytesAsString();if("blockCopy:"!==selector)return selector}}})),vm_interpreter}var vm_interpreter_proxy={},hasRequiredVm_interpreter_proxy;function requireVm_interpreter_proxy(){return hasRequiredVm_interpreter_proxy||(hasRequiredVm_interpreter_proxy=1,Object.subclass("Squeak.InterpreterProxy","initialization",{VM_PROXY_MAJOR:1,VM_PROXY_MINOR:11,initialize:function(vm){this.vm=vm,this.remappableOops=[],Object.defineProperty(this,"successFlag",{get:function(){return vm.primHandler.success},set:function(success){vm.primHandler.success=success}})},majorVersion:function(){return this.VM_PROXY_MAJOR},minorVersion:function(){return this.VM_PROXY_MINOR}},"success",{failed:function(){return!this.successFlag},primitiveFail:function(){this.successFlag=!1},primitiveFailFor:function(reasonCode){this.successFlag=!1},success:function(boolean){boolean||(this.successFlag=!1)}},"stack access",{pop:function(n){this.vm.popN(n)},popthenPush:function(n,obj){this.vm.popNandPush(n,obj)},push:function(obj){this.vm.push(obj)},pushBool:function(bool){this.vm.push(bool?this.vm.trueObj:this.vm.falseObj)},pushInteger:function(int){this.vm.push(int)},pushFloat:function(num){this.vm.push(this.floatObjectOf(num))},stackValue:function(n){return this.vm.stackValue(n)},stackIntegerValue:function(n){var int=this.vm.stackValue(n);return"number"==typeof int?int:(this.successFlag=!1,0)},stackFloatValue:function(n){this.vm.success=!0;var float=this.vm.stackIntOrFloat(n);return this.vm.success?float:(this.successFlag=!1,0)},stackObjectValue:function(n){var obj=this.vm.stackValue(n);return"number"!=typeof obj?obj:(this.successFlag=!1,this.vm.nilObj)},stackBytes:function(n){var oop=this.vm.stackValue(n);return oop.bytes?oop.bytes:("number"!=typeof oop&&oop.isBytes()||(this.successFlag=!1),[])},stackWords:function(n){var oop=this.vm.stackValue(n);return oop.words?oop.words:("number"!=typeof oop&&oop.isWords()||(this.successFlag=!1),[])},stackInt32Array:function(n){var oop=this.vm.stackValue(n);return oop.words?oop.wordsAsInt32Array():("number"!=typeof oop&&oop.isWords()||(this.successFlag=!1),[])},stackInt16Array:function(n){var oop=this.vm.stackValue(n);return oop.words?oop.wordsAsInt16Array():("number"!=typeof oop&&oop.isWords()||(this.successFlag=!1),[])},stackUint16Array:function(n){var oop=this.vm.stackValue(n);return oop.words?oop.wordsAsUint16Array():("number"!=typeof oop&&oop.isWords()||(this.successFlag=!1),[])}},"object access",{isBytes:function(obj){return"number"!=typeof obj&&obj.isBytes()},isWords:function(obj){return"number"!=typeof obj&&obj.isWords()},isWordsOrBytes:function(obj){return"number"!=typeof obj&&obj.isWordsOrBytes()},isPointers:function(obj){return"number"!=typeof obj&&obj.isPointers()},isIntegerValue:function(obj){return"number"==typeof obj&&obj>=-1073741824&&obj<=1073741823},isArray:function(obj){return obj.sqClass===this.vm.specialObjects[Squeak.splOb_ClassArray]},isMemberOf:function(obj,className){var nameBytes=obj.sqClass.pointers[Squeak.Class_name].bytes;if(className.length!==nameBytes.length)return!1;for(var i=0;i=array.pointers.length)return this.successFlag=!1;array.pointers[index]=obj}},"constant access",{isKindOfInteger:function(obj){return"number"==typeof obj||obj.sqClass==this.classLargeNegativeInteger()||obj.sqClass==this.classLargePositiveInteger()},classArray:function(){return this.vm.specialObjects[Squeak.splOb_ClassArray]},classBitmap:function(){return this.vm.specialObjects[Squeak.splOb_ClassBitmap]},classSmallInteger:function(){return this.vm.specialObjects[Squeak.splOb_ClassInteger]},classLargePositiveInteger:function(){return this.vm.specialObjects[Squeak.splOb_ClassLargePositiveInteger]},classLargeNegativeInteger:function(){return this.vm.specialObjects[Squeak.splOb_ClassLargeNegativeInteger]},classPoint:function(){return this.vm.specialObjects[Squeak.splOb_ClassPoint]},classString:function(){return this.vm.specialObjects[Squeak.splOb_ClassString]},classByteArray:function(){return this.vm.specialObjects[Squeak.splOb_ClassByteArray]},nilObject:function(){return this.vm.nilObj},falseObject:function(){return this.vm.falseObj},trueObject:function(){return this.vm.trueObj}},"vm functions",{clone:function(object){return this.vm.image.clone(object)},instantiateClassindexableSize:function(aClass,indexableSize){return this.vm.instantiateClass(aClass,indexableSize)},methodArgumentCount:function(){return this.argCount},makePointwithxValueyValue:function(x,y){return this.vm.primHandler.makePointWithXandY(x,y)},pushRemappableOop:function(obj){this.remappableOops.push(obj)},popRemappableOop:function(){return this.remappableOops.pop()},showDisplayBitsLeftTopRightBottom:function(form,left,top,right,bottom){if(left13)throw Error("unusedBytecode")}return 8===type?this.interpretExtension(offset,method,client):9===type?offset<8?client.jump(offset+1):client.jumpIf(!1,offset-8+1):10===type?(byte=this.method.bytes[this.pc++],offset<8?client.jump(256*(offset-4)+byte):client.jumpIf(offset<12,256*(3&offset)+byte)):11===type?client.send(this.vm.specialSelectors[2*offset],this.vm.specialSelectors[2*offset+1],!1):12===type?client.send(this.vm.specialSelectors[2*(offset+16)],this.vm.specialSelectors[2*(offset+16)+1],!1):type>12?client.send(method.methodGetLiteral(offset),type-13,!1):void 0},interpretExtension:function(offset,method,client){if(offset<=6){var byte2=this.method.bytes[this.pc++];if(offset<=2){var type=byte2/64|0,offset2=byte2%64;if(0===offset){if(0===type)return client.pushReceiverVariable(offset2);if(1===type)return client.pushTemporaryVariable(offset2);if(2===type)return client.pushConstant(this.method.methodGetLiteral(offset2));if(3===type)return client.pushLiteralVariable(this.method.methodGetLiteral(offset2))}if(1===offset){if(0===type)return client.storeIntoReceiverVariable(offset2);if(1===type)return client.storeIntoTemporaryVariable(offset2);if(2===type)throw Error("illegalStore");if(3===type)return client.storeIntoLiteralVariable(this.method.methodGetLiteral(offset2))}if(2===offset){if(0===type)return client.popIntoReceiverVariable(offset2);if(1===type)return client.popIntoTemporaryVariable(offset2);if(2===type)throw Error("illegalStore");if(3===type)return client.popIntoLiteralVariable(this.method.methodGetLiteral(offset2))}}if(3===offset)return client.send(this.method.methodGetLiteral(byte2%32),byte2/32|0,!1);if(4===offset){var byte3=this.method.bytes[this.pc++];if(0===(type=byte2/32|0))return client.send(this.method.methodGetLiteral(byte3),byte2%32,!1);if(1===type)return client.send(this.method.methodGetLiteral(byte3),byte2%32,!0);if(2===type)return client.pushReceiverVariable(byte3);if(3===type)return client.pushConstant(this.method.methodGetLiteral(byte3));if(4===type)return client.pushLiteralVariable(this.method.methodGetLiteral(byte3));if(5===type)return client.storeIntoReceiverVariable(byte3);if(6===type)return client.popIntoReceiverVariable(byte3);if(7===type)return client.storeIntoLiteralVariable(this.method.methodGetLiteral(byte3))}if(5===offset)return client.send(this.method.methodGetLiteral(31&byte2),byte2>>5,!0);if(6===offset)return client.send(this.method.methodGetLiteral(63&byte2),byte2>>6,!1)}if(7===offset)return client.doPop();if(8===offset)return client.doDup();if(9===offset)return client.pushActiveContext();byte2=this.method.bytes[this.pc++];if(10===offset)return byte2<128?client.pushNewArray(byte2):client.popIntoNewArray(byte2-128);byte3=this.method.bytes[this.pc++];if(11===offset)return client.callPrimitive(byte2+256*byte3);if(12===offset)return client.pushRemoteTemp(byte2,byte3);if(13===offset)return client.storeIntoRemoteTemp(byte2,byte3);if(14===offset)return client.popIntoRemoteTemp(byte2,byte3);var byte4=this.method.bytes[this.pc++];return client.pushClosureCopy(byte2>>4,15&byte2,256*byte3+byte4)}})),vm_instruction_stream}var vm_instruction_stream_sista={},hasRequiredVm_instruction_stream_sista;function requireVm_instruction_stream_sista(){return hasRequiredVm_instruction_stream_sista||(hasRequiredVm_instruction_stream_sista=1,Squeak.InstructionStream.subclass("Squeak.InstructionStreamSista","decoding",{interpretNextInstructionFor:function(client){return this.interpretNextInstructionExtFor(client,0,0)},interpretNextInstructionExtFor:function(client,extA,extB){this.Squeak;var b=this.method.bytes[this.pc++];switch(b){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9:case 10:case 11:case 12:case 13:case 14:case 15:return client.pushReceiverVariable(15&b);case 16:case 17:case 18:case 19:case 20:case 21:case 22:case 23:case 24:case 25:case 26:case 27:case 28:case 29:case 30:case 31:return client.pushLiteralVariable(this.method.methodGetLiteral(15&b));case 32:case 33:case 34:case 35:case 36:case 37:case 38:case 39:case 40:case 41:case 42:case 43:case 44:case 45:case 46:case 47:case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:case 58:case 59:case 60:case 61:case 62:case 63:return client.pushConstant(this.method.methodGetLiteral(31&b));case 64:case 65:case 66:case 67:case 68:case 69:case 70:case 71:return client.pushTemporaryVariable(15&b);case 72:case 73:case 74:case 75:return client.pushTemporaryVariable(8+(3&b));case 76:return client.pushReceiver();case 77:return client.pushConstant(this.vm.trueObj);case 78:return client.pushConstant(this.vm.falseObj);case 79:return client.pushConstant(this.vm.nilObj);case 80:return client.pushConstant(0);case 81:return client.pushConstant(1);case 82:return client.pushActiveContext();case 83:return client.doDup();case 88:return client.methodReturnReceiver();case 89:return client.methodReturnConstant(this.vm.trueObj);case 90:return client.methodReturnConstant(this.vm.falseObj);case 91:return client.methodReturnConstant(this.vm.nilObj);case 92:return client.methodReturnTop();case 93:return client.blockReturnConstant(this.vm.nilObj);case 94:if(0===extA)return client.blockReturnTop();break;case 95:return client.nop();case 96:case 97:case 98:case 99:case 100:case 101:case 102:case 103:case 104:case 105:case 106:case 107:case 108:case 109:case 110:case 111:case 112:case 113:case 114:case 115:case 116:case 117:case 118:case 119:case 120:case 121:case 122:case 123:case 124:case 125:case 126:case 127:return client.send(this.vm.specialSelectors[2*(b-96)],this.vm.specialSelectors[2*(b-96)+1],!1);case 128:case 129:case 130:case 131:case 132:case 133:case 134:case 135:case 136:case 137:case 138:case 139:case 140:case 141:case 142:case 143:return client.send(this.method.methodGetLiteral(15&b),0,!1);case 144:case 145:case 146:case 147:case 148:case 149:case 150:case 151:case 152:case 153:case 154:case 155:case 156:case 157:case 158:case 159:return client.send(this.method.methodGetLiteral(15&b),1,!1);case 160:case 161:case 162:case 163:case 164:case 165:case 166:case 167:case 168:case 169:case 170:case 171:case 172:case 173:case 174:case 175:return client.send(this.method.methodGetLiteral(15&b),2,!1);case 176:case 177:case 178:case 179:case 180:case 181:case 182:case 183:return client.jump(1+(7&b));case 184:case 185:case 186:case 187:case 188:case 189:case 190:case 191:return client.jumpIf(!0,1+(7&b));case 192:case 193:case 194:case 195:case 196:case 197:case 198:case 199:return client.jumpIf(!1,1+(7&b));case 200:case 201:case 202:case 203:case 204:case 205:case 206:case 207:return client.popIntoReceiverVariable(7&b);case 208:case 209:case 210:case 211:case 212:case 213:case 214:case 215:return client.popIntoTemporaryVariable(b-208);case 216:return client.doPop()}var b2=this.method.bytes[this.pc++];switch(b){case 224:return this.interpretNextInstructionExtFor(client,(extA<<8)+b2,extB);case 225:return this.interpretNextInstructionExtFor(client,extA,(extB<<8)+(b2<128?b2:b2-256));case 226:return client.pushReceiverVariable(b2+(extA<<8));case 227:return client.pushLiteralVariable(this.method.methodGetLiteral(b2+(extA<<8)));case 228:return client.pushConstant(this.method.methodGetLiteral(b2+(extA<<8)));case 229:return client.pushTemporaryVariable(b2);case 231:return b2<128?client.pushNewArray(b2):client.popIntoNewArray(b2-128);case 232:return client.pushConstant(b2+(extB<<8));case 233:var unicode=b2+(extB<<8);return client.pushConstant("$"+String.fromCodePoint(unicode)+" ("+unicode+")");case 234:return client.send(this.method.methodGetSelector((b2>>3)+(extA<<5)),(7&b2)+(extB<<3),!1);case 235:var literal=this.method.methodGetSelector((b2>>3)+(extA<<5));return extB>=64?client.sendSuperDirected(literal):client.send(literal,(7&b2)+(extB<<3),!0);case 237:return client.jump(b2+(extB<<8));case 238:return client.jumpIf(!0,b2+(extB<<8));case 239:return client.jumpIf(!1,b2+(extB<<8));case 240:return client.popIntoReceiverVariable(b2+(extA<<8));case 241:return client.popIntoLiteralVariable(this.method.methodGetLiteral(b2+(extA<<8)));case 242:return client.popIntoTemporaryVariable(b2);case 243:return client.storeIntoReceiverVariable(b2+(extA<<8));case 244:return client.storeIntoLiteralVariable(this.method.methodGetLiteral(b2+(extA<<8)));case 245:return client.storeIntoTemporaryVariable(b2)}var b3=this.method.bytes[this.pc++];switch(b){case 248:return client.callPrimitive(b2+(b3<<8));case 249:var literalIndex=b2+(extA<<8),numCopied=63&b3,compiledBlock=this.method.methodGetLiteral(literalIndex);return client.pushFullClosure(literalIndex,numCopied,compiledBlock.methodNumArgs());case 250:var numArgs=(7&b2)+8*this.mod(extA,16),blockSize=(numCopied=(b2>>3&7)+8*this.div(extA,16),b3+(extB<<8));return client.pushClosureCopy(numCopied,numArgs,blockSize);case 251:return client.pushRemoteTemp(b2,b3);case 252:return client.storeIntoRemoteTemp(b2,b3);case 253:return client.popIntoRemoteTemp(b2,b3)}throw Error("Unknown bytecode: "+b)}})),vm_instruction_stream_sista}var vm_instruction_printer={},hasRequiredVm_instruction_printer;function requireVm_instruction_printer(){return hasRequiredVm_instruction_printer||(hasRequiredVm_instruction_printer=1,Object.subclass("Squeak.InstructionPrinter","initialization",{initialize:function(method,vm){this.method=method,this.vm=vm}},"printing",{printInstructions:function(indent,highlight,highlightPC){this.indent=indent,this.highlight=highlight,this.highlightPC=highlightPC,this.innerIndents={},this.result="",this.scanner=this.method.methodSignFlag()?new Squeak.InstructionStreamSista(this.method,this.vm):new Squeak.InstructionStream(this.method,this.vm),this.oldPC=this.scanner.pc,this.endPC=0,this.done=!1;try{for(;!this.done;)this.scanner.interpretNextInstructionFor(this)}catch(ex){this.print("!!! "+ex.message)}return this.result},print:function(instruction){this.oldPC===this.highlightPC?this.highlight&&(this.result+=this.highlight):this.indent&&(this.result+=this.indent),this.result+=this.oldPC;for(var i=0;ithis.oldPC&&(this.result+=" "),this.result+=(this.method.bytes[i]+256).toString(16).substr(-2).toUpperCase();this.result+="> "+instruction+"\n",this.oldPC=this.scanner.pc}},"decoding",{blockReturnConstant:function(obj){this.print("blockReturn: "+obj.toString()),this.done=this.scanner.pc>this.endPC},blockReturnTop:function(){this.print("blockReturn"),this.done=this.scanner.pc>this.endPC},doDup:function(){this.print("dup")},doPop:function(){this.print("pop")},jump:function(offset){this.print("jumpTo: "+(this.scanner.pc+offset)),this.scanner.pc+offset>this.endPC&&(this.endPC=this.scanner.pc+offset)},jumpIf:function(condition,offset){this.print((condition?"jumpIfTrue: ":"jumpIfFalse: ")+(this.scanner.pc+offset)),this.scanner.pc+offset>this.endPC&&(this.endPC=this.scanner.pc+offset)},methodReturnReceiver:function(){this.print("return: receiver"),this.done=this.scanner.pc>this.endPC},methodReturnTop:function(){this.print("return: topOfStack"),this.done=this.scanner.pc>this.endPC},methodReturnConstant:function(obj){this.print("returnConst: "+obj.toString()),this.done=this.scanner.pc>this.endPC},nop:function(){this.print("nop")},popIntoLiteralVariable:function(anAssociation){this.print("popIntoBinding: "+anAssociation.assnKeyAsString())},popIntoReceiverVariable:function(offset){this.print("popIntoInstVar: "+offset)},popIntoTemporaryVariable:function(offset){this.print("popIntoTemp: "+offset)},pushActiveContext:function(){this.print("push: thisContext")},pushConstant:function(obj){var value=obj.sqInstName?obj.sqInstName():obj.toString();this.print("pushConst: "+value)},pushLiteralVariable:function(anAssociation){this.print("pushBinding: "+anAssociation.assnKeyAsString())},pushReceiver:function(){this.print("push: self")},pushReceiverVariable:function(offset){this.print("pushInstVar: "+offset)},pushTemporaryVariable:function(offset){this.print("pushTemp: "+offset)},send:function(selector,numberArguments,supered){this.print((supered?"superSend: #":"send: #")+(selector.bytesAsString?selector.bytesAsString():selector))},sendSuperDirected:function(selector){this.print("directedSuperSend: #"+(selector.bytesAsString?selector.bytesAsString():selector))},storeIntoLiteralVariable:function(anAssociation){this.print("storeIntoBinding: "+anAssociation.assnKeyAsString())},storeIntoReceiverVariable:function(offset){this.print("storeIntoInstVar: "+offset)},storeIntoTemporaryVariable:function(offset){this.print("storeIntoTemp: "+offset)},pushNewArray:function(size){this.print("push: (Array new: "+size+")")},popIntoNewArray:function(numElements){this.print("pop: "+numElements+" into: (Array new: "+numElements+")")},pushRemoteTemp:function(offset,arrayOffset){this.print("push: "+offset+" ofTemp: "+arrayOffset)},storeIntoRemoteTemp:function(offset,arrayOffset){this.print("storeInto: "+offset+" ofTemp: "+arrayOffset)},popIntoRemoteTemp:function(offset,arrayOffset){this.print("popInto: "+offset+" ofTemp: "+arrayOffset)},pushClosureCopy:function(numCopied,numArgs,blockSize){var from=this.scanner.pc,to=from+blockSize;this.print("closure("+from+"-"+(to-1)+"): "+numCopied+" copied, "+numArgs+" args");for(var i=from;ithis.endPC&&(this.endPC=to)},pushFullClosure:function(literalIndex,numCopied,numArgs){this.print("pushFullClosure: (self literalAt: "+(literalIndex+1)+") numCopied: "+numCopied+" numArgs: "+numArgs)},callPrimitive:function(primitiveIndex){this.print("primitive: "+primitiveIndex)}})),vm_instruction_printer}var vm_primitives={},hasRequiredVm_primitives;function requireVm_primitives(){return hasRequiredVm_primitives||(hasRequiredVm_primitives=1,Object.subclass("Squeak.Primitives","initialization",{initialize:function(vm,display){this.vm=vm,this.oldPrims=!this.vm.image.hasClosures,this.allowAccessBeyondSP=this.oldPrims,this.deferDisplayUpdates=!1,this.semaphoresToSignal=[],this.initDisplay(display),this.initAtCache(),this.initModules(),this.initPlugins(),vm.image.isSpur&&(this.charFromInt=this.charFromIntSpur,this.charToInt=this.charToIntSpur,this.identityHash=this.identityHashSpur)},initDisplay:function(display){this.display=display},initModules:function(){this.loadedModules={},this.builtinModules={},this.patchModules={},this.interpreterProxy=new Squeak.InterpreterProxy(this.vm)},initPlugins:function(){}},"dispatch",{quickSendOther:function(rcvr,lobits){switch(this.success=!0,lobits){case 0:return this.popNandPushIfOK(2,this.objectAt(!0,!0,!1));case 1:return this.popNandPushIfOK(3,this.objectAtPut(!0,!0,!1));case 2:return this.popNandPushIfOK(1,this.objectSize(!0));case 6:return this.popNandPushBoolIfOK(2,this.vm.stackValue(1)===this.vm.stackValue(0));case 7:return this.popNandPushIfOK(1,this.vm.getClass(this.vm.top()));case 8:return this.popNandPushIfOK(2,this.doBlockCopy());case 9:return this.primitiveBlockValue(0);case 10:return this.primitiveBlockValue(1)}return!1},doPrimitive:function(index,argCount,primMethod){switch(this.success=!0,index){case 1:return this.popNandPushIntIfOK(argCount+1,this.stackInteger(1)+this.stackInteger(0));case 2:return this.popNandPushIntIfOK(argCount+1,this.stackInteger(1)-this.stackInteger(0));case 3:return this.popNandPushBoolIfOK(argCount+1,this.stackInteger(1)this.stackInteger(0));case 5:return this.popNandPushBoolIfOK(argCount+1,this.stackInteger(1)<=this.stackInteger(0));case 6:return this.popNandPushBoolIfOK(argCount+1,this.stackInteger(1)>=this.stackInteger(0));case 7:return this.popNandPushBoolIfOK(argCount+1,this.stackInteger(1)===this.stackInteger(0));case 8:return this.popNandPushBoolIfOK(argCount+1,this.stackInteger(1)!==this.stackInteger(0));case 9:return this.popNandPushIntIfOK(argCount+1,this.stackInteger(1)*this.stackInteger(0));case 10:return this.popNandPushIntIfOK(argCount+1,this.vm.quickDivide(this.stackInteger(1),this.stackInteger(0)));case 11:return this.popNandPushIntIfOK(argCount+1,this.vm.mod(this.stackInteger(1),this.stackInteger(0)));case 12:return this.popNandPushIntIfOK(argCount+1,this.vm.div(this.stackInteger(1),this.stackInteger(0)));case 13:return this.popNandPushIntIfOK(argCount+1,this.stackInteger(1)/this.stackInteger(0)|0);case 14:return this.popNandPushIfOK(argCount+1,this.doBitAnd());case 15:return this.popNandPushIfOK(argCount+1,this.doBitOr());case 16:return this.popNandPushIfOK(argCount+1,this.doBitXor());case 17:return this.popNandPushIfOK(argCount+1,this.doBitShift());case 18:return this.primitiveMakePoint(argCount,!1);case 19:return!1;case 20:return this.primitiveRemLargeIntegers(argCount);case 21:return this.primitiveAddLargeIntegers(argCount);case 22:return this.primitiveSubtractLargeIntegers(argCount);case 23:return this.primitiveLessThanLargeIntegers(argCount);case 24:return this.primitiveGreaterThanLargeIntegers(argCount);case 25:return this.primitiveLessOrEqualLargeIntegers(argCount);case 26:return this.primitiveGreaterOrEqualLargeIntegers(argCount);case 27:return this.primitiveEqualLargeIntegers(argCount);case 28:return this.primitiveNotEqualLargeIntegers(argCount);case 29:return this.primitiveMultiplyLargeIntegers(argCount);case 30:return this.primitiveDivideLargeIntegers(argCount);case 31:return this.primitiveModLargeIntegers(argCount);case 32:return this.primitiveDivLargeIntegers(argCount);case 33:return this.primitiveQuoLargeIntegers(argCount);case 34:return this.vm.warnOnce("missing primitive: 34 (primitiveBitAndLargeIntegers)"),!1;case 35:return this.vm.warnOnce("missing primitive: 35 (primitiveBitOrLargeIntegers)"),!1;case 36:return this.vm.warnOnce("missing primitive: 36 (primitiveBitXorLargeIntegers)"),!1;case 37:return this.vm.warnOnce("missing primitive: 37 (primitiveBitShiftLargeIntegers)"),!1;case 38:return this.popNandPushIfOK(argCount+1,this.objectAt(!1,!1,!1));case 39:return this.popNandPushIfOK(argCount+1,this.objectAtPut(!1,!1,!1));case 40:return this.popNandPushFloatIfOK(argCount+1,this.stackInteger(0));case 41:return this.popNandPushFloatIfOK(argCount+1,this.stackFloat(1)+this.stackFloat(0));case 42:return this.popNandPushFloatIfOK(argCount+1,this.stackFloat(1)-this.stackFloat(0));case 43:return this.popNandPushBoolIfOK(argCount+1,this.stackFloat(1)this.stackFloat(0));case 45:return this.popNandPushBoolIfOK(argCount+1,this.stackFloat(1)<=this.stackFloat(0));case 46:return this.popNandPushBoolIfOK(argCount+1,this.stackFloat(1)>=this.stackFloat(0));case 47:return this.popNandPushBoolIfOK(argCount+1,this.stackFloat(1)===this.stackFloat(0));case 48:return this.popNandPushBoolIfOK(argCount+1,this.stackFloat(1)!==this.stackFloat(0));case 49:return this.popNandPushFloatIfOK(argCount+1,this.stackFloat(1)*this.stackFloat(0));case 50:return this.popNandPushFloatIfOK(argCount+1,this.safeFDiv(this.stackFloat(1),this.stackFloat(0)));case 51:return this.popNandPushIfOK(argCount+1,this.floatAsSmallInt(this.stackFloat(0)));case 52:return this.popNandPushFloatIfOK(argCount+1,this.floatFractionPart(this.stackFloat(0)));case 53:return this.popNandPushIntIfOK(argCount+1,this.frexp_exponent(this.stackFloat(0))-1);case 54:return this.popNandPushFloatIfOK(argCount+1,this.ldexp(this.stackFloat(1),this.stackFloat(0)));case 55:return this.popNandPushFloatIfOK(argCount+1,Math.sqrt(this.stackFloat(0)));case 56:return this.popNandPushFloatIfOK(argCount+1,Math.sin(this.stackFloat(0)));case 57:return this.popNandPushFloatIfOK(argCount+1,Math.atan(this.stackFloat(0)));case 58:return this.popNandPushFloatIfOK(argCount+1,Math.log(this.stackFloat(0)));case 59:return this.popNandPushFloatIfOK(argCount+1,Math.exp(this.stackFloat(0)));case 60:return this.popNandPushIfOK(argCount+1,this.objectAt(!1,!1,!1));case 61:return this.popNandPushIfOK(argCount+1,this.objectAtPut(!1,!1,!1));case 62:return this.popNandPushIfOK(argCount+1,this.objectSize(!1));case 63:return this.popNandPushIfOK(argCount+1,this.objectAt(!1,!0,!1));case 64:return this.popNandPushIfOK(argCount+1,this.objectAtPut(!1,!0,!1));case 65:return this.vm.warnOnce("missing primitive: 65 (primitiveNext)"),!1;case 66:return this.vm.warnOnce("missing primitive: 66 (primitiveNextPut)"),!1;case 67:return this.vm.warnOnce("missing primitive: 67 (primitiveAtEnd)"),!1;case 68:return this.popNandPushIfOK(argCount+1,this.objectAt(!1,!1,!0));case 69:return this.popNandPushIfOK(argCount+1,this.objectAtPut(!1,!1,!0));case 70:return this.popNandPushIfOK(argCount+1,this.instantiateClass(this.stackNonInteger(0),0));case 71:return this.popNandPushIfOK(argCount+1,this.instantiateClass(this.stackNonInteger(1),this.stackPos32BitInt(0)));case 72:return this.primitiveArrayBecome(argCount,!1,!0);case 73:return this.popNandPushIfOK(argCount+1,this.objectAt(!1,!1,!0));case 74:return this.popNandPushIfOK(argCount+1,this.objectAtPut(!1,!1,!0));case 75:return this.popNandPushIfOK(argCount+1,this.identityHash(this.stackNonInteger(0)));case 76:return this.primitiveStoreStackp(argCount);case 77:return this.popNandPushIfOK(argCount+1,this.someInstanceOf(this.stackNonInteger(0)));case 78:return this.popNandPushIfOK(argCount+1,this.nextInstanceAfter(this.stackNonInteger(0)));case 79:return this.primitiveNewMethod(argCount);case 80:return this.popNandPushIfOK(argCount+1,this.doBlockCopy());case 81:return this.primitiveBlockValue(argCount);case 82:return this.primitiveBlockValueWithArgs(argCount);case 83:return this.vm.primitivePerform(argCount);case 84:return this.vm.primitivePerformWithArgs(argCount,!1);case 85:return this.primitiveSignal();case 86:return this.primitiveWait();case 87:return this.primitiveResume();case 88:return this.primitiveSuspend();case 89:return this.vm.flushMethodCache();case 90:return this.primitiveMousePoint(argCount);case 91:return this.primitiveTestDisplayDepth(argCount);case 92:return this.vm.warnOnce("missing primitive: 92 (primitiveSetDisplayMode)"),!1;case 93:return this.primitiveInputSemaphore(argCount);case 94:return this.primitiveGetNextEvent(argCount);case 95:return this.primitiveInputWord(argCount);case 96:return this.namedPrimitive("BitBltPlugin","primitiveCopyBits",argCount);case 97:return this.primitiveSnapshot(argCount);case 98:return this.primitiveStoreImageSegment(argCount);case 99:return this.primitiveLoadImageSegment(argCount);case 100:return this.vm.primitivePerformWithArgs(argCount,!0);case 101:return this.primitiveBeCursor(argCount);case 102:return this.primitiveBeDisplay(argCount);case 103:return this.primitiveScanCharacters(argCount);case 104:return this.vm.warnOnce("missing primitive: 104 (primitiveDrawLoop)"),!1;case 105:return this.popNandPushIfOK(argCount+1,this.doStringReplace());case 106:return this.primitiveScreenSize(argCount);case 107:return this.primitiveMouseButtons(argCount);case 108:return this.primitiveKeyboardNext(argCount);case 109:return this.primitiveKeyboardPeek(argCount);case 110:return this.popNandPushBoolIfOK(argCount+1,this.vm.stackValue(1)===this.vm.stackValue(0));case 111:return this.popNandPushIfOK(argCount+1,this.vm.getClass(this.vm.top()));case 112:return this.popNandPushIfOK(argCount+1,this.vm.image.bytesLeft());case 113:return this.primitiveQuit(argCount);case 114:return this.primitiveExitToDebugger(argCount);case 115:return this.primitiveChangeClass(argCount);case 116:return this.vm.flushMethodCacheForMethod(this.vm.top());case 117:return this.doNamedPrimitive(argCount,primMethod);case 118:return this.primitiveDoPrimitiveWithArgs(argCount);case 119:return this.vm.flushMethodCacheForSelector(this.vm.top());case 120:return this.primitiveCalloutToFFI(argCount,primMethod);case 121:return this.primitiveImageName(argCount);case 122:return this.primitiveReverseDisplay(argCount);case 123:return this.vm.warnOnce("missing primitive: 123 (primitiveValueUninterruptably)"),!1;case 124:return this.popNandPushIfOK(argCount+1,this.registerSemaphore(Squeak.splOb_TheLowSpaceSemaphore));case 125:return this.popNandPushIfOK(argCount+1,this.setLowSpaceThreshold());case 126:return this.primitiveDeferDisplayUpdates(argCount);case 127:return this.primitiveShowDisplayRect(argCount);case 128:return this.primitiveArrayBecome(argCount,!0,!0);case 129:return this.popNandPushIfOK(argCount+1,this.vm.image.specialObjectsArray);case 130:return this.primitiveFullGC(argCount);case 131:return this.primitivePartialGC(argCount);case 132:return this.popNandPushBoolIfOK(argCount+1,this.pointsTo(this.stackNonInteger(1),this.vm.top()));case 133:return this.popNIfOK(argCount);case 134:return this.popNandPushIfOK(argCount+1,this.registerSemaphore(Squeak.splOb_TheInterruptSemaphore));case 135:return this.popNandPushIfOK(argCount+1,this.millisecondClockValue());case 136:return this.primitiveSignalAtMilliseconds(argCount);case 137:return this.popNandPushIfOK(argCount+1,this.secondClock());case 138:return this.popNandPushIfOK(argCount+1,this.someObject());case 139:return this.popNandPushIfOK(argCount+1,this.nextObject(this.vm.top()));case 140:return this.primitiveBeep(argCount);case 141:return this.primitiveClipboardText(argCount);case 142:return this.popNandPushIfOK(argCount+1,this.makeStString(this.filenameToSqueak(Squeak.vmPath)));case 143:case 144:return this.primitiveShortAtAndPut(argCount);case 145:return this.primitiveConstantFill(argCount);case 146:return this.namedPrimitive("JoystickTabletPlugin","primitiveReadJoystick",argCount);case 147:return this.namedPrimitive("BitBltPlugin","primitiveWarpBits",argCount);case 148:return this.popNandPushIfOK(argCount+1,this.vm.image.clone(this.vm.top()));case 149:return this.primitiveGetAttribute(argCount);case 150:if(this.oldPrims)return this.primitiveFileAtEnd(argCount);case 151:if(this.oldPrims)return this.primitiveFileClose(argCount);case 152:if(this.oldPrims)return this.primitiveFileGetPosition(argCount);case 153:if(this.oldPrims)return this.primitiveFileOpen(argCount);case 154:if(this.oldPrims)return this.primitiveFileRead(argCount);case 155:if(this.oldPrims)return this.primitiveFileSetPosition(argCount);case 156:if(this.oldPrims)return this.primitiveFileDelete(argCount);case 157:if(this.oldPrims)return this.primitiveFileSize(argCount);break;case 158:return this.oldPrims?this.primitiveFileWrite(argCount):(this.vm.warnOnce("missing primitive: 158 (primitiveCompareWith)"),!1);case 159:return this.oldPrims?this.primitiveFileRename(argCount):this.popNandPushIntIfOK(argCount+1,1664525*this.stackSigned53BitInt(0)&268435455);case 160:return this.oldPrims?this.primitiveDirectoryCreate(argCount):this.primitiveAdoptInstance(argCount);case 161:return this.oldPrims?this.primitiveDirectoryDelimitor(argCount):(this.vm.warnOnce("missing primitive: 161 (primitiveSetIdentityHash)"),!1);case 162:if(this.oldPrims)return this.primitiveDirectoryLookup(argCount);break;case 163:return this.oldPrims?this.primitiveDirectoryDelete(argCount):(this.vm.warnOnce("missing primitive: 163 (primitiveGetImmutability)"),!1);case 164:return this.popNandPushIfOK(argCount+1,this.vm.trueObj);case 165:case 166:return this.primitiveIntegerAtAndPut(argCount);case 167:return!1;case 168:return this.primitiveCopyObject(argCount);case 169:return this.oldPrims?this.primitiveDirectorySetMacTypeAndCreator(argCount):this.popNandPushBoolIfOK(argCount+1,this.vm.stackValue(1)!==this.vm.stackValue(0));case 170:return this.oldPrims?this.namedPrimitive("SoundPlugin","primitiveSoundStart",argCount):this.primitiveAsCharacter(argCount);case 171:return this.oldPrims?this.namedPrimitive("SoundPlugin","primitiveSoundStartWithSemaphore",argCount):this.popNandPushIfOK(argCount+1,this.stackNonInteger(0).hash);case 172:return this.oldPrims?this.namedPrimitive("SoundPlugin","primitiveSoundStop",argCount):(this.vm.warnOnce("missing primitive: 172 (primitiveFetchMourner)"),this.popNandPushIfOK(argCount,this.vm.nilObj));case 173:return this.oldPrims?this.namedPrimitive("SoundPlugin","primitiveSoundAvailableSpace",argCount):this.popNandPushIfOK(argCount+1,this.objectAt(!1,!1,!0));case 174:return this.oldPrims?this.namedPrimitive("SoundPlugin","primitiveSoundPlaySamples",argCount):this.popNandPushIfOK(argCount+1,this.objectAtPut(!1,!1,!0));case 175:return this.oldPrims?this.namedPrimitive("SoundPlugin","primitiveSoundPlaySilence",argCount):this.vm.image.isSpur?this.popNandPushIfOK(argCount+1,this.behaviorHash(this.stackNonInteger(0))):(this.vm.warnOnce("primitive 175 called in non-spur image"),this.popNandPushIfOK(argCount+1,this.identityHash(this.stackNonInteger(0))));case 176:return this.oldPrims?this.namedPrimitive("SoundGenerationPlugin","primWaveTableSoundmixSampleCountintostartingAtpan",argCount):this.popNandPushIfOK(argCount+1,this.vm.image.isSpur?4194303:4095);case 177:return this.oldPrims?this.namedPrimitive("SoundGenerationPlugin","primFMSoundmixSampleCountintostartingAtpan",argCount):this.popNandPushIfOK(argCount+1,this.allInstancesOf(this.stackNonInteger(0)));case 178:return!!this.oldPrims&&this.namedPrimitive("SoundGenerationPlugin","primPluckedSoundmixSampleCountintostartingAtpan",argCount);case 179:if(this.oldPrims)return this.namedPrimitive("SoundGenerationPlugin","primSampledSoundmixSampleCountintostartingAtpan",argCount);break;case 180:return!!this.oldPrims&&this.namedPrimitive("SoundGenerationPlugin","primitiveMixFMSound",argCount);case 181:return this.oldPrims?this.namedPrimitive("SoundGenerationPlugin","primitiveMixPluckedSound",argCount):this.primitiveSizeInBytesOfInstance(argCount);case 182:return this.oldPrims?this.namedPrimitive("SoundGenerationPlugin","oldprimSampledSoundmixSampleCountintostartingAtleftVolrightVol",argCount):this.primitiveSizeInBytes(argCount);case 183:return this.oldPrims?this.namedPrimitive("SoundGenerationPlugin","primitiveApplyReverb",argCount):this.primitiveIsPinned(argCount);case 184:return this.oldPrims?this.namedPrimitive("SoundGenerationPlugin","primitiveMixLoopedSampledSound",argCount):this.primitivePin(argCount);case 185:return this.oldPrims?this.namedPrimitive("SoundGenerationPlugin","primitiveMixSampledSound",argCount):this.primitiveExitCriticalSection(argCount);case 186:if(this.oldPrims)break;return this.primitiveEnterCriticalSection(argCount);case 187:if(this.oldPrims)break;return this.primitiveTestAndSetOwnershipOfCriticalSection(argCount);case 188:if(this.oldPrims)break;return this.primitiveExecuteMethodArgsArray(argCount);case 189:return!!this.oldPrims&&this.namedPrimitive("SoundPlugin","primitiveSoundInsertSamples",argCount);case 190:if(this.oldPrims)return this.namedPrimitive("SoundPlugin","primitiveSoundStartRecording",argCount);case 191:if(this.oldPrims)return this.namedPrimitive("SoundPlugin","primitiveSoundStopRecording",argCount);case 192:if(this.oldPrims)return this.namedPrimitive("SoundPlugin","primitiveSoundGetRecordingSampleRate",argCount);case 193:if(this.oldPrims)return this.namedPrimitive("SoundPlugin","primitiveSoundRecordSamples",argCount);case 194:if(this.oldPrims)return this.namedPrimitive("SoundPlugin","primitiveSoundSetRecordLevel",argCount);break;case 195:case 196:case 197:case 198:case 199:return!1;case 200:return this.oldPrims?this.namedPrimitive("SocketPlugin","primitiveInitializeNetwork",argCount):this.primitiveClosureCopyWithCopiedValues(argCount);case 201:return this.oldPrims?this.namedPrimitive("SocketPlugin","primitiveResolverStartNameLookup",argCount):this.primitiveClosureValue(argCount);case 202:return this.oldPrims?this.namedPrimitive("SocketPlugin","primitiveResolverNameLookupResult",argCount):this.primitiveClosureValue(argCount);case 203:return this.oldPrims?this.namedPrimitive("SocketPlugin","primitiveResolverStartAddressLookup",argCount):this.primitiveClosureValue(argCount);case 204:return this.oldPrims?this.namedPrimitive("SocketPlugin","primitiveResolverAddressLookupResult",argCount):this.primitiveClosureValue(argCount);case 205:return this.oldPrims?this.namedPrimitive("SocketPlugin","primitiveResolverAbortLookup",argCount):this.primitiveClosureValue(argCount);case 206:return this.oldPrims?this.namedPrimitive("SocketPlugin","primitiveResolverLocalAddress",argCount):this.primitiveClosureValueWithArgs(argCount);case 207:return this.oldPrims?this.namedPrimitive("SocketPlugin","primitiveResolverStatus",argCount):this.primitiveFullClosureValue(argCount);case 208:return this.oldPrims?this.namedPrimitive("SocketPlugin","primitiveResolverError",argCount):this.primitiveFullClosureValueWithArgs(argCount);case 209:return this.oldPrims?this.namedPrimitive("SocketPlugin","primitiveSocketCreate",argCount):this.primitiveFullClosureValueNoContextSwitch(argCount);case 210:return this.oldPrims?this.namedPrimitive("SocketPlugin","primitiveSocketDestroy",argCount):this.popNandPushIfOK(argCount+1,this.objectAt(!1,!1,!1));case 211:return this.oldPrims?this.namedPrimitive("SocketPlugin","primitiveSocketConnectionStatus",argCount):this.popNandPushIfOK(argCount+1,this.objectAtPut(!1,!1,!1));case 212:return this.oldPrims?this.namedPrimitive("SocketPlugin","primitiveSocketError",argCount):this.popNandPushIfOK(argCount+1,this.objectSize(!1));case 213:if(this.oldPrims)return this.namedPrimitive("SocketPlugin","primitiveSocketLocalAddress",argCount);case 214:if(this.oldPrims)return this.namedPrimitive("SocketPlugin","primitiveSocketLocalPort",argCount);case 215:if(this.oldPrims)return this.namedPrimitive("SocketPlugin","primitiveSocketRemoteAddress",argCount);case 216:if(this.oldPrims)return this.namedPrimitive("SocketPlugin","primitiveSocketRemotePort",argCount);case 217:if(this.oldPrims)return this.namedPrimitive("SocketPlugin","primitiveSocketConnectToPort",argCount);case 218:return this.oldPrims?this.namedPrimitive("SocketPlugin","primitiveSocketListenWithOrWithoutBacklog",argCount):this.primitiveDoNamedPrimitive(argCount);case 219:if(this.oldPrims)return this.namedPrimitive("SocketPlugin","primitiveSocketCloseConnection",argCount);case 220:if(this.oldPrims)return this.namedPrimitive("SocketPlugin","primitiveSocketAbortConnection",argCount);break;case 221:return this.oldPrims?this.namedPrimitive("SocketPlugin","primitiveSocketReceiveDataBufCount",argCount):this.primitiveClosureValueNoContextSwitch(argCount);case 222:return this.oldPrims?this.namedPrimitive("SocketPlugin","primitiveSocketReceiveDataAvailable",argCount):this.primitiveClosureValueNoContextSwitch(argCount);case 223:if(this.oldPrims)return this.namedPrimitive("SocketPlugin","primitiveSocketSendDataBufCount",argCount);case 224:if(this.oldPrims)return this.namedPrimitive("SocketPlugin","primitiveSocketSendDone",argCount);case 225:if(this.oldPrims)return this.namedPrimitive("SocketPlugin","primitiveSocketAccept",argCount);break;case 230:return this.primitiveRelinquishProcessorForMicroseconds(argCount);case 231:return this.primitiveForceDisplayUpdate(argCount);case 232:return this.vm.warnOnce("missing primitive: 232 (primitiveFormPrint)"),!1;case 233:return this.primitiveSetFullScreen(argCount);case 234:if(this.oldPrims)return this.namedPrimitive("MiscPrimitivePlugin","primitiveDecompressFromByteArray",argCount);case 235:if(this.oldPrims)return this.namedPrimitive("MiscPrimitivePlugin","primitiveCompareString",argCount);case 236:if(this.oldPrims)return this.namedPrimitive("MiscPrimitivePlugin","primitiveConvert8BitSigned",argCount);case 237:if(this.oldPrims)return this.namedPrimitive("MiscPrimitivePlugin","primitiveCompressToByteArray",argCount);break;case 238:return this.oldPrims?this.namedPrimitive("SerialPlugin","primitiveSerialPortOpen",argCount):this.namedPrimitive("FloatArrayPlugin","primitiveAt",argCount);case 239:return this.oldPrims?this.namedPrimitive("SerialPlugin","primitiveSerialPortClose",argCount):this.namedPrimitive("FloatArrayPlugin","primitiveAtPut",argCount);case 240:return this.oldPrims?this.namedPrimitive("SerialPlugin","primitiveSerialPortWrite",argCount):this.popNandPushIfOK(argCount+1,this.microsecondClockUTC());case 241:return this.oldPrims?this.namedPrimitive("SerialPlugin","primitiveSerialPortRead",argCount):this.popNandPushIfOK(argCount+1,this.microsecondClockLocal());case 242:if(this.oldPrims)break;return this.primitiveSignalAtUTCMicroseconds(argCount);case 243:return this.oldPrims?this.namedPrimitive("MiscPrimitivePlugin","primitiveTranslateStringWithTable",argCount):(this.vm.warnOnce("missing primitive: 243 (primitiveUpdateTimeZone)"),!1);case 244:if(this.oldPrims)return this.namedPrimitive("MiscPrimitivePlugin","primitiveFindFirstInString",argCount);case 245:if(this.oldPrims)return this.namedPrimitive("MiscPrimitivePlugin","primitiveIndexOfAsciiInString",argCount);case 246:if(this.oldPrims)return this.namedPrimitive("MiscPrimitivePlugin","primitiveFindSubstring",argCount);break;case 248:return this.primitiveArrayBecome(argCount,!1,!1);case 249:return this.primitiveArrayBecome(argCount,!1,!0);case 254:return this.primitiveVMParameter(argCount);case 521:return this.namedPrimitive("MIDIPlugin","primitiveMIDIClosePort",argCount);case 522:return this.namedPrimitive("MIDIPlugin","primitiveMIDIGetClock",argCount);case 523:return this.namedPrimitive("MIDIPlugin","primitiveMIDIGetPortCount",argCount);case 524:return this.namedPrimitive("MIDIPlugin","primitiveMIDIGetPortDirectionality",argCount);case 525:return this.namedPrimitive("MIDIPlugin","primitiveMIDIGetPortName",argCount);case 526:return this.namedPrimitive("MIDIPlugin","primitiveMIDIOpenPort",argCount);case 527:return this.namedPrimitive("MIDIPlugin","primitiveMIDIParameterGetOrSet",argCount);case 528:return this.namedPrimitive("MIDIPlugin","primitiveMIDIRead",argCount);case 529:return this.namedPrimitive("MIDIPlugin","primitiveMIDIWrite",argCount);case 550:return this.namedPrimitive("ADPCMCodecPlugin","primitiveDecodeMono",argCount);case 551:return this.namedPrimitive("ADPCMCodecPlugin","primitiveDecodeStereo",argCount);case 552:return this.namedPrimitive("ADPCMCodecPlugin","primitiveEncodeMono",argCount);case 553:return this.namedPrimitive("ADPCMCodecPlugin","primitiveEncodeStereo",argCount);case 571:return this.primitiveUnloadModule(argCount);case 572:return this.primitiveListBuiltinModule(argCount);case 573:return this.primitiveListLoadedModule(argCount);case 575:return this.vm.warnOnce("missing primitive: 575 (primitiveHighBit)"),!1;case 576:return this.vm.primitiveInvokeObjectAsMethod(argCount,primMethod);case 578:return this.vm.warnOnce("missing primitive: 578 (primitiveSuspendAndBackupPC)"),!1}return console.error("primitive "+index+" not implemented yet"),!1},namedPrimitive:function(modName,functionName,argCount){var mod=""===modName?this:this.loadedModules[modName],justLoaded=!1;void 0===mod&&(mod=this.loadModule(modName),this.loadedModules[modName]=mod,justLoaded=!0);var result=!1,sp=this.vm.sp;if(mod){this.interpreterProxy.argCount=argCount,this.interpreterProxy.primitiveName=functionName;var primitive=mod[functionName];"function"==typeof primitive?result=mod[functionName](argCount):"string"==typeof primitive?result=this[primitive](argCount):this.vm.warnOnce("missing primitive: "+modName+"."+functionName)}else justLoaded&&(this.success?this.vm.warnOnce("missing module: "+modName+" ("+functionName+")"):this.vm.warnOnce("failed to load module: "+modName+" ("+functionName+")"));return(!0===result||!1!==result&&this.success)&&this.vm.sp!==sp-argCount&&!this.vm.frozen&&this.vm.warnOnce("stack unbalanced after primitive "+modName+"."+functionName,"error"),!0===result||!1===result?result:this.success},doNamedPrimitive:function(argCount,primMethod){if(!primMethod.primFunction){if(primMethod.pointersSize()<2)return!1;if(4!==(firstLiteral=primMethod.pointers[1]).pointersSize())return!1;this.primMethod=primMethod;var moduleName=firstLiteral.pointers[0].bytesAsString(),functionName=firstLiteral.pointers[1].bytesAsString();if(primMethod.primFunction=this.loadFunctionFrom(functionName,moduleName),!primMethod.primFunction)return!1}this.interpreterProxy.argCount=argCount;var sp=this.vm.sp,result=primMethod.primFunction(argCount);if((!0===result||!1!==result&&this.success)&&this.vm.sp!==sp-argCount&&!this.vm.frozen){var firstLiteral;moduleName=(firstLiteral=primMethod.pointers[1]).pointers[0].bytesAsString(),functionName=firstLiteral.pointers[1].bytesAsString();this.vm.warnOnce("stack unbalanced after primitive "+moduleName+"."+functionName,"error")}return!0===result||!1===result?result:this.success},fakePrimitive:function(prim,retVal,argCount){return this.vm.warnOnce("faking primitive: "+prim),void 0===retVal?this.vm.popN(argCount):this.vm.popNandPush(argCount+1,this.makeStObject(retVal)),!0}},"modules",{loadModule:function(modName){var mod=Squeak.externalModules[modName]||this.builtinModules[modName]||this.loadModuleDynamically(modName);if(!mod)return null;if(this.patchModules[modName]&&this.patchModule(mod,modName),mod.setInterpreter&&!mod.setInterpreter(this.interpreterProxy))return console.log("Wrong interpreter proxy version: "+modName),null;var initFunc=mod.initialiseModule;return"function"==typeof initFunc?mod.initialiseModule():"string"==typeof initFunc&&this[initFunc](),this.interpreterProxy.failed()?(console.log("Module initialization failed: "+modName),null):(mod.getModuleName&&(modName=mod.getModuleName()),console.log("Loaded module: "+modName),mod)},loadModuleDynamically:function(modName){},patchModule:function(mod,modName){var patch=this.patchModules[modName];for(var key in patch)mod[key]=patch[key]},unloadModule:function(modName){var mod=this.loadedModules[modName];if(!modName||!mod||mod===this)return null;delete this.loadedModules[modName];var unloadFunc=mod.unloadModule;return"function"==typeof unloadFunc?mod.unloadModule(this):"string"==typeof unloadFunc&&this[unloadFunc](this),console.log("Unloaded module: "+modName),mod},loadFunctionFrom:function(functionName,modName){var mod=""===modName?this:this.loadedModules[modName];if(void 0===mod&&(mod=this.loadModule(modName),this.loadedModules[modName]=mod),!mod)return null;var func=mod[functionName];return"function"==typeof func?func.bind(mod):"string"==typeof func?this[func].bind(this):(this.vm.warnOnce("missing primitive: "+modName+"."+functionName),null)},primitiveUnloadModule:function(argCount){var moduleName=this.stackNonInteger(0).bytesAsString();return!!moduleName&&(this.unloadModule(moduleName),this.popNIfOK(argCount))},primitiveListBuiltinModule:function(argCount){var index=this.stackInteger(0)-1;if(!this.success)return!1;var moduleNames=Object.keys(this.builtinModules);return this.popNandPushIfOK(argCount+1,this.makeStObject(moduleNames[index]))},primitiveListLoadedModule:function(argCount){var index=this.stackInteger(0)-1;if(!this.success)return!1;var moduleNames=[];for(var key in this.loadedModules){var module=this.loadedModules[key];if(module){var moduleName=module.getModuleName?module.getModuleName():key;moduleNames.push(moduleName)}}return this.popNandPushIfOK(argCount+1,this.makeStObject(moduleNames[index]))}},"stack access",{popNIfOK:function(nToPop){return!!this.success&&(this.vm.popN(nToPop),!0)},pop2andPushBoolIfOK:function(bool){return this.vm.success=this.success,this.vm.pop2AndPushBoolResult(bool)},popNandPushBoolIfOK:function(nToPop,bool){return!!this.success&&(this.vm.popNandPush(nToPop,bool?this.vm.trueObj:this.vm.falseObj),!0)},popNandPushIfOK:function(nToPop,returnValue){return!(!this.success||null==returnValue)&&(this.vm.popNandPush(nToPop,returnValue),!0)},popNandPushIntIfOK:function(nToPop,returnValue){return!(!this.success||!this.vm.canBeSmallInt(returnValue))&&(this.vm.popNandPush(nToPop,returnValue),!0)},popNandPushFloatIfOK:function(nToPop,returnValue){return!!this.success&&(this.vm.popNandPush(nToPop,this.makeFloat(returnValue)),!0)},stackNonInteger:function(nDeep){return this.checkNonInteger(this.vm.stackValue(nDeep))},stackInteger:function(nDeep){return this.checkSmallInt(this.vm.stackValue(nDeep))},stackPos32BitInt:function(nDeep){return this.positive32BitValueOf(this.vm.stackValue(nDeep))},pos32BitIntFor:function(signed32){if(signed32>=0&&signed32<=Squeak.MaxSmallInt)return signed32;for(var lgIntClass=this.vm.specialObjects[Squeak.splOb_ClassLargePositiveInteger],lgIntObj=this.vm.instantiateClass(lgIntClass,4),bytes=lgIntObj.bytes,i=0;i<4;i++)bytes[i]=signed32>>>8*i&255;return lgIntObj},pos53BitIntFor:function(longlong){if(longlong<=4294967295)return this.pos32BitIntFor(longlong);if(longlong>9007199254740991)return console.warn("Out of range: pos53BitIntFor("+longlong+")"),this.success=!1,0;for(var sz=longlong<=0xffffffffff?5:longlong<=0xffffffffffff?6:7,lgIntClass=this.vm.specialObjects[Squeak.splOb_ClassLargePositiveInteger],lgIntObj=this.vm.instantiateClass(lgIntClass,sz),bytes=lgIntObj.bytes,i=0;i=-2147483648?-value:(this.success=!1,0)},signed32BitIntegerFor:function(signed32){if(signed32>=Squeak.MinSmallInt&&signed32<=Squeak.MaxSmallInt)return signed32;for(var negative=signed32<0,unsigned=negative?-signed32:signed32,lgIntClass=negative?Squeak.splOb_ClassLargeNegativeInteger:Squeak.splOb_ClassLargePositiveInteger,lgIntObj=this.vm.instantiateClass(this.vm.specialObjects[lgIntClass],4),bytes=lgIntObj.bytes,i=0;i<4;i++)bytes[i]=unsigned>>>8*i&255;return lgIntObj},stackFloat:function(nDeep){return this.checkFloat(this.vm.stackValue(nDeep))},stackBoolean:function(nDeep){return this.checkBoolean(this.vm.stackValue(nDeep))},stackSigned53BitInt:function(nDeep){var stackVal=this.vm.stackValue(nDeep);if("number"==typeof stackVal)return stackVal;var n=stackVal.bytesSize();if(n<=7){for(var bytes=stackVal.bytes,value=0,i=0,f=1;i>>-arg}else{if(arg>31)return this.success=!1,0;if((result=rcvr<>>arg!==rcvr)return this.success=!1,0}return this.pos32BitIntFor(result)},safeFDiv:function(dividend,divisor){return 0===divisor?(this.success=!1,1):dividend/divisor},floatAsSmallInt:function(float){var truncated=float>=0?Math.floor(float):Math.ceil(float);return this.ensureSmallInt(truncated)},floatFractionPart:function(float){return-9007199254740991<=float&&float<=9007199254740991?float-Math.floor(float):(this.success=!1,0)},frexp_exponent:function(value){if(0==value)return 0;var data=new DataView(new ArrayBuffer(8));data.setFloat64(0,value);var bits=data.getUint32(0)>>>20&2047;return 0===bits&&(data.setFloat64(0,value*Math.pow(2,64)),bits=(data.getUint32(0)>>>20&2047)-64),bits-1022},ldexp:function(mantissa,exponent){for(var steps=Math.min(3,Math.ceil(Math.abs(exponent)/1023)),result=mantissa,i=0;ithis.stackSigned53BitInt(0))},primitiveLessOrEqualLargeIntegers:function(argCount){return this.popNandPushBoolIfOK(argCount+1,this.stackSigned53BitInt(1)<=this.stackSigned53BitInt(0))},primitiveGreaterOrEqualLargeIntegers:function(argCount){return this.popNandPushBoolIfOK(argCount+1,this.stackSigned53BitInt(1)>=this.stackSigned53BitInt(0))},primitiveEqualLargeIntegers:function(argCount){return this.popNandPushBoolIfOK(argCount+1,this.stackSigned53BitInt(1)===this.stackSigned53BitInt(0))},primitiveNotEqualLargeIntegers:function(argCount){return this.popNandPushBoolIfOK(argCount+1,this.stackSigned53BitInt(1)!==this.stackSigned53BitInt(0))},primitiveMultiplyLargeIntegers:function(argCount){return this.popNandPushIfOK(argCount+1,this.makeStObject(this.stackSigned53BitInt(1)*this.stackSigned53BitInt(0)))},primitiveDivideLargeIntegers:function(argCount){return this.popNandPushIfOK(argCount+1,this.makeStObject(this.stackSigned53BitInt(1)/this.stackSigned53BitInt(0)))},primitiveModLargeIntegers:function(argCount){return this.popNandPushIfOK(argCount+1,this.makeStObject(Math.floor(this.stackSigned53BitInt(1)%this.stackSigned53BitInt(0))))},primitiveDivLargeIntegers:function(argCount){return this.popNandPushIfOK(argCount+1,this.makeStObject(Math.floor(this.stackSigned53BitInt(1)/this.stackSigned53BitInt(0))))},primitiveQuoLargeIntegers:function(argCount){return this.popNandPushIfOK(argCount+1,this.makeStObject(Math.trunc(this.stackSigned53BitInt(1)/this.stackSigned53BitInt(0))))}},"utils",{floatOrInt:function(obj){return obj.isFloat?obj.float:"number"==typeof obj?obj:0},positive32BitValueOf:function(obj){if("number"==typeof obj)return obj>=0?obj:(this.success=!1,0);if(!this.isA(obj,Squeak.splOb_ClassLargePositiveInteger)||4!==obj.bytesSize())return this.success=!1,0;for(var bytes=obj.bytes,value=0,i=0,f=1;i<4;i++,f*=256)value+=bytes[i]*f;return value},checkFloat:function(maybeFloat){return maybeFloat.isFloat?maybeFloat.float:"number"==typeof maybeFloat?maybeFloat:(this.success=!1,0)},checkSmallInt:function(maybeSmall){return"number"==typeof maybeSmall?maybeSmall:(this.success=!1,0)},checkNonInteger:function(obj){return"number"!=typeof obj?obj:(this.success=!1,this.vm.nilObj)},checkBoolean:function(obj){return!!obj.isTrue||!obj.isFalse&&(this.success=!1)},indexableSize:function(obj){return"number"==typeof obj?-1:obj.indexableSize(this)},isA:function(obj,knownClass){return obj.sqClass===this.vm.specialObjects[knownClass]},isKindOf:function(obj,knownClass){for(var classOrSuper=obj.sqClass,theClass=this.vm.specialObjects[knownClass];!classOrSuper.isNil;){if(classOrSuper===theClass)return!0;classOrSuper=classOrSuper.pointers[Squeak.Class_superclass]}return!1},isAssociation:function(obj){return"number"!=typeof obj&&2==obj.pointersSize()},ensureSmallInt:function(number){return number===(0|number)&&this.vm.canBeSmallInt(number)?number:(this.success=!1,0)},charFromInt:function(ascii){var char=this.vm.specialObjects[Squeak.splOb_CharacterTable].pointers[ascii];if(char)return char;var charClass=this.vm.specialObjects[Squeak.splOb_ClassCharacter];return(char=this.vm.instantiateClass(charClass,0)).pointers[0]=ascii,char},charFromIntSpur:function(unicode){return this.vm.image.getCharacter(unicode)},charToInt:function(obj){return obj.pointers[0]},charToIntSpur:function(obj){return obj.hash},makeFloat:function(value){var floatClass=this.vm.specialObjects[Squeak.splOb_ClassFloat],newFloat=this.vm.instantiateClass(floatClass,2);return newFloat.float=value,newFloat},makeLargeIfNeeded:function(integer){return this.vm.canBeSmallInt(integer)?integer:this.makeLargeInt(integer)},makeLargeInt:function(integer){if(integer<0)throw Error("negative large ints not implemented yet");if(integer>4294967295)throw Error("large large ints not implemented yet");return this.pos32BitIntFor(integer)},makePointWithXandY:function(x,y){var pointClass=this.vm.specialObjects[Squeak.splOb_ClassPoint],newPoint=this.vm.instantiateClass(pointClass,0);return newPoint.pointers[Squeak.Point_x]=x,newPoint.pointers[Squeak.Point_y]=y,newPoint},makeStArray:function(jsArray,proxyClass){for(var array=this.vm.instantiateClass(this.vm.specialObjects[Squeak.splOb_ClassArray],jsArray.length),i=0;i=0},asUint8Array:function(buffer){if("Uint8Array"===buffer.constructor.name)return buffer;if("ArrayBuffer"===buffer.constructor.name)return new Uint8Array(buffer);if("string"==typeof buffer){for(var array=new Uint8Array(buffer.length),i=0;iinfo.size)return this.success=!1,array;if(includeInstVars)return array.pointers[index-1];if(array.isPointers())return array.pointers[index-1+info.ivarOffset];if(array.isWords())return info.convertChars?this.charFromInt(1073741823&array.words[index-1]):this.pos32BitIntFor(array.words[index-1]);if(array.isBytes())return info.convertChars?this.charFromInt(255&array.bytes[index-1]):255&array.bytes[index-1];var offset=4*array.pointersSize();return index-1-offset<0?(this.success=!1,array):255&array.bytes[index-1-offset]},objectAtPut:function(cameFromBytecode,convertChars,includeInstVars){var info,array=this.stackNonInteger(2),index=this.stackPos32BitInt(1);if(!this.success)return array;if(cameFromBytecode){if((info=this.atPutCache[array.hash&this.atCacheMask]).array!==array)return this.success=!1,array}else{if(array.isFloat){var wordToPut=this.stackPos32BitInt(0);if(!this.success||1!=index&&2!=index)this.success=!1;else{var floatData=array.floatData();floatData.setUint32(1==index?0:4,wordToPut,!1),array.float=floatData.getFloat64(0)}return this.vm.stackValue(0)}info=this.makeAtCacheInfo(this.atPutCache,this.vm.specialSelectors[34],array,convertChars,includeInstVars)}if(index<1||index>info.size)return this.success=!1,array;var intToPut,objToPut=this.vm.stackValue(0);if(includeInstVars)return array.dirty=!0,array.pointers[index-1]=objToPut;if(array.isPointers())return array.dirty=!0,array.pointers[index-1+info.ivarOffset]=objToPut;if(array.isWords()){if(convertChars){if(objToPut.sqClass!==this.vm.specialObjects[Squeak.splOb_ClassCharacter])return this.success=!1,objToPut;if("number"!=typeof(intToPut=this.charToInt(objToPut)))return this.success=!1,objToPut}else intToPut=this.stackPos32BitInt(0);return this.success&&(array.words[index-1]=intToPut),objToPut}if(convertChars){if(objToPut.sqClass!==this.vm.specialObjects[Squeak.splOb_ClassCharacter])return this.success=!1,objToPut;if("number"!=typeof(intToPut=this.charToInt(objToPut)))return this.success=!1,objToPut}else{if("number"!=typeof objToPut)return this.success=!1,objToPut;intToPut=objToPut}if(intToPut<0||intToPut>255)return this.success=!1,objToPut;if(array.isBytes())return array.bytes[index-1]=intToPut,objToPut;var offset=4*array.pointersSize();return index-1-offset<0?(this.success=!1,array):(array.bytes[index-1-offset]=intToPut,objToPut)},objectSize:function(cameFromBytecode){var rcvr=this.vm.stackValue(0),size=-1;return cameFromBytecode?rcvr.sqClass===this.vm.specialObjects[Squeak.splOb_ClassArray]?size=rcvr.pointersSize():rcvr.sqClass===this.vm.specialObjects[Squeak.splOb_ClassString]&&(size=rcvr.bytesSize()):size=this.indexableSize(rcvr),-1===size?(this.success=!1,-1):this.pos32BitIntFor(size)},initAtCache:function(){this.atCacheSize=32,this.atCacheMask=this.atCacheSize-1,this.atCache=[],this.atPutCache=[],this.nonCachedInfo={};for(var i=0;ithis.vm.image.bytesLeft()?(console.warn("squeak: out of memory, failing allocation"),this.success=!1,this.vm.primFailCode=Squeak.PrimErrNoMemory,null):this.vm.instantiateClass(clsObj,indexableSize)},someObject:function(){return this.vm.image.firstOldObject},nextObject:function(obj){return this.vm.image.objectAfter(obj)||0},someInstanceOf:function(clsObj){var someInstance=this.vm.image.someInstanceOf(clsObj);return someInstance||(this.success=!1,0)},nextInstanceAfter:function(obj){var nextInstance=this.vm.image.nextInstanceAfter(obj);return nextInstance||(this.success=!1,0)},allInstancesOf:function(clsObj){var instances=this.vm.image.allInstancesOf(clsObj),array=this.vm.instantiateClass(this.vm.specialObjects[Squeak.splOb_ClassArray],instances.length);return array.pointers=instances,array},identityHash:function(obj){return obj.hash},identityHashSpur:function(obj){var hash=obj.hash;return hash>0?hash:obj.hash=this.newObjectHash()},behaviorHash:function(obj){var hash=obj.hash;return hash>0?hash:this.vm.image.enterIntoClassTable(obj)},newObjectHash:function(obj){return Math.floor(4194302*Math.random())+1},primitivePin:function(argCount){var rcvr=this.stackNonInteger(1),pin=this.stackBoolean(0);if(!this.success)return!1;var wasPinned=rcvr.pinned;return rcvr.pinned=pin,this.popNandPushIfOK(argCount+1,this.makeStObject(!!wasPinned))},primitiveIsPinned:function(argCount){var rcvr=this.stackNonInteger(0);return!!this.success&&this.popNandPushIfOK(argCount+1,this.makeStObject(!!rcvr.pinned))},primitiveSizeInBytesOfInstance:function(argCount){if(argCount>1)return!1;var classObj=this.stackNonInteger(argCount),nElements=argCount?this.stackInteger(0):0,bytes=classObj.classByteSizeOfInstance(nElements);return this.popNandPushIfOK(argCount+1,this.makeLargeIfNeeded(bytes))},primitiveSizeInBytes:function(argCount){var bytes=this.stackNonInteger(0).totalBytes();return this.popNandPushIfOK(argCount+1,this.makeLargeIfNeeded(bytes))},primitiveAsCharacter:function(argCount){var unicode=this.stackInteger(0);if(unicode<0||unicode>1073741823)return!1;var char=this.charFromInt(unicode);return!!char&&this.popNandPushIfOK(argCount+1,char)},primitiveFullGC:function(argCount){this.vm.image.fullGC("primitive");var bytes=this.vm.image.bytesLeft();return this.popNandPushIfOK(argCount+1,this.makeLargeIfNeeded(bytes))},primitivePartialGC:function(argCount){for(var young=this.vm.image.partialGC("primitive"),youngSpaceBytes=0;young;)youngSpaceBytes+=young.totalBytes(),young=young.nextObject;console.log(" old space: "+this.vm.image.oldSpaceBytes.toLocaleString()+" bytes, young space: "+youngSpaceBytes.toLocaleString()+" bytes, total: "+(this.vm.image.oldSpaceBytes+youngSpaceBytes).toLocaleString()+" bytes");var bytes=this.vm.image.bytesLeft()-youngSpaceBytes;return this.popNandPushIfOK(argCount+1,this.makeLargeIfNeeded(bytes))},primitiveMakePoint:function(argCount,checkNumbers){var x=this.vm.stackValue(1),y=this.vm.stackValue(0);return!(checkNumbers&&(this.checkFloat(x),this.checkFloat(y),!this.success))&&(this.vm.popNandPush(1+argCount,this.makePointWithXandY(x,y)),!0)},primitiveStoreStackp:function(argCount){var ctxt=this.stackNonInteger(1),newStackp=this.stackInteger(0);if(!this.success||newStackp<0||this.vm.decodeSqueakSP(newStackp)>=ctxt.pointers.length)return!1;for(var stackp=ctxt.pointers[Squeak.Context_stackPointer];stackp2)return!1;var rcvr=this.stackNonInteger(1),arg=this.stackNonInteger(0);return!!this.changeClassTo(rcvr,arg.sqClass)&&this.popNIfOK(argCount)},primitiveAdoptInstance:function(argCount){if(argCount>2)return!1;var cls=this.stackNonInteger(1),obj=this.stackNonInteger(0);return!!this.changeClassTo(obj,cls)&&this.popNIfOK(argCount)},changeClassTo:function(rcvr,cls){if(rcvr.sqClass.isCompact!==cls.isCompact)return!1;var classInstIsPointers=cls.classInstIsPointers();if(rcvr.isPointers()){if(!classInstIsPointers)return!1;if(rcvr.sqClass.classInstSize()!==cls.classInstSize())return!1}else{if(classInstIsPointers)return!1;var hasBytes=rcvr.isBytes(),needBytes=cls.classInstIsBytes();if(hasBytes&&!needBytes){if(rcvr.bytes){if(3&rcvr.bytes.length)return!1;rcvr.words=new Uint32Array(rcvr.bytes.buffer),delete rcvr.bytes}}else!hasBytes&&needBytes&&rcvr.words&&(rcvr.bytes=new Uint8Array(rcvr.words.buffer),delete rcvr.words)}return rcvr._format=cls.classInstFormat(),rcvr.sqClass=cls,!0},primitiveDoPrimitiveWithArgs:function(argCount){var argumentArray=this.stackNonInteger(0),primIdx=this.stackInteger(1);if(!this.success)return!1;var arraySize=argumentArray.pointersSize(),cntxSize=this.vm.activeContext.pointersSize();if(this.vm.sp+arraySize>=cntxSize)return!1;this.vm.popN(2);for(var i=0;i=cntxSize)return!1;this.vm.popN(3),this.vm.push(rcvr);for(var i=0;i=array.length)return!1;if(argCount<2)value=array[index];else{if((value=this.stackInteger(0))<-32768||value>32767)return!1;array[index]=value}return this.popNandPushIfOK(argCount+1,value),!0},primitiveIntegerAtAndPut:function(argCount){var value,rcvr=this.stackNonInteger(argCount),index=this.stackInteger(argCount-1)-1,array=rcvr.wordsAsInt32Array();if(!this.success||!array||index<0||index>=array.length)return!1;if(argCount<2)value=this.signed32BitIntegerFor(array[index]);else{if(value=this.stackSigned32BitInt(0),!this.success)return!1;array[index]=value}return this.popNandPushIfOK(argCount+1,value),!0},primitiveConstantFill:function(argCount){var rcvr=this.stackNonInteger(1),value=this.stackPos32BitInt(0);if(!this.success||!rcvr.isWordsOrBytes())return!1;var array=rcvr.words||rcvr.bytes;if(array){if(array===rcvr.bytes&&value>255)return!1;for(var i=0;i4)return!1;var numArgs=methodObj.methodNumArgs();if(numArgs!==argsArray.pointersSize())return!1;this.vm.popNandPush(argCount+1,receiver);for(var i=0;i1&&(copyHash=this.stackBoolean(argCount-2)),!!this.success&&(this.success=this.vm.image.bulkBecome(rcvr.pointers,arg.pointers,doBothWays,copyHash),this.popNIfOK(argCount))},doStringReplace:function(){var dst=this.stackNonInteger(4),dstPos=this.stackInteger(3)-1,count=this.stackInteger(2)-dstPos,src=this.stackNonInteger(1),srcPos=this.stackInteger(0)-1;if(!this.success)return dst;if(!src.sameFormatAs(dst))return this.success=!1,dst;if(src.isPointers()){var totalLength=src.pointersSize();if((srcPos+=src.instSize())<0||srcPos+count>totalLength)return this.success=!1,dst;if(totalLength=dst.pointersSize(),(dstPos+=dst.instSize())<0||dstPos+count>totalLength)return this.success=!1,dst;for(var i=0;itotalLength)return this.success=!1,dst;if(totalLength=dst.wordsSize(),dstPos<0||dstPos+count>totalLength)return this.success=!1,dst;if(src.isFloat&&dst.isFloat)dst.float=src.float;else if(src.isFloat)dst.wordsAsFloat64Array()[dstPos]=src.float;else if(dst.isFloat)dst.float=src.wordsAsFloat64Array()[srcPos];else for(i=0;itotalLength)return this.success=!1,dst;if(totalLength=dst.bytesSize(),dstPos<0||dstPos+count>totalLength)return this.success=!1,dst;for(i=0;iactivePriority?(this.putToSleep(activeProc),this.transferTo(newProc)):this.putToSleep(newProc)},putToSleep:function(aProcess){if(null!==aProcess){var priority=aProcess.pointers[Squeak.Proc_priority],processList=this.getScheduler().pointers[Squeak.ProcSched_processLists].pointers[priority-1];this.linkProcessToList(aProcess,processList)}},transferTo:function(newProc){var sched=this.getScheduler(),oldProc=sched.pointers[Squeak.ProcSched_activeProcess];sched.pointers[Squeak.ProcSched_activeProcess]=newProc,sched.dirty=!0,null!==oldProc&&(oldProc.pointers[Squeak.Proc_suspendedContext]=this.vm.activeContext,oldProc.dirty=!0),null!==newProc&&(this.vm.newActiveContext(newProc.pointers[Squeak.Proc_suspendedContext]),newProc.pointers[Squeak.Proc_suspendedContext]=this.vm.nilObj,this.oldPrims||(newProc.pointers[Squeak.Proc_myList]=this.vm.nilObj)),this.vm.reclaimableContextCount=0,this.vm.breakOnContextChanged&&(this.vm.breakOnContextChanged=!1,this.vm.breakNow()),this.vm.logProcess&&console.log("\n============= Process Switch ==================\n"+this.vm.printProcess(newProc,!0,this.vm.logSends?"| ":"")+"===============================================")},wakeHighestPriority:function(){var processList,schedLists=this.getScheduler().pointers[Squeak.ProcSched_processLists],p=schedLists.pointersSize()-1;do{if(p<0)return null;processList=schedLists.pointers[p--]}while(this.isEmptyList(processList));return this.removeFirstLinkOfList(processList)},linkProcessToList:function(proc,aList){if(this.isEmptyList(aList))aList.pointers[Squeak.LinkedList_firstLink]=proc;else{var lastLink=aList.pointers[Squeak.LinkedList_lastLink];lastLink.pointers[Squeak.Link_nextLink]=proc,lastLink.dirty=!0}aList.pointers[Squeak.LinkedList_lastLink]=proc,aList.dirty=!0,proc.pointers[Squeak.Proc_myList]=aList,proc.dirty=!0},isEmptyList:function(aLinkedList){return aLinkedList.pointers[Squeak.LinkedList_firstLink].isNil},removeFirstLinkOfList:function(aList){var first=aList.pointers[Squeak.LinkedList_firstLink];if(first===aList.pointers[Squeak.LinkedList_lastLink])aList.pointers[Squeak.LinkedList_firstLink]=this.vm.nilObj,aList.pointers[Squeak.LinkedList_lastLink]=this.vm.nilObj;else{var next=first.pointers[Squeak.Link_nextLink];aList.pointers[Squeak.LinkedList_firstLink]=next,aList.dirty=!0}return first.pointers[Squeak.Link_nextLink]=this.vm.nilObj,first},removeProcessFromList:function(process,list){var first=list.pointers[Squeak.LinkedList_firstLink],last=list.pointers[Squeak.LinkedList_lastLink];if(process===first){var next=process.pointers[Squeak.Link_nextLink];list.pointers[Squeak.LinkedList_firstLink]=next,process===last&&(list.pointers[Squeak.LinkedList_lastLink]=this.vm.nilObj)}else{for(var temp=first;;){if(temp.isNil)return void(this.oldPrims&&(this.success=!1));if((next=temp.pointers[Squeak.Link_nextLink])===process)break;temp=next}next=process.pointers[Squeak.Link_nextLink],temp.pointers[Squeak.Link_nextLink]=next,process===last&&(list.pointers[Squeak.LinkedList_lastLink]=temp)}process.pointers[Squeak.Link_nextLink]=this.vm.nilObj},registerSemaphore:function(specialObjIndex){var sema=this.vm.top();return this.isA(sema,Squeak.splOb_ClassSemaphore)?this.vm.specialObjects[specialObjIndex]=sema:this.vm.specialObjects[specialObjIndex]=this.vm.nilObj,this.vm.stackValue(1)},primitiveWait:function(){var sema=this.vm.top();if(!this.isA(sema,Squeak.splOb_ClassSemaphore))return!1;var excessSignals=sema.pointers[Squeak.Semaphore_excessSignals];return excessSignals>0?sema.pointers[Squeak.Semaphore_excessSignals]=excessSignals-1:(this.linkProcessToList(this.activeProcess(),sema),this.transferTo(this.wakeHighestPriority())),!0},primitiveSignal:function(){var sema=this.vm.top();return!!this.isA(sema,Squeak.splOb_ClassSemaphore)&&(this.synchronousSignal(sema),!0)},synchronousSignal:function(sema){this.isEmptyList(sema)?sema.pointers[Squeak.Semaphore_excessSignals]++:this.resume(this.removeFirstLinkOfList(sema))},signalAtMilliseconds:function(sema,msTime){this.isA(sema,Squeak.splOb_ClassSemaphore)?(this.vm.specialObjects[Squeak.splOb_TheTimerSemaphore]=sema,this.vm.nextWakeupTick=msTime):(this.vm.specialObjects[Squeak.splOb_TheTimerSemaphore]=this.vm.nilObj,this.vm.nextWakeupTick=0)},primitiveSignalAtMilliseconds:function(argCount){var msTime=this.stackInteger(0),sema=this.stackNonInteger(1);return!!this.success&&(this.signalAtMilliseconds(sema,msTime),this.vm.popN(argCount),!0)},primitiveSignalAtUTCMicroseconds:function(argCount){var usecsUTC=this.stackSigned53BitInt(0),sema=this.stackNonInteger(1);if(!this.success)return!1;var msTime=usecsUTC/1e3+Squeak.EpochUTC-this.vm.startupTime&Squeak.MillisecondClockMask;return this.signalAtMilliseconds(sema,msTime),this.vm.popN(argCount),!0},signalSemaphoreWithIndex:function(semaIndex){this.semaphoresToSignal.push(semaIndex)},signalExternalSemaphores:function(){for(var semaphores=this.vm.specialObjects[Squeak.splOb_ExternalObjectsArray].pointers,semaClass=this.vm.specialObjects[Squeak.splOb_ClassSemaphore];this.semaphoresToSignal.length;){var sema=semaphores[this.semaphoresToSignal.shift()-1];sema.sqClass==semaClass&&this.synchronousSignal(sema)}},primitiveEnterCriticalSection:function(argCount){if(argCount>1)return!1;var mutex=this.vm.stackValue(argCount),activeProc=argCount?this.vm.top():this.activeProcess(),owningProcess=mutex.pointers[Squeak.Mutex_owner];return owningProcess.isNil?(mutex.pointers[Squeak.Mutex_owner]=activeProc,mutex.dirty=!0,this.popNandPushIfOK(argCount+1,this.vm.falseObj)):owningProcess===activeProc?this.popNandPushIfOK(argCount+1,this.vm.trueObj):(this.popNandPushIfOK(argCount+1,this.vm.falseObj),this.linkProcessToList(activeProc,mutex),this.transferTo(this.wakeHighestPriority())),!0},primitiveExitCriticalSection:function(argCount){var criticalSection=this.vm.top();if(this.isEmptyList(criticalSection))criticalSection.pointers[Squeak.Mutex_owner]=this.vm.nilObj;else{var owningProcess=this.removeFirstLinkOfList(criticalSection);criticalSection.pointers[Squeak.Mutex_owner]=owningProcess,criticalSection.dirty=!0,this.resume(owningProcess)}return!0},primitiveTestAndSetOwnershipOfCriticalSection:function(argCount){if(argCount>1)return!1;var mutex=this.vm.stackValue(argCount),activeProc=argCount?this.vm.top():this.activeProcess(),owningProcess=mutex.pointers[Squeak.Mutex_owner];return owningProcess.isNil?(mutex.pointers[Squeak.Mutex_owner]=activeProc,mutex.dirty=!0,this.popNandPushIfOK(argCount+1,this.vm.falseObj)):owningProcess===activeProc?this.popNandPushIfOK(argCount+1,this.vm.trueObj):this.popNandPushIfOK(argCount+1,this.vm.nilObj),!0}},"vm functions",{primitiveGetAttribute:function(argCount){var attr=this.stackInteger(0);if(!this.success)return!1;var argv=this.display.argv,vmOptions=this.display.vmOptions,value=null;switch(attr){case 0:value=argv&&argv[0]||this.filenameToSqueak(Squeak.vmPath+Squeak.vmFile);break;case 1:value=argv&&argv[1]||this.display.documentName;break;case 2:value=argv&&argv[2]||this.display.documentName;break;case 1001:value=this.vm.options.unix?"unix":Squeak.platformName;break;case 1002:value=Squeak.osVersion;break;case 1003:value=Squeak.platformSubtype;break;case 1004:value=Squeak.vmVersion+" "+Squeak.vmMakerVersion;break;case 1005:value=Squeak.windowSystem;break;case 1006:value=Squeak.vmBuild;break;case 1007:value=Squeak.vmInterpreterVersion;break;case 1009:value=Squeak.vmVersion+" Date: "+Squeak.vmDate;break;default:if(attr>=0&&argv&&argv.length>attr)value=argv[attr];else{if(!(attr<0&&vmOptions&&vmOptions.length>-attr-1))return!1;value=vmOptions[-attr-1]}}return this.vm.popNandPush(argCount+1,this.makeStObject(value)),!0},setLowSpaceThreshold:function(){var nBytes=this.stackInteger(0);return this.success&&(this.vm.lowSpaceThreshold=nBytes),this.vm.stackValue(1)},primitiveVMParameter:function(argCount){var paramsArraySize=this.vm.image.isSpur?71:44;switch(argCount){case 0:for(var arrayObj=this.vm.instantiateClass(this.vm.specialObjects[Squeak.splOb_ClassArray],paramsArraySize),i=0;iparamsArraySize)&&this.popNandPushIfOK(2,this.makeStObject(this.vmParameterAt(parm)));case 2:return this.popNandPushIfOK(3,0)}return!1},vmParameterAt:function(index){switch(index){case 1:case 2:return this.vm.image.oldSpaceBytes;case 3:case 67:return this.vm.image.totalMemory;case 4:return this.vm.image.allocationCount+this.vm.image.newSpaceCount;case 7:return this.vm.image.gcCount;case 8:return this.vm.image.gcMilliseconds;case 9:return this.vm.image.pgcCount;case 10:return this.vm.image.pgcMilliseconds;case 11:return this.vm.image.gcTenured;case 15:case 16:case 17:case 18:case 19:case 20:case 22:case 44:case 46:case 48:case 65:return 0;case 23:return this.vm.image.extraVMMemory;case 40:return 4;case 41:return this.vm.image.formatVersion();case 54:return this.vm.image.bytesLeft()}return null},primitiveImageName:function(argCount){return 0==argCount?this.popNandPushIfOK(1,this.makeStString(this.filenameToSqueak(this.vm.image.name))):(this.vm.image.name=this.filenameFromSqueak(this.vm.top().bytesAsString()),Squeak.Settings.squeakImageName=this.vm.image.name,this.vm.popN(argCount),!0)},primitiveSnapshot:function(argCount){this.vm.popNandPush(1,this.vm.trueObj),this.vm.storeContextRegisters(),this.activeProcess().pointers[Squeak.Proc_suspendedContext]=this.vm.activeContext,this.vm.image.fullGC("snapshot");var buffer=this.vm.image.writeToBuffer();return Squeak.flushAllFiles&&(Squeak.flushAllFiles(),Squeak.filePut(this.vm.image.name+".image",buffer)),this.vm.popNandPush(1,this.vm.falseObj),!0},primitiveQuit:function(argCount){return Squeak.flushAllFiles&&Squeak.flushAllFiles(),this.display.quitFlag=!0,this.vm.breakNow("quit"),!0},primitiveExitToDebugger:function(argCount){this.vm.breakNow("debugger primitive");debugger;return!0},primitiveSetGCBiasToGrow:function(argCount){return this.fakePrimitive(".primitiveSetGCBiasToGrow",0,argCount)},primitiveSetGCBiasToGrowGCLimit:function(argCount){return this.fakePrimitive(".primitiveSetGCBiasToGrowGCLimit",0,argCount)}},"time",{primitiveRelinquishProcessorForMicroseconds:function(argCount){return this.vm.popN(argCount),this.vm.goIdle(),!0},millisecondClockValue:function(){return Date.now()-this.vm.startupTime&Squeak.MillisecondClockMask},millisecondClockValueSet:function(clock){this.vm.startupTime=Date.now()-clock},secondClock:function(){return this.pos32BitIntFor(Squeak.totalSeconds())},microsecondClock:function(state){var millis=Date.now()-state.epoch;if("object"!=typeof performance)return this.pos53BitIntFor(1e3*millis);var micros=1e3*performance.now()%1e3|0,oldMillis=state.millis,oldMicros=state.micros;return oldMillis>millis&&(millis=oldMillis),millis===oldMillis&µs0){var stWordIndexableObject=this.vm.stackValue(0);return stWordIndexableObject.pointers[0]=posixMicroseconds,stWordIndexableObject.pointers[1]=offset,this.popNandPushIfOK(argCount+1,stWordIndexableObject),!0}var timeAndOffset=[posixMicroseconds,offset];return this.popNandPushIfOK(argCount+1,this.makeStArray(timeAndOffset)),!0}})),vm_primitives}var jit={},hasRequiredJit;function requireJit(){return hasRequiredJit||(hasRequiredJit=1,Object.subclass("Squeak.Compiler","initialization",{initialize:function(vm){this.vm=vm,this.comments=!!Squeak.Compiler.comments,this.specialSelectors=["+","-","<",">","<=",">=","=","~=","*","/","\\\\","@","bitShift:","//","bitAnd:","bitOr:","at:","at:put:","size","next","nextPut:","atEnd","==","class","blockCopy:","value","value:","do:","new","new:","x","y"],this.doitCounter=0,this.blockCounter=0}},"accessing",{compile:function(method,optClassObj,optSelObj){if(void 0===method.compiled)method.compiled=!1;else{var clsName,sel,instVars;if(this.singleStep=!1,this.debug=this.comments,this.debug&&!optClassObj){var isMethod=method.sqClass===this.vm.specialObjects[Squeak.splOb_ClassCompiledMethod];this.vm.allMethodsDo((function(classObj,methodObj,selectorObj){if(isMethod?methodObj===method:methodObj.pointers.includes(method))return optClassObj=classObj,optSelObj=selectorObj,!0}))}if(optClassObj)if(clsName=optClassObj.className(),sel=optSelObj.bytesAsString(),this.debug)(isMethod=method.sqClass===this.vm.specialObjects[Squeak.splOb_ClassCompiledMethod])||(clsName="[] in "+clsName),instVars=optClassObj.allInstVarNames();method.compiled=this.generate(method,clsName,sel,instVars)}},enableSingleStepping:function(method,optClass,optSel){if(!method.compiled||!method.compiled.canSingleStep){this.singleStep=!0,this.debug=!0,optClass||this.vm.allMethodsDo((function(classObj,methodObj,selectorObj){if(methodObj===method)return optClass=classObj,optSel=selectorObj,!0}));var cls=optClass&&optClass.className(),sel=optSel&&optSel.bytesAsString(),instVars=optClass&&optClass.allInstVarNames();method.compiled=this.generate(method,cls,sel,instVars),method.compiled.canSingleStep=!0}return!0},functionNameFor:function(cls,sel){return void 0===cls||"?"===cls?this.method.sqClass===this.vm.specialObjects[Squeak.splOb_ClassCompiledMethod]?"DOIT_"+ ++this.doitCounter:"BLOCK_"+ ++this.blockCounter:(cls=cls.replace(/ /g,"_").replace("[]","Block"),/[^a-zA-Z0-9:_]/.test(sel)?cls+"__"+sel.replace(/./g,(function(char){return{"|":"OR","~":"NOT","<":"LT","=":"EQ",">":"GT","&":"AND","@":"AT","*":"TIMES","+":"PLUS","\\":"MOD","-":"MINUS",",":"COMMA","/":"DIV","?":"IF"}[char]||"OPERATOR"}))+"__":cls+"_"+sel.replace(/:/g,"ː"))}},"generating",{generate:function(method,optClass,optSel,optInstVarNames){this.method=method,this.sista=method.methodSignFlag(),this.pc=0,this.endPC=0,this.prevPC=0,this.source=[],this.sourceLabels={},this.needsLabel={},this.sourcePos={},this.needsVar={},this.needsBreak=!1,optClass&&optSel&&this.source.push("// ",optClass,">>",optSel,"\n"),this.instVarNames=optInstVarNames,this.allVars=["context","stack","rcvr","inst[","temp[","lit["],this.sourcePos.context=this.source.length,this.source.push("var context = vm.activeContext;\n"),this.sourcePos.stack=this.source.length,this.source.push("var stack = context.pointers;\n"),this.sourcePos.rcvr=this.source.length,this.source.push("var rcvr = vm.receiver;\n"),this.sourcePos["inst["]=this.source.length,this.source.push("var inst = rcvr.pointers;\n"),this.sourcePos["temp["]=this.source.length,this.source.push("var temp = vm.homeContext.pointers;\n"),this.sourcePos["lit["]=this.source.length,this.source.push("var lit = vm.method.pointers;\n"),this.sourcePos["loop-start"]=this.source.length,this.source.push("while (true) switch (vm.pc) {\ncase 0:\n"),this.sista?this.generateSista(method):this.generateV3(method);var funcName=this.functionNameFor(optClass,optSel);this.singleStep?(this.debug&&this.source.push("// all valid PCs have a label;\n"),this.source.push("default: throw Error('invalid PC');\n}")):(this.sourcePos["loop-end"]=this.source.length,this.source.push("default: vm.interpretOne(true); return;\n}"),this.deleteUnneededLabels()),this.deleteUnneededVariables();var source="'use strict';\nreturn function "+funcName+"(vm) {\n"+this.source.join("")+"}";return new Function(source)()},generateV3:function(method){for(this.done=!1;!this.done;){var byte=method.bytes[this.pc++],byte2=0;switch(248&byte){case 0:case 8:this.generatePush("inst[",15&byte,"]");break;case 16:case 24:this.generatePush("temp[",6+(15&byte),"]");break;case 32:case 40:case 48:case 56:this.generatePush("lit[",1+(31&byte),"]");break;case 64:case 72:case 80:case 88:this.generatePush("lit[",1+(31&byte),"].pointers[1]");break;case 96:this.generatePopInto("inst[",7&byte,"]");break;case 104:this.generatePopInto("temp[",6+(7&byte),"]");break;case 112:switch(byte){case 112:this.generatePush("rcvr");break;case 113:this.generatePush("vm.trueObj");break;case 114:this.generatePush("vm.falseObj");break;case 115:this.generatePush("vm.nilObj");break;case 116:this.generatePush("-1");break;case 117:this.generatePush("0");break;case 118:this.generatePush("1");break;case 119:this.generatePush("2")}break;case 120:switch(byte){case 120:this.generateReturn("rcvr");break;case 121:this.generateReturn("vm.trueObj");break;case 122:this.generateReturn("vm.falseObj");break;case 123:this.generateReturn("vm.nilObj");break;case 124:this.generateReturn("stack[vm.sp]");break;case 125:this.generateBlockReturn();break;default:throw Error("unusedBytecode "+byte)}break;case 128:case 136:this.generateV3Extended(byte);break;case 144:this.generateJump(1+(7&byte));break;case 152:this.generateJumpIf(!1,1+(7&byte));break;case 160:byte2=method.bytes[this.pc++],this.generateJump(256*((7&byte)-4)+byte2);break;case 168:byte2=method.bytes[this.pc++],this.generateJumpIf(byte<172,256*(3&byte)+byte2);break;case 176:case 184:this.generateNumericOp(byte);break;case 192:case 200:this.generateQuickPrim(byte);break;case 208:case 216:this.generateSend("lit[",1+(15&byte),"]",0,!1);break;case 224:case 232:this.generateSend("lit[",1+(15&byte),"]",1,!1);break;case 240:case 248:this.generateSend("lit[",1+(15&byte),"]",2,!1)}}},generateV3Extended:function(bytecode){var byte2,byte3;switch(bytecode){case 128:switch((byte2=this.method.bytes[this.pc++])>>6){case 0:return void this.generatePush("inst[",63&byte2,"]");case 1:return void this.generatePush("temp[",6+(63&byte2),"]");case 2:return void this.generatePush("lit[",1+(63&byte2),"]");case 3:return void this.generatePush("lit[",1+(63&byte2),"].pointers[1]")}return;case 129:switch((byte2=this.method.bytes[this.pc++])>>6){case 0:return void this.generateStoreInto("inst[",63&byte2,"]");case 1:return void this.generateStoreInto("temp[",6+(63&byte2),"]");case 2:throw Error("illegal store into literal");case 3:return void this.generateStoreInto("lit[",1+(63&byte2),"].pointers[1]")}return;case 130:switch((byte2=this.method.bytes[this.pc++])>>6){case 0:return void this.generatePopInto("inst[",63&byte2,"]");case 1:return void this.generatePopInto("temp[",6+(63&byte2),"]");case 2:throw Error("illegal pop into literal");case 3:return void this.generatePopInto("lit[",1+(63&byte2),"].pointers[1]")}return;case 131:return byte2=this.method.bytes[this.pc++],void this.generateSend("lit[",1+(31&byte2),"]",byte2>>5,!1);case 132:switch(byte2=this.method.bytes[this.pc++],byte3=this.method.bytes[this.pc++],byte2>>5){case 0:return void this.generateSend("lit[",1+byte3,"]",31&byte2,!1);case 1:return void this.generateSend("lit[",1+byte3,"]",31&byte2,!0);case 2:return void this.generatePush("inst[",byte3,"]");case 3:return void this.generatePush("lit[",1+byte3,"]");case 4:return void this.generatePush("lit[",1+byte3,"].pointers[1]");case 5:return void this.generateStoreInto("inst[",byte3,"]");case 6:return void this.generatePopInto("inst[",byte3,"]");case 7:return void this.generateStoreInto("lit[",1+byte3,"].pointers[1]")}return;case 133:return byte2=this.method.bytes[this.pc++],void this.generateSend("lit[",1+(31&byte2),"]",byte2>>5,!0);case 134:return byte2=this.method.bytes[this.pc++],void this.generateSend("lit[",1+(63&byte2),"]",byte2>>6,!1);case 135:return void this.generateInstruction("pop","vm.sp--");case 136:return this.needsVar.stack=!0,void this.generateInstruction("dup","var dup = stack[vm.sp]; stack[++vm.sp] = dup");case 137:return this.needsVar.stack=!0,void this.generateInstruction("push thisContext","stack[++vm.sp] = vm.exportThisContext()");case 138:var popValues=(byte2=this.method.bytes[this.pc++])>127,count=127&byte2;return void this.generateClosureTemps(count,popValues);case 139:return byte2=this.method.bytes[this.pc++],byte3=this.method.bytes[this.pc++],void this.generateCallPrimitive(byte2+256*byte3,129);case 140:return byte2=this.method.bytes[this.pc++],byte3=this.method.bytes[this.pc++],void this.generatePush("temp[",6+byte3,"].pointers[",byte2,"]");case 141:return byte2=this.method.bytes[this.pc++],byte3=this.method.bytes[this.pc++],void this.generateStoreInto("temp[",6+byte3,"].pointers[",byte2,"]");case 142:return byte2=this.method.bytes[this.pc++],byte3=this.method.bytes[this.pc++],void this.generatePopInto("temp[",6+byte3,"].pointers[",byte2,"]");case 143:var numArgs=15&(byte2=this.method.bytes[this.pc++]),numCopied=byte2>>4,blockSize=(byte3=this.method.bytes[this.pc++])<<8|this.method.bytes[this.pc++];return void this.generateClosureCopy(numArgs,numCopied,blockSize)}},generateSista:function(){var b,b2,b3,bytes=this.method.bytes,extA=0,extB=0;for(this.done=!1;!this.done;){switch(b=bytes[this.pc++]){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9:case 10:case 11:case 12:case 13:case 14:case 15:this.generatePush("inst[",15&b,"]");break;case 16:case 17:case 18:case 19:case 20:case 21:case 22:case 23:case 24:case 25:case 26:case 27:case 28:case 29:case 30:case 31:this.generatePush("lit[",1+(15&b),"].pointers[1]");break;case 32:case 33:case 34:case 35:case 36:case 37:case 38:case 39:case 40:case 41:case 42:case 43:case 44:case 45:case 46:case 47:case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:case 58:case 59:case 60:case 61:case 62:case 63:this.generatePush("lit[",1+(31&b),"]");break;case 64:case 65:case 66:case 67:case 68:case 69:case 70:case 71:this.generatePush("temp[",6+(7&b),"]");break;case 72:case 73:case 74:case 75:this.generatePush("temp[",6+(3&b)+8,"]");break;case 76:this.generatePush("rcvr");break;case 77:this.generatePush("vm.trueObj");break;case 78:this.generatePush("vm.falseObj");break;case 79:this.generatePush("vm.nilObj");break;case 80:this.generatePush(0);break;case 81:this.generatePush(1);break;case 82:this.needsVar.stack=!0,this.generateInstruction("push thisContext","stack[++vm.sp] = vm.exportThisContext()");break;case 83:this.needsVar.stack=!0,this.generateInstruction("dup","var dup = stack[vm.sp]; stack[++vm.sp] = dup");break;case 84:case 85:case 86:case 87:case 218:case 219:case 220:case 221:case 222:case 223:case 246:case 247:case 254:case 255:throw Error("unusedBytecode "+b);case 88:this.generateReturn("rcvr");break;case 89:this.generateReturn("vm.trueObj");break;case 90:this.generateReturn("vm.falseObj");break;case 91:this.generateReturn("vm.nilObj");break;case 92:this.generateReturn("stack[vm.sp]");break;case 93:this.generateBlockReturn("vm.nilObj");break;case 94:this.generateBlockReturn();break;case 95:break;case 96:case 97:case 98:case 99:case 100:case 101:case 102:case 103:case 104:case 105:case 106:case 107:case 108:case 109:case 110:case 111:this.generateNumericOp(b);break;case 112:case 113:case 114:case 115:case 116:case 117:case 118:case 119:case 120:case 121:case 122:case 123:case 124:case 125:case 126:case 127:this.generateQuickPrim(b);break;case 128:case 129:case 130:case 131:case 132:case 133:case 134:case 135:case 136:case 137:case 138:case 139:case 140:case 141:case 142:case 143:this.generateSend("lit[",1+(15&b),"]",0,!1);break;case 144:case 145:case 146:case 147:case 148:case 149:case 150:case 151:case 152:case 153:case 154:case 155:case 156:case 157:case 158:case 159:this.generateSend("lit[",1+(15&b),"]",1,!1);break;case 160:case 161:case 162:case 163:case 164:case 165:case 166:case 167:case 168:case 169:case 170:case 171:case 172:case 173:case 174:case 175:this.generateSend("lit[",1+(15&b),"]",2,!1);break;case 176:case 177:case 178:case 179:case 180:case 181:case 182:case 183:this.generateJump(1+(7&b));break;case 184:case 185:case 186:case 187:case 188:case 189:case 190:case 191:this.generateJumpIf(!0,1+(7&b));break;case 192:case 193:case 194:case 195:case 196:case 197:case 198:case 199:this.generateJumpIf(!1,1+(7&b));break;case 200:case 201:case 202:case 203:case 204:case 205:case 206:case 207:this.generatePopInto("inst[",7&b,"]");break;case 208:case 209:case 210:case 211:case 212:case 213:case 214:case 215:this.generatePopInto("temp[",6+(7&b),"]");break;case 216:this.generateInstruction("pop","vm.sp--");break;case 217:throw Error("unumplementedBytecode: 0xD9 (unconditional trap)");case 224:extA=256*extA+(b2=bytes[this.pc++]);continue;case 225:extB=256*extB+((b2=bytes[this.pc++])<128?b2:b2-256);continue;case 226:b2=bytes[this.pc++],this.generatePush("inst[",b2+256*extA,"]");break;case 227:b2=bytes[this.pc++],this.generatePush("lit[",1+b2+256*extA,"].pointers[1]");break;case 228:b2=bytes[this.pc++],this.generatePush("lit[",1+b2+256*extA,"]");break;case 229:b2=bytes[this.pc++],this.generatePush("temp[",6+b2,"]");break;case 230:throw Error("unusedBytecode 0xE6");case 231:var popValues=(b2=bytes[this.pc++])>127,count=127&b2;this.generateClosureTemps(count,popValues);break;case 232:b2=bytes[this.pc++],this.generatePush(b2+256*extB);break;case 233:b2=bytes[this.pc++],this.generatePush("vm.image.getCharacter(",b2+256*extB,")");break;case 234:b2=bytes[this.pc++],this.generateSend("lit[",1+(b2>>3)+(extA<<5),"]",(7&b2)+(extB<<3),!1);break;case 235:var lit=((b2=bytes[this.pc++])>>3)+(extA<<5),numArgs=(7&b2)+((63&extB)<<3),directed=extB>=64;this.generateSend("lit[",1+lit,"]",numArgs,!directed||"directed");break;case 236:throw Error("unimplemented bytecode: 0xEC (class trap)");case 237:b2=bytes[this.pc++],this.generateJump(b2+256*extB);break;case 238:b2=bytes[this.pc++],this.generateJumpIf(!0,b2+256*extB);break;case 239:b2=bytes[this.pc++],this.generateJumpIf(!1,b2+256*extB);break;case 240:b2=bytes[this.pc++],this.generatePopInto("inst[",b2+256*extA,"]");break;case 241:b2=bytes[this.pc++],this.generatePopInto("lit[",1+b2+256*extA,"].pointers[1]");break;case 242:b2=bytes[this.pc++],this.generatePopInto("temp[",6+b2,"]");break;case 243:b2=bytes[this.pc++],this.generateStoreInto("inst[",b2+256*extA,"]");break;case 244:b2=bytes[this.pc++],this.generateStoreInto("lit[",1+b2+256*extA,"].pointers[1]");break;case 245:b2=bytes[this.pc++],this.generateStoreInto("temp[",6+b2,"]");break;case 248:b2=bytes[this.pc++],b3=bytes[this.pc++],this.generateCallPrimitive(b2+256*b3,245);break;case 249:b2=bytes[this.pc++],b3=bytes[this.pc++],this.generatePushFullClosure(b2+255*extA,b3);break;case 250:numArgs=(7&(b2=bytes[this.pc++]))+8*(15&extA);var numCopied=(b2>>3&7)+8*(extA>>4),blockSize=(b3=bytes[this.pc++])+(extB<<8);this.generateClosureCopy(numArgs,numCopied,blockSize);break;case 251:b2=bytes[this.pc++],b3=bytes[this.pc++],this.generatePush("temp[",6+b3,"].pointers[",b2,"]");break;case 252:b2=bytes[this.pc++],b3=bytes[this.pc++],this.generateStoreInto("temp[",6+b3,"].pointers[",b2,"]");break;case 253:b2=bytes[this.pc++],b3=bytes[this.pc++],this.generatePopInto("temp[",6+b3,"].pointers[",b2,"]");break;default:throw Error("illegal bytecode: "+b)}extA=0,extB=0}},generatePush:function(target,arg1,suffix1,arg2,suffix2){this.debug&&this.generateDebugCode("push",target,arg1,suffix1,arg2,suffix2),this.generateLabel(),this.needsVar[target]=!0,this.needsVar.stack=!0,this.source.push("stack[++vm.sp] = ",target),void 0!==arg1&&(this.source.push(arg1,suffix1),void 0!==arg2&&this.source.push(arg2,suffix2)),this.source.push(";\n")},generateStoreInto:function(target,arg1,suffix1,arg2,suffix2){this.debug&&this.generateDebugCode("store into",target,arg1,suffix1,arg2,suffix2),this.generateLabel(),this.needsVar[target]=!0,this.needsVar.stack=!0,this.source.push(target),void 0!==arg1&&(this.source.push(arg1,suffix1),void 0!==arg2&&this.source.push(arg2,suffix2)),this.source.push(" = stack[vm.sp];\n"),this.generateDirty(target,arg1,suffix1)},generatePopInto:function(target,arg1,suffix1,arg2,suffix2){this.debug&&this.generateDebugCode("pop into",target,arg1,suffix1,arg2,suffix2),this.generateLabel(),this.needsVar[target]=!0,this.needsVar.stack=!0,this.source.push(target),void 0!==arg1&&(this.source.push(arg1,suffix1),void 0!==arg2&&this.source.push(arg2,suffix2)),this.source.push(" = stack[vm.sp--];\n"),this.generateDirty(target,arg1,suffix1)},generateReturn:function(what){this.debug&&this.generateDebugCode("return",what),this.generateLabel(),this.needsVar[what]=!0,this.source.push("vm.pc = ",this.pc,"; vm.doReturn(",what,"); return;\n"),this.needsBreak=!1,this.done=this.pc>this.endPC},generateBlockReturn:function(retVal){this.debug&&this.generateDebugCode("block return"),this.generateLabel(),retVal||(this.needsVar.stack=!0,retVal="stack[vm.sp--]"),this.needsVar.context=!0,this.source.push("vm.pc = ",this.pc,"; vm.doReturn(",retVal,", context.pointers[0]); return;\n"),this.needsBreak=!1,this.done=this.pc>this.endPC},generateJump:function(distance){var destination=this.pc+distance;this.debug&&this.generateDebugCode("jump to "+destination),this.generateLabel(),this.needsVar.context=!0,this.source.push("vm.pc = ",destination,"; "),distance<0&&this.source.push("\nif (vm.interruptCheckCounter-- <= 0) {\n"," vm.checkForInterrupts();\n"," if (context !== vm.activeContext || vm.breakOutOfInterpreter !== false) return;\n","}\n"),this.singleStep&&this.source.push("\nif (vm.breakOutOfInterpreter) return;\n"),this.source.push("continue;\n"),this.needsBreak=!1,this.needsLabel[destination]=!0,destination>this.endPC&&(this.endPC=destination)},generateJumpIf:function(condition,distance){var destination=this.pc+distance;this.debug&&this.generateDebugCode("jump if "+condition+" to "+destination),this.generateLabel(),this.needsVar.stack=!0,this.source.push("var cond = stack[vm.sp--]; if (cond === vm.",condition,"Obj) {vm.pc = ",destination,"; "),this.singleStep&&this.source.push("if (vm.breakOutOfInterpreter) return; else "),this.source.push("continue}\n","else if (cond !== vm.",!condition,"Obj) {vm.sp++; vm.pc = ",this.pc,"; vm.send(vm.specialObjects[25], 0, false); return}\n"),this.needsLabel[this.pc]=!0,this.needsLabel[destination]=!0,destination>this.endPC&&(this.endPC=destination)},generateQuickPrim:function(byte){switch(this.debug&&this.generateDebugCode("quick send #"+this.specialSelectors[16+(15&byte)]),this.generateLabel(),15&byte){case 0:return this.needsVar.stack=!0,this.source.push("var a, b; if ((a=stack[vm.sp-1]).sqClass === vm.specialObjects[7] && typeof (b=stack[vm.sp]) === 'number' && b>0 && b<=a.pointers.length) {\n"," stack[--vm.sp] = a.pointers[b-1];","} else { var c = vm.primHandler.objectAt(true,true,false); if (vm.primHandler.success) stack[--vm.sp] = c; else {\n"," vm.pc = ",this.pc,"; vm.sendSpecial(16); if (context !== vm.activeContext || vm.breakOutOfInterpreter !== false) return; }}\n"),void(this.needsLabel[this.pc]=!0);case 1:return this.needsVar.stack=!0,this.source.push("var a, b; if ((a=stack[vm.sp-2]).sqClass === vm.specialObjects[7] && typeof (b=stack[vm.sp-1]) === 'number' && b>0 && b<=a.pointers.length) {\n"," var c = stack[vm.sp]; stack[vm.sp-=2] = a.pointers[b-1] = c; a.dirty = true;","} else { vm.primHandler.objectAtPut(true,true,false); if (vm.primHandler.success) stack[vm.sp-=2] = c; else {\n"," vm.pc = ",this.pc,"; vm.sendSpecial(17); if (context !== vm.activeContext || vm.breakOutOfInterpreter !== false) return; }}\n"),void(this.needsLabel[this.pc]=!0);case 2:return this.needsVar.stack=!0,this.source.push("if (stack[vm.sp].sqClass === vm.specialObjects[7]) stack[vm.sp] = stack[vm.sp].pointersSize();\n","else if (stack[vm.sp].sqClass === vm.specialObjects[6]) stack[vm.sp] = stack[vm.sp].bytesSize();\n","else { vm.pc = ",this.pc,"; vm.sendSpecial(18); if (context !== vm.activeContext || vm.breakOutOfInterpreter !== false) return; }\n"),void(this.needsLabel[this.pc]=!0);case 6:return this.needsVar.stack=!0,void this.source.push("var cond = stack[vm.sp-1] === stack[vm.sp];\nstack[--vm.sp] = cond ? vm.trueObj : vm.falseObj;\n");case 7:return this.needsVar.stack=!0,void this.source.push("stack[vm.sp] = typeof stack[vm.sp] === 'number' ? vm.specialObjects[5] : stack[vm.sp].sqClass;\n");case 8:return this.needsVar.rcvr=!0,this.source.push("vm.pc = ",this.pc,"; if (!vm.primHandler.quickSendOther(rcvr, ",15&byte,")) ","{vm.sendSpecial(",16+(15&byte),"); return}\n"),this.needsLabel[this.pc]=!0,void(this.needsLabel[this.pc+2]=!0);case 9:case 10:case 11:return this.needsVar.rcvr=!0,this.source.push("vm.pc = ",this.pc,"; if (!vm.primHandler.quickSendOther(rcvr, ",15&byte,")) vm.sendSpecial(",16+(15&byte),"); return;\n"),void(this.needsLabel[this.pc]=!0)}this.needsVar.rcvr=!0,this.needsVar.context=!0,this.source.push("vm.pc = ",this.pc,"; if (!vm.primHandler.quickSendOther(rcvr, ",15&byte,"))"," vm.sendSpecial(",16+(15&byte),");\n","if (context !== vm.activeContext || vm.breakOutOfInterpreter !== false) return;\n"),this.needsBreak=!1,this.needsLabel[this.pc]=!0},generateNumericOp:function(byte){switch(this.debug&&this.generateDebugCode("quick send #"+this.specialSelectors[15&byte]),this.generateLabel(),this.needsLabel[this.pc]=!0,15&byte){case 0:return this.needsVar.stack=!0,void this.source.push("var a = stack[vm.sp - 1], b = stack[vm.sp];\n","if (typeof a === 'number' && typeof b === 'number') {\n"," stack[--vm.sp] = vm.primHandler.signed32BitIntegerFor(a + b);\n","} else { vm.pc = ",this.pc,"; vm.sendSpecial(0); if (context !== vm.activeContext || vm.breakOutOfInterpreter !== false) return}\n");case 1:return this.needsVar.stack=!0,void this.source.push("var a = stack[vm.sp - 1], b = stack[vm.sp];\n","if (typeof a === 'number' && typeof b === 'number') {\n"," stack[--vm.sp] = vm.primHandler.signed32BitIntegerFor(a - b);\n","} else { vm.pc = ",this.pc,"; vm.sendSpecial(1); if (context !== vm.activeContext || vm.breakOutOfInterpreter !== false) return}\n");case 2:return this.needsVar.stack=!0,void this.source.push("var a = stack[vm.sp - 1], b = stack[vm.sp];\n","if (typeof a === 'number' && typeof b === 'number') {\n"," stack[--vm.sp] = a < b ? vm.trueObj : vm.falseObj;\n","} else { vm.pc = ",this.pc,"; vm.sendSpecial(2); if (context !== vm.activeContext || vm.breakOutOfInterpreter !== false) return}\n");case 3:return this.needsVar.stack=!0,void this.source.push("var a = stack[vm.sp - 1], b = stack[vm.sp];\n","if (typeof a === 'number' && typeof b === 'number') {\n"," stack[--vm.sp] = a > b ? vm.trueObj : vm.falseObj;\n","} else { vm.pc = ",this.pc,"; vm.sendSpecial(3); if (context !== vm.activeContext || vm.breakOutOfInterpreter !== false) return}\n");case 4:return this.needsVar.stack=!0,void this.source.push("var a = stack[vm.sp - 1], b = stack[vm.sp];\n","if (typeof a === 'number' && typeof b === 'number') {\n"," stack[--vm.sp] = a <= b ? vm.trueObj : vm.falseObj;\n","} else { vm.pc = ",this.pc,"; vm.sendSpecial(4); if (context !== vm.activeContext || vm.breakOutOfInterpreter !== false) return}\n");case 5:return this.needsVar.stack=!0,void this.source.push("var a = stack[vm.sp - 1], b = stack[vm.sp];\n","if (typeof a === 'number' && typeof b === 'number') {\n"," stack[--vm.sp] = a >= b ? vm.trueObj : vm.falseObj;\n","} else { vm.pc = ",this.pc,"; vm.sendSpecial(5); if (context !== vm.activeContext || vm.breakOutOfInterpreter !== false) return}\n");case 6:return this.needsVar.stack=!0,void this.source.push("var a = stack[vm.sp - 1], b = stack[vm.sp];\n","if (typeof a === 'number' && typeof b === 'number') {\n"," stack[--vm.sp] = a === b ? vm.trueObj : vm.falseObj;\n","} else if (a === b && a.float === a.float) {\n"," stack[--vm.sp] = vm.trueObj;\n","} else { vm.pc = ",this.pc,"; vm.sendSpecial(6); if (context !== vm.activeContext || vm.breakOutOfInterpreter !== false) return}\n");case 7:return this.needsVar.stack=!0,void this.source.push("var a = stack[vm.sp - 1], b = stack[vm.sp];\n","if (typeof a === 'number' && typeof b === 'number') {\n"," stack[--vm.sp] = a !== b ? vm.trueObj : vm.falseObj;\n","} else if (a === b && a.float === a.float) {\n"," stack[--vm.sp] = vm.falseObj;\n","} else { vm.pc = ",this.pc,"; vm.sendSpecial(7); if (context !== vm.activeContext || vm.breakOutOfInterpreter !== false) return}\n");case 8:return void this.source.push("vm.success = true; vm.resultIsFloat = false; if(!vm.pop2AndPushNumResult(vm.stackIntOrFloat(1) * vm.stackIntOrFloat(0))) { vm.pc = ",this.pc,"; vm.sendSpecial(8); return}\n");case 9:return void this.source.push("vm.success = true; if(!vm.pop2AndPushIntResult(vm.quickDivide(vm.stackInteger(1),vm.stackInteger(0)))) { vm.pc = ",this.pc,"; vm.sendSpecial(9); return}\n");case 10:return void this.source.push("vm.success = true; if(!vm.pop2AndPushIntResult(vm.mod(vm.stackInteger(1),vm.stackInteger(0)))) { vm.pc = ",this.pc,"; vm.sendSpecial(10); return}\n");case 11:return void this.source.push("vm.success = true; if(!vm.primHandler.primitiveMakePoint(1, true)) { vm.pc = ",this.pc,"; vm.sendSpecial(11); return}\n");case 12:return void this.source.push("vm.success = true; if(!vm.pop2AndPushIntResult(vm.safeShift(vm.stackInteger(1),vm.stackInteger(0)))) { vm.pc = ",this.pc,"; vm.sendSpecial(12); return}\n");case 13:return void this.source.push("vm.success = true; if(!vm.pop2AndPushIntResult(vm.div(vm.stackInteger(1),vm.stackInteger(0)))) { vm.pc = ",this.pc,"; vm.sendSpecial(13); return}\n");case 14:return void this.source.push("vm.success = true; if(!vm.pop2AndPushIntResult(vm.stackInteger(1) & vm.stackInteger(0))) { vm.pc = ",this.pc,"; vm.sendSpecial(14); return}\n");case 15:return void this.source.push("vm.success = true; if(!vm.pop2AndPushIntResult(vm.stackInteger(1) | vm.stackInteger(0))) { vm.pc = ",this.pc,"; vm.sendSpecial(15); return}\n")}},generateSend:function(prefix,num,suffix,numArgs,superSend){this.debug&&this.generateDebugCode(("directed"===superSend?"directed super send ":superSend?"super send ":"send ")+("lit["===prefix?this.method.pointers[num].bytesAsString():"...")),this.generateLabel(),this.needsVar[prefix]=!0,this.needsVar.context=!0,this.source.push("vm.pc = ",this.pc),"directed"===superSend?this.source.push("; vm.sendSuperDirected(",prefix,num,suffix,", ",numArgs,"); "):this.source.push("; vm.send(",prefix,num,suffix,", ",numArgs,", ",superSend,"); "),this.source.push("if (context !== vm.activeContext || vm.breakOutOfInterpreter !== false) return;\n"),this.needsBreak=!1,this.needsLabel[this.pc]=!0},generateClosureTemps:function(count,popValues){if(this.debug&&this.generateDebugCode("closure temps"),this.generateLabel(),this.needsVar.stack=!0,this.source.push("var array = vm.instantiateClass(vm.specialObjects[7], ",count,");\n"),popValues){for(var i=0;i0){for(var i=0;ithis.endPC&&(this.endPC=to)},generatePushFullClosure:function(index,b3){this.debug&&this.generateDebugCode("push full closure "+(index+1)),this.generateLabel(),this.needsVar["lit["]=!0,this.needsVar.rcvr=!0,this.needsVar.stack=!0;var outer,numCopied=63&b3;if(outer=1==(b3>>6&1)?"vm.nilObj":"context",1==(b3>>7&1))throw Error("on-stack receiver not yet supported");if(this.source.push("var closure = vm.newFullClosure(",outer,", ",numCopied,", lit[",1+index,"]);\n"),this.source.push("closure.pointers[",Squeak.ClosureFull_receiver,"] = rcvr;\n"),"context"===outer&&this.source.push("vm.reclaimableContextCount = 0;\n"),numCopied>0){for(var i=0;i ",command),void 0!==what)switch(this.source.push(" "),what){case"vm.nilObj":this.source.push("nil");break;case"vm.trueObj":this.source.push("true");break;case"vm.falseObj":this.source.push("false");break;case"rcvr":this.source.push("self");break;case"stack[vm.sp]":this.source.push("top of stack");break;case"inst[":this.instVarNames?this.source.push(this.instVarNames[arg1]):this.source.push("inst var ",arg1);break;case"temp[":this.source.push("tmp",arg1-6),"]"!==suffix1&&this.source.push("[",arg2,"]");break;case"lit[":var lit=this.method.pointers[arg1];"]"===suffix1?this.source.push(lit):this.source.push(lit.pointers[0].bytesAsString());break;default:this.source.push(what)}this.source.push("\n"),this.needsBreak=this.singleStep},generateInstruction:function(comment,instr){this.debug&&this.generateDebugCode(comment),this.generateLabel(),this.source.push(instr,";\n")},deleteUnneededLabels:function(){var hasAnyLabel=!1;for(var i in this.sourceLabels)if(this.needsLabel[i])hasAnyLabel=!0;else for(var j=0;j<3;j++)this.source[this.sourceLabels[i]+j]="";hasAnyLabel||(this.source[this.sourcePos["loop-start"]]="",this.source[this.sourcePos["loop-end"]]="")},deleteUnneededVariables:function(){this.needsVar.stack&&(this.needsVar.context=!0),this.needsVar["inst["]&&(this.needsVar.rcvr=!0);for(var i=0;idirEntries.length)return!1;var dirEntry=dirEntries[index-1],stats=fs.statSync(dirName+path.sep+dirEntry);entry=[dirEntry,Math.floor((stats.ctimeMs-Squeak.Epoch)/1e3),Math.floor((stats.mtimeMs-Squeak.Epoch)/1e3),stats.isDirectory(),stats.isFile()?stats.size:0]}catch(e){return-20!==e.errno&&console.error("Failed to read directory: "+dirName),!1}return this.popNandPushIfOK(argCount+1,this.makeStObject(entry)),!0},primitiveFileStdioHandles:function(argCount){var handles=[this.makeFileHandle("/dev/stdin",0,!1),this.makeFileHandle("/dev/stdout",1,!0),this.makeFileHandle("/dev/stderr",2,!0)];return this.popNandPushIfOK(argCount+1,this.makeStArray(handles)),!0},primitiveFileOpen:function(argCount){var writeFlag=this.stackBoolean(0),fileNameObj=this.stackNonInteger(1);if(!this.success)return!1;var fd,fileName=fileNameObj.bytesAsString();try{if((fd=fs.openSync(fileName,writeFlag?"a+":"r"))<0)return!1}catch(e){return console.error("Failed to open file: "+fileName),!1}var handle=this.makeFileHandle(fileName,fd,writeFlag);return openFileDescriptors.push(fd),this.popNandPushIfOK(argCount+1,handle),!0},primitiveFileSize:function(argCount){var fileSize,handle=this.stackNonInteger(0);if(!this.success)return!1;try{fileSize=fs.fstatSync(handle.fd).size}catch(e){return console.error("Failed to get file size"),!1}return this.popNandPushIfOK(argCount+1,this.makeLargeIfNeeded(fileSize)),!0},primitiveFileGetPosition:function(argCount){var handle=this.stackNonInteger(0);return!!this.success&&(this.popNandPushIfOK(argCount+1,this.makeLargeIfNeeded(handle.filePos)),!0)},primitiveFileSetPosition:function(argCount){var pos=this.stackPos32BitInt(0),handle=this.stackNonInteger(1);return!!this.success&&(handle.filePos=pos,this.popNIfOK(argCount))},primitiveFileAtEnd:function(argCount){var fileAtEnd,handle=this.stackNonInteger(0);if(!this.success)return!1;try{fileAtEnd=handle.filePos>=fs.fstatSync(handle.fd).size}catch(e){return console.error("Failed to decide if at end of file"),!1}return this.popNandPushIfOK(argCount+1,this.makeStObject(fileAtEnd)),!0},primitiveDirectorySetMacTypeAndCreator:function(argCount){return this.popNIfOK(argCount)},primitiveFileRead:function(argCount){var count=this.stackInteger(0),startIndex=this.stackInteger(1)-1,arrayObj=this.stackNonInteger(2),handle=this.stackNonInteger(3);if(!this.success||!arrayObj.isWordsOrBytes())return!1;if(!count)return this.popNandPushIfOK(argCount+1,0);var bytesRead,array=arrayObj.bytes;if(array||(array=arrayObj.wordsAsUint8Array(),startIndex*=4,count*=4),startIndex<0||startIndex+count>array.length)return!1;if(0===handle.fd)return console.warn("File reading on stdin not implemented yet"),!1;try{bytesRead=fs.readSync(handle.fd,array,startIndex,count,handle.filePos),handle.filePos+=bytesRead}catch(e){return console.error("Failed to read from file"),!1}return count=arrayObj.bytes?bytesRead:bytesRead>>2,this.popNandPushIfOK(argCount+1,count),!0},primitiveFileWrite:function(argCount){var count=this.stackInteger(0),startIndex=this.stackInteger(1)-1,arrayObj=this.stackNonInteger(2),handle=this.stackNonInteger(3);if(!this.success||!handle.fileWrite)return!1;if(!count)return this.popNandPushIfOK(argCount+1,0);var bytesWritten,array=arrayObj.bytes;if(array||(array=arrayObj.wordsAsUint8Array(),startIndex*=4,count*=4),!array)return!1;if(startIndex<0||startIndex+count>array.length)return!1;if(1===handle.fd||2===handle.fd)for(var logger=1===handle.fd?console.log:console.error,buffer=array.slice(startIndex,startIndex+count);count>0&&buffer.length>0;){var linefeedIndex=buffer.indexOf(10);linefeedIndex>=0?(logger(previousWriteBuffers[handle.fd]+String.fromCharCode.apply(null,buffer.slice(0,linefeedIndex))),previousWriteBuffers[handle.fd]="",buffer=buffer.slice(linefeedIndex+1),bytesWritten+=linefeedIndex+1,count-=linefeedIndex+1,handle.filePos+=linefeedIndex+1):(previousWriteBuffers[handle.fd]+=String.fromCharCode.apply(null,buffer),bytesWritten+=buffer.length,count-=buffer.length,handle.filePos+=buffer.length)}else try{bytesWritten=fs.writeSync(handle.fd,array,startIndex,count,handle.filePos),handle.filePos+=bytesWritten}catch(e){return console.error("Failed to write to file"),!1}return arrayObj.bytes||(bytesWritten>>=2),this.popNandPushIfOK(argCount+1,bytesWritten),!0},primitiveFileFlush:function(argCount){var handle=this.stackNonInteger(0);if(!this.success)return!1;if(1===handle.fd||2===handle.fd)(1===handle.fd?console.log:console.error)(previousWriteBuffers[handle.fd]),previousWriteBuffers[handle.fd]="";else try{fs.fsyncSync(handle.fd)}catch(e){return console.error("Failed to flush file"),!1}return this.popNIfOK(argCount)},primitiveFileTruncate:function(argCount){var pos=this.stackPos32BitInt(0),handle=this.stackNonInteger(1);if(!this.success||!handle.fileWrite)return!1;try{fs.fstatSync(handle.fd).size>pos&&(fs.ftruncateSync(handle.fd,pos),handle.filePos>pos&&(handle.filePos=pos))}catch(e){return console.error("Failed to truncate file"),!1}return this.popNIfOK(argCount)},primitiveFileClose:function(argCount){var handle=this.stackNonInteger(0);if(!this.success)return!1;try{fs.closeSync(handle.fd),openFileDescriptors=openFileDescriptors.filter((function(fd){return fd!==handle.fd}))}catch(e){return console.error("Failed to close file"),!1}return this.popNIfOK(argCount)},primitiveFileRename:function(argCount){var oldNameObj=this.stackNonInteger(1),newNameObj=this.stackNonInteger(0);if(!this.success)return!1;var oldName=oldNameObj.bytesAsString(),newName=newNameObj.bytesAsString();try{fs.renameSync(oldName,newName)}catch(e){return console.error("Failed to rename file from: "+oldName+" to: "+newName),!1}return this.popNIfOK(argCount)},primitiveFileDelete:function(argCount){var fileNameObj=this.stackNonInteger(0);if(!this.success)return!1;var fileName=fileNameObj.bytesAsString();try{fs.unlinkSync(fileName)}catch(e){return console.error("Failed to delete file: "+fileName),!1}return this.popNIfOK(argCount)},makeFileHandle:function(filename,fd,writeFlag){var handle=this.makeStString(filename);return handle.fd=fd,handle.fileWrite=writeFlag,handle.filePos=0,handle},filenameToSqueak:function(unixpath){return unixpath},filenameFromSqueak:function(filepath){return filepath}}),Object.extend(Squeak,{flushAllFiles:function(){openFileDescriptors.forEach((function(fd){try{fs.fsyncSync(fd)}catch(e){console.error("Failed to flush one of the files")}}))},filePut:function(fileName,buffer){try{fs.writeFileSync(fileName,new Uint8Array(buffer))}catch(e){console.error("Failed to create file with content: "+fileName)}}}),vm_plugins_file_node}var os=require$$0$4,fs=require$$0$3,process$1=require$$2$1,path=require$$1$1,processArgs=process$1.argv.slice(2),ignoreQuit="-ignoreQuit"===processArgs[0];ignoreQuit&&(processArgs=processArgs.slice(1));var fullName=processArgs[0];fullName||(console.error("No image name specified."),console.log("Usage (simplified): "+path.basename(process$1.argv0)+path.basename(process$1.argv[1])+" [-ignoreQuit] "),process$1.exit(1));var root=path.dirname(fullName)+path.sep,imageName=path.basename(fullName,".image");Object.assign(commonjsGlobal,{self:new Proxy({},{get:function(obj,prop){return commonjsGlobal[prop]},set:function(obj,prop,value){return commonjsGlobal[prop]=value,!0}})});class SessionStorage{storage={};constructor(){var self=this;Object.keys(process$1.env).forEach((function(key){self.storage[key]=process$1.env[key]}))}getItem(name){return this.storage[name]}setItem(name,value){this.storage[name]=value}removeItem(name){delete this.storage[name]}get length(){return Object.keys(this.storage).length}key(index){return Object.keys(this.storage)[index]}}function CpSystemPlugin(){return{getModuleName:function(){return"CpSystemPlugin"},interpreterProxy:null,primHandler:null,setInterpreter:function(anInterpreter){return this.setupGlobalObject(),this.interpreterProxy=anInterpreter,this.vm=anInterpreter.vm,this.primHandler=this.vm.primHandler,this.characterClass=this.vm.globalNamed("Character"),this.symbolClass=this.vm.globalNamed("Symbol"),this.symbolTable=Object.create(null),this.stringClass=this.vm.globalNamed("String"),this.byteStringClass=this.vm.globalNamed("ByteString"),this.wideStringClass=this.vm.globalNamed("WideString"),this.arrayClass=this.vm.globalNamed("Array"),this.byteArrayClass=this.vm.globalNamed("ByteArray"),this.wordArrayClass=this.vm.globalNamed("WordArray"),this.associationClass=this.vm.globalNamed("Association"),this.dictionaryClass=this.vm.globalNamed("Dictionary"),this.orderedDictionaryClass=this.vm.globalNamed("OrderedDictionary"),this.largePositiveIntegerClass=this.vm.globalNamed("LargePositiveInteger"),this.largeNegativeIntegerClass=this.vm.globalNamed("LargeNegativeInteger"),this.contextClass=this.vm.globalNamed("Context"),this.processClass=this.vm.globalNamed("Process"),this.functionCalls=[],this.maxProcessPriority=this.primHandler.getScheduler().pointers[Squeak.ProcSched_processLists].pointersSize(),this.globalProxyClasses={},this.lastException=null,this.updateStringSupport(),this.updateMakeStObject(),this.updateMakeStArray(),!0},setupGlobalObject:function(){"undefined"==typeof window||window.global?(commonjsGlobal.require=function(name){var module=require(name);return Object.keys(module).forEach((function(key){if(key[0]>="A"&&key[0]<="Z"){var value=module[key];value&&value.constructor&&value.prototype&&value===value.prototype.constructor&&(value.__cp_className=name+"."+key)}})),module},commonjsGlobal.constructor=function(){}):window.global=window,commonjsGlobal.identity=function(x){return x??commonjsGlobal}},runUninterrupted:function(process){var primHandler=this.primHandler,scheduler=primHandler.getScheduler();primHandler.putToSleep(scheduler.pointers[Squeak.ProcSched_activeProcess]),primHandler.transferTo(process);var compiled,vm=this.vm;do{(compiled=vm.method.compiled)?compiled(vm):vm.interpretOne()}while(process===scheduler.pointers[Squeak.ProcSched_activeProcess])},signalSemaphoreWithIndex:function(index){this.vm.runProcessLoop(!0),this.primHandler.signalSemaphoreWithIndex(index)},updateStringSupport:function(){this.stringClass.classInstProto().prototype.asString=function(){for(var charChunks=[],src=this.bytes||this.words||[],i=0;i=256&&(isWideString=!0),charValue})),newString=thisHandle.vm.instantiateClass(isWideString?thisHandle.wideStringClass:thisHandle.byteStringClass,src.length),dst=newString.bytes||newString.words||[],i=0;ithisHandle.maxSmallInteger||obj0;){var byte=255&obj;bytes[i++]=byte,obj=(obj-byte)/256}var largeInteger=this.vm.instantiateClass(this.vm.specialObjects[isNegative?Squeak.splOb_ClassLargeNegativeInteger:Squeak.splOb_ClassLargePositiveInteger],bytes.length);return largeInteger.bytes=bytes,largeInteger}return obj}return this.makeFloat(obj)}var stObj;if(seen=seen||[],void 0!==(stObj=thisHandle.findSeenObj(seen,obj)))return stObj;if(obj.substring)return thisHandle.addSeenObj(seen,obj,this.makeStString(obj));if(obj.slice&&void 0!==obj.length){if(!obj.BYTES_PER_ELEMENT)return thisHandle.addSeenObj(seen,obj,this.makeStArray(obj,proxyClass,seen));switch(obj.BYTES_PER_ELEMENT){case 1:return thisHandle.addSeenObj(seen,obj,this.makeStByteArray(obj));case 2:case 4:return thisHandle.addSeenObj(seen,obj,thisHandle.makeStWordArray(obj));default:return console.error("No support for TypedArrays with bytes per element: "+obj.BYTES_PER_ELEMENT,obj),this.vm.nilObj}}return obj.constructor===Object&&!thisHandle.hasFunctions(obj)||void 0===obj.constructor&&"object"==typeof obj?thisHandle.makeStOrderedDictionary(obj,seen):(proxyClass||(proxyClass=thisHandle.getProxyClassFor(obj)),proxyClass?((stObj=this.vm.instantiateClass(proxyClass,0)).jsObj=obj,thisHandle.addSeenObj(seen,obj,stObj)):(console.error("Can't create Smalltalk object for the following object (answering nil)",obj),this.vm.nilObj))}},updateMakeStArray:function(){var thisHandle=this;this.primHandler.makeStArray=function(obj,proxyClass,seen){seen=seen||[];var stObj=thisHandle.findSeenObj(seen,obj);if(void 0!==stObj)return stObj;var array=this.vm.instantiateClass(thisHandle.arrayClass,obj.length);seen.push({jsObj:obj,stObj:array});for(var i=0;i0;if(result){var isLetter=function(c){return c>=65&&c<=90||c>=97&&c<=122},isBinary=function(c){return[33,37,38,42,43,44,45,47,60,61,62,63,64,92,96,124,215,247].indexOf(c)>=0||c>=126&&c<=191&&[170,181,186].indexOf(c)<0},check=isLetter(src[0])?function(c){return isLetter(c)||function(c){return c>=48&&c<=57}(c)||function(c){return 58===c}(c)}:isBinary(src[0])?function(c){return isBinary(c)}:null;for(result=null!==check;i36)return!1;var receiver=this.interpreterProxy.stackValue(argCount),value=null;return receiver.isFloat?10===base&&(value=receiver.float.toString()):"number"==typeof receiver&&(value=receiver.toString(base)),null!==value&&this.answer(argCount,10!==base?base+"r"+value:value)},primitiveIntegerAtRandom:function(argCount){if(0!==argCount)return!1;var upperBound=this.interpreterProxy.stackValue(argCount);return"number"==typeof upperBound&&this.answer(argCount,Math.floor(Math.random()*(upperBound-1)+1))},"primitiveStringFromWordArray:":function(argCount){if(1!==argCount)return!1;for(var receiver=this.interpreterProxy.stackValue(argCount),src=this.interpreterProxy.stackValue(0).words||[],newString=this.vm.instantiateClass(receiver,src.length),dst=newString.bytes||newString.words,i=0;i=0)return from;return src.length+1},createSubstring:function(src,start,end){for(var substring=src.slice(start,end),isWideString=substring.some((function(charValue){return charValue>=256})),newString=this.vm.instantiateClass(isWideString?this.wideStringClass:this.byteStringClass,substring.length),dst=newString.bytes||newString.words||[],i=0;i0)return this.answer(argCount,3);if(cmp<0)return this.answer(argCount,1)}return src.length>minLength?this.answer(argCount,3):dst.length>minLength?this.answer(argCount,1):this.answer(argCount,2)},primitiveStringAsUppercase:function(argCount){if(0!==argCount)return!1;for(var receiver=this.interpreterProxy.stackValue(argCount),src=receiver.bytes||receiver.words||[],uppercaseString=this.vm.instantiateClass(receiver.sqClass,src.length),dst=receiver.bytes?uppercaseString.bytes:uppercaseString.words,i=0;i=2&&base<=36&&numberMatch[2].indexOf(".")<0&&numberMatch[2].indexOf("e")<0&&(result=Number.parseInt(numberMatch[2],base))}else result=+numberMatch[2]}return null!==result&&this.answer(argCount,result)},"primitiveStringFindTokens:":function(argCount){if(1!==argCount)return!1;for(var receiver=this.interpreterProxy.stackValue(argCount),src=receiver.bytes||receiver.words||[],delimitersString=this.interpreterProxy.stackValue(0),delimiters=delimitersString.bytes||delimitersString.words||[],result=[],keyStop=0;keyStop=0)},primitiveStringHash:function(argCount){if(0!==argCount)return!1;var receiver=this.interpreterProxy.stackValue(argCount),src=receiver.bytes||receiver.words||[],hash=this.stringHash(src);return this.answer(argCount,hash)},"primitiveWideStringFrom:":function(argCount){if(1!==argCount)return!1;for(var receiver=this.interpreterProxy.stackValue(argCount),srcString=this.interpreterProxy.stackValue(0),src=srcString.bytes||srcString.words||[],newString=this.vm.instantiateClass(receiver,src.length),dst=newString.words,i=0;i0&&(selectorDescription=this.getSelectorNamed(obj,selectorName.slice(0,colonIndex)))}if(!selectorDescription)return!1;if(selectorDescription.get&&0===args.length)result=selectorDescription.get.apply(obj);else if(selectorDescription.set&&1===args.length)result=selectorDescription.set.apply(obj,args);else if(selectorDescription.value&&selectorDescription.value.constructor===Function)result=selectorDescription.value.apply(obj,args);else{if(void 0===selectorDescription.writable)return!1;0===args.length?result=selectorDescription.value:1===args.length&&selectorDescription.writable&&(result=obj[selectorName]=args[0])}}}catch(e){return this.lastException=e,!1}if(null!=result&&!proxyClass.isNil){var proxyInstance=this.vm.instantiateClass(proxyClass,0);proxyInstance.jsObj=result,result=proxyInstance}return this.answer(argCount,result)},"primitiveJavaScriptObjectLastExceptionAs:":function(argCount){if(1!==argCount)return!1;var proxyClass=this.interpreterProxy.stackValue(0),exception=this.lastException;if(null!==exception){var proxyInstance=this.vm.instantiateClass(proxyClass,0);proxyInstance.jsObj=exception,exception=proxyInstance,this.lastException=null}return this.answer(argCount,exception)},"primitiveJavaScriptObjectPropertyAt:resultAs:":function(argCount){if(2!==argCount)return!1;var obj=this.interpreterProxy.stackValue(argCount).jsObj;if(void 0===obj)return!1;var propertyName=this.interpreterProxy.stackValue(1).asString(),proxyClass=this.interpreterProxy.stackValue(0),result=obj[propertyName];if(null!=result&&!proxyClass.isNil){var proxyInstance=this.vm.instantiateClass(proxyClass,0);proxyInstance.jsObj=result,result=proxyInstance}return this.answer(argCount,result)},"primitiveJavaScriptObjectPropertyAt:put:":function(argCount){if(2!==argCount)return!1;var obj=this.interpreterProxy.stackValue(argCount).jsObj;if(void 0===obj)return!1;var propertyName=this.interpreterProxy.stackValue(1).asString(),propertyValue=this.asJavaScriptObject(this.interpreterProxy.stackValue(0));return obj[propertyName]=propertyValue,this.answerSelf(argCount)},primitiveJavaScriptObjectGetSelectorNames:function(argCount){if(0!==argCount)return!1;var obj=this.interpreterProxy.stackValue(argCount).jsObj;if(void 0===obj)return!1;for(var names=Object.create(null);obj;){Object.getOwnPropertyNames(obj).forEach((function(name){names[name]=!0})),obj=Object.getPrototypeOf(obj)}return this.answer(argCount,Object.keys(names))},"primitiveJavaScriptObjectGetSelectorType:":function(argCount){if(1!==argCount)return!1;var obj=this.interpreterProxy.stackValue(argCount).jsObj;if(void 0===obj)return!1;var selectorName=this.interpreterProxy.stackValue(0).asString();if(!selectorName)return!1;var selectorDescription=this.getSelectorNamed(obj,selectorName);if(!selectorDescription)return this.answer(argCount,null);var type=void 0;return type=selectorDescription.get?selectorDescription.set?"read-write-prop":"read-prop":selectorDescription.set?"write-prop":void 0!==selectorDescription.writable?selectorDescription.value&&selectorDescription.value.constructor===Function?"function":selectorDescription.writable?"read-write-attr":"read-attr":"unknown",this.answer(argCount,this.symbolFromString(type))},"primitiveJavaScriptObjectGetClassRefFrom:resultAs:":function(argCount){if(2!==argCount)return!1;var obj=this.interpreterProxy.stackValue(argCount).jsObj;if(void 0===obj)return!1;var selectorName=this.interpreterProxy.stackValue(1).asString();if(!selectorName)return!1;var proxyClass=this.interpreterProxy.stackValue(0);if(proxyClass.isNil)return!1;var objClass=obj[selectorName];if(!objClass)return!1;var proxyInstance=this.vm.instantiateClass(proxyClass,0);return proxyInstance.jsObj=objClass,this.answer(argCount,proxyInstance)},getSelectorNamed:function(obj,selectorName){for(var selectorDescription=void 0;obj&&!selectorDescription;)(selectorDescription=Object.getOwnPropertyDescriptor(obj,selectorName))||(obj=Object.getPrototypeOf(obj));return selectorDescription},"primitiveJavaScriptClassNewInstanceWithArguments:resultAs:":function(argCount){if(2!==argCount)return!1;var jsClass=this.interpreterProxy.stackValue(argCount).jsObj,args=this.asJavaScriptObject(this.interpreterProxy.stackValue(1))||[],proxyClass=this.interpreterProxy.stackValue(0),instance=void 0;try{var jsInstance=Reflect.construct(jsClass,args);(instance=this.vm.instantiateClass(proxyClass.isNil?this.getProxyClassFor(jsInstance):proxyClass,0)).jsObj=jsInstance}catch(e){console.error("Failed to instantiate class "+jsClass)}return this.answer(argCount,instance)},primitiveJavaScriptFunctionCurrentArguments:function(argCount){if(0!==argCount)return!1;var currentFunction=this.functionCalls[this.functionCalls.length-1];return void 0===currentFunction?(console.error("primitiveJavaScriptFunctionCurrentArguments called without a function present"),!1):this.answer(argCount,currentFunction.arguments)},"primitiveJavaScriptFunctionCurrentSetResult:":function(argCount){if(1!==argCount)return!1;var result=this.asJavaScriptObject(this.interpreterProxy.stackValue(0)),currentFunction=this.functionCalls[this.functionCalls.length-1];return void 0===currentFunction?(console.error("primitiveJavaScriptFunctionCurrentSetResult: called without a function present"),!1):(currentFunction.result=result,this.answerSelf(argCount))},"primitiveEnvironmentVariableAt:":function(argCount){if(1!==argCount)return!1;var variableName=this.interpreterProxy.stackValue(0).asString();if(!variableName)return!1;var variableValue=commonjsGlobal.sessionStorage.getItem(variableName);return this.answer(argCount,variableValue)},"primitiveEnvironmentVariableAt:put:":function(argCount){if(2!==argCount)return!1;var variableName=this.interpreterProxy.stackValue(1).asString();if(!variableName)return!1;var variableValue=this.interpreterProxy.stackValue(0).asString();return!!variableValue&&(commonjsGlobal.sessionStorage.setItem(variableName,variableValue),this.answerSelf(argCount))},primitiveEnvironmentVariableNames:function(argCount){if(0!==argCount)return!1;for(var variableNames=new Array(commonjsGlobal.sessionStorage.length),i=0;i7&&(vm.stoppedProcessLoop=!0)}else vm.processLoopCounter=0;!ignoreQuit&&display.quitFlag||setTimeout(vm.runProcessLoop,"sleep"===ms?10:ms)}))}catch(e){console.error("Failure during Squeak run: ",e)}},vm.runProcessLoop()}))}})),function(){var VM_PROXY_MAJOR=1,VM_PROXY_MINOR=11;function CLASSOF(obj){return"number"==typeof obj?interpreterProxy.classSmallInteger():obj.sqClass}function BYTESIZEOF(obj){return obj.bytes?obj.bytes.length:obj.words?4*obj.words.length:0}function DIV(a,b){return 0|Math.floor(a/b)}function MOD(a,b){return a-DIV(a,b)*b|0}function SHL(a,b){return b>31?0:a<31?0:a>>>b}var andOpIndex=0,interpreterProxy=null,moduleName="LargeIntegers v1.5 (e)",orOpIndex=1,xorOpIndex=2;function anyBitOfBytesfromto(aBytesOop,start,stopArg){var lastByteIx,magnitude,leftShift,rightShift,firstByteIx,stop,mask,ix;if(start<1||stopArg<1)return interpreterProxy.primitiveFail();if(magnitude=aBytesOop,stop=Math.min(stopArg,function(aBytesOop){return cDigitHighBitlen(aBytesOop.bytes,BYTESIZEOF(aBytesOop))}(magnitude)),start>stop)return!1;if(firstByteIx=1+(start-1>>3),lastByteIx=1+(stop-1>>3),rightShift=MOD(start-1,8),leftShift=7-MOD(stop-1,8),firstByteIx===lastByteIx)return mask=SHL(255,rightShift)&SHR(255,leftShift),0!=(digitOfBytesat(magnitude,firstByteIx)&mask);if(0!==SHR(digitOfBytesat(magnitude,firstByteIx),rightShift))return!0;for(ix=firstByteIx+1;ix<=lastByteIx-1;ix++)if(0!==digitOfBytesat(magnitude,ix))return!0;return 0!=(255&SHL(digitOfBytesat(magnitude,lastByteIx),leftShift))}function bytesgrowTo(aBytesObject,newLen){var oldLen,copyLen,newBytes;return newBytes=interpreterProxy.instantiateClassindexableSize(CLASSOF(aBytesObject),newLen),copyLen=(oldLen=BYTESIZEOF(aBytesObject))=0;){if((secondDigit=pSecond[ix])!==(firstDigit=pFirst[ix]))return secondDigit-256?1:csi<65536&&csi>-65536?2:csi<16777216&&csi>-16777216?3:4}function cDigitOfCSIat(csi,ix){return ix<1&&interpreterProxy.primitiveFail(),ix>4?0:csi<0?255&SHR(0-csi,8*(ix-1)):255&SHR(csi,8*(ix-1))}function cDigitReplacefromtowithstartingAt(pTo,start,stop,pFrom,repStart){return function(){for(var len=stop-start+1,i=0;i>>=16,bitNo+=16),shifted<256||(shifted>>>=8,bitNo+=8),shifted<16||(shifted>>>=4,bitNo+=4),shifted<4||(shifted>>>=2,bitNo+=2),shifted<2||(shifted>>>=1,++bitNo),bitNo+shifted}function createLargeFromSmallInteger(anOop){var size,res,pByte,ix,sq_class,val;for(sq_class=(val=anOop)<0?interpreterProxy.classLargeNegativeInteger():interpreterProxy.classLargePositiveInteger(),size=cDigitLengthOfCSI(val),pByte=(res=interpreterProxy.instantiateClassindexableSize(sq_class,size)).bytes,ix=1;ix<=size;ix++)pByte[ix-1]=cDigitOfCSIat(val,ix);return res}function digitLshift(aBytesOop,shiftCount){var newLen,oldLen,newBytes,highBit;return oldLen=BYTESIZEOF(aBytesOop),0===(highBit=cDigitHighBitlen(aBytesOop.bytes,oldLen))?0:(newLen=highBit+shiftCount+7>>3,newBytes=interpreterProxy.instantiateClassindexableSize(CLASSOF(aBytesOop),newLen),function(shiftCount,pFrom,lenFrom,pTo,lenTo){var digitShift,carry,digit,i,bitShift,rshift,limit;for(digitShift=shiftCount>>3,bitShift=MOD(shiftCount,8),limit=digitShift-1,i=0;i<=limit;i++)pTo[i]=0;if(0===bitShift)return cDigitReplacefromtowithstartingAt(pTo,digitShift,lenTo-1,pFrom,0);for(rshift=8-bitShift,carry=0,limit=lenFrom-1,i=0;i<=limit;i++)digit=pFrom[i],pTo[i+digitShift]=255&(carry|SHL(digit,bitShift)),carry=SHR(digit,rshift);0!==carry&&(pTo[lenTo-1]=carry)}(shiftCount,aBytesOop.bytes,oldLen,newBytes.bytes,newLen),newBytes)}function digitRshiftlookfirst(aBytesOop,shiftCount,a){var newOop,oldDigitLen,newByteLen,newBitLen,oldBitLen;return oldDigitLen=(oldBitLen=cDigitHighBitlen(aBytesOop.bytes,a))+7>>3,(newBitLen=oldBitLen-shiftCount)<=0?interpreterProxy.instantiateClassindexableSize(CLASSOF(aBytesOop),0):(newByteLen=newBitLen+7>>3,newOop=interpreterProxy.instantiateClassindexableSize(CLASSOF(aBytesOop),newByteLen),function(shiftCount,pFrom,fromLen,pTo,toLen){var j,digitShift,carry,digit,bitShift,leftShift,limit,start;if(digitShift=shiftCount>>3,0===(bitShift=MOD(shiftCount,8)))return cDigitReplacefromtowithstartingAt(pTo,0,toLen-1,pFrom,digitShift);for(leftShift=8-bitShift,carry=SHR(pFrom[digitShift],bitShift),limit=fromLen-1,j=start=digitShift+1;j<=limit;j++)digit=pFrom[j],pTo[j-start]=255&(carry|SHL(digit,leftShift)),carry=SHR(digit,bitShift);0!==carry&&(pTo[toLen-1]=carry)}(shiftCount,aBytesOop.bytes,oldDigitLen,newOop.bytes,newByteLen),newOop)}function digitAddLargewith(firstInteger,secondInteger){var sum,shortLen,over,shortInt,resClass,newSum,longLen,firstLen,secondLen,longInt;return firstLen=BYTESIZEOF(firstInteger),secondLen=BYTESIZEOF(secondInteger),resClass=CLASSOF(firstInteger),firstLen<=secondLen?(shortInt=firstInteger,shortLen=firstLen,longInt=secondInteger,longLen=secondLen):(shortInt=secondInteger,shortLen=secondLen,longInt=firstInteger,longLen=firstLen),sum=interpreterProxy.instantiateClassindexableSize(resClass,longLen),over=function(pByteShort,shortLen,pByteLong,longLen,pByteRes){var i,limit,accum;for(accum=0,limit=shortLen-1,i=0;i<=limit;i++)accum=(accum>>>8)+pByteShort[i]+pByteLong[i],pByteRes[i]=255&accum;for(limit=longLen-1,i=shortLen;i<=limit;i++)accum=(accum>>>8)+pByteLong[i],pByteRes[i]=255&accum;return accum>>>8}(shortInt.bytes,shortLen,longInt.bytes,longLen,sum.bytes),over>0&&(newSum=interpreterProxy.instantiateClassindexableSize(resClass,longLen+1),cDigitCopyFromtolen(sum.bytes,newSum.bytes,longLen),(sum=newSum).bytes[longLen]=over),sum}function digitBitLogicwithopIndex(firstInteger,secondInteger,opIx){var shortLen,shortLarge,firstLarge,secondLarge,longLen,longLarge,firstLen,secondLen,result;if("number"==typeof firstInteger){if(firstInteger<0)return interpreterProxy.primitiveFail();firstLarge=createLargeFromSmallInteger(firstInteger)}else{if(CLASSOF(firstInteger)===interpreterProxy.classLargeNegativeInteger())return interpreterProxy.primitiveFail();firstLarge=firstInteger}if("number"==typeof secondInteger){if(secondInteger<0)return interpreterProxy.primitiveFail();secondLarge=createLargeFromSmallInteger(secondInteger)}else{if(CLASSOF(secondInteger)===interpreterProxy.classLargeNegativeInteger())return interpreterProxy.primitiveFail();secondLarge=secondInteger}return(firstLen=BYTESIZEOF(firstLarge))<(secondLen=BYTESIZEOF(secondLarge))?(shortLen=firstLen,shortLarge=firstLarge,longLen=secondLen,longLarge=secondLarge):(shortLen=secondLen,shortLarge=secondLarge,longLen=firstLen,longLarge=firstLarge),result=interpreterProxy.instantiateClassindexableSize(interpreterProxy.classLargePositiveInteger(),longLen),function(opIndex,pByteShort,shortLen,pByteLong,longLen,pByteRes){var i,limit;if(limit=shortLen-1,opIndex===andOpIndex){for(i=0;i<=limit;i++)pByteRes[i]=pByteShort[i]&pByteLong[i];for(limit=longLen-1,i=shortLen;i<=limit;i++)pByteRes[i]=0;return 0}if(opIndex===orOpIndex){for(i=0;i<=limit;i++)pByteRes[i]=pByteShort[i]|pByteLong[i];for(limit=longLen-1,i=shortLen;i<=limit;i++)pByteRes[i]=pByteLong[i];return 0}if(opIndex===xorOpIndex){for(i=0;i<=limit;i++)pByteRes[i]=pByteShort[i]^pByteLong[i];for(limit=longLen-1,i=shortLen;i<=limit;i++)pByteRes[i]=pByteLong[i];return 0}interpreterProxy.primitiveFail()}(opIx,shortLarge.bytes,shortLen,longLarge.bytes,longLen,result.bytes),interpreterProxy.failed()?0:normalizePositive(result)}function digitCompareLargewith(firstInteger,secondInteger){var secondLen,firstLen;return firstLen=BYTESIZEOF(firstInteger),(secondLen=BYTESIZEOF(secondInteger))!==firstLen?secondLen>firstLen?-1:1:cDigitComparewithlen(firstInteger.bytes,secondInteger.bytes,firstLen)}function digitDivLargewithnegative(firstInteger,secondInteger,neg){var resultClass,result,rem,div,quo,d,l,secondLen,firstLen;return firstLen=BYTESIZEOF(firstInteger),secondLen=BYTESIZEOF(secondInteger),resultClass=neg?interpreterProxy.classLargeNegativeInteger():interpreterProxy.classLargePositiveInteger(),(l=firstLen-secondLen+1)<=0?(result=interpreterProxy.instantiateClassindexableSize(interpreterProxy.classArray(),2),interpreterProxy.stObjectatput(result,1,0),interpreterProxy.stObjectatput(result,2,firstInteger),result):(div=bytesOrIntgrowTo(div=digitLshift(secondInteger,d=8-cHighBit(unsafeByteOfat(secondInteger,secondLen))),digitLength(div)+1),digitLength(rem=digitLshift(firstInteger,d))===firstLen&&(rem=bytesOrIntgrowTo(rem,firstLen+1)),quo=interpreterProxy.instantiateClassindexableSize(resultClass,l),function(pDiv,divLen,pRem,remLen,pQuo,quoLen){var b,q,a,dnh,lo,hi,r3,mul,cond,l,k,j,i,dl,ql,r1r2,dh,t;for(ql=quoLen,dh=pDiv[(dl=divLen-1)-1],dnh=1===dl?0:pDiv[dl-2],k=1;k<=ql;k++){if(pRem[(j=remLen+1-k)-1]===dh)q=255;else for(t=MOD(r1r2=((r1r2=pRem[j-1])<<8)+pRem[j-2],dh),hi=(mul=(q=DIV(r1r2,dh))*dnh)>>>8,lo=255&mul,r3=j<3?0:pRem[j-3];t=dh):cond=!1,cond;)hi-=dh;for(l=j-dl,a=0,i=1;i<=divLen;i++)hi=pDiv[i-1]*(q>>>8),lo=pDiv[i-1]*(255&q),b=pRem[l-1]-a-(255&lo),pRem[l-1]=255&b,a=hi+(lo>>>8)-(b>>=8),++l;if(a>0)for(--q,l=j-dl,a=0,i=1;i<=divLen;i++)a=(a>>>8)+pRem[l-1]+pDiv[i-1],pRem[l-1]=255&a,++l;pQuo[quoLen-k]=q}}(div.bytes,digitLength(div),rem.bytes,digitLength(rem),quo.bytes,digitLength(quo)),rem=digitRshiftlookfirst(rem,d,digitLength(div)-1),result=interpreterProxy.instantiateClassindexableSize(interpreterProxy.classArray(),2),interpreterProxy.stObjectatput(result,1,quo),interpreterProxy.stObjectatput(result,2,rem),result)}function digitLength(oop){return"number"==typeof oop?cDigitLengthOfCSI(oop):BYTESIZEOF(oop)}function digitMontgomerytimesmodulomInvModB(firstLarge,secondLarge,thirdLarge,mInv){var prod,thirdLen,firstLen,secondLen;return firstLen=BYTESIZEOF(firstLarge),secondLen=BYTESIZEOF(secondLarge),firstLen<=(thirdLen=BYTESIZEOF(thirdLarge))&&secondLen<=thirdLen&&mInv>=0&&mInv<=255?(prod=interpreterProxy.instantiateClassindexableSize(interpreterProxy.classLargePositiveInteger(),thirdLen),function(pBytesFirst,firstLen,pBytesSecond,secondLen,pBytesThird,thirdLen,mInv,pBytesRes){var k,i,lastByte,limit3,limit2,limit1,u,accum;for(limit1=firstLen-1,limit2=secondLen-1,limit3=thirdLen-1,lastByte=0,i=0;i<=limit1;i++){for(accum=pBytesRes[0]+pBytesFirst[i]*pBytesSecond[0],accum+=(u=accum*mInv&255)*pBytesThird[0],k=1;k<=limit2;k++)accum=(accum>>>8)+pBytesRes[k]+pBytesFirst[i]*pBytesSecond[k]+u*pBytesThird[k],pBytesRes[k-1]=255&accum;for(k=secondLen;k<=limit3;k++)accum=(accum>>>8)+pBytesRes[k]+u*pBytesThird[k],pBytesRes[k-1]=255&accum;accum=(accum>>>8)+lastByte,pBytesRes[limit3]=255&accum,lastByte=accum>>>8}for(i=firstLen;i<=limit3;i++){for(accum=pBytesRes[0],accum+=(u=accum*mInv&255)*pBytesThird[0],k=1;k<=limit3;k++)accum=(accum>>>8)+pBytesRes[k]+u*pBytesThird[k],pBytesRes[k-1]=255&accum;accum=(accum>>>8)+lastByte,pBytesRes[limit3]=255&accum,lastByte=accum>>>8}if(0!==lastByte||1!==cDigitComparewithlen(pBytesThird,pBytesRes,thirdLen))for(accum=0,i=0;i<=limit3;i++)accum=accum+pBytesRes[i]-pBytesThird[i],pBytesRes[i]=255&accum,accum>>=8}(firstLarge.bytes,firstLen,secondLarge.bytes,secondLen,thirdLarge.bytes,thirdLen,mInv,prod.bytes),normalizePositive(prod)):interpreterProxy.primitiveFail()}function digitMultiplyLargewithnegative(firstInteger,secondInteger,neg){var longInt,resultClass,shortLen,shortInt,longLen,prod,secondLen,firstLen;return(firstLen=BYTESIZEOF(firstInteger))<=(secondLen=BYTESIZEOF(secondInteger))?(shortInt=firstInteger,shortLen=firstLen,longInt=secondInteger,longLen=secondLen):(shortInt=secondInteger,shortLen=secondLen,longInt=firstInteger,longLen=firstLen),resultClass=neg?interpreterProxy.classLargeNegativeInteger():interpreterProxy.classLargePositiveInteger(),prod=interpreterProxy.instantiateClassindexableSize(resultClass,longLen+shortLen),function(pByteShort,shortLen,pByteLong,longLen,pByteRes){var ab,j,digit,carry,i,limitLong,k,limitShort;if(1===shortLen&&0===pByteShort[0])return 0;if(1===longLen&&0===pByteLong[0])return 0;for(limitShort=shortLen-1,limitLong=longLen-1,i=0;i<=limitShort;i++)if(0!==(digit=pByteShort[i])){for(k=i,carry=0,j=0;j<=limitLong;j++)carry=(ab=(ab=pByteLong[j])*digit+carry+pByteRes[k])>>>8,pByteRes[k]=255&ab,++k;pByteRes[k]=carry}}(shortInt.bytes,shortLen,longInt.bytes,longLen,prod.bytes),normalize(prod)}function digitOfBytesat(aBytesOop,ix){return ix>BYTESIZEOF(aBytesOop)?0:unsafeByteOfat(aBytesOop,ix)}function digitSubLargewith(firstInteger,secondInteger){var smallerLen,larger,res,smaller,resLen,largerLen,firstNeg,firstLen,secondLen,neg;if(firstNeg=CLASSOF(firstInteger)===interpreterProxy.classLargeNegativeInteger(),(firstLen=BYTESIZEOF(firstInteger))===(secondLen=BYTESIZEOF(secondInteger))){for(;firstLen>1&&digitOfBytesat(firstInteger,firstLen)===digitOfBytesat(secondInteger,firstLen);)--firstLen;secondLen=firstLen}return firstLen>=8;for(i=smallLen;i<=largeLen-1;i++)z+=pByteLarge[i],pByteRes[i]=255&z,z>>=8}(smaller.bytes,smallerLen,larger.bytes,largerLen,res.bytes),neg?normalizeNegative(res):normalizePositive(res)}function getModuleName(){return moduleName}function isNormalized(anInteger){var ix,len;if("number"==typeof anInteger)return!0;if(0===(len=digitLength(anInteger)))return!1;if(0===unsafeByteOfat(anInteger,len))return!1;if(4,len>4)return!0;if(len<4)return!1;if(CLASSOF(anInteger)===interpreterProxy.classLargePositiveInteger())return 1073741823,unsafeByteOfat(anInteger,4)>cDigitOfCSIat(1073741823,4);if(-1073741824,unsafeByteOfat(anInteger,4)=1;i+=-1)val=256*val-unsafeByteOfat(aLargeNegativeInteger,i);return val}for(i=1;i<=4;i++)if(digitOfBytesat(aLargeNegativeInteger,i)!==cDigitOfCSIat(-1073741824,i))return len=1;i+=-1)val=256*val+unsafeByteOfat(aLargePositiveInteger,i);return val}return len=0?(_return_value=digitLshift(aLarge,shiftCount),interpreterProxy.failed()||interpreterProxy.popthenPush(3,_return_value),null):(_return_value=normalize(digitRshiftlookfirst(aLarge,0-shiftCount,BYTESIZEOF(aLarge))),interpreterProxy.failed()||interpreterProxy.popthenPush(3,_return_value),null))}function primDigitAdd(){var firstInteger,secondInteger,_return_value;return interpreterProxy.success(interpreterProxy.isKindOfInteger(interpreterProxy.stackValue(0))),secondInteger=interpreterProxy.stackValue(0),interpreterProxy.success(interpreterProxy.isKindOfInteger(interpreterProxy.stackValue(1))),firstInteger=interpreterProxy.stackValue(1),interpreterProxy.failed()?null:(_return_value=digitAddLargewith("number"==typeof firstInteger?createLargeFromSmallInteger(firstInteger):firstInteger,"number"==typeof secondInteger?createLargeFromSmallInteger(secondInteger):secondInteger),interpreterProxy.failed()||interpreterProxy.popthenPush(2,_return_value),null)}function primDigitAddWith(){var firstInteger,secondInteger,_return_value;return interpreterProxy.success(interpreterProxy.isKindOfInteger(interpreterProxy.stackValue(1))),firstInteger=interpreterProxy.stackValue(1),interpreterProxy.success(interpreterProxy.isKindOfInteger(interpreterProxy.stackValue(0))),secondInteger=interpreterProxy.stackValue(0),interpreterProxy.failed()?null:(_return_value=digitAddLargewith("number"==typeof firstInteger?createLargeFromSmallInteger(firstInteger):firstInteger,"number"==typeof secondInteger?createLargeFromSmallInteger(secondInteger):secondInteger),interpreterProxy.failed()||interpreterProxy.popthenPush(3,_return_value),null)}function primDigitBitAnd(){var firstInteger,secondInteger,_return_value;return interpreterProxy.success(interpreterProxy.isKindOfInteger(interpreterProxy.stackValue(0))),secondInteger=interpreterProxy.stackValue(0),interpreterProxy.success(interpreterProxy.isKindOfInteger(interpreterProxy.stackValue(1))),firstInteger=interpreterProxy.stackValue(1),interpreterProxy.failed()?null:(_return_value=digitBitLogicwithopIndex(firstInteger,secondInteger,andOpIndex),interpreterProxy.failed()||interpreterProxy.popthenPush(2,_return_value),null)}function primDigitBitLogicWithOp(){var firstInteger,secondInteger,opIndex,_return_value;return interpreterProxy.success(interpreterProxy.isKindOfInteger(interpreterProxy.stackValue(2))),firstInteger=interpreterProxy.stackValue(2),interpreterProxy.success(interpreterProxy.isKindOfInteger(interpreterProxy.stackValue(1))),secondInteger=interpreterProxy.stackValue(1),opIndex=interpreterProxy.stackIntegerValue(0),interpreterProxy.failed()?null:(_return_value=digitBitLogicwithopIndex(firstInteger,secondInteger,opIndex),interpreterProxy.failed()||interpreterProxy.popthenPush(4,_return_value),null)}function primDigitBitOr(){var firstInteger,secondInteger,_return_value;return interpreterProxy.success(interpreterProxy.isKindOfInteger(interpreterProxy.stackValue(0))),secondInteger=interpreterProxy.stackValue(0),interpreterProxy.success(interpreterProxy.isKindOfInteger(interpreterProxy.stackValue(1))),firstInteger=interpreterProxy.stackValue(1),interpreterProxy.failed()?null:(_return_value=digitBitLogicwithopIndex(firstInteger,secondInteger,orOpIndex),interpreterProxy.failed()||interpreterProxy.popthenPush(2,_return_value),null)}function primDigitBitShift(){var aLarge,anInteger,shiftCount,_return_value;return shiftCount=interpreterProxy.stackIntegerValue(0),interpreterProxy.success(interpreterProxy.isKindOfInteger(interpreterProxy.stackValue(1))),anInteger=interpreterProxy.stackValue(1),interpreterProxy.failed()?null:(aLarge="number"==typeof anInteger?createLargeFromSmallInteger(anInteger):anInteger,shiftCount>=0?(_return_value=digitLshift(aLarge,shiftCount),interpreterProxy.failed()||interpreterProxy.popthenPush(2,_return_value),null):(_return_value=normalize(digitRshiftlookfirst(aLarge,0-shiftCount,BYTESIZEOF(aLarge))),interpreterProxy.failed()||interpreterProxy.popthenPush(2,_return_value),null))}function primDigitBitShiftMagnitude(){var aLarge,anInteger,shiftCount,_return_value;return shiftCount=interpreterProxy.stackIntegerValue(0),interpreterProxy.success(interpreterProxy.isKindOfInteger(interpreterProxy.stackValue(1))),anInteger=interpreterProxy.stackValue(1),interpreterProxy.failed()?null:(aLarge="number"==typeof anInteger?createLargeFromSmallInteger(anInteger):anInteger,shiftCount>=0?(_return_value=digitLshift(aLarge,shiftCount),interpreterProxy.failed()||interpreterProxy.popthenPush(2,_return_value),null):(_return_value=normalize(digitRshiftlookfirst(aLarge,0-shiftCount,BYTESIZEOF(aLarge))),interpreterProxy.failed()||interpreterProxy.popthenPush(2,_return_value),null))}function primDigitBitXor(){var firstInteger,secondInteger,_return_value;return interpreterProxy.success(interpreterProxy.isKindOfInteger(interpreterProxy.stackValue(0))),secondInteger=interpreterProxy.stackValue(0),interpreterProxy.success(interpreterProxy.isKindOfInteger(interpreterProxy.stackValue(1))),firstInteger=interpreterProxy.stackValue(1),interpreterProxy.failed()?null:(_return_value=digitBitLogicwithopIndex(firstInteger,secondInteger,xorOpIndex),interpreterProxy.failed()||interpreterProxy.popthenPush(2,_return_value),null)}function primDigitCompare(){var firstVal,firstInteger,secondVal,secondInteger,_return_value;return interpreterProxy.success(interpreterProxy.isKindOfInteger(interpreterProxy.stackValue(0))),secondInteger=interpreterProxy.stackValue(0),interpreterProxy.success(interpreterProxy.isKindOfInteger(interpreterProxy.stackValue(1))),firstInteger=interpreterProxy.stackValue(1),interpreterProxy.failed()?null:"number"==typeof firstInteger?"number"==typeof secondInteger?(firstVal=firstInteger)>(secondVal=secondInteger)?(_return_value=1,interpreterProxy.failed()||interpreterProxy.popthenPush(2,_return_value),null):firstVal(secondVal=secondInteger)?(_return_value=1,interpreterProxy.failed()||interpreterProxy.popthenPush(3,_return_value),null):firstVal=VM_PROXY_MINOR}function unsafeByteOfat(bytesOop,ix){return bytesOop.bytes[ix-1]}!function registerPlugin(){"object"==typeof Squeak&&Squeak.registerExternalModule?Squeak.registerExternalModule("LargeIntegers",{primDigitAddWith,primDigitBitShiftMagnitude,primGetModuleName,primDigitBitLogicWithOp,primCheckIfCModuleExists,primDigitCompare,primDigitMultiplyNegative,primDigitBitShift,primNormalizePositive,primDigitSubtractWith,_primDigitBitShift,primDigitMultiplyWithNegative,primDigitSubtract,primDigitDivNegative,primNormalizeNegative,primDigitBitOr,primMontgomeryTimesModulo,primDigitBitAnd,primDigitDivWithNegative,setInterpreter,primNormalize,primDigitBitXor,primDigitCompareWith,primDigitAdd,getModuleName,primAsLargeInteger,primAnyBitFromTo}):self.setTimeout(registerPlugin,100)}()}(),registerCpSystemPlugin(),module.exports=node_app;