Allow implicit zero-init for globals

This commit is contained in:
2026-03-15 14:26:22 +00:00
parent 5e39024f6d
commit 8d4c53ca92

9
asm.js
View File

@@ -522,17 +522,13 @@ class Parser {
token_global_init(token) {
if (token == LINE_END) {
console.error(
"ERROR: Unexpected newline in .global: expected"
+ " initial value");
this.global = undefined;
this.global_name = undefined;
this.state = State.TOP;
this.global.init = 0;
} else {
const value = this.integer(token) ?? console.error(
`ERROR: Unexpected token ${token} in .global: expected`
+ " initial value");
this.global.init = value;
}
const action = {
type: Action.GLOBAL,
global: { [this.global_name]: this.global }
@@ -542,7 +538,6 @@ class Parser {
this.state = State.TOP;
return action;
}
}
token_at_mem(token) {
this.at = { mem: token };