ref: a62770976b151dd1fe3acc8dc4781aa62155c385
parent: 3730a2515fa554695c3c424053ed683ac2bdd596
author: Ori Bernstein <[email protected]>
date: Fri Nov 1 09:12:48 EDT 2013
Split response reading from dumping.
--- a/libstd/Makefile
+++ b/libstd/Makefile
@@ -11,6 +11,7 @@
fmt.myr \
hashfuncs.myr \
htab.myr \
+ ipaddr.myr \
intparse.myr \
now.myr \
option.myr \
--- a/libstd/resolve.myr
+++ b/libstd/resolve.myr
@@ -73,8 +73,8 @@
;;
/* hardcode Google DNS for now */
sa.fam = Afinet
- sa.port = hosttonet(53)
- sa.addr = 0x08080808
+ sa.port = hosttonet(53) /* port 53 */
+ sa.addr = [8,8,8,8] /* 8.8.8.8 */
status = connect(s, (&sa) castto(sockaddr#), sizeof(sockaddr_in))
if status < 0
put("Warning: Failed to connect to server: %l\n", status)
@@ -122,12 +122,7 @@
const rquery = {srv
var pktbuf : byte[1024]
var pkt
- var off
- var nans
- var nquery
var n
- var v
- var i
put("Waiting for response...\n")
n = read(srv, pktbuf[:])
@@ -135,8 +130,18 @@
put("Warning: Failed to read from %z: %i\n", srv, n)
;;
pkt = pktbuf[:n]
+ dumpresponse(pkt)
+}
- put("packet size = %z\n", n)
+
+const dumpresponse = {pkt
+ var nquery
+ var nans
+ var off
+ var v
+ var i
+
+ put("packet size = %z\n", pkt.len)
(v, off) = unpack16(pkt, 0)
put("hdr.id = %w\n", v)
(v, off) = unpack16(pkt, off)
--- a/libstd/sys-osx.myr
+++ b/libstd/sys-osx.myr
@@ -70,7 +70,7 @@
len : byte
fam : sockfam
port : uint16
- addr : uint32
+ addr : byte[4]
zero : byte[8]
;;
--- a/parse/infer.c
+++ b/parse/infer.c
@@ -317,8 +317,11 @@
* match the instantiation */
if (orig->type == Tyunres && t->isgeneric) {
t = tyfreshen(st, t);
- for (i = 0; i < t->narg; i++)
- unify(st, NULL, t->arg[i], orig->arg[i]);
+ for (i = 0; i < t->narg; i++) {
+ unify(st, NULL, t->arg[i], orig->arg[i]);
+ if (orig->arg[i]->type == Typaram || isgeneric(st, t->arg[i]))
+ t->isgeneric = 1;
+ }
}
st->ingeneric -= t->isgeneric;
return t;
--- a/parse/specialize.c
+++ b/parse/specialize.c
@@ -23,8 +23,6 @@
if (t->type == Typaram)
return 1;
- if (t->type == Tyname && t->isgeneric)
- return 1;
for (i = 0; i < t->nsub; i++)
if (hasparams(t->sub[i]))
return 1;
@@ -67,6 +65,7 @@
htput(tsmap, t, ret);
for (i = 0; i < t->nparam; i++)
lappend(&ret->arg, &ret->narg, tyspecialize(t->param[i], tsmap));
+ ret->isgeneric = hasparams(ret);
}
break;
case Tystruct: