Converted the rest of the PCjs machines to ES6

This commit is contained in:
Jeff Parsons 2017-01-31 11:44:32 -08:00 • committed by Jeff Parsons
commit 323a42be37
301 changed files with 60754 additions and 52273 deletions

View file

@ -29,66 +29,73 @@
"use strict";
if (NODE) {
var web = require("../../shared/lib/weblib");
var Component = require("../../shared/lib/component");
var Web = require("../../shared/es6/weblib");
var Component = require("../../shared/es6/component");
}
/**
* C1PRAM(parmsRAM)
* TODO: The Closure Compiler treats ES6 classes as 'struct' rather than 'dict' by default,
* which would force us to declare all class properties in the constructor, as well as prevent
* us from defining any named properties. So, for now, we mark all our classes as 'unrestricted'.
*
* The RAM component expects the following (parmsRAM) properties:
*
* size: amount of RAM, in bytes
*
* NOTE: We may make a note of the specified size, but we will not actually allocate
* any memory for the RAM; we wait for the Computer object to tell us where our RAM is,
* using the setBuffer() method.
*
* @constructor
* @extends Component
* @unrestricted
*/
function C1PRAM(parmsRAM)
{
Component.call(this, "C1PRAM", parmsRAM);
}
Component.subclass(C1PRAM);
/**
* @this {C1PRAM}
* @param {Array} abMemory
* @param {number} start
* @param {number} end
* @param {C1PCPU} cpu
*/
C1PRAM.prototype.setBuffer = function(abMemory, start, end, cpu)
{
this.abMem = abMemory;
// this.offRAM = start;
// this.cbRAM = end - start + 1;
this.setReady();
};
/**
* C1PRAM.init()
*
* This function operates on every HTML element of class "ram", extracting the
* JSON-encoded parameters for the C1PRAM constructor from the element's "data-value"
* attribute, invoking the constructor to create a C1PRAM component, and then binding
* any associated HTML controls to the new component.
*/
C1PRAM.init = function()
{
var aeRAM = Component.getElementsByClass(document, C1PJS.APPCLASS, "ram");
for (var iRAM=0; iRAM < aeRAM.length; iRAM++) {
var eRAM = aeRAM[iRAM];
var parmsRAM = Component.getComponentParms(eRAM);
var ram = new C1PRAM(parmsRAM);
Component.bindComponentControls(ram, eRAM, C1PJS.APPCLASS);
class C1PRAM extends Component {
/**
* C1PRAM(parmsRAM)
*
* The RAM component expects the following (parmsRAM) properties:
*
* size: amount of RAM, in bytes
*
* NOTE: We may make a note of the specified size, but we will not actually allocate
* any memory for the RAM; we wait for the Computer object to tell us where our RAM is,
* using the setBuffer() method.
*
* @this {C1PRAM}
* @param {Object} parmsRAM
*/
constructor(parmsRAM)
{
super("C1PRAM", parmsRAM);
}
};
/**
* @this {C1PRAM}
* @param {Array} abMemory
* @param {number} start
* @param {number} end
* @param {C1PCPU} cpu
*/
setBuffer(abMemory, start, end, cpu)
{
this.abMem = abMemory;
// this.offRAM = start;
// this.cbRAM = end - start + 1;
this.setReady();
}
/**
* C1PRAM.init()
*
* This function operates on every HTML element of class "ram", extracting the
* JSON-encoded parameters for the C1PRAM constructor from the element's "data-value"
* attribute, invoking the constructor to create a C1PRAM component, and then binding
* any associated HTML controls to the new component.
*/
static init()
{
var aeRAM = Component.getElementsByClass(document, C1PJS.APPCLASS, "ram");
for (var iRAM=0; iRAM < aeRAM.length; iRAM++) {
var eRAM = aeRAM[iRAM];
var parmsRAM = Component.getComponentParms(eRAM);
var ram = new C1PRAM(parmsRAM);
Component.bindComponentControls(ram, eRAM, C1PJS.APPCLASS);
}
}
}
/*
* Initialize all the RAM modules on the page.
*/
web.onInit(C1PRAM.init);
Web.onInit(C1PRAM.init);