Implement basic integer math operations

This commit is contained in:
2026-08-01 13:50:24 -05:00
parent e728c3fdfa
commit 6e0eb2786e
8 changed files with 521 additions and 166 deletions

24
src/vm/commands/abs.ts Normal file
View File

@@ -0,0 +1,24 @@
import {Command} from "./command.js";
import {LexInput} from "../lexer.js";
import {StrVM} from "../vm.js";
import {Awaitable} from "../../util/types.js";
export class Abs extends Command<{}> {
attemptParse(): Awaitable<{}> {
return {}
}
getDisplayName(): string {
return 'abs'
}
isParseCandidate(token: LexInput): boolean {
return this.isKeyword(token, 'abs')
}
async execute(vm: StrVM): Promise<StrVM> {
return vm.replaceContextMatchingTerm({
int: sub => Math.abs(sub),
})
}
}