summaryrefslogtreecommitdiff
path: root/parse/node.c
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/node.c
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/node.c')
-rw-r--r--parse/node.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/parse/node.c b/parse/node.c
index d6b2724..34fdd74 100644
--- a/parse/node.c
+++ b/parse/node.c
@@ -216,11 +216,17 @@ mkfunc(Srcloc loc, Node **args, size_t nargs, Type *ret, Node *body)
f->func.body = body;
f->func.scope = mkstab(1);
f->func.type = mktyfunc(loc, args, nargs, ret);
+ f->func.env = mkenv();
st = body->block.scope;
for (i = 0; i < nargs; i++)
putdcl(st, args[i]);
+ bindtype(f->func.env, ret);
+ for (i = 0; i < nargs; i++)
+ bindtype(f->func.env, decltype(args[i]));
+
+
n = mknode(loc, Nlit);
n->lit.littype = Lfunc;
n->lit.fnval = f;
@@ -250,6 +256,10 @@ mkimplstmt(Srcloc loc, Node *name, Type *t, Type **aux, size_t naux, Node **decl
n->impl.decls = decls;
n->impl.ndecls = ndecls;
lappend(&impltab, &nimpltab, n);
+ if (hasparams(t)) {
+ n->impl.env = mkenv();
+ bindtype(n->impl.env, t);
+ }
return n;
}
@@ -382,6 +392,11 @@ mkdecl(Srcloc loc, Node *name, Type *ty)
n->decl.name = name;
n->decl.type = ty;
lappend(&decls, &ndecls, n);
+ if (ty && hasparams(ty)) {
+ n->decl.env = mkenv();
+ bindtype(n->decl.env, ty);
+ }
+
return n;
}