106 lines
1.6 KiB
JavaScript
106 lines
1.6 KiB
JavaScript
/**
|
|
* @import { Radix } from "./num.js"
|
|
*/
|
|
import { S16_0 } from "./symbol/S16.js"
|
|
import { S8_0 } from "./symbol/S8.js"
|
|
import { S2_0 } from "./symbol/S2.js"
|
|
import { S10_0 } from "./symbol/S10.js"
|
|
|
|
function alloc16() {
|
|
return [
|
|
S16_0,
|
|
S16_0,
|
|
S16_0,
|
|
S16_0,
|
|
S16_0,
|
|
S16_0,
|
|
S16_0,
|
|
S16_0
|
|
]
|
|
}
|
|
export const size16 = 8;
|
|
|
|
function alloc8() {
|
|
return [
|
|
S8_0,
|
|
S8_0,
|
|
S8_0,
|
|
S8_0,
|
|
S8_0,
|
|
S8_0,
|
|
S8_0,
|
|
S8_0,
|
|
S8_0,
|
|
S8_0,
|
|
S8_0
|
|
]
|
|
}
|
|
export const size8 = 11;
|
|
|
|
function alloc2() {
|
|
return [
|
|
S2_0,
|
|
S2_0,
|
|
S2_0,
|
|
S2_0,
|
|
S2_0,
|
|
S2_0,
|
|
S2_0,
|
|
S2_0,
|
|
S2_0,
|
|
S2_0,
|
|
S2_0,
|
|
S2_0,
|
|
S2_0,
|
|
S2_0,
|
|
S2_0,
|
|
S2_0,
|
|
S2_0,
|
|
S2_0,
|
|
S2_0,
|
|
S2_0,
|
|
S2_0,
|
|
S2_0,
|
|
S2_0,
|
|
S2_0,
|
|
S2_0,
|
|
S2_0,
|
|
S2_0,
|
|
S2_0,
|
|
S2_0,
|
|
S2_0,
|
|
S2_0,
|
|
S2_0
|
|
]
|
|
}
|
|
export const size2 = 32;
|
|
|
|
function alloc10() {
|
|
return [
|
|
S10_0,
|
|
S10_0,
|
|
S10_0,
|
|
S10_0,
|
|
S10_0,
|
|
S10_0,
|
|
S10_0,
|
|
S10_0,
|
|
S10_0,
|
|
S10_0
|
|
]
|
|
}
|
|
export const size10 = 10;
|
|
export const last10 = size10 - 1;
|
|
|
|
/**
|
|
* @param { Radix } radix
|
|
*/
|
|
export function alloc(radix) {
|
|
switch (radix) {
|
|
case 2: return alloc2();
|
|
case 8: return alloc8();
|
|
case 16: return alloc16();
|
|
case 10: return alloc10();
|
|
default: throw new Error(`unsupported radix (${radix})`);
|
|
}
|
|
} |