libyasm/expr.h

Go to the documentation of this file.
00001 
00034 #ifndef YASM_EXPR_H
00035 #define YASM_EXPR_H
00036 
00037 #ifndef YASM_LIB_DECL
00038 #define YASM_LIB_DECL
00039 #endif
00040 
00046 typedef enum yasm_expr__type {
00047     YASM_EXPR_NONE = 0,     
00048     YASM_EXPR_REG = 1<<0,   
00049     YASM_EXPR_INT = 1<<1,   
00050     YASM_EXPR_SUBST = 1<<2, 
00051     YASM_EXPR_FLOAT = 1<<3, 
00052     YASM_EXPR_SYM = 1<<4,   
00053     YASM_EXPR_PRECBC = 1<<5,
00054     YASM_EXPR_EXPR = 1<<6   
00055 } yasm_expr__type;
00056 
00058 typedef struct yasm_expr__item {
00059     yasm_expr__type type;   
00062     union {
00063         yasm_bytecode *precbc;  
00064         yasm_symrec *sym;       
00065         yasm_expr *expn;        
00066         yasm_intnum *intn;      
00067         yasm_floatnum *flt;     
00068         uintptr_t reg;          
00069         unsigned int subst;     
00070     } data;
00071 } yasm_expr__item;
00072 
00074 struct yasm_expr {
00075     yasm_expr_op op;    
00076     unsigned long line; 
00077     int numterms;       
00083     yasm_expr__item terms[2];
00084 };
00085 
00093 YASM_LIB_DECL
00094 /*@only@*/ yasm_expr *yasm_expr_create
00095     (yasm_expr_op op, /*@only@*/ yasm_expr__item *a,
00096      /*@only@*/ /*@null@*/ yasm_expr__item *b, unsigned long line);
00097 
00102 YASM_LIB_DECL
00103 /*@only@*/ yasm_expr__item *yasm_expr_precbc(/*@keep@*/ yasm_bytecode *precbc);
00104 
00109 YASM_LIB_DECL
00110 /*@only@*/ yasm_expr__item *yasm_expr_sym(/*@keep@*/ yasm_symrec *sym);
00111 
00116 YASM_LIB_DECL
00117 /*@only@*/ yasm_expr__item *yasm_expr_expr(/*@keep@*/ yasm_expr *e);
00118 
00123 YASM_LIB_DECL
00124 /*@only@*/ yasm_expr__item *yasm_expr_int(/*@keep@*/ yasm_intnum *intn);
00125 
00130 YASM_LIB_DECL
00131 /*@only@*/ yasm_expr__item *yasm_expr_float(/*@keep@*/ yasm_floatnum *flt);
00132 
00137 YASM_LIB_DECL
00138 /*@only@*/ yasm_expr__item *yasm_expr_reg(uintptr_t reg);
00139 
00147 #define yasm_expr_create_tree(l,o,r,i) \
00148     yasm_expr_create ((o), yasm_expr_expr(l), yasm_expr_expr(r), i)
00149 
00156 #define yasm_expr_create_branch(o,r,i) \
00157     yasm_expr_create ((o), yasm_expr_expr(r), (yasm_expr__item *)NULL, i)
00158 
00164 #define yasm_expr_create_ident(r,i) \
00165     yasm_expr_create (YASM_EXPR_IDENT, (r), (yasm_expr__item *)NULL, i)
00166 
00171 yasm_expr *yasm_expr_copy(const yasm_expr *e);
00172 #ifndef YASM_DOXYGEN
00173 #define yasm_expr_copy(e)   yasm_expr__copy_except(e, -1)
00174 #endif
00175 
00179 YASM_LIB_DECL
00180 void yasm_expr_destroy(/*@only@*/ /*@null@*/ yasm_expr *e);
00181 
00188 YASM_LIB_DECL
00189 int yasm_expr_is_op(const yasm_expr *e, yasm_expr_op op);
00190 
00197 typedef /*@only@*/ yasm_expr * (*yasm_expr_xform_func)
00198     (/*@returned@*/ /*@only@*/ yasm_expr *e, /*@null@*/ void *d);
00199 
00212 YASM_LIB_DECL
00213 /*@only@*/ /*@null@*/ yasm_expr *yasm_expr__level_tree
00214     (/*@returned@*/ /*@only@*/ /*@null@*/ yasm_expr *e, int fold_const,
00215      int simplify_ident, int simplify_reg_mul, int calc_bc_dist,
00216      /*@null@*/ yasm_expr_xform_func expr_xform_extra,
00217      /*@null@*/ void *expr_xform_extra_data);
00218 
00226 #define yasm_expr_simplify(e, cbd) \
00227     yasm_expr__level_tree(e, 1, 1, 1, cbd, NULL, NULL)
00228 
00237 YASM_LIB_DECL
00238 /*@only@*/ /*@null@*/ yasm_expr *yasm_expr_extract_deep_segoff(yasm_expr **ep);
00239 
00247 YASM_LIB_DECL
00248 /*@only@*/ /*@null@*/ yasm_expr *yasm_expr_extract_segoff(yasm_expr **ep);
00249 
00258 YASM_LIB_DECL
00259 /*@only@*/ /*@null@*/ yasm_expr *yasm_expr_extract_wrt(yasm_expr **ep);
00260 
00269 YASM_LIB_DECL
00270 /*@dependent@*/ /*@null@*/ yasm_intnum *yasm_expr_get_intnum
00271     (yasm_expr **ep, int calc_bc_dist);
00272 
00279 YASM_LIB_DECL
00280 /*@dependent@*/ /*@null@*/ const yasm_symrec *yasm_expr_get_symrec
00281     (yasm_expr **ep, int simplify);
00282 
00289 YASM_LIB_DECL
00290 /*@dependent@*/ /*@null@*/ const uintptr_t *yasm_expr_get_reg
00291     (yasm_expr **ep, int simplify);
00292 
00297 YASM_LIB_DECL
00298 void yasm_expr_print(/*@null@*/ const yasm_expr *e, FILE *f);
00299 
00308 YASM_LIB_DECL
00309 int yasm_expr__traverse_leaves_in_const
00310     (const yasm_expr *e, /*@null@*/ void *d,
00311      int (*func) (/*@null@*/ const yasm_expr__item *ei, /*@null@*/ void *d));
00312 
00321 YASM_LIB_DECL
00322 int yasm_expr__traverse_leaves_in
00323     (yasm_expr *e, /*@null@*/ void *d,
00324      int (*func) (/*@null@*/ yasm_expr__item *ei, /*@null@*/ void *d));
00325 
00334 YASM_LIB_DECL
00335 void yasm_expr__order_terms(yasm_expr *e);
00336 
00342 YASM_LIB_DECL
00343 yasm_expr *yasm_expr__copy_except(const yasm_expr *e, int except);
00344 
00351 YASM_LIB_DECL
00352 int yasm_expr__contains(const yasm_expr *e, yasm_expr__type t);
00353 
00362 YASM_LIB_DECL
00363 int yasm_expr__bc_dist_subst(yasm_expr **ep, void *cbd,
00364                              void (*callback) (unsigned int subst,
00365                                                yasm_bytecode *precbc,
00366                                                yasm_bytecode *precbc2,
00367                                                void *cbd));
00368 
00376 YASM_LIB_DECL
00377 int yasm_expr__subst(yasm_expr *e, unsigned int num_items,
00378                      const yasm_expr__item *items);
00379 
00380 #endif

Generated on Thu Jul 24 01:23:31 2008 for libyasm by  doxygen 1.5.2