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