From 2c5d7c9066570395e35544c27a31107f293297be Mon Sep 17 00:00:00 2001 From: Jeff Parsons Date: Sun, 8 Jan 2017 23:33:32 -0800 Subject: [PATCH] Fixed RL11 type errors --- .../1170/panel/debugger/xxdp/README.md | 1 + modules/pdp11/lib/rl11.js | 29 ++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/devices/pdp11/machine/1170/panel/debugger/xxdp/README.md b/devices/pdp11/machine/1170/panel/debugger/xxdp/README.md index fa9d1a838..a296f0328 100644 --- a/devices/pdp11/machine/1170/panel/debugger/xxdp/README.md +++ b/devices/pdp11/machine/1170/panel/debugger/xxdp/README.md @@ -32,3 +32,4 @@ we need to use an RL02 drive. A typical PDP-11 machine with a single RL11 disk up to four such drives, which we refer to as RL0 through RL3. To select drive RL0, press {% include machine-command.html type='button' label='Select RL0' machine='test1170' component='RL11' command='selectDrive' value='RL0' %} + diff --git a/modules/pdp11/lib/rl11.js b/modules/pdp11/lib/rl11.js index fc0053932..65fc5024f 100644 --- a/modules/pdp11/lib/rl11.js +++ b/modules/pdp11/lib/rl11.js @@ -39,6 +39,31 @@ if (NODE) { var DiskPDP11 = require("./disk"); } +/** + * Since the Closure Compiler treats ES6 classes as @struct rather than @dict by default, + * it deters us from defining named properties on our components; eg: + * + * this['exports'] = {...} + * + * results in an error: + * + * Cannot do '[]' access on a struct + * + * So, in order to define 'exports', we must override the @struct assumption by annotating + * the class as @unrestricted (or @dict). Note that this must be done both here and in the + * Component class, because otherwise the Compiler won't allow us to *reference* the named + * property either. + * + * TODO: Consider marking ALL our classes unrestricted, because otherwise it forces us to + * define every single property the class uses in its constructor, which results in a fair + * bit of redundant initialization, since many properties aren't (and don't need to be) fully + * initialized until the appropriate init(), reset(), restore(), etc. function is called. + * + * The upside, however, may be that since the structure of the class is completely defined by + * the constructor, JavaScript engines may be able to optimize and run more efficiently. + * + * @unrestricted + */ class RL11 extends Component { /** * RL11(parms) @@ -837,7 +862,9 @@ class RL11 extends Component { for (var i = 0; i < nDrives; i++) { if (controlDrives.options[i].innerHTML == sDrive) { var iDrive = Str.parseInt(controlDrives.options[i].value, 10); - return this.displayDisk(iDrive, true); + if (iDrive >= 0) { + return this.displayDisk(iDrive, true); + } } } }