assembler - Add feature: throw useful error on references to undefined constants
This commit is contained in:
parent
d6b55db381
commit
d56eb34a44
|
|
@ -303,6 +303,13 @@ function decodeInstructions(source) {
|
||||||
// Operands - Handle references to constants
|
// Operands - Handle references to constants
|
||||||
if (line.argument.startsWith(ASM_CONSTANT_PREFIX)) {
|
if (line.argument.startsWith(ASM_CONSTANT_PREFIX)) {
|
||||||
dbg(1, `References '${line.argument}'`);
|
dbg(1, `References '${line.argument}'`);
|
||||||
|
if (typeof constants[line.argument.substring(1)] === 'undefined') {
|
||||||
|
console.error();
|
||||||
|
console.error(`Error: Undefined constant '${line.argument}'`);
|
||||||
|
console.error(` at line ${line.number}`);
|
||||||
|
console.error();
|
||||||
|
throw new Error('Undefined constant');
|
||||||
|
}
|
||||||
decodedArg = decodeNumericOp(constants[line.argument.substring(1)]); // substring(1) strips '>'
|
decodedArg = decodeNumericOp(constants[line.argument.substring(1)]); // substring(1) strips '>'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue