scoped bindings

This commit is contained in:
Ellen Arvidsson 2025-06-24 16:31:23 +02:00
parent 396716de09
commit 858f5c3eed
17 changed files with 1185 additions and 821 deletions

View file

@ -5,50 +5,49 @@
#include "spho/scope.h"
#define SPHO_BIND_KIND_TP 1
#define SPHO_BIND_KIND_TPOP 2
#define SPHO_BIND_UNDECLARED 0x0
#define SPHO_BIND_UNDEFINED 0x01
#define SPHO_BIND_TP 0x11
#define SPHO_BIND_TP_OP 0x12
#define SPHO_BIND_MEMB_TP 0x13
union spho_bound {
struct spho_tp *tp;
struct spho_tpop *op;
union spho_prebind_val {
const void *undef;
const struct spho_tp *tp;
const struct spho_tp_op *op;
};
struct spho_binding {
struct spho_nom *nom;
struct spho_prebind_pair {
const struct spho_nom *nom;
int kind;
union spho_bound bound;
int kind;
union spho_prebind_val val;
};
struct spho_bind_scope {
struct spho_scope *sc;
struct spho_prebind {
struct spho_scope *sc;
size_t cap_bds;
size_t n_bds;
struct spho_binding *bds;
size_t sz;
struct spho_prebind_pair *binds;
};
struct spho_bind {
struct spho_ctx *ctx;
struct spho_bind_scope *binder;
struct spho_prebind *local;
struct spho_bind *parent;
};
struct spho_bind_scope *spho_bind_scope_create(struct spho_scope *);
struct spho_prebind *spho_prebind_create(struct spho_scope *);
int spho_bind_scope_add_tp(struct spho_bind_scope *, struct spho_nom *,
struct spho_tp *);
int spho_bind_scope_add_tpop(struct spho_bind_scope *, struct spho_nom *,
struct spho_tpop *);
int spho_prebind_undef(struct spho_prebind *, const struct spho_nom *);
int spho_prebind_tp(struct spho_prebind *, const struct spho_nom *,
const struct spho_tp *);
int spho_prebind_tp_op(struct spho_prebind *, const struct spho_nom *,
const struct spho_tp_op *);
int spho_prebind_member_tp(struct spho_prebind *, const struct spho_nom *,
const struct spho_tp *);
void spho_bind_scope_destroy(struct spho_bind_scope *);
struct spho_prebind *spho_prebind_dupl(const struct spho_prebind *);
struct spho_bind *spho_bind_create(struct spho_ctx *, struct spho_bind_scope *,
struct spho_bind *);
int spho_bind_lkp(int, struct spho_bind *, struct spho_nom *,
union spho_bound **);
void spho_bind_destroy(struct spho_bind *);
void spho_prebind_destroy(struct spho_prebind *);
#endif