ref: da45fcd5ccafb05f813c989a379dd6920e517c53
parent: 96f7ecd57ed79995544a125e752c9711aeedbcb8
author: Ori Bernstein <ori@eigenstate.org>
date: Thu Sep 17 22:05:13 EDT 2015
Remove 'long' type. It wasn't ever actually used.
--- a/6/simp.c
+++ b/6/simp.c
@@ -562,7 +562,7 @@
case Tybool: case Tychar: case Tybyte:
case Tyint8: case Tyint16: case Tyint32: case Tyint:
case Tyuint8: case Tyuint16: case Tyuint32: case Tyuint:
- case Tyint64: case Tyuint64: case Tylong: case Tyulong:
+ case Tyint64: case Tyuint64:
case Tyflt32: case Tyflt64:
case Typtr: case Tyfunc:
v = mkexpr(pat->loc, Oeq, pat, val, NULL);
@@ -904,8 +904,7 @@
case Tybool:
case Tyint8: case Tyint16: case Tyint32: case Tyint64:
case Tyuint8: case Tyuint16: case Tyuint32: case Tyuint64:
- case Tyint: case Tyuint: case Tylong: case Tyulong:
- case Tychar: case Tybyte:
+ case Tyint: case Tyuint: case Tychar: case Tybyte:
case Typtr:
t = tybase(exprtype(val));
switch (t->type) {
@@ -918,13 +917,13 @@
break;
/* signed conversions */
case Tyint8: case Tyint16: case Tyint32: case Tyint64:
- case Tyint: case Tylong:
+ case Tyint:
r = intconvert(s, val, to, 1);
break;
/* unsigned conversions */
case Tybool:
case Tyuint8: case Tyuint16: case Tyuint32: case Tyuint64:
- case Tyuint: case Tyulong: case Tychar: case Tybyte:
+ case Tyuint: case Tychar: case Tybyte:
case Typtr:
case Tyfunc:
r = intconvert(s, val, to, 0);
@@ -946,8 +945,7 @@
switch (t->type) {
case Tyint8: case Tyint16: case Tyint32: case Tyint64:
case Tyuint8: case Tyuint16: case Tyuint32: case Tyuint64:
- case Tyint: case Tyuint: case Tylong: case Tyulong:
- case Tychar: case Tybyte:
+ case Tyint: case Tyuint: case Tychar: case Tybyte:
r = mkexpr(val->loc, Oint2flt, rval(s, val, NULL), NULL);
r->expr.type = to;
break;
--- a/6/typeinfo.c
+++ b/6/typeinfo.c
@@ -125,8 +125,8 @@
/* atomic types -- nothing else to do */
case Tyvoid: case Tychar: case Tybool: case Tyint8:
case Tyint16: case Tyint: case Tyint32: case Tyint64:
- case Tylong: case Tybyte: case Tyuint8: case Tyuint16:
- case Tyuint: case Tyuint32: case Tyuint64: case Tyulong:
+ case Tybyte: case Tyuint8: case Tyuint16:
+ case Tyuint: case Tyuint32: case Tyuint64:
case Tyflt32: case Tyflt64: case Tyvalist:
break;
@@ -250,8 +250,8 @@
case Tyvalist: /* ptr to first element of valist */
return Ptrsz;
- case Tyint64: case Tylong:
- case Tyuint64: case Tyulong:
+ case Tyint64:
+ case Tyuint64:
return 8;
/*end integer types*/
--- a/lib/std/fmt.myr
+++ b/lib/std/fmt.myr
@@ -243,9 +243,9 @@
var f32_val : flt32, f64_val : flt64
var i8 : int8, i16: int16, i32 : int32
var by : byte
- var i : int, i64 : int64, l : long
+ var i : int, i64 : int64
var ui8 : int8, ui16: int16, ui32 : int32
- var ui : int, ui64 : int64, ul : long
+ var ui : int, ui64 : int64
match typedesc(tyenc)
| `Tynone: /* nothing */
@@ -277,10 +277,6 @@
| `Tyint64:
l_val = vanext(ap)
intfmt(sb, intparams(params), true, l_val)
- | `Tylong:
- l_val = vanext(ap)
- intfmt(sb, intparams(params), true, l_val)
-
| `Tybyte:
ub_val = vanext(ap)
intfmt(sb, intparams(params), false, ub_val)
@@ -297,9 +293,6 @@
ui_val = vanext(ap)
intfmt(sb, intparams(params), false, ui_val)
| `Tyuint64:
- ul_val = vanext(ap)
- intfmt(sb, intparams(params), false, ul_val)
- | `Tyulong:
ul_val = vanext(ap)
intfmt(sb, intparams(params), false, ul_val)
| `Tyflt32:
--- a/lib/std/introspect.myr
+++ b/lib/std/introspect.myr
@@ -15,7 +15,6 @@
`Tyint
`Tyint32
`Tyint64
- `Tylong
`Tybyte
`Tyuint8
@@ -23,7 +22,6 @@
`Tyuint
`Tyuint32
`Tyuint64
- `Tyulong
`Tyflt32
`Tyflt64
`Tyvalist
@@ -80,31 +78,29 @@
const Encint : byte = 6
const Encint32 : byte = 7
const Encint64 : byte = 8
-const Enclong : byte = 9
-const Encbyte : byte = 10
-const Encuint8 : byte = 11
-const Encuint16 : byte = 12
-const Encuint : byte = 13
-const Encuint32 : byte = 14
-const Encuint64 : byte = 15
-const Enculong : byte = 16
-const Encflt32 : byte = 17
-const Encflt64 : byte = 18
-const Encvalist : byte = 19
+const Encbyte : byte = 9
+const Encuint8 : byte = 10
+const Encuint16 : byte = 11
+const Encuint : byte = 12
+const Encuint32 : byte = 13
+const Encuint64 : byte = 14
+const Encflt32 : byte = 15
+const Encflt64 : byte = 16
+const Encvalist : byte = 17
/* compound types */
-const Encptr : byte = 20
-const Encfunc : byte = 21
-const Encslice : byte = 22
-const Encarray : byte = 23
+const Encptr : byte = 18
+const Encfunc : byte = 19
+const Encslice : byte = 20
+const Encarray : byte = 21
/* aggregate types */
-const Enctuple : byte = 24
-const Encstruct : byte = 25
-const Encunion : byte = 26
-const Encname : byte = 30
-const Encindname :byte = 30 | 0x80
+const Enctuple : byte = 22
+const Encstruct : byte = 23
+const Encunion : byte = 24
+const Encname : byte = 28
+const Encindname :byte = 28 | 0x80
generic typeof = {v : @a -> byte[:]
var tc
@@ -189,7 +185,6 @@
| Encint: -> `Tyint
| Encint32: -> `Tyint32
| Encint64: -> `Tyint64
- | Enclong: -> `Tylong
| Encbyte: -> `Tybyte
| Encuint8: -> `Tyuint8
@@ -197,7 +192,6 @@
| Encuint: -> `Tyuint
| Encuint32: -> `Tyuint32
| Encuint64: -> `Tyuint64
- | Enculong: -> `Tyulong
| Encflt32: -> `Tyflt32
| Encflt64: -> `Tyflt64
| Encvalist: -> `Tyvalist
@@ -251,7 +245,6 @@
| Encint: -> [.size=4, .align=4]
| Encint32: -> [.size=4, .align=4]
| Encint64: -> [.size=8, .align=8]
- | Enclong: -> [.size=8, .align=8]
| Encbyte: -> [.size=1, .align=1]
| Encuint8: -> [.size=1, .align=1]
@@ -259,7 +252,6 @@
| Encuint: -> [.size=4, .align=4]
| Encuint32: -> [.size=4, .align=4]
| Encuint64: -> [.size=8, .align=8]
- | Enculong: -> [.size=8, .align=8]
| Encflt32: -> [.size=4, .align=4]
| Encflt64: -> [.size=8, .align=8]
| Encvalist: -> [.size=8, .align=8]
--- a/lib/std/rand.myr
+++ b/lib/std/rand.myr
@@ -1,6 +1,8 @@
use "die.use"
use "types.use"
use "alloc.use"
+use "now.use"
+
/*
Translated from C by Ori Bernstein
*/
@@ -48,11 +50,13 @@
type rng
const mksrng : (seed : uint32 -> rng#)
- const delrng : (rng : rng# -> void)
- generic rand : (rng : rng#, lo : @a::(numeric,integral), hi : @a::(numeric,integral) -> @a::(numeric,integral))
- generic randN : (rng : rng# -> @a::(numeric,integral))
- const randbytes : (rng : rng#, buf : byte[:] -> size)
- const rand32 : (rng : rng# -> uint32)
+ const freerng : (rng : rng# -> void)
+
+ generic rand : (lo : @a::(numeric,integral), hi : @a::(numeric,integral) -> @a::(numeric,integral))
+
+ generic rngrand : (rng : rng#, lo : @a::(numeric,integral), hi : @a::(numeric,integral) -> @a::(numeric,integral))
+ generic rngrandnum : (rng : rng# -> @a::(numeric,integral))
+ const rngrandbytes : (rng : rng#, buf : byte[:] -> size)
;;
type rng = struct
@@ -60,6 +64,12 @@
i : uint32
;;
+var _rng : rng#
+
+const __init__ = {
+ _rng = mksrng(now() castto(uint32))
+}
+
/* allocates and initializes a random number generator */
const mksrng = {seed
var rng
@@ -69,10 +79,14 @@
-> rng
}
-const delrng = {rng
+const freerng = {rng
free(rng)
}
+generic rand = {lo, hi
+ -> rngrand(_rng, lo, hi)
+}
+
/* initializes a random number generator from the seed `seed`. */
const init = {rng, seed
for var i = 0; i < 624; i++
@@ -88,7 +102,7 @@
nonempty, and the difference between hi and lo must be
less then 2^(type_bits - 1)
*/
-generic rand = {rng, lo, hi -> @a::(integral,numeric)
+generic rngrand = {rng, lo, hi -> @a::(integral,numeric)
var span, lim
var maxrand
var val
@@ -102,9 +116,9 @@
;;
lim = (maxrand/span)*span
- val = (randN(rng) & maxrand)
+ val = (rngrandnum(rng) & maxrand)
while val > lim
- val = (randN(rng) & maxrand)
+ val = (rngrandnum(rng) & maxrand)
;;
-> val % span + lo
}
@@ -114,7 +128,7 @@
random number generator `rng`. The returned value
may be negative, if the type is signed.
*/
-generic randN = {rng -> @a::(integral,numeric)
+generic rngrandN = {rng -> @a::(integral,numeric)
var val
val = 0
@@ -144,7 +158,7 @@
-> x ^ (x >> 18)
}
-const randbytes = {rng, buf
+const rngrandbytes = {rng, buf
var n, r
n = 0
--- a/mbld/deps.myr
+++ b/mbld/deps.myr
@@ -14,7 +14,7 @@
var usepat : regex.regex#
;;
-const Abiversion = 5
+const Abiversion = 6
var usepat : regex.regex#
type dep = union
--- a/mi/fold.c
+++ b/mi/fold.c
@@ -73,15 +73,13 @@
case Tybool:
case Tyint8: case Tyint16: case Tyint32: case Tyint64:
case Tyuint8: case Tyuint16: case Tyuint32: case Tyuint64:
- case Tyint: case Tyuint: case Tylong: case Tyulong:
- case Tychar: case Tybyte:
+ case Tyint: case Tyuint: case Tychar: case Tybyte:
case Typtr:
switch (tybase(from)->type) {
case Tybool:
case Tyint8: case Tyint16: case Tyint32: case Tyint64:
case Tyuint8: case Tyuint16: case Tyuint32: case Tyuint64:
- case Tyint: case Tyuint: case Tylong: case Tyulong:
- case Tychar: case Tybyte:
+ case Tyint: case Tyuint: case Tychar: case Tybyte:
case Typtr:
if (exprop(sub) == Olit || tybase(from)->type == tybase(to)->type) {
sub->expr.type = to;
--- a/mi/match.c
+++ b/mi/match.c
@@ -59,7 +59,6 @@
case Tyint16: return 0x10000; break;
case Tyint32: return 0x100000000; break;
case Tyint: return 0x100000000; break;
- case Tylong: return ~0ull; break;
case Tyint64: return ~0ull; break;
/* unsigned ints */
@@ -68,7 +67,6 @@
case Tyuint16: return 0x10000; break;
case Tyuint32: return 0x100000000; break;
case Tyuint: return 0x100000000; break;
- case Tyulong: return ~0ull; break;
case Tyuint64: return ~0ull; break;
/* floats */
--- a/parse/infer.c
+++ b/parse/infer.c
@@ -1950,7 +1950,6 @@
[Tyint32] = {-2147483648LL, 2*2147483647LL}, /* FIXME: this has been doubled allow for uints... */
[Tyint] = {-2147483648LL, 2*2147483647LL},
[Tyint64] = {-9223372036854775808ULL, 9223372036854775807LL},
- [Tylong] = {-9223372036854775808ULL, 9223372036854775807LL},
};
static const uint64_t uvranges[][2] = {
@@ -1959,17 +1958,16 @@
[Tyuint16] = {0, 65535ULL},
[Tyuint32] = {0, 4294967295ULL},
[Tyuint64] = {0, 18446744073709551615ULL},
- [Tyulong] = {0, 18446744073709551615ULL},
[Tychar] = {0, 4294967295ULL},
};
/* signed types */
t = type(st, n);
- if (t->type >= Tyint8 && t->type <= Tylong) {
+ if (t->type >= Tyint8 && t->type <= Tyint64) {
sval = n->lit.intval;
if (sval < svranges[t->type][0] || sval > svranges[t->type][1])
fatal(n, "literal value %lld out of range for type \"%s\"", sval, tystr(t));
- } else if ((t->type >= Tybyte && t->type <= Tyulong) || t->type == Tychar) {
+ } else if ((t->type >= Tybyte && t->type <= Tyint64) || t->type == Tychar) {
uval = n->lit.intval;
if (uval < uvranges[t->type][0] || uval > uvranges[t->type][1])
fatal(n, "literal value %llu out of range for type \"%s\"", uval, tystr(t));
--- a/parse/parse.h
+++ b/parse/parse.h
@@ -4,7 +4,7 @@
# define FATAL
#endif
-#define Abiversion 5
+#define Abiversion 6
typedef uint8_t byte;
typedef unsigned int uint;
--- a/parse/type.c
+++ b/parse/type.c
@@ -303,7 +303,7 @@
{
switch (tybase(t)->type) {
case Tybyte: case Tyuint8: case Tyuint16: case Tyuint:
- case Tychar: case Tyuint32: case Tyuint64: case Tyulong:
+ case Tychar: case Tyuint32: case Tyuint64:
case Typtr: case Tybool:
return 1;
default:
@@ -315,7 +315,7 @@
{
switch (tybase(t)->type) {
case Tyint8: case Tyint16: case Tyint:
- case Tyint32: case Tyint64: case Tylong:
+ case Tyint32: case Tyint64:
return 1;
default:
return 0;
@@ -535,7 +535,6 @@
case Tyint: p += bprintf(p, end - p, "int"); break;
case Tyint32: p += bprintf(p, end - p, "int32"); break;
case Tyint64: p += bprintf(p, end - p, "int64"); break;
- case Tylong: p += bprintf(p, end - p, "long"); break;
case Tybyte: p += bprintf(p, end - p, "byte"); break;
case Tyuint8: p += bprintf(p, end - p, "uint8"); break;
case Tyuint16: p += bprintf(p, end - p, "uint16"); break;
@@ -542,7 +541,6 @@
case Tyuint: p += bprintf(p, end - p, "uint"); break;
case Tyuint32: p += bprintf(p, end - p, "uint32"); break;
case Tyuint64: p += bprintf(p, end - p, "uint64"); break;
- case Tyulong: p += bprintf(p, end - p, "ulong"); break;
case Tyflt32: p += bprintf(p, end - p, "flt32"); break;
case Tyflt64: p += bprintf(p, end - p, "flt64"); break;
case Tyvalist: p += bprintf(p, end - p, "..."); break;
@@ -783,7 +781,6 @@
case Tyint: p += bprintf(p, end - p, "i"); break;
case Tyint32: p += bprintf(p, end - p, "w"); break;
case Tyint64: p += bprintf(p, end - p, "q"); break;
- case Tylong: p += bprintf(p, end - p, "l"); break;
case Tybyte: p += bprintf(p, end - p, "H"); break;
case Tyuint8: p += bprintf(p, end - p, "B"); break;
@@ -791,7 +788,6 @@
case Tyuint: p += bprintf(p, end - p, "I"); break;
case Tyuint32: p += bprintf(p, end - p, "W"); break;
case Tyuint64: p += bprintf(p, end - p, "Q"); break;
- case Tyulong: p += bprintf(p, end - p, "L"); break;
case Tyflt32: p += bprintf(p, end - p, "f"); break;
case Tyflt64: p += bprintf(p, end - p, "d"); break;
case Tyvalist: p += bprintf(p, end - p, "V"); break;
--- a/parse/types.def
+++ b/parse/types.def
@@ -13,7 +13,6 @@
Ty(Tyint, "int")
Ty(Tyint32, "int32")
Ty(Tyint64, "int64")
-Ty(Tylong, "long")
Ty(Tybyte, "byte")
Ty(Tyuint8, "uint8")
@@ -21,7 +20,7 @@
Ty(Tyuint, "uint")
Ty(Tyuint32, "uint32")
Ty(Tyuint64, "uint64")
-Ty(Tyulong, "ulong")
+
/*end integer types*/
Ty(Tyflt32, "flt32")
Ty(Tyflt64, "flt64")