Defines | Functions

rvalue.c File Reference

SIP-router core :: rvalue expressionsModule: SIP-router core. More...

#include "rvalue.h"
#include <stdlib.h>
Include dependency graph for rvalue.c:

Go to the source code of this file.

Defines

Functions


Detailed Description

Definition in file rvalue.c.


Define Documentation

#define rval_get_int_handle_ret (   ret,
  txt,
  rve 
)
Value:
do { \
                if (unlikely((ret)<0)) { \
                        RVE_LOG(L_WARN, rve, txt); \
                        (ret)=0; \
                } \
        }while(0)

check if the return code is an rval_get_int error and if so handle the error (e.g. print a log message, ignore the error by setting ret to 0 a.s.o.)

Parameters:
ret - retcode as returned by rval_get_int() (might be changed)
txt - warning message txt (no pointer allowed)
rve - rval_expr, used to access the config. pos

Definition at line 1050 of file rvalue.c.

Referenced by rval_expr_eval(), rval_expr_eval_int(), and rval_expr_eval_rvint().

#define RVE_LOG (   lev,
  rve,
  txt 
)
Value:
LOG((lev), txt " (%d,%d-%d,%d)\n", \
                        (rve)->fpos.s_line, rve->fpos.s_col, \
                        (rve)->fpos.e_line, rve->fpos.e_col )

Definition at line 1035 of file rvalue.c.


Function Documentation

static int bool_rvstrop2 ( enum rval_expr_op  op,
int *  res,
struct rvalue *  rv1,
struct rvalue *  rv2 
) [inline, static]

Warning: rv1 & rv2 must be RV_STR

Returns:
0 on success, -1 on error

Definition at line 1449 of file rvalue.c.

References _str::len, RV_RE_F, RVE_DIFF_OP, RVE_EQ_OP, RVE_MATCH_OP, RVE_STRDIFF_OP, RVE_STREQ_OP, and _str::s.

Referenced by rval_str_lop2().

Here is the caller graph for this function:

static int fix_match_rve ( struct rval_expr *  rve  )  [static]
Returns:
0 on success and -1 on error.

Definition at line 2976 of file rvalue.c.

References fix_rval_expr(), RV_RE_ALLOCED_F, RV_RE_F, rval_destroy(), rval_expr_eval(), rval_get_str(), rve_guess_type(), rve_is_constant(), and rve_replace_with_val().

Here is the call graph for this function:

int fix_rval_expr ( void *  p  ) 

fixes action, bexprs, resolves selects, pvars and optimizes simple sub expressions (e.g. 1+2).

Parameters:
p - pointer to a rval_expr
Returns:
0 on success, <0 on error (modifies also *(struct rval_expr*)p)

Definition at line 3778 of file rvalue.c.

Referenced by fix_match_rve().

Here is the caller graph for this function:

static int int_intop1 ( int *  res,
enum rval_expr_op  op,
int  v 
) [inline, static]
Returns:
0 on succes, <0 on error

Definition at line 1337 of file rvalue.c.

References RVE_BNOT_OP, RVE_BOOL_OP, RVE_LNOT_OP, and RVE_UMINUS_OP.

Referenced by rval_expr_eval_int(), and rval_intop1().

Here is the caller graph for this function:

static int int_intop2 ( int *  res,
enum rval_expr_op  op,
int  v1,
int  v2 
) [inline, static]
static int int_rve_defined ( struct run_act_ctx *  h,
struct sip_msg msg,
int *  res,
struct rval_expr *  rve 
) [inline, static]
Parameters:
h run action context
msg SIP message
res - set to 1 defined, 0 not defined
rve rvalue expression
Returns:
0 on success, -1 on error

Definition at line 1884 of file rvalue.c.

References rv_defined(), and RVE_RVAL_OP.

Referenced by rval_expr_eval_int().

Here is the call graph for this function:

Here is the caller graph for this function:

static int int_strop1 ( int *  res,
enum rval_expr_op  op,
str s1 
) [inline, static]
Returns:
0 on succes, <0 on error

Definition at line 1497 of file rvalue.c.

References _str::len, RVE_STREMPTY_OP, and RVE_STRLEN_OP.

Referenced by rval_int_strop1().

Here is the caller graph for this function:

struct rval_expr* mk_rval_expr1 ( enum rval_expr_op  op,
struct rval_expr *  rve1,
struct cfg_pos *  pos 
) [read]

rval_expr ret= op rve1

Parameters:
op - rval expr. unary operator
rve1 - rval expr. on which the operator will act.
pos configuration position
Returns:
new pkg_malloc'ed rval_expr or 0 on error.

Definition at line 2591 of file rvalue.c.

References RVE_BNOT_OP, RVE_BOOL_OP, RVE_DEFINED_OP, RVE_INT_OP, RVE_LNOT_OP, RVE_STR_OP, RVE_STREMPTY_OP, RVE_STRLEN_OP, and RVE_UMINUS_OP.

struct rval_expr* mk_rval_expr2 ( enum rval_expr_op  op,
struct rval_expr *  rve1,
struct rval_expr *  rve2,
struct cfg_pos *  pos 
) [read]

from 2 other rval exprs, using op ret = rve1 op rve2

Parameters:
op - rval expr. operator
rve1 - rval expr. on which the operator will act.
rve2 - rval expr. on which the operator will act.
pos configuration position
Returns:
new pkg_malloc'ed rval_expr or 0 on error.

Definition at line 2632 of file rvalue.c.

References RVE_BAND_OP, RVE_BLSHIFT_OP, RVE_BOR_OP, RVE_BRSHIFT_OP, RVE_BXOR_OP, RVE_CONCAT_OP, RVE_DIFF_OP, RVE_DIV_OP, RVE_EQ_OP, RVE_GT_OP, RVE_GTE_OP, RVE_IDIFF_OP, RVE_IEQ_OP, RVE_IPLUS_OP, RVE_LAND_OP, RVE_LOR_OP, RVE_LT_OP, RVE_LTE_OP, RVE_MATCH_OP, RVE_MINUS_OP, RVE_MOD_OP, RVE_MUL_OP, RVE_PLUS_OP, RVE_STRDIFF_OP, and RVE_STREQ_OP.

struct rval_expr* mk_rval_expr_v ( enum rval_type  rv_type,
void *  val,
struct cfg_pos *  pos 
) [read]

create a RVE_RVAL_OP rval_expr, containing a single rval of the given type

Parameters:
rv_type - rval type
val - rval value
pos - config position
Returns:
new pkg_malloc'ed rval_expr or 0 on error.

Definition at line 2526 of file rvalue.c.

References rval_init().

Here is the call graph for this function:

static int rv_defined ( struct run_act_ctx *  h,
struct sip_msg msg,
int *  res,
struct rvalue *  rv,
struct rval_cache cache 
) [inline, static]
Parameters:
h run action context
msg SIP message
res set to the result 1 is defined, 0 not defined
rv rvalue
cache rvalue cache
Returns:
0 on success, -1 on error
Note:
Can use cached rvalues (cache). A rv can be undefined if it's an undefined avp or pvar or select or if it's NONE
An error in the avp, pvar or select search is equivalent to undefined (and it's not reported)

Definition at line 1819 of file rvalue.c.

Referenced by int_rve_defined().

Here is the caller graph for this function:

struct rvalue* rval_convert ( struct run_act_ctx *  h,
struct sip_msg msg,
enum rval_type  type,
struct rvalue *  v,
struct rval_cache c 
) [read]

Convert a rvalue to another rvalue, of a specific type. The result is read-only in most cases (can be a reference to another rvalue, can be checked by using rv_chg_in_place()) and _must_ be rval_destroy()'ed.

Parameters:
h run action context
msg SIP mesasge
type - type to convert to
v - rvalue to convert
c - rval_cache (cached v value if known/filled by another function), can be 0 (unknown/not needed)
Returns:
pointer to a rvalue (reference to an existing one or a new one,
See also:
rv_chg_in_place() and the above comment), or 0 on error.

Definition at line 1294 of file rvalue.c.

References rval_cache_clean(), rval_cache_init, rval_get_int(), rval_get_tmp_str(), rval_new(), and rval_new_str().

Referenced by rval_expr_eval(), rval_int_strop1(), rval_intop1(), rval_intop2(), rval_str_add2(), and rval_str_lop2().

Here is the call graph for this function:

Here is the caller graph for this function:

void rval_destroy ( struct rvalue *  rv  ) 
struct rvalue* rval_expr_eval ( struct run_act_ctx *  h,
struct sip_msg msg,
struct rval_expr *  rve 
) [read]
Warning:
result must be rval_destroy()'ed if non-null (it might be a reference to another rval). The result can be modified only if rv_chg_in_place() returns true.
Parameters:
h run action context
msg SIP message
rve rvalue expression
Returns:
rvalue on success, 0 on error

Definition at line 2314 of file rvalue.c.

References int_intop2(), rval_cache_clean(), rval_cache_init, rval_convert(), rval_destroy(), rval_expr_eval(), rval_expr_eval_int(), rval_get_btype(), rval_get_int(), rval_get_int_handle_ret, rval_new(), rval_str_add2(), RVE_BAND_OP, RVE_BLSHIFT_OP, RVE_BNOT_OP, RVE_BOOL_OP, RVE_BOR_OP, RVE_BRSHIFT_OP, RVE_BXOR_OP, RVE_CONCAT_OP, RVE_DEFINED_OP, RVE_DIFF_OP, RVE_DIV_OP, RVE_EQ_OP, RVE_GT_OP, RVE_GTE_OP, RVE_IDIFF_OP, RVE_IEQ_OP, RVE_INT_OP, RVE_IPLUS_OP, RVE_LAND_OP, RVE_LNOT_OP, RVE_LOR_OP, RVE_LT_OP, RVE_LTE_OP, RVE_MATCH_OP, RVE_MINUS_OP, RVE_MOD_OP, RVE_MUL_OP, RVE_NONE_OP, RVE_PLUS_OP, RVE_RVAL_OP, RVE_STR_OP, RVE_STRDIFF_OP, RVE_STREMPTY_OP, RVE_STREQ_OP, RVE_STRLEN_OP, and RVE_UMINUS_OP.

Referenced by fix_match(), fix_match_rve(), lval_assign(), rval_expr_eval(), rval_expr_eval_int(), rval_expr_eval_new(), and rval_expr_eval_rvint().

Here is the call graph for this function:

Here is the caller graph for this function:

int rval_expr_eval_int ( struct run_act_ctx *  h,
struct sip_msg msg,
int *  res,
struct rval_expr *  rve 
)
struct rvalue* rval_expr_eval_new ( struct run_act_ctx *  h,
struct sip_msg msg,
struct rval_expr *  rve 
) [read]

like rval_expr_eval, but always returns a new rvalue (never a reference to an exisiting one). WARNING: result must be rval_destroy()'ed if non-null (it might be a reference to another rval). The result can be modified only if rv_chg_in_place() returns true.

Returns:
rvalue on success, 0 on error

Definition at line 2501 of file rvalue.c.

References rval_destroy(), rval_expr_eval(), and rval_new().

Referenced by rve_opt_01().

Here is the call graph for this function:

Here is the caller graph for this function:

int rval_expr_eval_rvint ( struct run_act_ctx *  h,
struct sip_msg msg,
struct rvalue **  res_rv,
int *  res_i,
struct rval_expr *  rve,
struct rval_cache cache 
)
Warning:
rv result (rv_res) must be rval_destroy()'ed if non-null (it might be a reference to another rval). The result can be modified only if rv_chg_in_place() returns true.
Parameters:
h run action context
msg SIP message
res_rv pointer to rvalue result, if non-null it means the expression evaluated to a non-int (str), which will be stored here.
res_i pointer to int result, if res_rv==0 and the function returns success => the result is an int which will be stored here.
rve expression that will be evaluated.
cache write-only value cache, it might be filled if non-null and empty (rval_cache_init()). If non-null, it _must_ be rval_cache_clean()'ed when done.
Returns:
0 on success, -1 on error, sets *res_rv or *res_i.

Definition at line 2169 of file rvalue.c.

References int_intop2(), rval_cache_clean(), rval_cache_init, rval_destroy(), rval_expr_eval(), rval_expr_eval_int(), rval_expr_eval_rvint(), rval_get_btype(), rval_get_int(), rval_get_int_handle_ret, rval_str_add2(), RVE_BAND_OP, RVE_BLSHIFT_OP, RVE_BNOT_OP, RVE_BOOL_OP, RVE_BOR_OP, RVE_BRSHIFT_OP, RVE_BXOR_OP, RVE_CONCAT_OP, RVE_DEFINED_OP, RVE_DIFF_OP, RVE_DIV_OP, RVE_EQ_OP, RVE_GT_OP, RVE_GTE_OP, RVE_IDIFF_OP, RVE_IEQ_OP, RVE_INT_OP, RVE_IPLUS_OP, RVE_LAND_OP, RVE_LNOT_OP, RVE_LOR_OP, RVE_LT_OP, RVE_LTE_OP, RVE_MATCH_OP, RVE_MINUS_OP, RVE_MOD_OP, RVE_MUL_OP, RVE_NONE_OP, RVE_PLUS_OP, RVE_RVAL_OP, RVE_STR_OP, RVE_STRDIFF_OP, RVE_STREMPTY_OP, RVE_STREQ_OP, RVE_STRLEN_OP, and RVE_UMINUS_OP.

Referenced by rval_expr_eval_int(), and rval_expr_eval_rvint().

Here is the call graph for this function:

Here is the caller graph for this function:

static enum rval_type rval_get_btype ( struct run_act_ctx *  h,
struct sip_msg msg,
struct rvalue *  rv,
struct rval_cache val_cache 
) [inline, static]

Given a rvalue it tries to determinte its basic type. Fills val_cache if non-null and empty (can be used in other rval* function calls, to avoid re-resolving avps or pvars). It must be rval_cache_clean()'en when no longer needed.

Parameters:
h run action context
msg SIP message
rv target rvalue
val_cache write-only value cache, might be filled if non-null, it _must_ be rval_cache_clean()'en when done.
Returns:
basic type or RV_NONE on error

Definition at line 389 of file rvalue.c.

References rval_cache::avp_val, and rval_cache::pval.

Referenced by rval_expr_eval(), and rval_expr_eval_rvint().

Here is the caller graph for this function:

int rval_get_int ( struct run_act_ctx *  h,
struct sip_msg msg,
int *  i,
struct rvalue *  rv,
struct rval_cache cache 
)

*i=(int)rv if rv == undefined select, avp or pvar, return 0. if an error occurs while evaluating a select, avp or pvar, behave as for the undefined case (and return success).

Parameters:
h - script context handle
msg - sip msg
i - pointer to int, where the conversion result will be stored
rv - rvalue to be converted
cache - cached rv value (read-only), can be 0
Returns:
0 on success, <0 on error and EXPR_DROP on drop

Definition at line 889 of file rvalue.c.

References rval_cache::avp_val, _str::len, rval_cache::pval, run_actions_safe(), and _str::s.

Referenced by rval_convert(), rval_expr_eval(), rval_expr_eval_int(), rval_expr_eval_rvint(), and rve_replace_with_ct_rv().

Here is the call graph for this function:

Here is the caller graph for this function:

int rval_get_str ( struct run_act_ctx *  h,
struct sip_msg msg,
str s,
struct rvalue *  rv,
struct rval_cache cache 
)

*s=(str)rv The result is pkg malloc'ed (so it should be pkg_free()'ed when finished.

Returns:
0 on success, <0 on error and EXPR_DROP on drop

Definition at line 1250 of file rvalue.c.

References _str::len, rval_cache_clean(), rval_cache_init, rval_get_tmp_str(), and _str::s.

Referenced by fix_match(), fix_match_rve(), and rve_replace_with_ct_rv().

Here is the call graph for this function:

Here is the caller graph for this function:

int rval_get_tmp_str ( struct run_act_ctx *  h,
struct sip_msg msg,
str tmpv,
struct rvalue *  rv,
struct rval_cache cache,
struct rval_cache tmp_cache 
)

get the string value of an rv in a tmp variable

if an error occurs while evaluating a select, avp or pvar, behave as for the undefined case (and return success). The result points either inside the passed rv, inside new_cache or inside an avp. new_cache must be non zero, initialized previously and it _must_ be rval_cache_clean(...)'ed when done. WARNING: it's not intended for general use. It might return a pointer inside rv so the result _must_ be treated as read-only. rv and new_cache must not be released/freed until the result is no longer needed. For general use see rval_get_str().

Parameters:
h - script context handle
msg - sip msg
tmpv - str return value (pointer to a str struct that will be be filled with the conversion result)
rv - rvalue to be converted
cache - cached rv value (read-only), can be 0
tmp_cache - used for temporary storage (so that tmpv will not point to possible freed data), it must be non-null, initialized and cleaned afterwards.
Returns:
0 on success, <0 on error and EXPR_DROP on drop

Definition at line 1102 of file rvalue.c.

References rval_cache::avp_val, rval_cache::i2s, _str::len, rval_cache::pval, run_actions_safe(), _str::s, and sint2strbuf().

Referenced by rval_convert(), and rval_get_str().

Here is the call graph for this function:

Here is the caller graph for this function:

void rval_init ( struct rvalue *  rv,
enum rval_type  t,
union rval_val *  v,
int  flags 
)

inits a rvalue structure-

Note: not needed if the structure is allocate with one of the rval_new* functions

Definition at line 208 of file rvalue.c.

Referenced by mk_rval_expr_v(), and rve_replace_with_val().

Here is the caller graph for this function:

static int rval_int_strop1 ( struct run_act_ctx *  h,
struct sip_msg msg,
int *  res,
enum rval_expr_op  op,
struct rvalue *  l,
struct rval_cache c1 
) [inline, static]

Integer operation on rval evaluated as string, can use cached rvalues (c1 & c2).

Parameters:
h run action context
msg SIP message
res will be set to the result
op rvalue expression operation
l rvalue
c1 rvalue cache
Returns:
0 success, -1 on error

Definition at line 1781 of file rvalue.c.

References int_strop1(), rval_convert(), and rval_destroy().

Referenced by rval_expr_eval_int().

Here is the call graph for this function:

Here is the caller graph for this function:

static struct rvalue* rval_intop1 ( struct run_act_ctx *  h,
struct sip_msg msg,
enum rval_expr_op  op,
struct rvalue *  v 
) [static, read]
Returns:
rvalue on success, 0 on error

Definition at line 1519 of file rvalue.c.

References int_intop1(), rval_convert(), rval_destroy(), and rval_new().

Here is the call graph for this function:

static struct rvalue* rval_intop2 ( struct run_act_ctx *  h,
struct sip_msg msg,
enum rval_expr_op  op,
struct rvalue *  l,
struct rvalue *  r 
) [static, read]
Returns:
rvalue on success, 0 on error

Definition at line 1562 of file rvalue.c.

References int_intop2(), rval_convert(), rval_destroy(), and rval_new().

Here is the call graph for this function:

struct rvalue* rval_new ( enum rval_type  t,
union rval_val *  v,
int  extra_size 
) [read]
Parameters:
t rvalue type
v rvalue value
extra_size extra space to allocate (so that future string operation can reuse the space)
Returns:
new rv or 0 on error

Definition at line 351 of file rvalue.c.

References rval_new_empty(), and rval_new_str().

Referenced by rval_convert(), rval_expr_eval(), rval_expr_eval_new(), rval_intop1(), rval_intop2(), and rval_str_add2().

Here is the call graph for this function:

Here is the caller graph for this function:

struct rvalue* rval_new_empty ( int  extra_size  )  [read]

allocates a new rval (should be freed by rval_destroy()).

Parameters:
extra_size - extra space to allocate (e.g.: so that future string operation can reuse the space)
Returns:
new rv or 0 on error

Definition at line 230 of file rvalue.c.

Referenced by rval_new(), rval_new_re(), and rval_new_str().

Here is the caller graph for this function:

struct rvalue* rval_new_re ( str s  )  [read]

It acts as rval_new_str, but also compiles a RE from the str and sets v->re.regex.

Parameters:
s - pointer to str, must be non-null, zero-term'ed and a valid RE.
Returns:
new rv or 0 on error

Definition at line 279 of file rvalue.c.

References _str::len, rval_new_empty(), and _str::s.

Here is the call graph for this function:

struct rvalue* rval_new_str ( str s,
int  extra_size 
) [read]
Parameters:
s - pointer to str, must be non-null
extra_size - extra space to allocate (so that future string operation can reuse the space)
Returns:
new rv or 0 on error

Definition at line 256 of file rvalue.c.

References _str::len, rval_new_empty(), and _str::s.

Referenced by rval_convert(), and rval_new().

Here is the call graph for this function:

Here is the caller graph for this function:

static struct rvalue* rval_str_add2 ( struct run_act_ctx *  h,
struct sip_msg msg,
struct rvalue *  l,
struct rval_cache c1,
struct rvalue *  r,
struct rval_cache c2 
) [static, read]

r (returns a rvalue). Can use cached rvalues (c1 & c2).

Returns:
rvalue on success, 0 on error

Definition at line 1618 of file rvalue.c.

References _str::len, RV_CNT_ALLOCED_F, rval_convert(), rval_destroy(), rval_new(), and _str::s.

Referenced by rval_expr_eval(), and rval_expr_eval_rvint().

Here is the call graph for this function:

Here is the caller graph for this function:

static int rval_str_lop2 ( struct run_act_ctx *  h,
struct sip_msg msg,
int *  res,
enum rval_expr_op  op,
struct rvalue *  l,
struct rval_cache c1,
struct rvalue *  r,
struct rval_cache c2 
) [inline, static]

Can use cached rvalues (c1 & c2).

Returns:
0 success, -1 on error

Definition at line 1737 of file rvalue.c.

References bool_rvstrop2(), rval_convert(), and rval_destroy().

Referenced by rval_expr_eval_int().

Here is the call graph for this function:

Here is the caller graph for this function:

char* rval_type_name ( enum rval_type  type  ) 

returns a string name for type (debugging).

Returns:
- null terminated name of the type

Definition at line 317 of file rvalue.c.

int rve_check_type ( enum rval_type *  type,
struct rval_expr *  rve,
struct rval_expr **  bad_rve,
enum rval_type *  bad_t,
enum rval_type *  exp_t 
)
Parameters:
type filled with the type of the expression (RV_INT, RV_STR or RV_NONE if it's dynamic)
rve checked expression
bad_rve set on failure to the subexpression for which the type check failed
bad_t set on failure to the type of the bad subexpression
exp_t set on failure to the expected type for the bad subexpression
Returns:
0 or 1 and sets *type to the resulting type (RV_INT, RV_STR or RV_NONE if it can be found only at runtime)

Definition at line 690 of file rvalue.c.

References RVE_BAND_OP, RVE_BLSHIFT_OP, RVE_BNOT_OP, RVE_BOOL_OP, RVE_BOR_OP, RVE_BRSHIFT_OP, RVE_BXOR_OP, rve_check_type(), RVE_CONCAT_OP, RVE_DEFINED_OP, RVE_DIFF_OP, RVE_DIV_OP, RVE_EQ_OP, RVE_GT_OP, RVE_GTE_OP, rve_guess_type(), RVE_IDIFF_OP, RVE_IEQ_OP, RVE_INT_OP, RVE_IPLUS_OP, RVE_LAND_OP, RVE_LNOT_OP, RVE_LOR_OP, RVE_LT_OP, RVE_LTE_OP, RVE_MATCH_OP, RVE_MINUS_OP, RVE_MOD_OP, RVE_MUL_OP, RVE_NONE_OP, RVE_PLUS_OP, RVE_RVAL_OP, RVE_STR_OP, RVE_STRDIFF_OP, RVE_STREMPTY_OP, RVE_STREQ_OP, RVE_STRLEN_OP, and RVE_UMINUS_OP.

Referenced by rve_check_type().

Here is the call graph for this function:

Here is the caller graph for this function:

void rve_destroy ( struct rval_expr *  rve  ) 

Definition at line 156 of file rvalue.c.

References rval_destroy(), rve_destroy(), and RVE_RVAL_OP.

Referenced by fix_match(), fix_switch(), rve_destroy(), rve_opt_01(), and rve_replace_with_val().

Here is the call graph for this function:

Here is the caller graph for this function:

enum rval_type rve_guess_type ( struct rval_expr *  rve  ) 
int rve_has_side_effects ( struct rval_expr *  rve  ) 

returns true if the expression can have side-effect

Returns:
1 for possible side-effects, 0 for no side-effects TODO: add better checks

Definition at line 617 of file rvalue.c.

References rve_is_constant().

Referenced by fix_match(), and fix_switch().

Here is the call graph for this function:

Here is the caller graph for this function:

int rve_is_constant ( struct rval_expr *  rve  ) 
static int rve_op_is_assoc ( enum rval_expr_op  op  )  [static]
static int rve_op_is_commutative ( enum rval_expr_op  op  )  [static]
static int rve_op_unary ( enum rval_expr_op  op  )  [static]
static int rve_opt_01 ( struct rval_expr *  rve,
enum rval_type  rve_type 
) [static]

Note: internal use only from rve_optimize It should be called after ct optimization, for non-contant expressions (the left or right side is not constant).

Returns:
1 on success (rve was changed), 0 on failure and -1 on error

Definition at line 3056 of file rvalue.c.

References rval_destroy(), rval_expr_eval_new(), RVE_BAND_OP, RVE_BOR_OP, RVE_CONCAT_OP, rve_destroy(), RVE_DIV_OP, RVE_EQ_OP, RVE_INT_OP, RVE_IPLUS_OP, rve_is_constant(), RVE_LAND_OP, RVE_LOR_OP, RVE_MINUS_OP, RVE_MOD_OP, RVE_MUL_OP, RVE_PLUS_OP, rve_replace_with_ct_rv(), RVE_RVAL_OP, RVE_STR_OP, and RVE_STREQ_OP.

Here is the call graph for this function:

static int rve_optimize ( struct rval_expr *  rve  )  [static]

Definition at line 3450 of file rvalue.c.

static int rve_replace_with_ct_rv ( struct rval_expr *  rve,
struct rvalue *  rv 
) [static]
Parameters:
rve - expression to be replaced (in-place)
rv - pointer to the replacement _constant_ rvalue structure
Returns:
0 on success, -1 on error

Definition at line 2937 of file rvalue.c.

References rval_get_int(), rval_get_str(), and rve_replace_with_val().

Referenced by rve_opt_01().

Here is the call graph for this function:

Here is the caller graph for this function:

static int rve_replace_with_val ( struct rval_expr *  rve,
enum rval_type  type,
union rval_val *  v,
int  flags 
) [static]
Warning:
since it replaces in-place, one should make sure that if rve is in fact a rval (rve->op==RVE_RVAL_OP), no reference is kept to the rval!
Parameters:
rve expression to be replaced (in-place)
type rvalue type
v pointer to a rval_val union containing the replacement value.
flags value flags (how it was alloc'ed, e.g.: RV_CNT_ALLOCED_F)
Returns:
0 on success, -1 on error

Definition at line 2904 of file rvalue.c.

References rval_destroy(), rval_init(), rve_destroy(), rve_op_unary(), and RVE_RVAL_OP.

Referenced by fix_match_rve(), and rve_replace_with_ct_rv().

Here is the call graph for this function:

Here is the caller graph for this function: