Assemble kernel on the client #1
16
asm.js
16
asm.js
@@ -306,7 +306,7 @@ class Parser {
|
|||||||
this.state = State.TOP;
|
this.state = State.TOP;
|
||||||
} else {
|
} else {
|
||||||
this.mem.init = this.integer(token) ?? console.error(
|
this.mem.init = this.integer(token) ?? console.error(
|
||||||
`ERROR: Invalid initial size {token} in .mem`);
|
`ERROR: Invalid initial size ${token} in .mem`);
|
||||||
this.state = State.MEM_MAX;
|
this.state = State.MEM_MAX;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -316,7 +316,7 @@ class Parser {
|
|||||||
return this.mem_action();
|
return this.mem_action();
|
||||||
} else {
|
} else {
|
||||||
this.mem.max = this.integer(token) ?? console.error(
|
this.mem.max = this.integer(token) ?? console.error(
|
||||||
`ERROR: Invalid maximum size {token} in .mem`);
|
`ERROR: Invalid maximum size ${token} in .mem`);
|
||||||
this.mem.flags |= mem_flags.max;
|
this.mem.flags |= mem_flags.max;
|
||||||
this.state = State.MEM_FLAGS;
|
this.state = State.MEM_FLAGS;
|
||||||
}
|
}
|
||||||
@@ -328,7 +328,7 @@ class Parser {
|
|||||||
} else {
|
} else {
|
||||||
for (const flag of token.split(",")) {
|
for (const flag of token.split(",")) {
|
||||||
this.mem.flags |= mem_flags[flag] ?? console.error(
|
this.mem.flags |= mem_flags[flag] ?? console.error(
|
||||||
`ERROR: Invalid flag {flag} in .mem`);
|
`ERROR: Invalid flag ${flag} in .mem`);
|
||||||
}
|
}
|
||||||
this.state = State.TOP;
|
this.state = State.TOP;
|
||||||
return this.mem_action();
|
return this.mem_action();
|
||||||
@@ -354,7 +354,7 @@ class Parser {
|
|||||||
this.state = State.TOP;
|
this.state = State.TOP;
|
||||||
} else if (token.string == undefined) {
|
} else if (token.string == undefined) {
|
||||||
console.error(
|
console.error(
|
||||||
`ERROR: Unexpected token {token} in .import: expected`
|
`ERROR: Unexpected token ${token} in .import: expected`
|
||||||
+ " module string");
|
+ " module string");
|
||||||
this.import = undefined;
|
this.import = undefined;
|
||||||
this.state = State.TOP;
|
this.state = State.TOP;
|
||||||
@@ -405,7 +405,8 @@ class Parser {
|
|||||||
this.state = State.TOP;
|
this.state = State.TOP;
|
||||||
} else {
|
} else {
|
||||||
this.global.type = types[token] ?? console.error(
|
this.global.type = types[token] ?? console.error(
|
||||||
`ERROR: Unexpected token {token} in .global: expected type`);
|
`ERROR: Unexpected token ${token} in .global: `
|
||||||
|
+ "expected type");
|
||||||
this.state = State.GLOBAL_INIT;
|
this.state = State.GLOBAL_INIT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -420,7 +421,7 @@ class Parser {
|
|||||||
this.state = State.TOP;
|
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");
|
||||||
const const_opcode = const_opcodes[this.global.type];
|
const const_opcode = const_opcodes[this.global.type];
|
||||||
this.global.init = [ const_opcode, value, opcodes["end"] ];
|
this.global.init = [ const_opcode, value, opcodes["end"] ];
|
||||||
@@ -444,7 +445,8 @@ class Parser {
|
|||||||
const value = this.integer(token);
|
const value = this.integer(token);
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
console.error(
|
console.error(
|
||||||
`ERROR: Unexpected token {token} in .mem: expected address`);
|
`ERROR: Unexpected token ${token} in .mem: `
|
||||||
|
+ "expected address");
|
||||||
this.at = undefined;
|
this.at = undefined;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user