MCPcopy Create free account
hub / github.com/ElementsProject/elements / applyBinding

Function applyBinding

src/simplicity/typeInference.c:197–202  ·  view source on GitHub ↗

Add a new binding, 'bound', to a unification variable 'alpha'. * If 'alpha' is already bound to a type that doesn't unify with 'bound', then 'false' is returned. * Otherwise variables of 'bound's bindings and 'alpha's bindings (if any) are recursively unified and 'true' is returned. * '*bindings_used' is decremented by the number of pairs of (non-trivial) bindings that are successfully unified.

Source from the content-addressed store, hash-verified

195 * NULL != bindings_used
196 */
197static bool applyBinding(unification_var* alpha, binding* bound, size_t* bindings_used) {
198 unification_cont scratch = {0};
199 unification_cont* cont = &scratch;
200 if (!applyBinding_cont(findRoot(alpha), bound, &cont, bindings_used)) return false;
201 return NULL == cont || unify_cont(cont, bindings_used);
202}
203
204/* Unify a pair of unification variables.
205 * If unification fails, then NULL is returned.

Callers

nothing calls this directly

Calls 3

applyBinding_contFunction · 0.85
findRootFunction · 0.85
unify_contFunction · 0.85

Tested by

no test coverage detected