return retval;
}
+yasm_expr *
+yasm_expr_extract_wrt(yasm_expr **ep)
+{
+ yasm_expr *retval;
+ yasm_expr *e = *ep;
+
+ /* If not WRT, we can't do this transformation */
+ if (e->op != YASM_EXPR_WRT)
+ return NULL;
+
+ /* Extract the right side portion out to its own expression */
+ if (e->terms[1].type == YASM_EXPR_EXPR)
+ retval = e->terms[1].data.expn;
+ else {
+ /* Need to build IDENT expression to hold non-expression contents */
+ retval = yasm_xmalloc(sizeof(yasm_expr));
+ retval->op = YASM_EXPR_IDENT;
+ retval->numterms = 1;
+ retval->terms[0] = e->terms[1]; /* structure copy */
+ }
+
+ /* Delete the right side portion by changing the expr into an IDENT */
+ e->op = YASM_EXPR_IDENT;
+ e->numterms = 1;
+
+ return retval;
+}
+
/*@-unqualifiedtrans -nullderef -nullstate -onlytrans@*/
const yasm_intnum *
yasm_expr_get_intnum(yasm_expr **ep, yasm_calc_bc_dist_func calc_bc_dist)
*/
/*@only@*/ /*@null@*/ yasm_expr *yasm_expr_extract_segment(yasm_expr **ep);
+/** Extract the right portion (y) of a x WRT y expression, leaving the left
+ * portion (x).
+ * \param ep expression (pointer to)
+ * \return NULL if unable to extract (YASM_EXPR_WRT not the top-level
+ * operator), otherwise the right side of the WRT expression. The
+ * input expression is modified such that on return, it's the left side
+ * of the WRT expression.
+ */
+/*@only@*/ /*@null@*/ yasm_expr *yasm_expr_extract_wrt(yasm_expr **ep);
+
/** Get the integer value of an expression if it's just an integer.
* \param ep expression (pointer to)
* \param calc_bc_dist bytecode distance-calculation function