Allow implicit zero-init for globals
This commit is contained in:
9
asm.js
9
asm.js
@@ -522,17 +522,13 @@ class Parser {
|
|||||||
|
|
||||||
token_global_init(token) {
|
token_global_init(token) {
|
||||||
if (token == LINE_END) {
|
if (token == LINE_END) {
|
||||||
console.error(
|
this.global.init = 0;
|
||||||
"ERROR: Unexpected newline in .global: expected"
|
|
||||||
+ " initial value");
|
|
||||||
this.global = undefined;
|
|
||||||
this.global_name = undefined;
|
|
||||||
this.state = State.TOP;
|
|
||||||
} else {
|
} else {
|
||||||
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");
|
||||||
this.global.init = value;
|
this.global.init = value;
|
||||||
|
}
|
||||||
const action = {
|
const action = {
|
||||||
type: Action.GLOBAL,
|
type: Action.GLOBAL,
|
||||||
global: { [this.global_name]: this.global }
|
global: { [this.global_name]: this.global }
|
||||||
@@ -542,7 +538,6 @@ class Parser {
|
|||||||
this.state = State.TOP;
|
this.state = State.TOP;
|
||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
token_at_mem(token) {
|
token_at_mem(token) {
|
||||||
this.at = { mem: token };
|
this.at = { mem: token };
|
||||||
|
|||||||
Reference in New Issue
Block a user