type fixes and bindings + notes on subtyping
This commit is contained in:
parent
7e3c7c88ea
commit
c18f56f7be
28 changed files with 2253 additions and 783 deletions
|
@ -7,40 +7,18 @@
|
|||
|
||||
#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);
|
||||
|
||||
|
||||
#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;
|
||||
|
@ -51,11 +29,6 @@ struct tp_unop_data {
|
|||
struct spho_tp *operand;
|
||||
};
|
||||
|
||||
struct tp_binding_data {
|
||||
struct spho_nom *nom;
|
||||
struct spho_tp *bound;
|
||||
};
|
||||
|
||||
struct tp_nom_data {
|
||||
struct spho_nom *nom;
|
||||
};
|
||||
|
@ -70,6 +43,16 @@ struct tp_konst_data {
|
|||
const char *str;
|
||||
};
|
||||
|
||||
struct tp_forall_data {
|
||||
struct spho_nom *nom;
|
||||
struct spho_tp *tp;
|
||||
};
|
||||
|
||||
struct tp_member_data {
|
||||
struct spho_nom *nom;
|
||||
struct spho_tp *tp;
|
||||
};
|
||||
|
||||
extern const struct tp_konst_data tp_konst_true;
|
||||
extern const struct tp_konst_data tp_konst_false;
|
||||
|
||||
|
@ -80,22 +63,30 @@ extern const struct tp_konst_data tp_konst_false;
|
|||
union tp_data {
|
||||
struct tp_binop_data binop;
|
||||
struct tp_unop_data unop;
|
||||
struct tp_binding_data bind;
|
||||
struct tp_appl_data appl;
|
||||
struct tp_nom_data nom;
|
||||
struct tp_konst_data konst;
|
||||
struct tp_forall_data fa;
|
||||
struct tp_member_data memb;
|
||||
};
|
||||
|
||||
/* sappho type */
|
||||
struct spho_tp {
|
||||
struct spho_scope *sc;
|
||||
|
||||
int form;
|
||||
int kind;
|
||||
union tp_data d;
|
||||
|
||||
STAILQ_ENTRY(spho_tp) entries;
|
||||
};
|
||||
|
||||
struct spho_tp_op {
|
||||
struct spho_scope *sc;
|
||||
|
||||
struct spho_scope *op_sc;
|
||||
struct spho_tp *op_tp;
|
||||
};
|
||||
|
||||
STAILQ_HEAD(spho_tp_l, spho_tp);
|
||||
|
||||
struct spho_tp_ptr {
|
||||
|
@ -106,24 +97,33 @@ struct spho_tp_ptr {
|
|||
STAILQ_HEAD(spho_tp_ptr_l, spho_tp_ptr);
|
||||
|
||||
struct spho_tp_alloc {
|
||||
struct spho_tp tp;
|
||||
union {
|
||||
struct spho_tp tp;
|
||||
struct spho_tp_op tp_op;
|
||||
} alloc;
|
||||
|
||||
TAILQ_ENTRY(spho_tp_alloc) allocs;
|
||||
};
|
||||
|
||||
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;
|
||||
|
||||
struct spho_scope_l subs;
|
||||
|
||||
size_t n_noms;
|
||||
struct spho_nom_l noms;
|
||||
struct spho_tp_alloc_l tps;
|
||||
|
||||
struct spho_prebind *bind_loc;
|
||||
|
||||
SLIST_ENTRY(spho_scope) next;
|
||||
};
|
||||
|
||||
|
@ -140,9 +140,16 @@ struct spho_scope *spho_scope_create(struct spho_scope *);
|
|||
void spho_scope_destroy(struct spho_scope *);
|
||||
|
||||
struct spho_nom *spho_scope_nom_add(struct spho_scope *, const char *, size_t);
|
||||
int spho_scope_nom_get(struct spho_scope *, const char *, size_t,
|
||||
struct spho_nom **);
|
||||
int spho_scope_nom_lookup(struct spho_scope *, const char *, size_t,
|
||||
struct spho_nom **);
|
||||
int spho_scope_nom_lookup_str(struct spho_scope *, const char *, size_t,
|
||||
struct spho_nom **);
|
||||
int spho_scope_nom_lookup_str_strict(struct spho_scope *, const char *,
|
||||
size_t, struct spho_nom **);
|
||||
|
||||
int spho_scope_prebind_init(struct spho_scope *);
|
||||
int spho_scope_prebind_tp(struct spho_scope *, struct spho_nom *,
|
||||
struct spho_tp *);
|
||||
int spho_scope_prebind_tp_op(struct spho_scope *, struct spho_nom *,
|
||||
struct spho_tp_op *);
|
||||
int spho_scope_prebind_undef(struct spho_scope *, struct spho_nom *);
|
||||
|
||||
#endif /* _SPHO_SCOPE_H */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue