From 6e2bda386896712a891d63af308fa72c8b710c36 Mon Sep 17 00:00:00 2001 From: sbosse Date: Mon, 16 Mar 2026 11:09:26 +0100 Subject: [PATCH] Mon 16 Mar 11:09:06 CET 2026 --- src/code.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/code.h diff --git a/src/code.h b/src/code.h new file mode 100644 index 0000000..28d8446 --- /dev/null +++ b/src/code.h @@ -0,0 +1,22 @@ +#ifndef _CODE_H +#define _CODE_H + +/* + Code area is bottom of heap memory +*/ +#define CODESTORE0(M,addr,cmd) M->data[addr]=(unsigned char)cmd +#define CODESTORE1N(M,addr,cmd,x) { CODESTORE0(M,addr,cmd); *((number_t *)&M->data[addr+1])=(number_t)x; } +#define CODESTORE1I(M,addr,cmd,x) { CODESTORE0(M,addr,cmd); *((index_t *)&M->data[addr+1])=x; } +#define CODESTORE1A(M,addr,cmd,x) { CODESTORE0(M,addr,cmd); *((address_t*)&M->data[addr+1])=x; } + + +#define CODEADD0(M,cmd) M->data[M->bottom++]=(unsigned char)cmd +#define CODEADD1N(M,cmd,x) { CODEADD0(M,cmd); *((number_t *)&M->data[M->bottom])=(number_t)x; M->bottom+=number_s; } +#define CODEADD1I(M,cmd,x) { CODEADD0(M,cmd); *((index_t *)&M->data[M->bottom])=x; M->bottom+=index_s;} +#define CODEADD1A(M,cmd,x) { CODEADD0(M,cmd); *((address_t*)&M->data[M->bottom])=x; M->bottom+=address_s;} +#define CODEADDREADVAR(M,R,name) { address_t addr=Allocate(M,R, name, MVAR, 1, NULL); if (addr<0) return error(R,EVAR); CODEADD0(M,READ); *((address_t*)&M->data[M->bottom])=addr; M->bottom+=address_s; } + +index_t CompileExpr(lexer_t *lex, mem_t *M, reg_t *R); +void CompileInstr(lexer_t *lex, mem_t *M, reg_t *R); +int Compile(lexer_t *lex, char *buffer ,context_t *C, int runnable /* pstate */); +#endif