mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-14 15:29:31 -06:00
Implement all Expr unmarshalling (untested). Put wordsize logic in constants.ts. Some README additions.
This commit is contained in:
39
src/runtime/javascript/constants.ts
Normal file
39
src/runtime/javascript/constants.ts
Normal 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}`)
|
||||
}
|
||||
Reference in New Issue
Block a user