Implement all Expr unmarshalling (untested). Put wordsize logic in constants.ts. Some README additions.

This commit is contained in:
John J. Camilleri
2021-10-08 12:39:42 +02:00
parent 15e3ca9acd
commit a27cf6a17b
5 changed files with 178 additions and 28 deletions

View File

@@ -0,0 +1,39 @@
// Untested!
import os from 'os'
export const BE: boolean = os.endianness() === 'BE'
export let WORDSIZE_BITS: number
switch (process.arch) {
case 'arm':
case 'ia32':
case 'ppc':
case 's390':
case 'x32':
WORDSIZE_BITS = 32
break
case 'arm64':
case 'mips':
case 'mipsel':
case 'ppc64':
case 's390x':
case 'x64':
WORDSIZE_BITS = 64
break
default:
throw Error(`Unknown architecture: ${process.arch}`)
}
export const WORDSIZE_BYTES = WORDSIZE_BITS / 8
export let LINT_BASE: bigint
switch (WORDSIZE_BITS) {
case 64: LINT_BASE = BigInt('10000000000000000000'); break
case 32: LINT_BASE = BigInt('1000000000'); break
case 16: LINT_BASE = BigInt('10000'); break
case 8: LINT_BASE = BigInt('100'); break
default: throw Error(`Unsupported word size: ${WORDSIZE_BITS}`)
}