From b3bd068f614a46580ee3e5688dd9cfd40694d75b Mon Sep 17 00:00:00 2001 From: Johnny Richard Date: Mon, 14 Apr 2025 23:22:57 +0200 Subject: Define clang-format and .editorconfig settings Signed-off-by: Johnny Richard --- src/vm.h | 90 +++++++++++++++++++++++++++++++++------------------------------- 1 file changed, 47 insertions(+), 43 deletions(-) (limited to 'src/vm.h') diff --git a/src/vm.h b/src/vm.h index 365b98e..143275f 100644 --- a/src/vm.h +++ b/src/vm.h @@ -22,59 +22,63 @@ #define STACK_CAPACITY 1024 #define HEAP_CAPACITY 1024 -typedef enum inst_type { - // stack - INST_PUSH, - INST_DUP, - INST_COPY, - INST_SWAP, - INST_DROP, - INST_SLIDE, - // arithmetics - INST_ADD, - INST_SUB, - INST_MUL, - INST_DIV, - INST_MOD, - // heap access - INST_STORE, - INST_LOAD, - // Flow control - INST_CALL, - INST_RET, - INST_LABEL, - INST_JMP, - INST_JMPZ, - INST_JMPN, - // I/O - INST_PRINTI, - INST_PRINTC, - INST_READI, - INST_READC, - INST_END, +typedef enum inst_type +{ + // stack + INST_PUSH, + INST_DUP, + INST_COPY, + INST_SWAP, + INST_DROP, + INST_SLIDE, + // arithmetics + INST_ADD, + INST_SUB, + INST_MUL, + INST_DIV, + INST_MOD, + // heap access + INST_STORE, + INST_LOAD, + // Flow control + INST_CALL, + INST_RET, + INST_LABEL, + INST_JMP, + INST_JMPZ, + INST_JMPN, + // I/O + INST_PRINTI, + INST_PRINTC, + INST_READI, + INST_READC, + INST_END, } inst_type_t; -typedef struct instr { - inst_type_t type; - int operand; +typedef struct instr +{ + inst_type_t type; + int operand; } inst_t; -typedef struct label { - int name; - int index; +typedef struct label +{ + int name; + int index; } label_t; -typedef struct vm { - stack_t stack; - stack_t call_stack; - int *heap; - label_t *labels; +typedef struct vm +{ + stack_t stack; + stack_t call_stack; + int* heap; + label_t* labels; } vm_t; void -vm_init(vm_t *vm); +vm_init(vm_t* vm); void -vm_run(vm_t *vm, inst_t *insts); +vm_run(vm_t* vm, inst_t* insts); #endif /* VM_H */ -- cgit v1.2.3