mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-16 08:21:44 +00:00
Add conditional BigInt support to loader & minor README fixes
This commit is contained in:
@ -1,5 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
const hasBigInt64 = typeof BigUint64Array !== "undefined";
|
||||
|
||||
/** Instantiates an AssemblyScript module using the specified imports. */
|
||||
function instantiate(module, imports) {
|
||||
|
||||
@ -17,7 +19,7 @@ function instantiate(module, imports) {
|
||||
var exports = instance.exports;
|
||||
|
||||
// Provide views for all sorts of basic values
|
||||
var mem, I8, U8, I16, U16, I32, U32, F32, F64;
|
||||
var mem, I8, U8, I16, U16, I32, U32, F32, F64, I64, U64;
|
||||
|
||||
/** Updates memory views if memory has grown meanwhile. */
|
||||
function checkMem() {
|
||||
@ -30,6 +32,10 @@ function instantiate(module, imports) {
|
||||
U16 = new Uint16Array(mem);
|
||||
I32 = new Int32Array(mem);
|
||||
U32 = new Uint32Array(mem);
|
||||
if (hasBigInt64) {
|
||||
I64 = new BigInt64Array(mem);
|
||||
U64 = new BigUint64Array(mem);
|
||||
}
|
||||
F32 = new Float32Array(mem);
|
||||
F64 = new Float64Array(mem);
|
||||
}
|
||||
@ -73,6 +79,8 @@ function instantiate(module, imports) {
|
||||
get U16() { checkMem(); return U16; },
|
||||
get I32() { checkMem(); return I32; },
|
||||
get U32() { checkMem(); return U32; },
|
||||
get I64() { checkMem(); return I64; },
|
||||
get U64() { checkMem(); return U64; },
|
||||
get F32() { checkMem(); return F32; },
|
||||
get F64() { checkMem(); return F64; },
|
||||
newString,
|
||||
|
Reference in New Issue
Block a user