summaryrefslogtreecommitdiff
path: root/lib/bio
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2016-05-17 22:00:50 -0700
committerOri Bernstein <ori@eigenstate.org>2016-05-17 22:00:50 -0700
commit7aac15b2bfcc5eec279aa14f9f199685f9d7e0d9 (patch)
treec9434a55ea6850aee7103f608c6333cfe3148d60 /lib/bio
parentc96238b89583ed91e92ad909c507797d00015e95 (diff)
downloadmc-7aac15b2bfcc5eec279aa14f9f199685f9d7e0d9.tar.gz
New syntax for casts.
Diffstat (limited to 'lib/bio')
-rw-r--r--lib/bio/bio.myr10
-rw-r--r--lib/bio/geti.myr8
-rw-r--r--lib/bio/iter.myr4
-rw-r--r--lib/bio/puti.myr48
-rw-r--r--lib/bio/test/bio-endianrd.myr2
-rw-r--r--lib/bio/test/bio-endianwr.myr2
6 files changed, 37 insertions, 37 deletions
diff --git a/lib/bio/bio.myr b/lib/bio/bio.myr
index 14cfd7d..abfc2a5 100644
--- a/lib/bio/bio.myr
+++ b/lib/bio/bio.myr
@@ -133,7 +133,7 @@ const sysmode = {mode
/* open the file, and return it */
const sysopen = {path, mode, openmode, perm
- match std.openmode(path, openmode, perm castto(int64))
+ match std.openmode(path, openmode, (perm : int64))
| `std.Ok fd: -> `std.Ok mkfile(fd, mode)
| `std.Fail e: -> `std.Fail "could not open fd"
;;
@@ -352,7 +352,7 @@ const ensurecodepoint : (f : file# -> status(std.size)) = {f
*/
generic putle = {f, v : @a::(numeric,integral)
for var i = 0; i < sizeof(@a); i++
- putb(f, (v & 0xff) castto(byte))
+ putb(f, (v & 0xff : byte))
v >>= 8
;;
-> sizeof(@a)
@@ -364,7 +364,7 @@ generic putle = {f, v : @a::(numeric,integral)
*/
generic putbe = {f, v : @a::(numeric,integral)
for var i = sizeof(@a); i != 0; i--
- putb(f, ((v >> ((i-1)*8)) & 0xff) castto(byte))
+ putb(f, ((v >> ((i-1)*8)) & 0xff : byte))
;;
-> sizeof(@a)
}
@@ -448,7 +448,7 @@ const readln = {f
;;
/* scan for delimiter */
for var i = f.rstart; i < f.rend; i++
- c = f.rbuf[i] castto(char)
+ c = (f.rbuf[i] : char)
if c == '\r' || c == '\n'
ret = readinto(f, ret, i - f.rstart)
f.rstart++
@@ -664,7 +664,7 @@ const geterr = {f
const errtype : (e : std.errno -> ioerr )= {e : std.errno -> ioerr
var errno
- errno = e castto(std.errno)
+ errno = (e : std.errno)
if errno == std.Ebadf
-> `Ebadfile
elif errno == std.Einval
diff --git a/lib/bio/geti.myr b/lib/bio/geti.myr
index 3fd85aa..70186b2 100644
--- a/lib/bio/geti.myr
+++ b/lib/bio/geti.myr
@@ -29,9 +29,9 @@ generic getle = {f, n -> status(@a::(numeric,integral))
| `Err e : -> `Err e
| `Ok _:
for i = 0; i < n; i++
- v |= (f.rbuf[f.rstart++] castto(uint64)) << (8*(i castto(uint64)))
+ v |= (f.rbuf[f.rstart++] : uint64) << (8*(i : uint64))
;;
- -> `Ok v castto(@a::(numeric,integral))
+ -> `Ok (v : @a::(numeric,integral))
;;
}
@@ -49,9 +49,9 @@ generic getbe = {f, n -> status(@a::(numeric,integral))
| `Ok _:
for i = 0; i < n; i++
v <<= 8
- v |= (f.rbuf[f.rstart++] castto(uint64))
+ v |= (f.rbuf[f.rstart++] : uint64)
;;
- -> `Ok v castto(@a::(numeric,integral))
+ -> `Ok (v : @a::(numeric,integral))
;;
}
diff --git a/lib/bio/iter.myr b/lib/bio/iter.myr
index 9280cc4..ba7d765 100644
--- a/lib/bio/iter.myr
+++ b/lib/bio/iter.myr
@@ -9,12 +9,12 @@ pkg bio =
;;
const byline = {f
- -> f castto(lineiter)
+ -> (f : lineiter)
}
impl iterable lineiter -> byte[:] =
__iternext__ = {itp, outp
- match bio.readln(itp# castto(file#))
+ match bio.readln((itp# : file#))
| `Ok ln:
outp# = ln
-> true
diff --git a/lib/bio/puti.myr b/lib/bio/puti.myr
index f02c962..d4d7a3f 100644
--- a/lib/bio/puti.myr
+++ b/lib/bio/puti.myr
@@ -16,15 +16,15 @@ pkg bio =
generic putle64 : (f : file#, v : @a::(numeric,integral) -> status(std.size))
;;
-generic putbe8 = {f, v; -> putbe(f, v castto(uint64), 1)}
-generic putbe16 = {f, v; -> putbe(f, v castto(uint64), 2)}
-generic putbe32 = {f, v; -> putbe(f, v castto(uint64), 4)}
-generic putbe64 = {f, v; -> putbe(f, v castto(uint64), 8)}
+generic putbe8 = {f, v; -> putbe(f, (v : uint64), 1)}
+generic putbe16 = {f, v; -> putbe(f, (v : uint64), 2)}
+generic putbe32 = {f, v; -> putbe(f, (v : uint64), 4)}
+generic putbe64 = {f, v; -> putbe(f, (v : uint64), 8)}
-generic putle8 = {f, v; -> putle(f, v castto(uint64), 1)}
-generic putle16 = {f, v; -> putle(f, v castto(uint64), 2)}
-generic putle32 = {f, v; -> putle(f, v castto(uint64), 4)}
-generic putle64 = {f, v; -> putle(f, v castto(uint64), 8)}
+generic putle8 = {f, v; -> putle(f, (v : uint64), 1)}
+generic putle16 = {f, v; -> putle(f, (v : uint64), 2)}
+generic putle32 = {f, v; -> putle(f, (v : uint64), 4)}
+generic putle64 = {f, v; -> putle(f, (v : uint64), 8)}
const putle = {f, v, n
var buf : byte[8]
@@ -33,14 +33,14 @@ const putle = {f, v, n
| `Eof: -> `Eof
| `Err e: -> `Err e
| `Ok _:
- buf[0] = (v >> 0) & 0xff castto(byte)
- buf[1] = (v >> 8) & 0xff castto(byte)
- buf[2] = (v >> 16) & 0xff castto(byte)
- buf[3] = (v >> 24) & 0xff castto(byte)
- buf[4] = (v >> 32) & 0xff castto(byte)
- buf[5] = (v >> 40) & 0xff castto(byte)
- buf[6] = (v >> 48) & 0xff castto(byte)
- buf[7] = (v >> 56) & 0xff castto(byte)
+ buf[0] = ((v >> 0) & 0xff : byte)
+ buf[1] = ((v >> 8) & 0xff : byte)
+ buf[2] = ((v >> 16) & 0xff : byte)
+ buf[3] = ((v >> 24) & 0xff : byte)
+ buf[4] = ((v >> 32) & 0xff : byte)
+ buf[5] = ((v >> 40) & 0xff : byte)
+ buf[6] = ((v >> 48) & 0xff : byte)
+ buf[7] = ((v >> 56) & 0xff : byte)
-> write(f, buf[:n])
;;
}
@@ -52,14 +52,14 @@ const putbe = {f, v, n
| `Eof: -> `Eof
| `Err e: -> `Err e
| `Ok _:
- buf[0] = (v >> 56) & 0xff castto(byte)
- buf[1] = (v >> 48) & 0xff castto(byte)
- buf[2] = (v >> 40) & 0xff castto(byte)
- buf[3] = (v >> 32) & 0xff castto(byte)
- buf[4] = (v >> 24) & 0xff castto(byte)
- buf[5] = (v >> 16) & 0xff castto(byte)
- buf[6] = (v >> 8) & 0xff castto(byte)
- buf[7] = (v >> 0) & 0xff castto(byte)
+ buf[0] = ((v >> 56) & 0xff : byte)
+ buf[1] = ((v >> 48) & 0xff : byte)
+ buf[2] = ((v >> 40) & 0xff : byte)
+ buf[3] = ((v >> 32) & 0xff : byte)
+ buf[4] = ((v >> 24) & 0xff : byte)
+ buf[5] = ((v >> 16) & 0xff : byte)
+ buf[6] = ((v >> 8) & 0xff : byte)
+ buf[7] = ((v >> 0) & 0xff : byte)
-> write(f, buf[8-n:])
;;
}
diff --git a/lib/bio/test/bio-endianrd.myr b/lib/bio/test/bio-endianrd.myr
index 6011496..629d9a6 100644
--- a/lib/bio/test/bio-endianrd.myr
+++ b/lib/bio/test/bio-endianrd.myr
@@ -40,7 +40,7 @@ const main = {
std.assert(try(bio.getbe32(f)) == l, "be long broken\n")
/* quad */
- q = 0x11223344aabbccdd castto(uint64)
+ q = (0x11223344aabbccdd : uint64)
std.assert(try(bio.getle64(f)) == q, "le quad broken\n")
std.assert(try(bio.getbe64(f)) == q, "be quad broken\n")
diff --git a/lib/bio/test/bio-endianwr.myr b/lib/bio/test/bio-endianwr.myr
index b672571..1173bef 100644
--- a/lib/bio/test/bio-endianwr.myr
+++ b/lib/bio/test/bio-endianwr.myr
@@ -33,7 +33,7 @@ const main = {
bio.putbe32(f, l)
/* quad */
- q = 0x11223344aabbccdd castto(uint64)
+ q = (0x11223344aabbccdd : uint64)
bio.putle64(f, q)
bio.putbe64(f, q)