libStd top-level property
The standard library It is possible to load the vm without this, but it's nearly useless
Implementation
final libStd = Library({
"true": true,
"false": false,
// "unit": _Unit(),
"dup": (VirtualMachine state) => state.eval(Duplicate),
// use this to load a function without calling it
// "load": (VirtualMachine state) => state.load(callFunction: false),
// // rotate and execute - allows "infix" functions
// ";": (VirtualMachine state) {
// state.rotate(2, 1);
// state.execute();
// },
// "!": infix((VirtualMachine state) => state.push(!state.popBool())),
// "+": infix((VirtualMachine state) => state.push(
// state.popNumber() + state.popNumber(),
// )),
// "-": infix((VirtualMachine state) =>
// state.push(-state.popNumber() + state.popNumber())),
// "*": infix((VirtualMachine state) =>
// state.push(state.popNumber() * state.popNumber())),
// "/": infix((VirtualMachine state) =>
// state.push((1.0 / state.popNumber()) * state.popNumber())),
// "=": infix((VirtualMachine state) => state.push(state.pop() == state.pop())),
// "!=": infix((VirtualMachine state) => state.push(state.pop() != state.pop())),
// ">": infix((VirtualMachine state) =>
// state.push(state.popNumber() < state.popNumber())),
// "<": infix((VirtualMachine state) =>
// state.push(state.popNumber() > state.popNumber())),
// ">=": infix((VirtualMachine state) =>
// state.push(state.popNumber() <= state.popNumber())),
// "<=": infix((VirtualMachine state) =>
// state.push(state.popNumber() >= state.popNumber())),
// // using the [, ] as seperate functions is a neat trick for pushing an array
// "[": (VirtualMachine state) => state.push(<FlightValue, FlightValue>{}),
// "[]": (VirtualMachine state) => state.push(<FlightValue, FlightValue>{}),
// "]": (VirtualMachine state) => state.mapInitComplete(),
// "to": infix((VirtualMachine vm) => vm.pushMapEntry()),
// "<<": infix((VirtualMachine state) => state.mapSet()),
// ">>": infix((VirtualMachine state) {
// state.rotate(2, 1);
// state.mapSet();
// }),
// "#": infix((VirtualMachine state) => state.mapGet()),
// "[]!": (VirtualMachine state) => state.mapDelete(),
// "max": (VirtualMachine state) => state.mapMax(),
// "if": (VirtualMachine state) => state.if_(),
// "loop": (VirtualMachine state) => state.loop(),
// "print": (VirtualMachine state) => print(state.pop().value),
// "inspect": (VirtualMachine state) => print(state.pop()),
});