Allow using defs in code

This commit is contained in:
2026-03-14 13:52:10 +00:00
parent 33f5a4be06
commit d4718f1106

11
asm.js
View File

@@ -675,14 +675,15 @@ export class Assembler {
action_symbol(action) { action_symbol(action) {
const func = this.funcs[this.current_func]; const func = this.funcs[this.current_func];
const index = this.lookup_param(func, action.symbol) const value = 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)
if (index == null) { ?? this.lookup_def(action.symbol);
if (value == null) {
console.error(`ERROR: Unable to resolve symbol {action.symbol}`); console.error(`ERROR: Unable to resolve symbol {action.symbol}`);
index = 0; value = 0;
} }
func.body.push(index); func.body.push(value);
} }
action_mem(action) { action_mem(action) {