UNPKG

@powerlang/egg-js

Version:

A Smalltalk VM that runs on top of JavaScript

82 lines (67 loc) 1.02 kB
let EggObjectHeader = class { constructor() { this._behavior = nil; this._flags = nil; this._size = nil; this._hash = nil; } behavior() { return this._behavior; } behavior_(anEggHeapObject) { this._behavior = anEggHeapObject; return this; } bytes_arrayed_named_(bytes, arrayed, named) { let b, a, n; if (bytes) { b = 1 } else { b = 0 } ; if (arrayed) { a = 2 } else { a = 0 } ; if (named) { n = 4 } else { n = 0 } ; this._flags = b._or(a)._or(n); return this; } flags() { return this._flags; } hash() { return this._hash; } hash_(anInteger) { this._hash = anInteger; return this; } isSmall() { return this.size()._lessThan(256); } size() { return this._size; } size_(anInteger) { this._size = anInteger; if (this.isSmall()) { this._flags = this._flags._or(128) } ; return this; } } export default EggObjectHeader