ref: bf99f35f97bc7593237df154f7ae19c16f3e215c
parent: 28ec6a3f0d0cc0e248ce54a65d92bddc8b125363
author: Ori Bernstein <[email protected]>
date: Thu Nov 29 20:43:48 EST 2012
Make nested generic calls work.
--- a/libstd/slurp.myr
+++ b/libstd/slurp.myr
@@ -2,6 +2,7 @@
use "alloc.use"
use "die.use"
use "sys.use"
+use "fmt.use"
use "extremum.use"
pkg std =
@@ -24,10 +25,9 @@
len = 0
buf = slalloc(Bufinc)
while true
+ put("", fd, n, buf.len)
n = read(fd, buf[len:])
- if n < 0
- die("Error reading file")
- elif n == 0
+ if n == 0
goto done
;;
len += n
--- a/parse/specialize.c
+++ b/parse/specialize.c
@@ -137,6 +137,8 @@
d = getdcl(curstab(), n->expr.args[0]);
if (!d)
die("Missing decl %s\n", namestr(n->expr.args[0]));
+ if (d->decl.isgeneric)
+ d = specializedcl(d, n->expr.type, &n->expr.args[0]);
n->expr.did = d->decl.did;
}
break;
@@ -326,9 +328,16 @@
char *p;
char *end;
+ if (!n->decl.isgeneric)
+ return n->decl.name;
p = buf;
end = buf + 1024;
+ /* format of the generic uniqified name:
+ * ns$name$did$tid$tid$tid... */
+ if (n->decl.name->name.ns)
+ p += snprintf(p, end - p, "%s", n->decl.name->name.ns);
p += snprintf(p, end - p, "%s", n->decl.name->name.name);
+ p += snprintf(p, end - p, "$%zd", n->decl.did);
tidappend(p, end - p, t);
return mkname(n->line, buf);
}