summaryrefslogtreecommitdiff
path: root/parse/use.c
diff options
context:
space:
mode:
authorMichael Forney <mforney@mforney.org>2017-07-01 14:43:22 -0700
committerOri Bernstein <ori@eigenstate.org>2017-07-03 23:27:02 -0700
commit871ef281aaf3c2e8bdff5d92355461bedfa5d933 (patch)
tree76db674822cd67fb1cd1772a8d52f40910735d00 /parse/use.c
parentca10a1ec838b7d468a2b43894af659c111a0e9b1 (diff)
downloadmc-871ef281aaf3c2e8bdff5d92355461bedfa5d933.tar.gz
Specialize impl declarations on impl type in addition to decl type
This allows multiple specializations of a declarations with a concrete type, which can be selected with the new impl expression if it can't be deduced by its type alone. For example trait hasname @t = Name: byte[:] ;; impl hasname void = Name = "somename" ;; impl hasname bool = Name = "othername" ;; const boolname = impl(Name, void) To do this, pass the param type through to genericname and specializedcl. Since we now need the type parameter to look up trait decls, make sure n->expr.param gets the necessary treatment in typesub, specializenode, pickle, and unpickle. We also need to tag the param types for export.
Diffstat (limited to 'parse/use.c')
-rw-r--r--parse/use.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/parse/use.c b/parse/use.c
index 83fde08..4c95500 100644
--- a/parse/use.c
+++ b/parse/use.c
@@ -464,6 +464,9 @@ static void pickle(FILE *fd, Node *n)
case Nexpr:
wrbyte(fd, n->expr.op);
wrtype(fd, n->expr.type);
+ wrbool(fd, n->expr.param != NULL);
+ if (n->expr.param)
+ wrtype(fd, n->expr.param);
wrbool(fd, n->expr.isconst);
pickle(fd, n->expr.idx);
wrint(fd, n->expr.nargs);
@@ -598,6 +601,8 @@ static Node *unpickle(FILE *fd)
case Nexpr:
n->expr.op = rdbyte(fd);
rdtype(fd, &n->expr.type);
+ if (rdbool(fd))
+ rdtype(fd, &n->expr.param);
n->expr.isconst = rdbool(fd);
n->expr.idx = unpickle(fd);
n->expr.nargs = rdint(fd);