| 200 | |
| 201 | // mutable Int (we are explicitly using Int's private fields) |
| 202 | const Word64Mixin = (superclass) => |
| 203 | class extends superclass { |
| 204 | constructor(...args) { |
| 205 | if (!args.length) { |
| 206 | return super(0); |
| 207 | } |
| 208 | super(...args); |
| 209 | } |
| 210 | |
| 211 | get addr() { |
| 212 | // assume this is safe to cache |
| 213 | return mt.get_view_vector(this._u32); |
| 214 | } |
| 215 | |
| 216 | get length() { |
| 217 | return 1; |
| 218 | } |
| 219 | |
| 220 | get size() { |
| 221 | return 8; |
| 222 | } |
| 223 | |
| 224 | get byteLength() { |
| 225 | return 8; |
| 226 | } |
| 227 | |
| 228 | // no setters for top and bot since low/high can accept negative integers |
| 229 | |
| 230 | get lo() { |
| 231 | return super.lo; |
| 232 | } |
| 233 | |
| 234 | set lo(value) { |
| 235 | this._u32[0] = value; |
| 236 | } |
| 237 | |
| 238 | get hi() { |
| 239 | return super.hi; |
| 240 | } |
| 241 | |
| 242 | set hi(value) { |
| 243 | this._u32[1] = value; |
| 244 | } |
| 245 | |
| 246 | set(value) { |
| 247 | const buffer = this._u32; |
| 248 | const values = lohi_from_one(value); |
| 249 | |
| 250 | buffer[0] = values[0]; |
| 251 | buffer[1] = values[1]; |
| 252 | } |
| 253 | }; |
| 254 | |
| 255 | export class Long extends Word64Mixin(Int) { |
| 256 | as_addr() { |