First stab at factoring some common Debugger functionality into a shared component

This commit is contained in:
Jeff Parsons 2016-09-14 15:36:38 -07:00
commit a8bb0c7841
42 changed files with 3721 additions and 4457 deletions

View file

@ -76,7 +76,8 @@ try {
* Create is the constructor returned by require(). The only bit of fudging we do is
* overriding the constructor for component "cpu" with the constructor for "x86cpu",
* because when a "cpu" definition is encountered, it's the "x86cpu" subclass that we
* actually want to create, not the "cpu" superclass.
* actually want to create, not the "cpu" superclass. See aSubClasses for the complete
* list of subclassed components we manage like that.
*
* TODO: Update the list of ignored (ie, ignorable) components.
*/
@ -84,7 +85,11 @@ var Component;
var dbg;
var aComponents = [];
var asComponentsIgnore = ["embed","save"];
var aSubClasses = {
"pcx86/lib/x86cpu": "pcx86/lib/cpu",
"pcx86/lib/debugger": "shared/lib/debugger"
};
/**
* loadComponents(asFiles)
*
@ -106,9 +111,17 @@ function loadComponents(asFiles)
* we'll want to access later (eg, "component" in getComponentByType()).
*/
var fn = require(lib + "../../../" + sFile);
if (sName == "x86cpu") {
var sSuperClass = null;
for (var s in aSubClasses) {
if (sFile.indexOf(s) >= 0) {
sSuperClass = aSubClasses[s];
break;
}
}
if (sSuperClass) {
for (var j = 0; j < aComponents.length; j++) {
if (aComponents[j].name == "cpu") {
if (aComponents[j].path.indexOf(sSuperClass) >= 0) {
if (fDebug) console.log("updating superclass " + aComponents[j].path + " with subclass " + sFile);
aComponents[j].Create = fn;
sName = null;
break;
@ -121,7 +134,7 @@ function loadComponents(asFiles)
}; // jshint ignore:line
}
if (sName) {
aComponents.push({name: sName, Create: fn, objects: []});
aComponents.push({name: sName, path: sFile, Create: fn, objects: []});
}
if (sName == "defines") {
/*

View file

@ -68,7 +68,7 @@ if (NODE) {
* @extends Component
* @param {Object} parmsBus
* @param {X86CPU} cpu
* @param {Debugger} dbg
* @param {DebuggerX86} dbg
*/
function Bus(parmsBus, cpu, dbg)
{

View file

@ -1294,7 +1294,7 @@ ChipSet.prototype.setBinding = function(sHTMLType, sBinding, control, sValue)
* @param {Computer} cmp
* @param {Bus} bus
* @param {X86CPU} cpu
* @param {Debugger} dbg
* @param {DebuggerX86} dbg
*/
ChipSet.prototype.initBus = function(cmp, bus, cpu, dbg)
{

View file

@ -182,7 +182,7 @@ function Computer(parmsComputer, parmsMachine, fSuspended) {
Component.error("Unable to find CPU component");
return;
}
this.dbg = /** @type {Debugger} */ (Component.getComponentByType("Debugger", this.id));
this.dbg = /** @type {DebuggerX86} */ (Component.getComponentByType("Debugger", this.id));
/*
* Enumerate all Video components for future updateVideo() calls.

View file

@ -159,7 +159,7 @@ CPU.BUTTONS = ["power", "reset"];
* @param {Computer} cmp
* @param {Bus} bus
* @param {CPU} cpu
* @param {Debugger} dbg
* @param {DebuggerX86} dbg
*/
CPU.prototype.initBus = function(cmp, bus, cpu, dbg)
{

File diff suppressed because it is too large Load diff

View file

@ -34,12 +34,12 @@
/**
* @define {string}
*/
var APPCLASS = "pcx86"; // this @define is the default application class (eg, "pcx86", "c1pjs")
var APPCLASS = "pcx86"; // this @define is the default application class (eg, "pcx86", "c1pjs")
/**
* @define {string}
*/
var APPNAME = "PCx86"; // this @define is the default application name (eg, "PCx86", "C1Pjs")
var APPNAME = "PCx86"; // this @define is the default application name (eg, "PCx86", "C1Pjs")
/**
* @define {boolean}

View file

@ -811,7 +811,7 @@ var SectorInfo;
* @param {Computer} cmp
* @param {Bus} bus
* @param {X86CPU} cpu
* @param {Debugger} dbg
* @param {DebuggerX86} dbg
*/
Disk.prototype.initBus = function(cmp, bus, cpu, dbg) {
this.dbg = dbg;

View file

@ -623,7 +623,7 @@ FDC.prototype.setBinding = function(sHTMLType, sBinding, control, sValue)
* @param {Computer} cmp
* @param {Bus} bus
* @param {X86CPU} cpu
* @param {Debugger} dbg
* @param {DebuggerX86} dbg
*/
FDC.prototype.initBus = function(cmp, bus, cpu, dbg)
{

View file

@ -594,7 +594,7 @@ HDC.prototype.setBinding = function(sHTMLType, sBinding, control, sValue)
* @param {Computer} cmp
* @param {Bus} bus
* @param {X86CPU} cpu
* @param {Debugger} dbg
* @param {DebuggerX86} dbg
*/
HDC.prototype.initBus = function(cmp, bus, cpu, dbg)
{

View file

@ -31,22 +31,6 @@
"use strict";
/*
* Components that previously used Debugger interrupt definitions by including:
*
* var Debugger = require("./debugger");
*
* and using:
*
* Debugger.INT.FOO
*
* must now instead include:
*
* var Interrupts = require("./interrupts");
*
* and then replace all occurrences of "Debugger.INT.FOO" with "Interrupts.FOO".
*/
var Interrupts = {
VIDEO: 0x10,
DISK: 0x13,
@ -184,7 +168,7 @@ if (DEBUGGER) {
0x4A8: ["SAVE_PTR",4] // POINTER TO EGA PARAMETER CONTROL BLOCK
},
/*
* See Debugger.prototype.replaceRegs() for the rules governing how register contents are replaced in the strings below.
* See DebuggerX86.prototype.replaceRegs() for the rules governing how register contents are replaced in the strings below.
*
* Replacements occur in the following order:
*
@ -1546,7 +1530,7 @@ if (DEBUGGER) {
* INT 2E Execute command (*) (2.0+)
* Entry: DS:SI-&gt;command string-1 followed by a carriage return
* Exit: All registers except CS and IP are destroyed
* Note: This function is not re-enterant and should not be issued from a
* Note: This function is not re-entrant and should not be issued from a
* batch file.
*
* INT 2F Multiplex (3.0+)
@ -1922,7 +1906,7 @@ if (DEBUGGER) {
*
* Stacks descriptor (8 bytes)
* 00 Flag (0=free,1=in use)
* 02 Savearea for SS:SP
* 02 Save area for SS:SP
* 06 Offset of end of stack
*
* Device driver header (12h bytes)

View file

@ -1324,7 +1324,7 @@ Keyboard.prototype.findBinding = function(simCode, sType, fDown)
* @param {Computer} cmp
* @param {Bus} bus
* @param {X86CPU} cpu
* @param {Debugger} dbg
* @param {DebuggerX86} dbg
*/
Keyboard.prototype.initBus = function(cmp, bus, cpu, dbg)
{

View file

@ -288,7 +288,7 @@ Memory.prototype = {
* @this {Memory}
* @param {Memory} mem
* @param {number} [type]
* @param {Debugger} [dbg]
* @param {DebuggerX86} [dbg]
*/
clone: function(mem, type, dbg) {
/*
@ -620,7 +620,7 @@ Memory.prototype = {
* copyBreakpoints(dbg, mem)
*
* @this {Memory}
* @param {Debugger} [dbg]
* @param {DebuggerX86} [dbg]
* @param {Memory} [mem] (outgoing Memory block to copy breakpoints from, if any)
*/
copyBreakpoints: function(dbg, mem) {

View file

@ -31,22 +31,6 @@
"use strict";
/*
* Components that previously used Debugger messages definitions by including:
*
* var Debugger = require("./debugger");
*
* and using:
*
* Debugger.MESSAGE.FOO
*
* must now instead include:
*
* var Messages = require("./messages");
*
* and then replace all occurrences of "Debugger.MESSAGE.FOO" with "Messages.FOO".
*/
var Messages = {
CPU: 0x00000001,
SEG: 0x00000002,

View file

@ -181,7 +181,7 @@ Mouse.BUTTON = {
* @param {Computer} cmp
* @param {Bus} bus
* @param {X86CPU} cpu
* @param {Debugger} dbg
* @param {DebuggerX86} dbg
*/
Mouse.prototype.initBus = function(cmp, bus, cpu, dbg)
{

View file

@ -341,7 +341,7 @@ Panel.prototype.setBinding = function(sHTMLType, sBinding, control, sValue)
* @param {Computer} cmp
* @param {Bus} bus
* @param {X86CPU} cpu
* @param {Debugger} dbg
* @param {DebuggerX86} dbg
*/
Panel.prototype.initBus = function(cmp, bus, cpu, dbg)
{

View file

@ -230,7 +230,7 @@ ParallelPort.prototype.setBinding = function(sHTMLType, sBinding, control, sValu
* @param {Computer} cmp
* @param {Bus} bus
* @param {X86CPU} cpu
* @param {Debugger} dbg
* @param {DebuggerX86} dbg
*/
ParallelPort.prototype.initBus = function(cmp, bus, cpu, dbg)
{

View file

@ -77,7 +77,7 @@ Component.subclass(RAM);
* @param {Computer} cmp
* @param {Bus} bus
* @param {X86CPU} cpu
* @param {Debugger} dbg
* @param {DebuggerX86} dbg
*/
RAM.prototype.initBus = function(cmp, bus, cpu, dbg)
{

View file

@ -162,7 +162,7 @@ ROM.BIOS.RESET_FLAG_WARMBOOT = 0x1234; // value stored at ROM.BIOS.RESET_FLAG t
* @param {Computer} cmp
* @param {Bus} bus
* @param {X86CPU} cpu
* @param {Debugger} dbg
* @param {DebuggerX86} dbg
*/
ROM.prototype.initBus = function(cmp, bus, cpu, dbg)
{

View file

@ -456,7 +456,7 @@ SerialPort.prototype.setBinding = function(sHTMLType, sBinding, control, sValue)
* @param {Computer} cmp
* @param {Bus} bus
* @param {X86CPU} cpu
* @param {Debugger} dbg
* @param {DebuggerX86} dbg
*/
SerialPort.prototype.initBus = function(cmp, bus, cpu, dbg)
{

View file

@ -2899,7 +2899,7 @@ Video.TOUCH = {
* @param {Computer} cmp
* @param {Bus} bus
* @param {X86CPU} cpu
* @param {Debugger} dbg
* @param {DebuggerX86} dbg
*/
Video.prototype.initBus = function(cmp, bus, cpu, dbg)
{

View file

@ -163,7 +163,7 @@ Component.subclass(X86FPU);
* @param {Computer} cmp
* @param {Bus} bus
* @param {X86CPU} cpu
* @param {Debugger} dbg
* @param {DebuggerX86} dbg
*/
X86FPU.prototype.initBus = function(cmp, bus, cpu, dbg)
{