4 #include <HashVector.h>
5 #include <TupleSchema.h>
8 * A BindingTable is a chain of \ref HashVector "HashVectors" of
9 * Binding items that associate a (char*) name with a (void*) value.
11 typedef struct _BindingTable {
13 struct _BindingTable *next;
17 * \brief Allocate a new \ref BindingTable and chain it to the one given.
19 * \returns the allocated \ref bandingtable.
21 * \related BindingTable
23 extern BindingTable *BindingTable_create(BindingTable *next);
26 * \brief Reclaim a \ref BindingTable with all its bindings and return
29 * \param bt is the \ref BindingTable to reclaim.
31 * \returns the chained \ref BindingTable.
33 * \related BindingTable
35 extern BindingTable *BindingTable_release(BindingTable *bt);
38 * \brief Set a Binding in a \ref BindingTable.
40 * \param bt is the \ref BindingTable concerned.
42 * \param name is the Binding name.
44 * \param value is the Binding value.
46 * \note Binding names are equal or not by means of strcmp, and each
47 * name has a at most single Binding.
49 * A value of \b 0 indicates "unbound".
51 * \related BindingTable
53 extern void BindingTable_set(BindingTable *bt,char *name,void *value);
56 * \brief Get a Binding from a BindingTable chain.
58 * \param bt is the first BindingTable concerned.
60 * \param name is the Binding variable name.
62 * \param value is the Binding value.
64 * \note Binding names are equal or not by means of strcmp, and each
65 * name has a at most single Binding.
67 * This function scan's the \ref BindingTable chain for the first
68 * assignment, if any, of the name. Note that a name can be made
69 * unbound on top of being bound by setting it to \b 0.
71 * \related BindingTable
73 extern void *BindingTable_get(BindingTable *bt,char *name);
76 * \brief Replace all names with their values.
78 * \param bt is the BindingTable concerned.
80 * \param arity is the tuple arity.
82 * \param t is the tuple of (char*) names to dereference.
84 void BindingTable_deref(BindingTable *bt,int arity,tuple *t);
87 * \brief Unify two named bindings with option equal-value callback.
89 * \param bt is the first BindingTable concerned.
91 * \param n1 is the first Binding name.
93 * \param n2 is the second Binding name.
95 * \param eq is the optional equal-value callback that returns 0 if
96 * the given values are equal.
98 * This function updates the top \ref BindingTable by assigning n1 or
99 * n2 to any value the other has (in the chain) unless they have
100 * different values (in the chain). If both are unassigned, then
101 * neither get reassigned in the to both BindingTable/
103 * \related BindingTable
105 extern int BindingTable_unify(
106 BindingTable *bt,char *n1,char *n2,int (*eq)(void*,void*));