starting to add code for name bindings

This commit is contained in:
Ellen Arvidsson 2025-05-23 14:02:51 +02:00
parent 15fc99b8c8
commit 55970b1baf
8 changed files with 131 additions and 59 deletions

View file

@ -7,40 +7,22 @@
#define SPHO_NOM_LEN 128
/* name */
struct spho_nom {
char s[SPHO_NOM_LEN];
SLIST_ENTRY(spho_nom) next;
SLIST_ENTRY(spho_nom) next; // TODO change to allocs
};
SLIST_HEAD(spho_nom_l, spho_nom);
/* binding
*
* bindings needs to be able to change, so we do not store it in names directly.
*/
#define TP_KONST_KEY_TRUE 0x43445 /* don't change!!!!! */
#define TP_KONST_KEY_FALSE 0x66a57 /* don't change!1! */
struct spho_var {
struct spho_nom nom;
STAILQ_ENTRY(spho_var) next;
};
STAILQ_HEAD(spho_var_l, spho_var);
struct spho_bind {
struct spho_nom nom;
struct spho_tpop *op;
};
struct spho_tpop {
struct spho_var_l params;
struct spho_tp *def;
};
struct spho_rec {
struct spho_nom mnom;
struct spho_tp *tp;
};
/* type data */
struct tp_binop_data {
struct spho_tp *left;
@ -90,7 +72,7 @@ union tp_data {
struct spho_tp {
struct spho_scope *sc;
int form;
int kind;
union tp_data d;
STAILQ_ENTRY(spho_tp) entries;
@ -116,6 +98,9 @@ TAILQ_HEAD(spho_tp_alloc_l, spho_tp_alloc);
SLIST_HEAD(spho_scope_l, spho_scope);
/* defined in spho/bind.h */
struct spho_bind;
struct spho_scope {
struct spho_ctx *ctx;
struct spho_scope *parent;
@ -124,6 +109,8 @@ struct spho_scope {
struct spho_nom_l noms;
struct spho_tp_alloc_l tps;
struct spho_bind *bind;
SLIST_ENTRY(spho_scope) next;
};