Rename 'sourceInfo' variables (etc) to 'sourceAnnotations'

This commit is contained in:
n loewen 2023-09-23 20:23:44 -07:00
parent 3e32cb97e1
commit f802420799
3 changed files with 10 additions and 10 deletions

View File

@ -173,7 +173,7 @@ function handleConstantDefinitions(op, arg, IP, constants) {
* it will be assembled to the default intial value of the IP,
* as specified in `machine.config.js`.
* @param {string} source - Assembly source to decode
* @return {{ sourceInfo: Object, machineCode: Array }};
* @return {{ sourceAnnotations: Object, machineCode: Array }};
**/
// TODO rename?
function decodeInstructions(source) {
@ -203,7 +203,7 @@ function decodeInstructions(source) {
/** @type {Array<number>} - Assembled source code, as an array of bytes **/
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
machineCode[CFG.pointerToDisplay] = CFG.displayAddr;
@ -343,7 +343,7 @@ function decodeInstructions(source) {
machineCode[IP] = decodedOp;
machineCode[IP + 1] = decodedArg;
sourceInfo[IP] = {
sourceAnnotations[IP] = {
lineNumber: line.number,
source: line.source,
address: IP,
@ -381,7 +381,7 @@ function decodeInstructions(source) {
}
}
return { 'machineCode': machineCode, 'sourceInfo': sourceInfo };
return { 'machineCode': machineCode, 'sourceAnnotations': sourceAnnotations };
}

View File

@ -30,11 +30,11 @@ async function main() {
}
let code = null;
let sourceInfo = null;
let sourceAnnotations = null;
try {
const parsedInput = JSON.parse(input);
sourceInfo = parsedInput.sourceInfo;
sourceAnnotations = parsedInput.sourceAnnotations;
code = new Uint8Array(parsedInput.machineCode);
} catch (error) {
if (error.name === 'SyntaxError') {
@ -43,7 +43,7 @@ async function main() {
}
cpu.loadMemory(code);
if (sourceInfo !== null) { cpu.loadSourceInfo(sourceInfo); }
if (sourceAnnotations !== null) { cpu.loadSourceAnnotations(sourceAnnotations); }
cpu.onCycleEnd(tick);
cpu.onCycleEnd(logCPUState);
@ -66,8 +66,8 @@ async function tick() {
function logCPUState() {
let lineInfo = null;
if (cpu.dbg.sourceInfo) {
lineInfo = cpu.dbg.sourceInfo[cpu.dbg.previousIP];
if (cpu.dbg.sourceAnnotations) {
lineInfo = cpu.dbg.sourceAnnotations[cpu.dbg.previousIP];
}
console.group(`Step ${cpu.dbg.cycleCounter}`);
console.log();

View File

@ -40,7 +40,7 @@ module.exports = class CPU {
poke() { return; } // TODO - implement Poke
/** @param {Array} info **/ // TODO - document type for 'sourceInfo'
loadSourceInfo(info) {
loadSourceAnnotations(info) {
this.dbg.sourceInfo = info;
}