simple-lisp/bootstrap/constants.h

77 lines
3.0 KiB
C
Raw Normal View History

2024-09-24 07:03:52 -07:00
#ifndef INCLUDED_CONSTANTS_H
#define INCLUDED_CONSTANTS_H
#include <stdint.h>
typedef uint16_t LispInst;
2024-09-24 22:24:02 -07:00
#define INST_NIL ((LispInst) 0)
#define INST_T ((LispInst) 1)
#define INST_STRING ((LispInst) 2)
#define INST_INT ((LispInst) 3)
#define INST_FLOAT ((LispInst) 4)
#define INST_CONS ((LispInst) 5)
#define INST_LIST ((LispInst) 6)
#define INST_VECTOR ((LispInst) 7)
#define INST_INTERN_LIT ((LispInst) 8)
#define INST_INTERN_DYN ((LispInst) 9)
#define INST_SYMBOL_NAME ((LispInst) 10)
#define INST_MOV ((LispInst) 11)
#define INST_FUNCALL ((LispInst) 12)
#define INST_RETVAL_COUNT ((LispInst) 13)
#define INST_ENTER_LEXENV ((LispInst) 14)
#define INST_ENTER_INHERITED_LEXENV ((LispInst) 15)
#define INST_LEAVE_LEXENV ((LispInst) 16)
#define INST_ENTER_BLOCK ((LispInst) 17)
#define INST_LEAVE_BLOCK ((LispInst) 18)
#define INST_SET_VALUE ((LispInst) 19)
#define INST_SET_FUNCTION ((LispInst) 20)
#define INST_GET_VALUE ((LispInst) 21)
#define INST_GET_FUNCTION ((LispInst) 22)
#define INST_NEWFUNCTION_LIT ((LispInst) 23)
#define INST_NEWFUNCTION_DYN ((LispInst) 24)
#define INST_PUT ((LispInst) 25)
#define INST_GET ((LispInst) 26)
#define INST_AND ((LispInst) 27)
#define INST_OR ((LispInst) 28)
#define INST_XOR ((LispInst) 29)
#define INST_NOT ((LispInst) 30)
#define INST_CJMP ((LispInst) 31)
#define INST_CAR ((LispInst) 32)
#define INST_CDR ((LispInst) 33)
#define INST_SETCAR ((LispInst) 34)
#define INST_SETCDR ((LispInst) 35)
#define INST_GETELT_LIT ((LispInst) 36)
#define INST_GETELT_DYN ((LispInst) 37)
#define INST_SETELT_LIT ((LispInst) 38)
#define INST_SETELT_DYN ((LispInst) 39)
#define INST_EQ_TWO ((LispInst) 40)
#define INST_EQ_N ((LispInst) 41)
#define INST_NUM_GT ((LispInst) 42)
#define INST_NUM_GE ((LispInst) 43)
#define INST_NUM_EQ ((LispInst) 44)
#define INST_NUM_LE ((LispInst) 45)
#define INST_NUM_LT ((LispInst) 46)
#define N_INSTRUCTIONS ((LispInst) 47)
2024-09-24 07:03:52 -07:00
extern const char *INSTRUCTION_NAMES[];
typedef uint8_t LispRegType;
typedef struct {
LispRegType type;
uint32_t which;
} LispReg;
#define REG_VAL ((LispRegType) 0)
#define REG_SAVED ((LispRegType) 1)
#define REG_ARG ((LispRegType) 2)
#define REG_RET ((LispRegType) 3)
2024-09-24 22:24:02 -07:00
#define N_REGISTTERS 4
2024-09-24 07:03:52 -07:00
extern const char *REGISTER_NAMES[];
#define SAME_REG(r1, r2) ((r1)->type == (r2)->type && (r1)->which == (r2)->which)
#endif