Files
adminandClaude Opus 5.5 a45e8b2382 Restore Riposte from the copy installed in ReaderJS
The GitHub repository (github.com/Alpaq92/Riposte) is gone with the suspended
account. These are the files npm installed for ReaderJS from commit
307ef7dfd9c5e8c0c07a840874e013cf94a85ada, so this is that commit's packaged content, without its history.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-29 16:26:53 +01:00

40 lines
1.1 KiB
JavaScript

// engine/operators/array.js — array construction and array-specific operators.
import { PS, MARK, NULL, T } from '../object.js';
import { PSError } from '../errors.js';
export default {
array(vm) {
const n = vm.popInt();
if (n < 0) throw new PSError('rangecheck');
vm.push(PS.array(new Array(n).fill(NULL), false));
},
// `[` pushes a mark; `]` collects everything above the mark into an array.
'['(vm) { vm.push(MARK); },
']'(vm) {
const items = [];
for (;;) {
if (!vm.ostack.length) throw new PSError('unmatchedmark');
const o = vm.ostack.pop();
if (o.type === T.MARK) break;
items.push(o);
}
items.reverse();
vm.push(PS.array(items, false));
},
aload(vm) {
const a = vm.popType(T.ARRAY);
for (let i = 0; i < a.value.length; i++) vm.push(a.value.get(i));
vm.push(a);
},
astore(vm) {
const a = vm.popType(T.ARRAY);
vm.recordMutation(a.value);
const n = a.value.length;
if (vm.ostack.length < n) throw new PSError('stackunderflow');
for (let i = n - 1; i >= 0; i--) a.value.put(i, vm.pop());
vm.push(a);
},
};