comparison src/expr.h @ 67:d5fe306f1ab1

Fixed numerous bugs in macro handling
author lost
date Mon, 05 Jan 2009 05:40:33 +0000
parents 538e15927776
children 2fe5fd7d65a3
comparison
equal deleted inserted replaced
66:aa9d9fedfdf4 67:d5fe306f1ab1
105 // useful macros 105 // useful macros
106 // is the expression "simple" (one term)? 106 // is the expression "simple" (one term)?
107 #define lwasm_expr_is_simple(s) ((s) -> head == (s) -> tail) 107 #define lwasm_expr_is_simple(s) ((s) -> head == (s) -> tail)
108 108
109 // is the expression constant? 109 // is the expression constant?
110 #define lwasm_expr_is_constant(s) (lwasm_expr_is_simple(s) && (s) -> head -> term -> term_type == LWASM_TERM_INT) 110 #define lwasm_expr_is_constant(s) (lwasm_expr_is_simple(s) && (!((s) -> head) || (s) -> head -> term -> term_type == LWASM_TERM_INT))
111 111
112 // get the constant value of an expression or 0 if not constant 112 // get the constant value of an expression or 0 if not constant
113 #define lwasm_expr_get_value(s) (lwasm_expr_is_constant(s) ? (s) -> head -> term -> value : 0) 113 #define lwasm_expr_get_value(s) (lwasm_expr_is_constant(s) ? ((s) -> head ? (s) -> head -> term -> value : 0) : 0)
114 114
115 #undef __expr_E__ 115 #undef __expr_E__
116 116
117 #endif // __expr_h_seen__ 117 #endif // __expr_h_seen__