-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Commit files to repo for distribution. *shrug*
- Loading branch information
Showing
7 changed files
with
240 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
* | ||
!.gitignore | ||
!*.user.js | ||
README.md | ||
package.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* tslint:disable */ | ||
/** | ||
* @param {string} name | ||
* @param {Uint8Array} memory | ||
* @param {any} symbols | ||
* @returns {Uint8Array} | ||
*/ | ||
export function gen_elf(name: string, memory: Uint8Array, symbols: any): Uint8Array; | ||
|
||
/** | ||
* If `module_or_path` is {RequestInfo}, makes a request and | ||
* for everything else, calls `WebAssembly.instantiate` directly. | ||
* | ||
* @param {RequestInfo | BufferSource | WebAssembly.Module} module_or_path | ||
* | ||
* @returns {Promise<any>} | ||
*/ | ||
export default function init (module_or_path: RequestInfo | BufferSource | WebAssembly.Module): Promise<any>; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,208 @@ | ||
(function() { | ||
const __exports = {}; | ||
let wasm; | ||
|
||
let WASM_VECTOR_LEN = 0; | ||
|
||
let cachedTextEncoder = new TextEncoder('utf-8'); | ||
|
||
const encodeString = (typeof cachedTextEncoder.encodeInto === 'function' | ||
? function (arg, view) { | ||
return cachedTextEncoder.encodeInto(arg, view); | ||
} | ||
: function (arg, view) { | ||
const buf = cachedTextEncoder.encode(arg); | ||
view.set(buf); | ||
return { | ||
read: arg.length, | ||
written: buf.length | ||
}; | ||
}); | ||
|
||
let cachegetUint8Memory = null; | ||
function getUint8Memory() { | ||
if (cachegetUint8Memory === null || cachegetUint8Memory.buffer !== wasm.memory.buffer) { | ||
cachegetUint8Memory = new Uint8Array(wasm.memory.buffer); | ||
} | ||
return cachegetUint8Memory; | ||
} | ||
|
||
function passStringToWasm(arg) { | ||
|
||
let len = arg.length; | ||
let ptr = wasm.__wbindgen_malloc(len); | ||
|
||
const mem = getUint8Memory(); | ||
|
||
let offset = 0; | ||
|
||
for (; offset < len; offset++) { | ||
const code = arg.charCodeAt(offset); | ||
if (code > 0x7F) break; | ||
mem[ptr + offset] = code; | ||
} | ||
|
||
if (offset !== len) { | ||
if (offset !== 0) { | ||
arg = arg.slice(offset); | ||
} | ||
ptr = wasm.__wbindgen_realloc(ptr, len, len = offset + arg.length * 3); | ||
const view = getUint8Memory().subarray(ptr + offset, ptr + len); | ||
const ret = encodeString(arg, view); | ||
|
||
offset += ret.written; | ||
} | ||
|
||
WASM_VECTOR_LEN = offset; | ||
return ptr; | ||
} | ||
|
||
function passArray8ToWasm(arg) { | ||
const ptr = wasm.__wbindgen_malloc(arg.length * 1); | ||
getUint8Memory().set(arg, ptr / 1); | ||
WASM_VECTOR_LEN = arg.length; | ||
return ptr; | ||
} | ||
|
||
const heap = new Array(32); | ||
|
||
heap.fill(undefined); | ||
|
||
heap.push(undefined, null, true, false); | ||
|
||
let stack_pointer = 32; | ||
|
||
function addBorrowedObject(obj) { | ||
if (stack_pointer == 1) throw new Error('out of js stack'); | ||
heap[--stack_pointer] = obj; | ||
return stack_pointer; | ||
} | ||
|
||
let cachegetInt32Memory = null; | ||
function getInt32Memory() { | ||
if (cachegetInt32Memory === null || cachegetInt32Memory.buffer !== wasm.memory.buffer) { | ||
cachegetInt32Memory = new Int32Array(wasm.memory.buffer); | ||
} | ||
return cachegetInt32Memory; | ||
} | ||
|
||
function getArrayU8FromWasm(ptr, len) { | ||
return getUint8Memory().subarray(ptr / 1, ptr / 1 + len); | ||
} | ||
/** | ||
* @param {string} name | ||
* @param {Uint8Array} memory | ||
* @param {any} symbols | ||
* @returns {Uint8Array} | ||
*/ | ||
__exports.gen_elf = function(name, memory, symbols) { | ||
const retptr = 8; | ||
try { | ||
const ret = wasm.gen_elf(retptr, passStringToWasm(name), WASM_VECTOR_LEN, passArray8ToWasm(memory), WASM_VECTOR_LEN, addBorrowedObject(symbols)); | ||
const memi32 = getInt32Memory(); | ||
const v0 = getArrayU8FromWasm(memi32[retptr / 4 + 0], memi32[retptr / 4 + 1]).slice(); | ||
wasm.__wbindgen_free(memi32[retptr / 4 + 0], memi32[retptr / 4 + 1] * 1); | ||
return v0; | ||
} finally { | ||
heap[stack_pointer++] = undefined; | ||
} | ||
}; | ||
|
||
function getObject(idx) { return heap[idx]; } | ||
|
||
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }); | ||
|
||
cachedTextDecoder.decode(); | ||
|
||
function getStringFromWasm(ptr, len) { | ||
return cachedTextDecoder.decode(getUint8Memory().subarray(ptr, ptr + len)); | ||
} | ||
|
||
let heap_next = heap.length; | ||
|
||
function addHeapObject(obj) { | ||
if (heap_next === heap.length) heap.push(heap.length + 1); | ||
const idx = heap_next; | ||
heap_next = heap[idx]; | ||
|
||
heap[idx] = obj; | ||
return idx; | ||
} | ||
|
||
function dropObject(idx) { | ||
if (idx < 36) return; | ||
heap[idx] = heap_next; | ||
heap_next = idx; | ||
} | ||
|
||
function takeObject(idx) { | ||
const ret = getObject(idx); | ||
dropObject(idx); | ||
return ret; | ||
} | ||
|
||
function init(module) { | ||
|
||
let result; | ||
const imports = {}; | ||
imports.wbg = {}; | ||
imports.wbg.__wbindgen_json_serialize = function(arg0, arg1) { | ||
const obj = getObject(arg1); | ||
const ret = JSON.stringify(obj === undefined ? null : obj); | ||
const ret0 = passStringToWasm(ret); | ||
const ret1 = WASM_VECTOR_LEN; | ||
getInt32Memory()[arg0 / 4 + 0] = ret0; | ||
getInt32Memory()[arg0 / 4 + 1] = ret1; | ||
}; | ||
imports.wbg.__wbindgen_string_new = function(arg0, arg1) { | ||
const ret = getStringFromWasm(arg0, arg1); | ||
return addHeapObject(ret); | ||
}; | ||
imports.wbg.__wbindgen_rethrow = function(arg0) { | ||
throw takeObject(arg0); | ||
}; | ||
|
||
if ((typeof URL === 'function' && module instanceof URL) || typeof module === 'string' || (typeof Request === 'function' && module instanceof Request)) { | ||
|
||
const response = fetch(module); | ||
if (typeof WebAssembly.instantiateStreaming === 'function') { | ||
result = WebAssembly.instantiateStreaming(response, imports) | ||
.catch(e => { | ||
return response | ||
.then(r => { | ||
if (r.headers.get('Content-Type') != 'application/wasm') { | ||
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e); | ||
return r.arrayBuffer(); | ||
} else { | ||
throw e; | ||
} | ||
}) | ||
.then(bytes => WebAssembly.instantiate(bytes, imports)); | ||
}); | ||
} else { | ||
result = response | ||
.then(r => r.arrayBuffer()) | ||
.then(bytes => WebAssembly.instantiate(bytes, imports)); | ||
} | ||
} else { | ||
|
||
result = WebAssembly.instantiate(module, imports) | ||
.then(result => { | ||
if (result instanceof WebAssembly.Instance) { | ||
return { instance: result, module }; | ||
} else { | ||
return result; | ||
} | ||
}); | ||
} | ||
return result.then(({instance, module}) => { | ||
wasm = instance.exports; | ||
init.__wbindgen_wasm_module = module; | ||
|
||
return wasm; | ||
}); | ||
} | ||
|
||
self.wasm_bindgen = Object.assign(init, __exports); | ||
|
||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/* tslint:disable */ | ||
export const memory: WebAssembly.Memory; | ||
export function gen_elf(a: number, b: number, c: number, d: number, e: number, f: number): void; | ||
export function __wbindgen_malloc(a: number): number; | ||
export function __wbindgen_realloc(a: number, b: number, c: number): number; | ||
export function __wbindgen_free(a: number, b: number): void; |
Binary file not shown.