Assemble kernel on the client #1

Merged
cdo merged 72 commits from client-side-assembler into main 2026-03-18 15:21:33 +00:00
Showing only changes of commit 72c5f64312 - Show all commits

12
asm.js
View File

@@ -531,8 +531,7 @@ class Parser {
const value = this.integer(token) ?? console.error( const value = this.integer(token) ?? console.error(
`ERROR: Unexpected token ${token} in .global: expected` `ERROR: Unexpected token ${token} in .global: expected`
+ " initial value"); + " initial value");
const const_opcode = const_opcodes[this.global.type]; this.global.init = value;
this.global.init = [ const_opcode, value, opcodes["end"] ];
const action = { const action = {
type: Action.GLOBAL, type: Action.GLOBAL,
global: { [this.global_name]: this.global } global: { [this.global_name]: this.global }
@@ -1222,8 +1221,13 @@ export class Assembler {
const globals = Object.values(this.globals); const globals = Object.values(this.globals);
if (globals.length == 0) if (globals.length == 0)
return null; return null;
const contents = globals.map( const contents = globals.map(({ type, init }) => [
({ type, init }) => [ type, 1, ...init ]); type,
1,
const_opcodes[type],
...this.leb128(init),
opcodes["end"],
]);
return [ globals.length ].concat(...contents); return [ globals.length ].concat(...contents);
} }