Browse code

expr engine: minor additions

- added rve_has_side_effects(), preliminary version
(for now is equivalent with !rve_is_constant())
- exported rve_destroy()

Andrei Pelinescu-Onciul authored on 04/02/2009 18:20:53
Showing 2 changed files
... ...
@@ -452,6 +452,17 @@ int rve_is_constant(struct rval_expr* rve)
452 452
 
453 453
 
454 454
 
455
+/** returns true if the expression has side-effects.
456
+  * @return  1 for possible side-effects, 0 for no side-effects
457
+  * TODO: add better checks
458
+  */
459
+int rve_has_side_effects(struct rval_expr* rve)
460
+{
461
+	return !rve_is_constant(rve);
462
+}
463
+
464
+
465
+
455 466
 /** returns true if operator is unary (takes only 1 arg).
456 467
   * @return 0 or 1 on
457 468
   */
... ...
@@ -188,6 +188,8 @@ int rval_expr_eval_rvint( struct run_act_ctx* h, struct sip_msg* msg,
188 188
 enum rval_type rve_guess_type(struct rval_expr* rve);
189 189
 /** returns true if expression is constant. */
190 190
 int rve_is_constant(struct rval_expr* rve);
191
+/** returns true if the expression can have side-effect */
192
+int rve_has_side_effects(struct rval_expr* rve);
191 193
 /** returns 1 if expression is valid (type-wise).*/
192 194
 int rve_check_type(enum rval_type* type, struct rval_expr* rve,
193 195
 					struct rval_expr** bad_rve, enum rval_type* bad_type,
... ...
@@ -206,6 +208,8 @@ struct rval_expr* mk_rval_expr1(enum rval_expr_op op, struct rval_expr* rve1,
206 206
 struct rval_expr* mk_rval_expr2(enum rval_expr_op op, struct rval_expr* rve1,
207 207
 													  struct rval_expr* rve2,
208 208
 													  struct cfg_pos* pos);
209
+/** destroys a pkg_malloc'ed rve. */
210
+void rve_destroy(struct rval_expr* rve);
209 211
 
210 212
 /** fix a rval_expr. */
211 213
 int fix_rval_expr(void** p);