///< require asynchronous expansion.
bool pure; //!< has no external side effects, true for BOX, LITERAL, and some functions
bool can_purify; //!< if the xlat has a pure function with pure arguments.
+
+ bool constant; //!< xlat is just tmpl_data, or XLAT_BOX
} xlat_flags_t;
/*
b->flags.needs_resolving = false;
b->flags.pure = tmpl_is_data(b->vpt);
+ b->flags.constant = b->flags.pure;
goto flags;
}
if (tmpl_resolve(a->vpt, &my_tr_rules) < 0) return -1;
a->flags.needs_resolving = false;
- a->flags.pure = tmpl_is_data(b->vpt);
+ a->flags.pure = tmpl_is_data(a->vpt);
+ a->flags.constant = a->flags.pure;
goto flags;
}
parent->type = XLAT_BOX;
fr_value_box_copy(parent, &parent->data, box);
- parent->flags = (xlat_flags_t) { .pure = true, };
+ parent->flags = (xlat_flags_t) { .pure = true, .constant = true, };
talloc_free_children(parent);
*/
MEM(node = xlat_exp_alloc_null(cast));
xlat_exp_set_type(node, XLAT_BOX);
+ node->flags.constant = true;
xlat_exp_set_name_buffer_shallow(node,
talloc_strdup(node,
fr_table_str_by_value(fr_type_table,
node->fmt = vpt->name;
node->flags.pure = tmpl_is_data(node->vpt);
+ node->flags.constant = node->flags.pure;
node->flags.needs_resolving = tmpl_needs_resolving(node->vpt);
}
if ((tmpl_value_type(vpt) == FR_TYPE_BOOL) && !tmpl_value_enumv(vpt)) {
tmpl_value_enumv(vpt) = attr_expr_bool_enum;
}
+
+ node->flags.constant = true;
}
fr_assert(!tmpl_contains_regex(vpt));
parent->pure &= child->pure; /* purity can only be removed, never added */
parent->pure &= !parent->needs_async; /* things needing async cannot be pure */
parent->can_purify |= child->can_purify;
+ parent->constant &= child->constant;
}
/** Set the type of an xlat node
xlat_exp_set_type(node, XLAT_BOX);
xlat_exp_set_name_buffer_shallow(node, str);
fr_value_box_strdup_shallow(&node->data, NULL, str, false);
+ node->flags.constant = true;
XLAT_DEBUG("VALUE-BOX (%s)<-- %pV",
escapes ? escapes->name : "(none)",
child = xlat_exp_alloc_null(node->group);
xlat_exp_set_type(child, XLAT_BOX);
+ node->flags.constant = true;
slen = fr_sbuff_out_aunescape_until(child, &str, &our_in, SIZE_MAX,
value_parse_rules_single_quoted.terminals,