shithub: mc

Download patch

ref: 460b6ed7be00fe2bbf4807bc67c49e07d10384f0
parent: 3f65d0e80c706fb06d946512d69421209071694e
author: Ori Bernstein <[email protected]>
date: Thu Dec 26 21:58:08 EST 2013

Remove a few FIXMEs from libstd

--- a/libstd/env.myr
+++ b/libstd/env.myr
@@ -1,10 +1,11 @@
-use "sleq.use"
 use "extremum.use"
+use "option.use"
+use "sleq.use"
 
 pkg std =
 	extern var _environment	: byte[:][:]
 
-	const getenv :	(name : byte[:] -> [byte[:], bool]) /* FIXME: should return an option, not a tuple, but we have a compiler bug. */
+	const getenv :	(name : byte[:] -> std.option(byte[:]))
 ;;
 
 const getenv = {name
@@ -14,9 +15,9 @@
 	for i = 0; i < _environment.len; i++
 		n = min(name.len, _environment[i].len)
 		if sleq(name, _environment[i][:n]) && sleq(_environment[i][n:n+1], "=")
-			-> (_environment[i][n+1:], true)
+			-> `Some _environment[i][n+1:]
 		;;
 	;;
-	-> ("", false)
+	-> `None
 }
 
--- a/libstd/htab.myr
+++ b/libstd/htab.myr
@@ -21,13 +21,9 @@
 	generic htput	: (ht : htab(@k, @v)#, k : @k, v : @v -> void)
 	generic htget	: (ht : htab(@k, @v)#, k : @k -> option(@v))
 	generic htkeys	: (ht : htab(@k, @v)# -> @k[:])
-
-	/* FIXME: Automatically pull out internal declarations as hidden */
-	const Initsz = 32
-	generic hash
-	generic resize
-	generic idx
 ;;
+
+const Initsz = 32
 
 generic hash = {ht, k
 	var h
--- a/libstd/intparse.myr
+++ b/libstd/intparse.myr
@@ -8,10 +8,6 @@
 pkg std =
 	generic intparsebase	: (s : byte[:], base : int -> option(@a::(tcint,tcnum,tctest)))
 	generic intparse	: (s : byte[:]	-> option(@a::(tcint,tcnum,tctest)))
-
-	/* FIXME: fix hidden exports */
-	generic charval
-	generic doparse
 ;;
 
 generic intparse = {s
--- a/libstd/ipparse.myr
+++ b/libstd/ipparse.myr
@@ -5,7 +5,6 @@
  /* FIXME: needed for decls which should be pulled in as hidden */
 use "strcmp.use"
 use "utf.use"
-use "fmt.use"
 
 pkg std =
 	const ip4parse	: (ip : byte[:] -> option(byte[4]))
@@ -23,7 +22,6 @@
 	i = 0
 	for j = 0; j < ip.len; j++
 		if ip[j] == '.' castto(byte)
-			put("seg[%z..%z] = %s\n", last, j, ip[last:j])
 			match intparsebase(ip[last:j], 10)
 			| `Some v:
 				val = v
--- a/parse/infer.c
+++ b/parse/infer.c
@@ -1737,6 +1737,7 @@
                 if (d->decl.isglobl && d->decl.vis == Visintern) {
                     d->decl.vis = Vishidden;
                     putdcl(st, d);
+                    nodetag(st, d, ingeneric);
                 }
             }
             break;
@@ -1773,6 +1774,13 @@
     Type *t;
     size_t i, j, n;
 
+    k = htkeys(st->dcl, &n);
+    for (i = 0; i < n; i++) {
+        s = getdcl(st, k[i]);
+        nodetag(st, s, 0);
+    }
+    free(k);
+
     /* get the explicitly exported symbols */
     k = htkeys(st->ty, &n);
     for (i = 0; i < n; i++) {
@@ -1788,11 +1796,6 @@
     }
     free(k);
 
-    k = htkeys(st->dcl, &n);
-    for (i = 0; i < n; i++) {
-        s = getdcl(st, k[i]);
-        nodetag(st, s, 0);
-    }
 }
 
 /* Take generics and build new versions of them
--- a/parse/use.c
+++ b/parse/use.c
@@ -21,7 +21,7 @@
 static Node *unpickle(FILE *fd);
 
 /* type fixup list */
-static Htab *dedup;     /* map from name -> type, contains all Tynames loaded ever */
+static Htab *tydedup;   /* map from name -> type, contains all Tynames loaded ever */
 static Htab *tidmap;    /* map from tid -> type */
 static Type ***typefixdest;  /* list of types we need to replace */
 static size_t ntypefixdest; /* size of replacement list */
@@ -627,7 +627,7 @@
     for (i = 0; i < ntypefixdest; i++) {
         t = htget(tidmap, (void*)typefixid[i]);
         if (t->type == Tyname && !t->issynth) {
-            old = htget(dedup, t->name);
+            old = htget(tydedup, t->name);
             if (old != t)
             if (t != old)
                 t = old;
@@ -641,7 +641,7 @@
         t = htget(tidmap, (void*)typefixid[i]);
         if (t->type != Tyname || t->issynth)
             continue;
-        old = htget(dedup, t->name);
+        old = htget(tydedup, t->name);
         if (old && !tyeq(t, old))
             fatal(-1, "Duplicate definition of type %s", tystr(old));
     }
@@ -666,8 +666,8 @@
     int c;
 
     pushstab(file->file.globls);
-    if (!dedup)
-        dedup = mkht(namehash, nameeq);
+    if (!tydedup)
+        tydedup = mkht(namehash, nameeq);
     if (fgetc(f) != 'U')
         return 0;
     pkg = rdstr(f);
@@ -705,8 +705,8 @@
                         break;
                     if (!gettype(st, t->name) && !t->ishidden)
                         puttype(s, t->name, t);
-                    if (!hthas(dedup, t->name))
-                        htput(dedup, t->name, t);
+                    if (!hthas(tydedup, t->name))
+                        htput(tydedup, t->name, t);
                 } else if (t->type == Tyunion)  {
                     for (i = 0; i < t->nmemb; i++)
                         if (!getucon(s, t->udecls[i]->name) && !t->udecls[i]->synth)