PageRenderTime 20ms CodeModel.GetById 2ms app.highlight 14ms RepoModel.GetById 1ms app.codeStats 0ms

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