xine-lib  1.2.9
goomsl_private.h
Go to the documentation of this 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 
51 typedef struct _ConstIntNodeType { /* {{{ */
52  int val;
53 } ConstIntNodeType; /* }}} */
54 typedef struct _ConstFloatNodeType { /* {{{ */
55  float val;
56 } ConstFloatNodeType; /* }}} */
57 typedef struct _ConstPtrNodeType { /* {{{ */
58  int id;
59 } ConstPtrNodeType; /* }}} */
60 typedef 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; /* }}} */
66 typedef struct _NODE_TYPE { /* {{{ */
67  int type;
68  char *str;
71  union {
76  } unode;
77 } NodeType; /* }}} */
78 typedef struct _INSTRUCTION_DATA { /* {{{ */
79 
80  union {
81  void *var;
82  int *var_int;
83  int *var_ptr;
84  float *var_float;
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;
99 /* }}} */
100 typedef struct _INSTRUCTION { /* {{{ */
101 
102  int id;
105  const char *name; /* name of the instruction */
106 
107  char **params; /* parametres de l'instruction */
109  int *types; /* type des parametres de l'instruction */
111  int nb_param;
112 
113  int address;
114  char *jump_label;
115  char *nop_label;
116 
118 
119 } Instruction;
120 /* }}} */
121 typedef struct _INSTRUCTION_FLOW { /* {{{ */
122 
124  int number;
125  int tabsize;
128 /* }}} */
129 typedef struct _FAST_INSTRUCTION { /* {{{ */
130  int id;
134 /* }}} */
135 typedef struct _FastInstructionFlow { /* {{{ */
136  int number;
140 /* }}} */
141 typedef struct _ExternalFunctionStruct { /* {{{ */
146 /* }}} */
147 typedef struct _Block {
148  int data;
149  int size;
150 } Block;
151 typedef struct _GSL_StructField { /* {{{ */
152  int type;
153  char name[256];
154  int offsetInStruct; /* Where this field is stored... */
156  /* }}} */
157 typedef struct _GSL_Struct { /* {{{ */
158  int nbFields;
160  int size;
163 } GSL_Struct;
164  /* }}} */
165 struct _GoomSL { /* {{{ */
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 */
175 
176  GoomHash *functions; /* table des fonctions externes */
177 
178  GoomHeap *data_heap; /* GSL Heap-like memory space */
179 
184 
185  int nbPtr;
187  void **ptrArray;
188 
190 #ifdef USE_JITC_X86
191  JitcX86Env *jitc;
192  JitcFunc jitc_func;
193 #endif
194 }; /* }}} */
195 
196 extern GoomSL *currentGoomSL;
197 
198 Instruction *gsl_instr_init(GoomSL *parent, const char *name, int id, int nb_param, int line_number);
199 void gsl_instr_add_param(Instruction *_this, const char *param, int type);
201 
202 void gsl_declare_task(const char *name);
203 void gsl_declare_external_task(const char *name);
204 
205 int gsl_type_of_var(GoomHash *namespace, const char *name);
206 
207 void gsl_enternamespace(const char *name);
210 GoomHash *gsl_find_namespace(const char *name);
211 
212 void 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
InstructionFlow * iflow
Definition: goomsl_private.h:169
Definition: goomsl_private.h:100
struct _ExternalFunctionStruct ExternalFunctionStruct
GoomHash * functions
Definition: goomsl_private.h:176
GoomHash * vnamespace
Definition: goomsl_private.h:69
int value_ptr
Definition: goomsl_private.h:95
struct _NODE_TYPE * next
Definition: goomsl_private.h:64
struct _ConstPtrNodeType ConstPtrNodeType
FastInstructionFlow * fastiflow
Definition: goomsl_private.h:170
void gsl_instr_set_namespace(Instruction *_this, GoomHash *ns)
Definition: goomsl.c:132
int gsl_type_of_var(GoomHash *namespace, const char *name)
Definition: goomsl_yacc.c:358
int type
Definition: goomsl_private.h:152
int * var_ptr
Definition: goomsl_private.h:83
void gsl_declare_task(const char *name)
Definition: goomsl.c:844
int jump_offset
Definition: goomsl_private.h:85
GoomHash * gsl_find_namespace(const char *name)
Definition: goomsl.c:834
void gsl_enternamespace(const char *name)
Definition: goomsl.c:809
ConstPtrNodeType constPtr
Definition: goomsl_private.h:74
Definition: goomsl_private.h:121
int value_int
Definition: goomsl_private.h:94
int ptrArraySize
Definition: goomsl_private.h:186
Definition: goomsl_private.h:54
struct _ConstFloatNodeType ConstFloatNodeType
int is_extern
Definition: goomsl_private.h:144
FastInstruction * instr
Definition: goomsl_private.h:137
int type
Definition: goomsl_private.h:67
union _NODE_TYPE::@35 unode
struct _Block Block
Definition: goomsl_private.h:129
struct _NODE_TYPE * op[3]
Definition: goomsl_private.h:63
void(* GoomSL_ExternalFunction)(GoomSL *gsl, GoomHash *global_vars, GoomHash *local_vars)
Definition: goomsl.h:7
Definition: goomsl_private.h:151
int num_lines
Definition: goomsl_private.h:166
Instruction * proto
Definition: goomsl_private.h:132
struct _ConstIntNodeType ConstIntNodeType
Definition: goomsl_private.h:157
int * types
Definition: goomsl_private.h:109
GoomHash * structIDS
Definition: goomsl_private.h:181
struct _FastInstructionFlow FastInstructionFlow
GoomHash ** vnamespace
Definition: goomsl_private.h:108
int * var_int
Definition: goomsl_private.h:82
float * var_float
Definition: goomsl_private.h:84
void gsl_commit_compilation(void)
Definition: goomsl_yacc.c:1150
struct _INSTRUCTION Instruction
char * str
Definition: goomsl_private.h:68
struct _NODE_TYPE NodeType
Definition: goomsl_private.h:57
void * var
Definition: goomsl_private.h:81
int id
Definition: goomsl_private.h:58
GoomHash * namespaces[16]
Definition: goomsl_private.h:174
ConstFloatNodeType constFloat
Definition: goomsl_private.h:73
Instruction * instr
Definition: goomsl_private.h:167
int number
Definition: goomsl_private.h:124
GoomHash * vars
Definition: goomsl_private.h:143
InstructionData data
Definition: goomsl_private.h:131
Definition: goomsl_private.h:78
Block fBlock[64]
Definition: goomsl_private.h:162
struct _GSL_Struct GSL_Struct
int val
Definition: goomsl_private.h:52
OprNodeType opr
Definition: goomsl_private.h:75
Instruction ** instr
Definition: goomsl_private.h:123
union _INSTRUCTION_DATA::@36 udest
int cur_param
Definition: goomsl_private.h:110
Definition: goomsl_private.h:135
Definition: goomsl_private.h:141
int offsetInStruct
Definition: goomsl_private.h:154
struct _FAST_INSTRUCTION FastInstruction
int tabsize
Definition: goomsl_private.h:125
Block iBlock[64]
Definition: goomsl_private.h:161
int nbPtr
Definition: goomsl_private.h:185
struct _ExternalFunctionStruct * external_function
Definition: goomsl_private.h:86
void gsl_declare_external_task(const char *name)
Definition: goomsl.c:858
char name[256]
Definition: goomsl_private.h:153
int nbStructID
Definition: goomsl_private.h:180
int data
Definition: goomsl_private.h:148
struct _OprNodeType OprNodeType
char * nop_label
Definition: goomsl_private.h:115
GSL_StructField * fields[64]
Definition: goomsl_private.h:159
char * jump_label
Definition: goomsl_private.h:114
union _INSTRUCTION_DATA::@37 usrc
void ** ptrArray
Definition: goomsl_private.h:187
int currentNS
Definition: goomsl_private.h:173
int compilationOK
Definition: goomsl_private.h:189
int size
Definition: goomsl_private.h:160
GoomHeap * data_heap
Definition: goomsl_private.h:178
Definition: goomsl_private.h:66
const char * name
Definition: asfheader.h:137
GoomHash * labels
Definition: goomsl_private.h:126
struct _GSL_StructField GSL_StructField
Definition: goomsl_private.h:51
Definition: goomsl_hash.h:20
struct _INSTRUCTION_FLOW InstructionFlow
Definition: goomsl_heap.c:10
InstructionData data
Definition: goomsl_private.h:103
void * mallocedInstr
Definition: goomsl_private.h:138
GoomSL * parent
Definition: goomsl_private.h:104
Definition: goomsl_private.h:60
struct _INSTRUCTION_DATA InstructionData
int nbOp
Definition: goomsl_private.h:62
float val
Definition: goomsl_private.h:55
void gsl_instr_add_param(Instruction *_this, const char *param, int type)
Definition: goomsl.c:141
float value_float
Definition: goomsl_private.h:96
int size
Definition: goomsl_private.h:149
GoomSL * currentGoomSL
Definition: goomsl_lex.c:635
int id
Definition: goomsl_private.h:130
int number
Definition: goomsl_private.h:136
int gsl_struct_size
Definition: goomsl_private.h:183
int line_number
Definition: goomsl_private.h:70
GoomHash * gsl_leavenamespace(void)
Definition: goomsl.c:828
int type
Definition: goomsl_private.h:61
char ** params
Definition: goomsl_private.h:107
ConstIntNodeType constInt
Definition: goomsl_private.h:72
int line_number
Definition: goomsl_private.h:117
GoomHash * vars
Definition: goomsl_private.h:172
int id
Definition: goomsl_private.h:102
int nb_param
Definition: goomsl_private.h:111
Definition: goomsl_private.h:165
void gsl_reenternamespace(GoomHash *ns)
Definition: goomsl.c:823
const char * name
Definition: goomsl_private.h:105
Definition: goomsl_private.h:147
GSL_Struct ** gsl_struct
Definition: goomsl_private.h:182
int address
Definition: goomsl_private.h:113
Instruction * gsl_instr_init(GoomSL *parent, const char *name, int id, int nb_param, int line_number)
Definition: goomsl.c:175
int nbFields
Definition: goomsl_private.h:158