shithub: mc

Download patch

ref: 2d00e8f657965583e906327bd4c0eff6953a71cd
parent: 5d40b4ead1f20776f23bed271412af829bbe0e96
author: Ori Bernstein <ori@eigenstate.org>
date: Fri Nov 3 06:49:27 EDT 2017

Rename comparable => equatable

--- a/lib/date/parse.myr
+++ b/lib/date/parse.myr
@@ -164,7 +164,7 @@
 
 const indexof = {dst, s, set, err
 	for var i = 0; i < set.len; i++
-		if s.len >= set[i].len && std.cmp(s[:set[i].len], set[i])
+		if s.len >= set[i].len && std.eq(s[:set[i].len], set[i])
 			dst# = i
 			-> s[set[i].len:]
 		;;
--- a/lib/fileutil/loopcheck+posixy.myr
+++ b/lib/fileutil/loopcheck+posixy.myr
@@ -57,8 +57,8 @@
 	}
 ;;
 
-impl std.comparable (int64, int64) =
-	cmp = {a, b
+impl std.equatable (int64, int64) =
+	eq = {a, b
 		var adev, aino
 		var bdev, bino
 
--- a/lib/inifile/types.myr
+++ b/lib/inifile/types.myr
@@ -13,7 +13,7 @@
 	;;
 
 	impl std.hashable (byte[:], byte[:])
-	impl std.comparable (byte[:], byte[:])
+	impl std.equatable (byte[:], byte[:])
 ;;
 
 impl std.hashable (byte[:], byte[:]) =
@@ -25,13 +25,13 @@
 	}
 ;;
 
-impl std.comparable (byte[:], byte[:]) =
-	cmp = {a, b
+impl std.equatable (byte[:], byte[:]) =
+	eq = {a, b
 		var s1, k1
 		var s2, k2
 
 		(s1, k1) = a
 		(s2, k2) = a
-		-> std.cmp(s1, s2) && std.cmp(k1, k2)
+		-> std.eq(s1, s2) && std.eq(k1, k2)
 	}
 ;;
--- a/lib/std/bitset.myr
+++ b/lib/std/bitset.myr
@@ -31,7 +31,7 @@
 	const bsunion	: (a : bitset#, b : bitset# -> void)
 	const bsissubset	: (a : bitset#, b : bitset# -> bool)
 
-	impl comparable bitset#
+	impl equatable bitset#
 	impl hashable bitset#
 
 	type bsiter = struct
@@ -147,8 +147,8 @@
 	-> true
 }
 
-impl comparable bitset# =
-	cmp = {a, b
+impl equatable bitset# =
+	eq = {a, b
 		eqsz(a, b)
 		for var i = 0; i < a.bits.len; i++
 			if a.bits[i] != b.bits[i]
--- a/lib/std/hashfuncs.myr
+++ b/lib/std/hashfuncs.myr
@@ -11,8 +11,8 @@
 pkg std =
 	const siphash24	: (data : byte[:], seed : byte[16] -> uint64)
 
-	impl comparable @a[:] =
-		cmp = {a, b
+	impl equatable @a[:] =
+		eq = {a, b
 			-> sleq(a, b)
 		}
 	;;
@@ -23,8 +23,8 @@
 		}
 	;;
 
-	impl comparable @a::(integral,numeric) =
-		cmp = {a, b
+	impl equatable @a::(integral,numeric) =
+		eq = {a, b
 			-> a == b
 		}
 	;;
@@ -35,8 +35,8 @@
 		}
 	;;
 
-	impl comparable @a# =
-		cmp = {a, b
+	impl equatable @a# =
+		eq = {a, b
 			-> a == b
 		}
 	;;
--- a/lib/std/htab.myr
+++ b/lib/std/htab.myr
@@ -93,7 +93,7 @@
 		if ht.hashes[i] == 0
 			-> `None
 		;;
-		if ht.hashes[i] == h && !ht.dead[i] && cmp(ht.keys[i], k)
+		if ht.hashes[i] == h && !ht.dead[i] && eq(ht.keys[i], k)
 			break
 		;;
 		di++
@@ -138,7 +138,7 @@
 	i = h & (ht.keys.len - 1)
 	neltincr = 1
 	while ht.hashes[i] != 0 && !ht.dead[i]
-		if ht.hashes[i] == h &&	cmp(ht.keys[i], k)
+		if ht.hashes[i] == h &&	eq(ht.keys[i], k)
 			neltincr = 0
 			break
 		;;
--- a/lib/std/test/hashfuncs.myr
+++ b/lib/std/test/hashfuncs.myr
@@ -5,19 +5,19 @@
 	testr.run([
 		[.name="string hash and equality", .fn={ctx
 			testr.check(ctx, std.hash("abc") == 0x5dbcfa53aa2007a5, "wrong hash\n")
-			testr.check(ctx, std.cmp("abc\0def", "abc\0def"), "equal strings not equal\n")
-			testr.check(ctx, !std.cmp("abc\0def", "abcdef"), "unequal strings are equal\n")
+			testr.check(ctx, std.eq("abc\0def", "abc\0def"), "equal strings not equal\n")
+			testr.check(ctx, !std.eq("abc\0def", "abcdef"), "unequal strings are equal\n")
 		}],
 		[.name="pointer equality", .fn={ctx
 			var x, y: int
 			/* can't sanely test ptrhash; it will change every time */
-			testr.check(ctx, std.cmp(&x, &x), "equal pointers not equal")
-			testr.check(ctx, !std.cmp(&x, &y), "unequal pointers are equal")
+			testr.check(ctx, std.eq(&x, &x), "equal pointers not equal")
+			testr.check(ctx, !std.eq(&x, &y), "unequal pointers are equal")
 		}],
 		[.name="int hash and equality", .fn={ctx
 			testr.check(ctx, std.hash(123) == 0x5671db246859d5b6, "wrong int hash")
-			testr.check(ctx, std.cmp(123, 123), "equal integers not equal")
-			testr.check(ctx, !std.cmp(123, 456), "unequal integers are equal")
+			testr.check(ctx, std.eq(123, 123), "equal integers not equal")
+			testr.check(ctx, !std.eq(123, 456), "unequal integers are equal")
 		}],
 		[.name="siphash test", .fn={ctx
 			siphashreferencetestvector(ctx)
--- a/lib/std/test/htab.myr
+++ b/lib/std/test/htab.myr
@@ -103,8 +103,8 @@
 	}
 ;;
 
-impl std.comparable collisionprone =
-	cmp = {a, b
+impl std.equatable collisionprone =
+	eq = {a, b
 		-> a == b
 	}
 ;;
--- a/lib/std/test/striter.myr
+++ b/lib/std/test/striter.myr
@@ -13,7 +13,7 @@
 
 	i = 0
 	for sp : std.bysplit("foo+++bar", "++")
-		std.assert(std.cmp(splits[i++], sp), "wrong split {}", sp)
+		std.assert(std.eq(splits[i++], sp), "wrong split {}", sp)
 	;;
 	std.assert(i == splits.len, "wrong split count")
 }
--- a/lib/std/traits.myr
+++ b/lib/std/traits.myr
@@ -1,6 +1,6 @@
 pkg std =
-	trait comparable @a =
-		cmp	: (a : @a, b : @a -> bool)
+	trait equatable @a =
+		eq	: (a : @a, b : @a -> bool)
 	;;
 
 	trait hashable @a =
--- a/parse/use.c
+++ b/parse/use.c
@@ -852,11 +852,16 @@
 {
 	size_t i, len;
 	char *protoname, *dclname, *p;
-	Node *proto;
+	Node *proto, *n;
+	Stab *st;
 
 	dclname = declname(dcl);
 	for (i = 0; i < tr->nproto; i++) {
-		proto = getdcl(curstab(), tr->proto[i]->decl.name);
+		n = tr->proto[i]->decl.name;
+		st = file->file.globls;
+		if (n->name.ns)
+			st = getns(n->name.ns);
+		proto = getdcl(st, n);
 		if (!proto)
 			proto = tr->proto[i];
 		protoname = declname(proto);