Fixed RL11 type errors

This commit is contained in:
Jeff Parsons 2017-01-08 23:33:32 -08:00 • committed by Jeff Parsons
commit 2c5d7c9066
2 changed files with 29 additions and 1 deletions

View file

@ -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. 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' %} To select drive RL0, press {% include machine-command.html type='button' label='Select RL0' machine='test1170' component='RL11' command='selectDrive' value='RL0' %}

View file

@ -39,6 +39,31 @@ if (NODE) {
var DiskPDP11 = require("./disk"); 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 { class RL11 extends Component {
/** /**
* RL11(parms) * RL11(parms)
@ -837,7 +862,9 @@ class RL11 extends Component {
for (var i = 0; i < nDrives; i++) { for (var i = 0; i < nDrives; i++) {
if (controlDrives.options[i].innerHTML == sDrive) { if (controlDrives.options[i].innerHTML == sDrive) {
var iDrive = Str.parseInt(controlDrives.options[i].value, 10); var iDrive = Str.parseInt(controlDrives.options[i].value, 10);
return this.displayDisk(iDrive, true); if (iDrive >= 0) {
return this.displayDisk(iDrive, true);
}
} }
} }
} }