@powerlang/egg-js
Version:
A Smalltalk VM that runs on top of JavaScript
61 lines (44 loc) • 1.12 kB
JavaScript
import EggHeapObject from './EggHeapObject.js';
let EggSlotObject = class extends EggHeapObject {
constructor() {
super();
this._slots = nil;
}
at_(index) {
return this._slots.at_((this._header.behavior().classInstSize()+index));
}
at_put_(index, anLMRObject) {
return this._slots.at_put_((this._header.behavior().classInstSize()+index), anLMRObject);
}
basicAt_put_(index, anLMRObject) {
return this._slots.at_put_(index, anLMRObject);
}
classInstSize() {
return this.slotAt_(1).slotAt_(3).value().bitAnd_(127);
}
header_(anLMRObjectHeader) {
super.header_(anLMRObjectHeader);
this._slots = Array.new_(this._header.size());
return this;
}
nilSlots_(nilObj) {
this._slots.atAllPut_(nilObj);
return this;
}
pointersSize() {
return this._header.size();
}
size() {
return this._header.size();
}
slotAt_(index) {
return this._slots.at_(index);
}
slotAt_put_(index, anLMRObject) {
return this._slots.at_put_(index, anLMRObject);
}
slots() {
return this._slots;
}
}
export default EggSlotObject