/xbmc/visualizations/Goom/goom2k4-0/src/goomsl_private.h

http://github.com/xbmc/xbmc · C++ Header · 251 lines · 201 code · 36 blank · 14 comment · 0 complexity · 5dfc02e62ff7535496e78ed84ed74b0c MD5 · raw file

  1. #ifndef _GSL_PRIVATE_H
  2. #define _GSL_PRIVATE_H
  3. /* -- internal use -- */
  4. #include "goomsl.h"
  5. #ifdef USE_JITC_X86
  6. #include "jitc_x86.h"
  7. #endif
  8. #include "goomsl_heap.h"
  9. /* {{{ type of nodes */
  10. #define EMPTY_NODE 0
  11. #define CONST_INT_NODE 1
  12. #define CONST_FLOAT_NODE 2
  13. #define CONST_PTR_NODE 3
  14. #define VAR_NODE 4
  15. #define PARAM_NODE 5
  16. #define READ_PARAM_NODE 6
  17. #define OPR_NODE 7
  18. /* }}} */
  19. /* {{{ type of operations */
  20. #define OPR_SET 1
  21. #define OPR_IF 2
  22. #define OPR_WHILE 3
  23. #define OPR_BLOCK 4
  24. #define OPR_ADD 5
  25. #define OPR_MUL 6
  26. #define OPR_EQU 7
  27. #define OPR_NOT 8
  28. #define OPR_LOW 9
  29. #define OPR_DIV 10
  30. #define OPR_SUB 11
  31. #define OPR_FUNC_INTRO 12
  32. #define OPR_FUNC_OUTRO 13
  33. #define OPR_CALL 14
  34. #define OPR_EXT_CALL 15
  35. #define OPR_PLUS_EQ 16
  36. #define OPR_SUB_EQ 17
  37. #define OPR_MUL_EQ 18
  38. #define OPR_DIV_EQ 19
  39. #define OPR_CALL_EXPR 20
  40. #define OPR_AFFECT_LIST 21
  41. #define OPR_FOREACH 22
  42. #define OPR_VAR_LIST 23
  43. /* }}} */
  44. typedef struct _ConstIntNodeType { /* {{{ */
  45. int val;
  46. } ConstIntNodeType; /* }}} */
  47. typedef struct _ConstFloatNodeType { /* {{{ */
  48. float val;
  49. } ConstFloatNodeType; /* }}} */
  50. typedef struct _ConstPtrNodeType { /* {{{ */
  51. int id;
  52. } ConstPtrNodeType; /* }}} */
  53. typedef struct _OprNodeType { /* {{{ */
  54. int type;
  55. int nbOp;
  56. struct _NODE_TYPE *op[3]; /* maximal number of operand needed */
  57. struct _NODE_TYPE *next;
  58. } OprNodeType; /* }}} */
  59. typedef struct _NODE_TYPE { /* {{{ */
  60. int type;
  61. char *str;
  62. GoomHash *vnamespace;
  63. int line_number;
  64. union {
  65. ConstIntNodeType constInt;
  66. ConstFloatNodeType constFloat;
  67. ConstPtrNodeType constPtr;
  68. OprNodeType opr;
  69. } unode;
  70. } NodeType; /* }}} */
  71. typedef struct _INSTRUCTION_DATA { /* {{{ */
  72. union {
  73. void *var;
  74. int *var_int;
  75. int *var_ptr;
  76. float *var_float;
  77. int jump_offset;
  78. struct _ExternalFunctionStruct *external_function;
  79. } udest;
  80. union {
  81. void *var;
  82. int *var_int;
  83. int *var_ptr;
  84. float *var_float;
  85. int value_int;
  86. int value_ptr;
  87. float value_float;
  88. } usrc;
  89. } InstructionData;
  90. /* }}} */
  91. typedef struct _INSTRUCTION { /* {{{ */
  92. int id;
  93. InstructionData data;
  94. GoomSL *parent;
  95. const char *name; /* name of the instruction */
  96. char **params; /* parametres de l'instruction */
  97. GoomHash **vnamespace;
  98. int *types; /* type des parametres de l'instruction */
  99. int cur_param;
  100. int nb_param;
  101. int address;
  102. char *jump_label;
  103. char *nop_label;
  104. int line_number;
  105. } Instruction;
  106. /* }}} */
  107. typedef struct _INSTRUCTION_FLOW { /* {{{ */
  108. Instruction **instr;
  109. int number;
  110. int tabsize;
  111. GoomHash *labels;
  112. } InstructionFlow;
  113. /* }}} */
  114. typedef struct _FAST_INSTRUCTION { /* {{{ */
  115. int id;
  116. InstructionData data;
  117. Instruction *proto;
  118. } FastInstruction;
  119. /* }}} */
  120. typedef struct _FastInstructionFlow { /* {{{ */
  121. int number;
  122. FastInstruction *instr;
  123. void *mallocedInstr;
  124. } FastInstructionFlow;
  125. /* }}} */
  126. typedef struct _ExternalFunctionStruct { /* {{{ */
  127. GoomSL_ExternalFunction function;
  128. GoomHash *vars;
  129. int is_extern;
  130. } ExternalFunctionStruct;
  131. /* }}} */
  132. typedef struct _Block {
  133. int data;
  134. int size;
  135. } Block;
  136. typedef struct _GSL_StructField { /* {{{ */
  137. int type;
  138. char name[256];
  139. int offsetInStruct; /* Where this field is stored... */
  140. } GSL_StructField;
  141. /* }}} */
  142. typedef struct _GSL_Struct { /* {{{ */
  143. int nbFields;
  144. GSL_StructField *fields[64];
  145. int size;
  146. Block iBlock[64];
  147. Block fBlock[64];
  148. } GSL_Struct;
  149. /* }}} */
  150. struct _GoomSL { /* {{{ */
  151. int num_lines;
  152. Instruction *instr; /* instruction en cours de construction */
  153. InstructionFlow *iflow; /* flow d'instruction 'normal' */
  154. FastInstructionFlow *fastiflow; /* flow d'instruction optimise */
  155. GoomHash *vars; /* table de variables */
  156. int currentNS;
  157. GoomHash *namespaces[16];
  158. GoomHash *functions; /* table des fonctions externes */
  159. GoomHeap *data_heap; /* GSL Heap-like memory space */
  160. int nbStructID;
  161. GoomHash *structIDS;
  162. GSL_Struct **gsl_struct;
  163. int gsl_struct_size;
  164. int nbPtr;
  165. int ptrArraySize;
  166. void **ptrArray;
  167. int compilationOK;
  168. #ifdef USE_JITC_X86
  169. JitcX86Env *jitc;
  170. JitcFunc jitc_func;
  171. #endif
  172. }; /* }}} */
  173. extern GoomSL *currentGoomSL;
  174. Instruction *gsl_instr_init(GoomSL *parent, const char *name, int id, int nb_param, int line_number);
  175. void gsl_instr_add_param(Instruction *_this, char *param, int type);
  176. void gsl_instr_set_namespace(Instruction *_this, GoomHash *ns);
  177. void gsl_declare_task(const char *name);
  178. void gsl_declare_external_task(const char *name);
  179. int gsl_type_of_var(GoomHash *namespace, const char *name);
  180. void gsl_enternamespace(const char *name);
  181. void gsl_reenternamespace(GoomHash *ns);
  182. GoomHash *gsl_leavenamespace(void);
  183. GoomHash *gsl_find_namespace(const char *name);
  184. void gsl_commit_compilation(void);
  185. /* #define TYPE_PARAM 1 */
  186. #define FIRST_RESERVED 0x80000
  187. #define TYPE_INTEGER 0x90001
  188. #define TYPE_FLOAT 0x90002
  189. #define TYPE_VAR 0x90003
  190. #define TYPE_PTR 0x90004
  191. #define TYPE_LABEL 0x90005
  192. #define TYPE_OP_EQUAL 6
  193. #define TYPE_IVAR 0xa0001
  194. #define TYPE_FVAR 0xa0002
  195. #define TYPE_PVAR 0xa0003
  196. #define TYPE_SVAR 0xa0004
  197. #define INSTR_JUMP 6
  198. #define INSTR_JZERO 29
  199. #define INSTR_CALL 36
  200. #define INSTR_RET 37
  201. #define INSTR_EXT_CALL 38
  202. #define INSTR_JNZERO 40
  203. #define INSTR_SET 0x80001
  204. #define INSTR_INT 0x80002
  205. #define INSTR_FLOAT 0x80003
  206. #define INSTR_PTR 0x80004
  207. #define INSTR_LABEL 0x80005
  208. #define INSTR_ISLOWER 0x80006
  209. #define INSTR_ADD 0x80007
  210. #define INSTR_MUL 0x80008
  211. #define INSTR_DIV 0x80009
  212. #define INSTR_SUB 0x80010
  213. #define INSTR_ISEQUAL 0x80011
  214. #define INSTR_NOT 0x80012
  215. #endif