Rename 'sourceInfo' variables (etc) to 'sourceAnnotations'
This commit is contained in:
parent
3e32cb97e1
commit
f802420799
|
|
@ -173,7 +173,7 @@ function handleConstantDefinitions(op, arg, IP, constants) {
|
||||||
* it will be assembled to the default intial value of the IP,
|
* it will be assembled to the default intial value of the IP,
|
||||||
* as specified in `machine.config.js`.
|
* as specified in `machine.config.js`.
|
||||||
* @param {string} source - Assembly source to decode
|
* @param {string} source - Assembly source to decode
|
||||||
* @return {{ sourceInfo: Object, machineCode: Array }};
|
* @return {{ sourceAnnotations: Object, machineCode: Array }};
|
||||||
**/
|
**/
|
||||||
// TODO rename?
|
// TODO rename?
|
||||||
function decodeInstructions(source) {
|
function decodeInstructions(source) {
|
||||||
|
|
@ -203,7 +203,7 @@ function decodeInstructions(source) {
|
||||||
/** @type {Array<number>} - Assembled source code, as an array of bytes **/
|
/** @type {Array<number>} - Assembled source code, as an array of bytes **/
|
||||||
let machineCode = new Array(IP).fill(0);
|
let machineCode = new Array(IP).fill(0);
|
||||||
|
|
||||||
let sourceInfo = {};
|
let sourceAnnotations = {};
|
||||||
|
|
||||||
// Initialize memory-mapped IO -- TODO this should probably be in the CPU, not here
|
// Initialize memory-mapped IO -- TODO this should probably be in the CPU, not here
|
||||||
machineCode[CFG.pointerToDisplay] = CFG.displayAddr;
|
machineCode[CFG.pointerToDisplay] = CFG.displayAddr;
|
||||||
|
|
@ -343,7 +343,7 @@ function decodeInstructions(source) {
|
||||||
machineCode[IP] = decodedOp;
|
machineCode[IP] = decodedOp;
|
||||||
machineCode[IP + 1] = decodedArg;
|
machineCode[IP + 1] = decodedArg;
|
||||||
|
|
||||||
sourceInfo[IP] = {
|
sourceAnnotations[IP] = {
|
||||||
lineNumber: line.number,
|
lineNumber: line.number,
|
||||||
source: line.source,
|
source: line.source,
|
||||||
address: IP,
|
address: IP,
|
||||||
|
|
@ -381,7 +381,7 @@ function decodeInstructions(source) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return { 'machineCode': machineCode, 'sourceInfo': sourceInfo };
|
return { 'machineCode': machineCode, 'sourceAnnotations': sourceAnnotations };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,11 +30,11 @@ async function main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
let code = null;
|
let code = null;
|
||||||
let sourceInfo = null;
|
let sourceAnnotations = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const parsedInput = JSON.parse(input);
|
const parsedInput = JSON.parse(input);
|
||||||
sourceInfo = parsedInput.sourceInfo;
|
sourceAnnotations = parsedInput.sourceAnnotations;
|
||||||
code = new Uint8Array(parsedInput.machineCode);
|
code = new Uint8Array(parsedInput.machineCode);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.name === 'SyntaxError') {
|
if (error.name === 'SyntaxError') {
|
||||||
|
|
@ -43,7 +43,7 @@ async function main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
cpu.loadMemory(code);
|
cpu.loadMemory(code);
|
||||||
if (sourceInfo !== null) { cpu.loadSourceInfo(sourceInfo); }
|
if (sourceAnnotations !== null) { cpu.loadSourceAnnotations(sourceAnnotations); }
|
||||||
|
|
||||||
cpu.onCycleEnd(tick);
|
cpu.onCycleEnd(tick);
|
||||||
cpu.onCycleEnd(logCPUState);
|
cpu.onCycleEnd(logCPUState);
|
||||||
|
|
@ -66,8 +66,8 @@ async function tick() {
|
||||||
|
|
||||||
function logCPUState() {
|
function logCPUState() {
|
||||||
let lineInfo = null;
|
let lineInfo = null;
|
||||||
if (cpu.dbg.sourceInfo) {
|
if (cpu.dbg.sourceAnnotations) {
|
||||||
lineInfo = cpu.dbg.sourceInfo[cpu.dbg.previousIP];
|
lineInfo = cpu.dbg.sourceAnnotations[cpu.dbg.previousIP];
|
||||||
}
|
}
|
||||||
console.group(`Step ${cpu.dbg.cycleCounter}`);
|
console.group(`Step ${cpu.dbg.cycleCounter}`);
|
||||||
console.log();
|
console.log();
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ module.exports = class CPU {
|
||||||
poke() { return; } // TODO - implement Poke
|
poke() { return; } // TODO - implement Poke
|
||||||
|
|
||||||
/** @param {Array} info **/ // TODO - document type for 'sourceInfo'
|
/** @param {Array} info **/ // TODO - document type for 'sourceInfo'
|
||||||
loadSourceInfo(info) {
|
loadSourceAnnotations(info) {
|
||||||
this.dbg.sourceInfo = info;
|
this.dbg.sourceInfo = info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue