flashmagic.js
Version:
NXP LPC Microprocessor Programmer
39 lines (38 loc) • 1.27 kB
JavaScript
;
var Symbol = require('es6-symbol');
var _addressSym = Symbol();
var RAMAddress = (function () {
function RAMAddress(addr) {
addr = ~~addr;
if (addr & 3) {
throw new RangeError("RAM address 0x" + addr.toString(16) + " must be aligned");
}
if (addr < RAMAddress.BASE || addr >= RAMAddress.BASE + RAMAddress.SIZE) {
throw new RangeError("RAM address 0x" + addr.toString(16) + " out of range");
}
this[_addressSym] = addr;
}
Object.defineProperty(RAMAddress, "BASE", {
get: function () { return 0x40000000; },
enumerable: true,
configurable: true
});
Object.defineProperty(RAMAddress, "SIZE", {
get: function () { return 32 * 1024; },
enumerable: true,
configurable: true
});
Object.defineProperty(RAMAddress.prototype, "address", {
get: function () { return this[_addressSym]; },
enumerable: true,
configurable: true
});
RAMAddress.prototype.increment = function (diff) {
return new RAMAddress(this[_addressSym] + diff);
};
RAMAddress.prototype.valueOf = function () {
return this.address;
};
return RAMAddress;
}());
exports.RAMAddress = RAMAddress;