summaryrefslogtreecommitdiff
path: root/parse/parse.h
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2017-07-15 00:36:08 -0700
committerOri Bernstein <ori@eigenstate.org>2017-07-15 00:36:42 -0700
commit357f87c1117edfdf77411781ebfae221a406c454 (patch)
tree5e70ba66596b8ee13ceb46e2c9268fe12101f17a /parse/parse.h
parent15b5fb5c0f9fee25b01a245229efcef21c103bdc (diff)
downloadmc-357f87c1117edfdf77411781ebfae221a406c454.tar.gz
Type binding refactoring now compiles.
Still a bit sloppy on a few things, needs some dedup work, but it's working.
Diffstat (limited to 'parse/parse.h')
-rw-r--r--parse/parse.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/parse/parse.h b/parse/parse.h
index 1b70c18..07ec44a 100644
--- a/parse/parse.h
+++ b/parse/parse.h
@@ -101,6 +101,11 @@ struct Stab {
Htab *impl; /* trait implementations: really a set of implemented traits. */
};
+struct Tyenv {
+ Tyenv *super;
+ Htab *tab;
+};
+
struct Type {
Ty type;
int tid;
@@ -116,6 +121,7 @@ struct Type {
Type **inst; /* Tyname: instances created */
size_t ninst; /* Tyname: count of instances created */
+ Tyenv *env; /* the environment for bound types, may be null */
Type **sub; /* sub-types; shared by all composite types */
size_t nsub; /* For compound types */
size_t nmemb; /* for aggregate types (struct, union) */
@@ -272,6 +278,7 @@ struct Node {
Node *name;
Type *type;
Node *init;
+ Tyenv *env; /* bound types */
/*
If we have a link to a trait, we should only look it up
@@ -301,6 +308,7 @@ struct Node {
} decl;
struct {
+ Tyenv *env;
Stab *scope;
Type *type;
size_t nargs;
@@ -313,6 +321,7 @@ struct Node {
Trait *trait;
Type *type;
Type **aux;
+ Tyenv *env;
size_t naux;
Node **decls;
size_t ndecls;
@@ -402,6 +411,15 @@ Stab *curstab(void);
void pushstab(Stab *st);
void popstab(void);
+void bindtype(Tyenv *env, Type *t);
+int isbound(Type *t);
+Tyenv *mkenv(void);
+Tyenv *curenv(void);
+void pushenv(Tyenv *e);
+void popenv(Tyenv *e);
+void _tybind(Tyenv *e, Type *t);
+void _bind(Tyenv *e, Node *n);
+
/* type creation */
void tyinit(Stab *st); /* sets up built in types */