summaryrefslogtreecommitdiff
path: root/libstd
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2014-02-10 23:26:32 -0500
committerOri Bernstein <ori@eigenstate.org>2014-02-10 23:26:32 -0500
commit68b18a7fba8313ad5b1d8b4c6be61e3b8b126304 (patch)
treea30c41e3637cd99fd50eefbff36cc617718fdb30 /libstd
parentc158da43321893956e4be405ed04af37f86259fa (diff)
downloadmc-68b18a7fba8313ad5b1d8b4c6be61e3b8b126304.tar.gz
Do some sanitization on traits.
- Remove tctest: all tests now take a boolean. - Rename traits to more sensible names: tcnum => numeric tcint => integral tcfloat => floating tcidx => indexable tcslice => sliceable - Remove duplicate trait setting. We were setting traits twice in some places, adding ones that didn't belong, which was making pointers look indexable.
Diffstat (limited to 'libstd')
-rw-r--r--libstd/bitset.myr6
-rw-r--r--libstd/chartype.myr12
-rw-r--r--libstd/endian.myr4
-rw-r--r--libstd/extremum.myr4
-rw-r--r--libstd/fmt.myr4
-rw-r--r--libstd/hashfuncs.myr4
-rw-r--r--libstd/intparse.myr6
-rw-r--r--libstd/rand.myr10
-rw-r--r--libstd/resolve.myr2
-rw-r--r--libstd/units.myr16
10 files changed, 34 insertions, 34 deletions
diff --git a/libstd/bitset.myr b/libstd/bitset.myr
index f022880..ec5df50 100644
--- a/libstd/bitset.myr
+++ b/libstd/bitset.myr
@@ -13,9 +13,9 @@ pkg std =
const bsdup : (bs : bitset# -> bitset#)
const bsfree : (bs : bitset# -> void)
- generic bsput : (bs : bitset#, v : @a::(tcint,tctest,tcnum) -> void)
- generic bsdel : (bs : bitset#, v : @a::(tcint,tctest,tcnum) -> void)
- generic bshas : (bs : bitset#, v : @a::(tcint,tctest,tcnum) -> bool)
+ generic bsput : (bs : bitset#, v : @a::(integral,numeric) -> void)
+ generic bsdel : (bs : bitset#, v : @a::(integral,numeric) -> void)
+ generic bshas : (bs : bitset#, v : @a::(integral,numeric) -> bool)
const bsdiff : (a : bitset#, b : bitset# -> void)
const bsintersect : (a : bitset#, b : bitset# -> void)
diff --git a/libstd/chartype.myr b/libstd/chartype.myr
index 13cb59b..c62fcf1 100644
--- a/libstd/chartype.myr
+++ b/libstd/chartype.myr
@@ -22,7 +22,7 @@ pkg std =
const toupper : (c : char -> char)
const totitle : (c : char -> char)
- generic charval : (c : char, base : int -> @a::(tcint,tcnum,tctest))
+ generic charval : (c : char, base : int -> @a::(integral,numeric))
;;
/*
@@ -1209,18 +1209,18 @@ const totitle = {c
-> c
}
-generic charval = {c, base -> @a::(tcnum,tcint,tctest)
+generic charval = {c, base -> @a::(numeric,integral)
var v = -1
if c >= '0' && c <= '9'
- v = (c - '0') castto(@a::(tcint,tcnum,tctest))
+ v = (c - '0') castto(@a::(integral,numeric))
elif c >= 'a' && c <= 'z'
- v = (c - 'a' + 10) castto(@a::(tcint,tcnum,tctest))
+ v = (c - 'a' + 10) castto(@a::(integral,numeric))
elif c >= 'A' && c <= 'Z'
- v = (c - 'A' + 10) castto(@a::(tcint,tcnum,tctest))
+ v = (c - 'A' + 10) castto(@a::(integral,numeric))
;;
- if v < 0 || v > (base castto(@a::(tcint,tcnum,tctest)))
+ if v < 0 || v > (base castto(@a::(integral,numeric)))
-> -1
;;
-> v
diff --git a/libstd/endian.myr b/libstd/endian.myr
index 4f01c64..8bac74f 100644
--- a/libstd/endian.myr
+++ b/libstd/endian.myr
@@ -5,7 +5,7 @@ pkg std =
/* FIXME: we only support little endian platforms right now,
so we assume a little endian machine. FIX THIS. */
-generic hosttonet = {v : @a::(tcint,tcnum,tctest)
+generic hosttonet = {v : @a::(integral,numeric)
var i
var ret
@@ -18,7 +18,7 @@ generic hosttonet = {v : @a::(tcint,tcnum,tctest)
-> ret
}
-generic nettohost = {v : @a::(tcint,tcnum,tctest)
+generic nettohost = {v : @a::(integral,numeric)
var i
var ret
diff --git a/libstd/extremum.myr b/libstd/extremum.myr
index 5d63acd..c4998da 100644
--- a/libstd/extremum.myr
+++ b/libstd/extremum.myr
@@ -1,6 +1,6 @@
pkg std =
- generic min : (a : @a::tcnum, b : @a::tcnum -> @a::tcnum)
- generic max : (a : @a::tcnum, b : @a::tcnum -> @a::tcnum)
+ generic min : (a : @a::numeric, b : @a::numeric -> @a::numeric)
+ generic max : (a : @a::numeric, b : @a::numeric -> @a::numeric)
;;
generic min = {a, b
diff --git a/libstd/fmt.myr b/libstd/fmt.myr
index 41cc501..dd4dd87 100644
--- a/libstd/fmt.myr
+++ b/libstd/fmt.myr
@@ -85,7 +85,7 @@ const bfmt = {buf, fmt, args
const digitchars = [
'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'
]
-generic intfmt = {buf : byte[:], bits : @a::(tcint,tctest,tcnum), base, signed
+generic intfmt = {buf : byte[:], bits : @a::(integral,numeric), base, signed
var isneg
var val
var b : char[32]
@@ -142,7 +142,7 @@ const bfmtv = {buf, fmt, ap
var f_val : float64, F_val : float32
n = 0
- while fmt.len
+ while fmt.len != 0
(c, fmt) = striter(fmt)
if c == '%'
base = 10
diff --git a/libstd/hashfuncs.myr b/libstd/hashfuncs.myr
index 539c94c..ced6fe7 100644
--- a/libstd/hashfuncs.myr
+++ b/libstd/hashfuncs.myr
@@ -8,8 +8,8 @@ pkg std =
generic ptrhash : (p : @a# -> uint32)
generic ptreq : (a : @a#, b : @a# -> bool)
- generic inthash : (v : @a::(tcint,tcnum,tctest) -> uint32)
- generic inteq : (a : @a::(tcint,tcnum,tctest), b : @a::(tcint,tcnum,tctest) -> bool)
+ generic inthash : (v : @a::(integral,numeric) -> uint32)
+ generic inteq : (a : @a::(integral,numeric), b : @a::(integral,numeric) -> bool)
;;
/* Supremely simple djb hash. */
diff --git a/libstd/intparse.myr b/libstd/intparse.myr
index 6794891..1ea96bd 100644
--- a/libstd/intparse.myr
+++ b/libstd/intparse.myr
@@ -7,8 +7,8 @@ use "types.use"
use "utf.use"
pkg std =
- generic intparsebase : (s : byte[:], base : int -> option(@a::(tcint,tcnum,tctest)))
- generic intparse : (s : byte[:] -> option(@a::(tcint,tcnum,tctest)))
+ generic intparsebase : (s : byte[:], base : int -> option(@a::(integral,numeric)))
+ generic intparse : (s : byte[:] -> option(@a::(integral,numeric)))
;;
generic intparse = {s
@@ -55,7 +55,7 @@ generic doparse = {s, isneg, base
;;
cv = charval(c, base)
if cv >= 0
- v *= (base castto(@a::(tcint,tcnum,tctest)))
+ v *= (base castto(@a::(integral,numeric)))
v += cv
else
-> `None
diff --git a/libstd/rand.myr b/libstd/rand.myr
index 002dabd..eede48f 100644
--- a/libstd/rand.myr
+++ b/libstd/rand.myr
@@ -49,8 +49,8 @@ pkg std =
type rng
const mksrng : (seed : uint32 -> rng#)
- generic rand : (rng : rng#, lo : @a::(tcnum,tctest,tcint), hi : @a::(tcnum,tctest,tcint) -> @a::(tcnum,tctest,tcint))
- generic randN : (rng : rng# -> @a::(tcnum,tctest,tcint))
+ generic rand : (rng : rng#, lo : @a::(numeric,integral), hi : @a::(numeric,integral) -> @a::(numeric,integral))
+ generic randN : (rng : rng# -> @a::(numeric,integral))
const rand32 : (rng : rng# -> uint32)
;;
@@ -85,7 +85,7 @@ const init = {rng, seed
nonempty, and the difference between hi and lo must be
less then 2^(type_bits - 1)
*/
-generic rand = {rng, lo, hi -> @a::(tcint,tcnum,tctest)
+generic rand = {rng, lo, hi -> @a::(integral,numeric)
var span, lim
var maxrand
var val
@@ -111,13 +111,13 @@ generic rand = {rng, lo, hi -> @a::(tcint,tcnum,tctest)
random number generator `rng`. The returned value
may be negative, if the type is signed.
*/
-generic randN = {rng -> @a::(tcint,tcnum,tctest)
+generic randN = {rng -> @a::(integral,numeric)
var i, val
val = 0
for i = 0; i < sizeof(@a)/4; i++
val <<= 8*sizeof(@a)
- val |= rand32(rng) castto(@a::(tcint,tcnum,tctest))
+ val |= rand32(rng) castto(@a::(integral,numeric))
;;
-> val
}
diff --git a/libstd/resolve.myr b/libstd/resolve.myr
index db7286c..f1cb698 100644
--- a/libstd/resolve.myr
+++ b/libstd/resolve.myr
@@ -424,7 +424,7 @@ const valid = {host : byte[:]
if seglen > 63
-> false
;;
- if host[i] & 0x80
+ if host[i] & 0x80 != 0
-> false
;;
;;
diff --git a/libstd/units.myr b/libstd/units.myr
index ff7c7a0..f1a99e9 100644
--- a/libstd/units.myr
+++ b/libstd/units.myr
@@ -1,11 +1,11 @@
pkg std =
/* JEDEC 100B.1 memory sizes */
- generic KiB : @a::(tcint,tcnum,tctest) = 1024
- generic MiB : @a::(tcint,tcnum,tctest) = KiB*1024
- generic GiB : @a::(tcint,tcnum,tctest) = MiB*1024
- generic TiB : @a::(tcint,tcnum,tctest) = GiB*1024
- generic PiB : @a::(tcint,tcnum,tctest) = TiB*1024
- generic EiB : @a::(tcint,tcnum,tctest) = PiB*1024
- generic ZiB : @a::(tcint,tcnum,tctest) = EiB*1024
- generic YiB : @a::(tcint,tcnum,tctest) = ZiB*1024
+ generic KiB : @a::(integral,numeric) = 1024
+ generic MiB : @a::(integral,numeric) = KiB*1024
+ generic GiB : @a::(integral,numeric) = MiB*1024
+ generic TiB : @a::(integral,numeric) = GiB*1024
+ generic PiB : @a::(integral,numeric) = TiB*1024
+ generic EiB : @a::(integral,numeric) = PiB*1024
+ generic ZiB : @a::(integral,numeric) = EiB*1024
+ generic YiB : @a::(integral,numeric) = ZiB*1024
;;