From 2960f1c83005d1d6c19362fa81b95bb40460c7fa Mon Sep 17 00:00:00 2001 From: SimonFJ20 Date: Fri, 1 Nov 2024 13:06:28 +0100 Subject: [PATCH] add runtime + arch --- src/arch.ts | 31 +++++++++++++++++++++++++++++++ src/runtime.ts | 5 +++++ 2 files changed, 36 insertions(+) create mode 100644 src/arch.ts create mode 100644 src/runtime.ts diff --git a/src/arch.ts b/src/arch.ts new file mode 100644 index 0000000..d9a4f47 --- /dev/null +++ b/src/arch.ts @@ -0,0 +1,31 @@ +export type Ins = Ops | number; +export type Program = Ins[]; + +export const Ops = { + Nop: 0, + PushNull: 1, + PushInt: 2, + PushString: 3, + PushArray: 4, + PushStruct: 5, + PushPtr: 6, + Pop: 7, + LoadLocal: 8, + StoreLocal: 9, + Call: 10, + Return: 11, + Jump: 12, + JumpIfNotZero: 13, + Add: 14, + Subtract: 15, + Multiply: 16, + Divide: 17, + Remainder: 18, + Equal: 19, + LessThan: 20, + And: 21, + Or: 22, + Xor: 23, + Not: 24, +} as const; +export type Ops = typeof Ops; diff --git a/src/runtime.ts b/src/runtime.ts new file mode 100644 index 0000000..5f37fc3 --- /dev/null +++ b/src/runtime.ts @@ -0,0 +1,5 @@ +import { Program } from "./arch"; + +export class VM { + public constructor(private program: Program) {} +}