78 lines
2.7 KiB
C
78 lines
2.7 KiB
C
|
#ifndef INCLUDED_CONSTANTS_H
|
||
|
#define INCLUDED_CONSTANTS_H
|
||
|
|
||
|
#include <stdint.h>
|
||
|
|
||
|
typedef uint16_t LispInst;
|
||
|
|
||
|
|
||
|
#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_LEAVE_ELEXENV ((LispInst) 15)
|
||
|
#define INST_ENTER_BLOCK ((LispInst) 16)
|
||
|
#define INST_LEAVE_BLOCK ((LispInst) 17)
|
||
|
#define INST_SET_VALUE ((LispInst) 18)
|
||
|
#define INST_SET_FUNCTION ((LispInst) 19)
|
||
|
#define INST_GET_VALUE ((LispInst) 20)
|
||
|
#define INST_GET_FUNCTION ((LispInst) 21)
|
||
|
#define INST_NEWFUNCTION_LIT ((LispInst) 22)
|
||
|
#define INST_NEWFUNCTION_DYN ((LispInst) 23)
|
||
|
#define INST_PUT ((LispInst) 24)
|
||
|
#define INST_GET ((LispInst) 25)
|
||
|
#define INST_AND ((LispInst) 26)
|
||
|
#define INST_OR ((LispInst) 27)
|
||
|
#define INST_XOR ((LispInst) 28)
|
||
|
#define INST_NOT ((LispInst) 29)
|
||
|
#define INST_CJMP ((LispInst) 30)
|
||
|
#define INST_CAR ((LispInst) 31)
|
||
|
#define INST_CDR ((LispInst) 32)
|
||
|
#define INST_SETCAR ((LispInst) 33)
|
||
|
#define INST_SETCDR ((LispInst) 34)
|
||
|
#define INST_GETELT_LIT ((LispInst) 35)
|
||
|
#define INST_GETELT_DYN ((LispInst) 36)
|
||
|
#define INST_SETELT_LIT ((LispInst) 37)
|
||
|
#define INST_SETELT_DYN ((LispInst) 38)
|
||
|
#define INST_EQ_TWO ((LispInst) 39)
|
||
|
#define INST_EQ_N ((LispInst) 40)
|
||
|
#define INST_NUM_GT ((LispInst) 41)
|
||
|
#define INST_NUM_GE ((LispInst) 42)
|
||
|
#define INST_NUM_EQ ((LispInst) 43)
|
||
|
#define INST_NUM_LE ((LispInst) 44)
|
||
|
#define INST_NUM_LT ((LispInst) 45)
|
||
|
#define N_INSTRUCTIONS ((LispInst) 46)
|
||
|
|
||
|
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)
|
||
|
#define REG_LEXENV ((LispRegType) 4)
|
||
|
#define REG_BLOCK ((LispRegType) 5)
|
||
|
#define N_REGISTTERS 6
|
||
|
|
||
|
extern const char *REGISTER_NAMES[];
|
||
|
|
||
|
#define SAME_REG(r1, r2) ((r1)->type == (r2)->type && (r1)->which == (r2)->which)
|
||
|
|
||
|
#endif
|