LEB128-encode values from defs

This commit is contained in:
2026-03-14 18:29:55 +00:00
parent 4f878fdbab
commit 714973f052

7
asm.js
View File

@@ -750,13 +750,18 @@ export class Assembler {
?? this.lookup_param(func, action.symbol) ?? this.lookup_param(func, action.symbol)
?? this.lookup_local(func, action.symbol) ?? this.lookup_local(func, action.symbol)
?? this.lookup_global(action.symbol) ?? this.lookup_global(action.symbol)
?? this.lookup_def(action.symbol);
if (value == null) { if (value == null) {
const def_value = this.lookup_def(action.symbol);
if (def_value == null) {
console.error( console.error(
`ERROR: Unable to resolve symbol ${action.symbol}`); `ERROR: Unable to resolve symbol ${action.symbol}`);
return;
} }
func.body.push(...this.leb128(def_value));
} else {
func.body.push(value); func.body.push(value);
} }
}
action_mem(action) { action_mem(action) {
Object.assign(this.mems, action.mem); Object.assign(this.mems, action.mem);