Assemble kernel on the client #1
44
asm.js
44
asm.js
@@ -578,7 +578,7 @@ class Parser {
|
|||||||
} else {
|
} else {
|
||||||
if (value > 0xff)
|
if (value > 0xff)
|
||||||
console.error(`WARNING: Value ${token} is truncated`);
|
console.error(`WARNING: Value ${token} is truncated`);
|
||||||
action.value = [ value & 0xff ];
|
action.value = value;
|
||||||
}
|
}
|
||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
@@ -595,12 +595,7 @@ class Parser {
|
|||||||
} else {
|
} else {
|
||||||
if (value > 0xffffffff)
|
if (value > 0xffffffff)
|
||||||
console.error(`WARNING: Value ${token} is truncated`);
|
console.error(`WARNING: Value ${token} is truncated`);
|
||||||
action.value = [
|
action.value = value;
|
||||||
value & 0xff,
|
|
||||||
(value >> 8) & 0xff,
|
|
||||||
(value >> 16) & 0xff,
|
|
||||||
(value >> 24) & 0xff,
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
@@ -614,8 +609,8 @@ class Parser {
|
|||||||
`ERROR: Unexpected token ${token}, expected string`);
|
`ERROR: Unexpected token ${token}, expected string`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const value = this.encoder.encode(token.string);
|
const bytes = this.encoder.encode(token.string);
|
||||||
const action = { type: Action.DATA, size: value.length, value };
|
const action = { type: Action.DATA, size: bytes.length, bytes };
|
||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1010,17 +1005,26 @@ export class Assembler {
|
|||||||
|
|
||||||
action_data(action) {
|
action_data(action) {
|
||||||
const data = this.data.at(-1).data;
|
const data = this.data.at(-1).data;
|
||||||
let value = action.value;
|
let bytes;
|
||||||
if (value == undefined) {
|
if (action.bytes != undefined) {
|
||||||
const raw = this.lookup_def(action.symbol);
|
bytes = action.bytes;
|
||||||
if (raw == undefined) {
|
} else {
|
||||||
console.error(
|
let value = action.value;
|
||||||
`ERROR: Unable to resolve symbol ${action.symbol}`);
|
if (value == undefined) {
|
||||||
return;
|
if (action.symbol == undefined) {
|
||||||
}
|
console.error("ERROR: Invalid data action", action);
|
||||||
value = this.le(raw, action.size);
|
return;
|
||||||
}
|
}
|
||||||
data.push(...value);
|
value = this.lookup_def(action.symbol);
|
||||||
|
if (value == undefined) {
|
||||||
|
console.error(
|
||||||
|
`ERROR: Unable to resolve symbol ${action.symbol}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
bytes = this.le(value, action.size);
|
||||||
|
}
|
||||||
|
data.push(...bytes);
|
||||||
this.pos.addr += action.size;
|
this.pos.addr += action.size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user