compiler_new.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. #ifndef SLEDGE_COMPILER_H
  2. #define SLEDGE_COMPILER_H
  3. #include <string.h>
  4. #define MAXARGS 8
  5. #define MAXFRAME 24 // maximum MAXFRAME-MAXARGS local vars
  6. typedef jit_word_t (*funcptr)();
  7. typedef enum arg_t {
  8. ARGT_CONST,
  9. ARGT_CELL,
  10. ARGT_ENV,
  11. ARGT_LAMBDA,
  12. ARGT_REG,
  13. ARGT_INT,
  14. ARGT_STACK,
  15. ARGT_STACK_INT
  16. } arg_t;
  17. typedef struct Arg {
  18. arg_t type;
  19. Cell* cell;
  20. env_entry* env;
  21. int slot;
  22. char* name;
  23. } Arg;
  24. typedef struct Frame {
  25. Arg* f;
  26. int sp;
  27. int locals;
  28. void* stack_end;
  29. } Frame;
  30. typedef enum builtin_t {
  31. BUILTIN_ADD = 1,
  32. BUILTIN_SUB,
  33. BUILTIN_MUL,
  34. BUILTIN_DIV,
  35. BUILTIN_MOD,
  36. BUILTIN_BITAND,
  37. BUILTIN_BITOR,
  38. BUILTIN_BITXOR,
  39. BUILTIN_SHL,
  40. BUILTIN_SHR,
  41. BUILTIN_LT,
  42. BUILTIN_GT,
  43. BUILTIN_EQ,
  44. BUILTIN_WHILE,
  45. BUILTIN_DEF,
  46. BUILTIN_IF ,
  47. BUILTIN_FN ,
  48. BUILTIN_CAR,
  49. BUILTIN_CDR,
  50. BUILTIN_CONS,
  51. BUILTIN_LIST,
  52. BUILTIN_ALLOC,
  53. BUILTIN_ALLOC_STR,
  54. BUILTIN_BYTES_TO_STR,
  55. BUILTIN_STR_TO_BYTES,
  56. BUILTIN_CONCAT,
  57. BUILTIN_SUBSTR,
  58. BUILTIN_GET,
  59. BUILTIN_GET32,
  60. BUILTIN_PUT,
  61. BUILTIN_PUT32,
  62. BUILTIN_SIZE,
  63. BUILTIN_UGET,
  64. BUILTIN_UPUT,
  65. BUILTIN_USIZE,
  66. BUILTIN_TYPE,
  67. BUILTIN_LET,
  68. BUILTIN_QUOTE,
  69. BUILTIN_MAP,
  70. BUILTIN_DO,
  71. BUILTIN_EVAL,
  72. BUILTIN_READ,
  73. BUILTIN_WRITE,
  74. BUILTIN_PRINT,
  75. BUILTIN_MOUNT,
  76. BUILTIN_MMAP,
  77. BUILTIN_OPEN,
  78. BUILTIN_CLOSE,
  79. BUILTIN_RECV,
  80. BUILTIN_SEND,
  81. BUILTIN_PIXEL,
  82. BUILTIN_FLIP,
  83. BUILTIN_RECTFILL,
  84. BUILTIN_BLIT,
  85. BUILTIN_BLIT_MONO,
  86. BUILTIN_BLIT_MONO_INV,
  87. BUILTIN_BLIT_STRING,
  88. BUILTIN_INKEY,
  89. BUILTIN_GC,
  90. BUILTIN_SYMBOLS,
  91. BUILTIN_DEBUG,
  92. BUILTIN_LOAD,
  93. BUILTIN_SAVE,
  94. BUILTIN_SIN,
  95. BUILTIN_COS,
  96. BUILTIN_SQRT
  97. } builtin_t;
  98. Cell* insert_global_symbol(Cell* symbol, Cell* cell);
  99. env_entry* lookup_global_symbol(char* name);
  100. extern Cell* platform_debug();
  101. #endif