inter.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. #ifndef VIRTUALMATH_INTER_H
  2. #define VIRTUALMATH_INTER_H
  3. struct Result;
  4. #define BASEOBJSZIE (17)
  5. #define VARNAMESIZE (8)
  6. #define BASEEXCESIZE (19)
  7. #define MAGFUNCSIZE (45)
  8. #define B_OBJECT (0)
  9. #define B_VOBJECT (1)
  10. #define B_INT_ (2)
  11. #define B_DOU (3)
  12. #define B_STR (4)
  13. #define B_BOOL (5)
  14. #define B_PASS (6)
  15. #define B_LIB (7)
  16. #define B_FILE (8)
  17. #define B_TUPLE (9)
  18. #define B_LIST (10)
  19. #define B_DICT (11)
  20. #define B_FUNCTION (12)
  21. #define B_NONE (13)
  22. #define B_LISTITER (14)
  23. #define B_DICTITER (15)
  24. #define B_POINTER (16)
  25. #define VN_str (0)
  26. #define VN_num (1)
  27. #define VN_bool (2)
  28. #define VN_file (3)
  29. #define VN_none (4)
  30. #define VN_pass (5)
  31. #define VN_class (6)
  32. #define VN_obj (7)
  33. #define M_INIT (0)
  34. #define M_NEW (1)
  35. #define M_CALL (2)
  36. #define M_ENTER (3)
  37. #define M_EXIT (4)
  38. #define M_ADD (5)
  39. #define M_SUB (6)
  40. #define M_MUL (7)
  41. #define M_DIV (8)
  42. #define M_DEL (9)
  43. #define M_DOWN (10)
  44. #define M_SLICE (11)
  45. #define M_ITER (12)
  46. #define M_NEXT (13)
  47. #define M_REPO (14)
  48. #define M_BOOL (15)
  49. #define M_NAME (16)
  50. #define M_SELF (17)
  51. #define M_FATHER (18)
  52. #define M_MESSAGE (19)
  53. #define M_STR (20)
  54. #define M_DOWN_ASSIGMENT (21)
  55. #define M_SLICE_ASSIGMENT (22)
  56. #define M_DOWN_DEL (23)
  57. #define M_SLICE_DEL (24)
  58. #define M_ATTR (25)
  59. #define M_VAL (26)
  60. #define M_INTDIV (27)
  61. #define M_MOD (28)
  62. #define M_POW (29)
  63. #define M_BAND (30)
  64. #define M_BOR (31)
  65. #define M_BXOR (32)
  66. #define M_BNOT (33)
  67. #define M_BL (34)
  68. #define M_BR (35)
  69. #define M_EQ (36)
  70. #define M_MOREEQ (37)
  71. #define M_LESSEQ (38)
  72. #define M_MORE (39)
  73. #define M_LESS (40)
  74. #define M_NOTEQ (41)
  75. #define M_AND (42)
  76. #define M_OR (43)
  77. #define M_NOT (44)
  78. struct Inter{
  79. struct Value *base;
  80. struct LinkValue *link_base;
  81. struct HashTable *hash_base;
  82. struct Var *base_var;
  83. struct LinkValue *base_belong;
  84. struct Package *package;
  85. struct VarList *var_list;
  86. struct InterData{
  87. FILE *inter_stdout;
  88. FILE *inter_stderr;
  89. FILE *inter_stdin;
  90. bool is_stdout;
  91. bool is_stderr;
  92. bool is_stdin;
  93. struct LinkValue *base_obj[BASEOBJSZIE];
  94. struct LinkValue *base_exc[BASEEXCESIZE];
  95. wchar_t *var_name[VARNAMESIZE];
  96. wchar_t *mag_func[MAGFUNCSIZE];
  97. int default_pt_type;
  98. } data;
  99. };
  100. typedef struct Inter Inter;
  101. typedef struct Statement Statement;
  102. typedef enum ResultType ResultType;
  103. Inter *makeInter(char *out, char *error_, char *in, LinkValue *belong);
  104. void freeInter(Inter *inter, bool show_gc);
  105. void setBaseInterData(struct Inter *inter);
  106. void runCodeStdin(Inter *inter, char *hello_string);
  107. void runCodeFile(Inter *inter, char *file[]);
  108. bool runParser(char *code_file, Inter *inter, bool is_one, Statement **st);
  109. void mergeInter(Inter *new, Inter *base);
  110. Inter *deriveInter(LinkValue *belong, Inter *inter);
  111. #endif //VIRTUALMATH_INTER_H