mirror of
https://git.sfja.dk/Mikkel/slige.git
synced 2025-01-18 18:16:31 +00:00
add runtime + arch
This commit is contained in:
parent
be71bab97e
commit
2960f1c830
31
src/arch.ts
Normal file
31
src/arch.ts
Normal file
@ -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;
|
5
src/runtime.ts
Normal file
5
src/runtime.ts
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import { Program } from "./arch";
|
||||||
|
|
||||||
|
export class VM {
|
||||||
|
public constructor(private program: Program) {}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user