| 129 | } |
| 130 | |
| 131 | const VariableMixin = (superclass) => |
| 132 | class extends superclass { |
| 133 | constructor(value = 0) { |
| 134 | // unlike the View classes, we don't allow number coercion. we |
| 135 | // explicitly allow floats unlike Int |
| 136 | if (typeof value !== "number") { |
| 137 | throw TypeError("value not a number"); |
| 138 | } |
| 139 | super([value]); |
| 140 | } |
| 141 | |
| 142 | addr_at(...args) { |
| 143 | throw TypeError("unimplemented method"); |
| 144 | } |
| 145 | |
| 146 | [Symbol.toPrimitive](hint) { |
| 147 | return this[0]; |
| 148 | } |
| 149 | |
| 150 | toString(...args) { |
| 151 | return this[0].toString(...args); |
| 152 | } |
| 153 | }; |
| 154 | |
| 155 | export class Byte extends VariableMixin(View1) {} |
| 156 | export class Short extends VariableMixin(View2) {} |