2 * Copyright 2012 Ecole Normale Superieure
4 * Use of this software is governed by the MIT license
6 * Written by Sven Verdoolaege,
7 * Ecole Normale Superieure, 45 rue d'Ulm, 75230 Paris, France
10 #define xFN(TYPE,NAME) TYPE ## _ ## NAME
11 #define FN(TYPE,NAME) xFN(TYPE,NAME)
13 /* Replace the field FIELD of "node" by "field",
14 * where the field may or may not have already been set in "node".
15 * However, if the field has not already been set,
16 * then "node" is required to have a single reference.
17 * In this case the call to isl_ast_node_cow has no effect.
19 __isl_give isl_ast_node
*FN(FN(FN(isl_ast_node
,NODE_TYPE
),set
),FIELD_NAME
)(
20 __isl_take isl_ast_node
*node
, __isl_take FIELD_TYPE
*field
)
22 if (FN(isl_ast_node_check
,NODE_TYPE
)(node
) < 0 || !field
)
24 if (node
->FIELD
== field
) {
25 FN(FIELD_TYPE
,free
)(field
);
29 node
= isl_ast_node_cow(node
);
33 FN(FIELD_TYPE
,free
)(node
->FIELD
);
38 isl_ast_node_free(node
);
39 FN(FIELD_TYPE
,free
)(field
);