From f802420799ec5415be9fe55e85f21cdb6f1d5ca9 Mon Sep 17 00:00:00 2001 From: n loewen Date: Sat, 23 Sep 2023 20:23:44 -0700 Subject: [PATCH] Rename 'sourceInfo' variables (etc) to 'sourceAnnotations' --- src/assembler.js | 8 ++++---- src/cardiograph.js | 10 +++++----- src/cpu.js | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/assembler.js b/src/assembler.js index b46080e..32ecef2 100755 --- a/src/assembler.js +++ b/src/assembler.js @@ -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} - 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 }; } diff --git a/src/cardiograph.js b/src/cardiograph.js index e2fbff0..31bbaf8 100755 --- a/src/cardiograph.js +++ b/src/cardiograph.js @@ -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(); diff --git a/src/cpu.js b/src/cpu.js index 16588fb..e81a7d0 100644 --- a/src/cpu.js +++ b/src/cpu.js @@ -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; }