ref: 4b22ab1d70ae00338f3af8dd876e4181194efcc8
parent: 29b1d01e4c8bd99be867ce986408362f8ae8d023
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Thu Mar 6 20:39:06 EST 2025
rename u?int{8,16,32,64} → {u,s}{8,16,32,64} Less typing, no conflicts. This is the first round of catering to Plan 9 namings.
--- a/boot/sl.boot
+++ b/boot/sl.boot
@@ -14,9 +14,9 @@
NIL NIL NIL NIL NIL NIL NIL NIL #fn("z0700}2:" #(aref)) NIL NIL NIL)
*properties* #table(*funvars* #table(*prompt* (NIL) lz-unpack ((data :to destination)
(data :size
- decompressed-bytes)) void? ((x)) >= ((a . rest)) rand-uint64 (NIL) help ((term)) length= ((lst
- n)) = ((a . rest)) car ((lst)) <= ((a . rest)) rand-uint32 (NIL) /= ((a . rest)) void (rest) lz-pack ((data
- (level 0))) rand (NIL) nan? ((x)) rand-float (NIL) cons? ((value)) vm-stats (NIL) * ((number…)) rand-double (NIL) cdr ((lst)) + ((number…)) > ((a . rest))) *doc* #table(>= "Return T if the arguments are in non-increasing order (previous\none is greater than or equal to the next one)." void? "Return T if x is #<void>, NIL otherwise." length= "Bounded length test.\nUse this instead of (= (length lst) n), since it avoids unnecessary\nwork and always terminates." car "Return the first element of a list or NIL if not available." *builtins* "VM instructions as closures." <= "Return T if the arguments are in non-decreasing order (previous\none is less than or equal to the next one)." void "Return the constant #<void> while ignoring any arguments.\n#<void> is mainly used when a function has side effects but does not\nproduce any meaningful value to return, so even though T or NIL could\nbe returned instead, in case of #<void> alone, REPL will not print\nit." rand "Return a random non-negative fixnum on its maximum range." nan? "Return T if the argument is NaN, regardless of the sign." Instructions "VM instructions mapped to their encoded byte representation." rand-double "Return a random double on [0.0, 1.0] interval." > "Return T if the arguments are in strictly decreasing order (previous\none is greater than the next one)." cdr "Return the tail of a list or NIL if not available." + "Return sum of the numbers or 0 with no arguments." lz-unpack "Return decompressed data previously compressed using lz-pack.\nEither destination for the decompressed data or the expected size of\nthe decompressed data must be specified. In the latter case a new\narray is allocated." rand-uint64 "Return a random integer on [0, 2⁶⁴-1] interval." help "Display documentation for the specified term, if available." = "Return T if the arguments are equal." rand-uint32 "Return a random integer on [0, 2³²-1] interval." /= "Return T if not all arguments are equal. Shorthand for (not (= …))." lz-pack "Return data compressed using Lempel-Ziv.\nThe data must be an array, returned value will have the same type.\nThe optional level is between 0 and 10. With level 0 a simple LZSS\nusing hashing will be performed. Levels between 1 and 9 offer a\ntrade-off between time/space and ratio. Level 10 is optimal but very\nslow." rand-float "Return a random float on [0.0, 1.0] interval." arg-counts "VM instructions mapped to their expected arguments count." *prompt* "Function called by REPL to signal the user input is required.\nDefault function prints \"#;> \"." cons? "Return T if the value is a cons cell." vm-stats "Print various VM-related information, such as the number of GC calls\nso far, heap and stack size, etc." * "Return product of the numbers or 1 with no arguments." *properties* "All properties of symbols recorded with putprop are recorded in this table."))
+ decompressed-bytes)) void? ((x)) >= ((a . rest)) help ((term)) length= ((lst
+ n)) rand-u32 (NIL) = ((a . rest)) rand-u64 (NIL) car ((lst)) <= ((a . rest)) /= ((a . rest)) lz-pack ((data
+ (level 0))) rand (NIL) nan? ((x)) rand-float (NIL) void (rest) cons? ((value)) vm-stats (NIL) * ((number…)) rand-double (NIL) cdr ((lst)) + ((number…)) > ((a . rest))) *doc* #table(>= "Return T if the arguments are in non-increasing order (previous\none is greater than or equal to the next one)." void? "Return T if x is #<void>, NIL otherwise." length= "Bounded length test.\nUse this instead of (= (length lst) n), since it avoids unnecessary\nwork and always terminates." car "Return the first element of a list or NIL if not available." *builtins* "VM instructions as closures." <= "Return T if the arguments are in non-decreasing order (previous\none is less than or equal to the next one)." void "Return the constant #<void> while ignoring any arguments.\n#<void> is mainly used when a function has side effects but does not\nproduce any meaningful value to return, so even though T or NIL could\nbe returned instead, in case of #<void> alone, REPL will not print\nit." rand "Return a random non-negative fixnum on its maximum range." nan? "Return T if the argument is NaN, regardless of the sign." Instructions "VM instructions mapped to their encoded byte representation." rand-double "Return a random double on [0.0, 1.0] interval." > "Return T if the arguments are in strictly decreasing order (previous\none is greater than the next one)." cdr "Return the tail of a list or NIL if not available." + "Return sum of the numbers or 0 with no arguments." lz-unpack "Return decompressed data previously compressed using lz-pack.\nEither destination for the decompressed data or the expected size of\nthe decompressed data must be specified. In the latter case a new\narray is allocated." help "Display documentation for the specified term, if available." rand-u32 "Return a random integer on [0, 2³²-1] interval." = "Return T if the arguments are equal." rand-u64 "Return a random integer on [0, 2⁶⁴-1] interval." /= "Return T if not all arguments are equal. Shorthand for (not (= …))." lz-pack "Return data compressed using Lempel-Ziv.\nThe data must be an array, returned value will have the same type.\nThe optional level is between 0 and 10. With level 0 a simple LZSS\nusing hashing will be performed. Levels between 1 and 9 offer a\ntrade-off between time/space and ratio. Level 10 is optimal but very\nslow." rand-float "Return a random float on [0.0, 1.0] interval." arg-counts "VM instructions mapped to their expected arguments count." *prompt* "Function called by REPL to signal the user input is required.\nDefault function prints \"#;> \"." cons? "Return T if the value is a cons cell." vm-stats "Print various VM-related information, such as the number of GC calls\nso far, heap and stack size, etc." * "Return product of the numbers or 1 with no arguments." *properties* "All properties of symbols recorded with putprop are recorded in this table."))
*syntax-environment* #table(bcode:nconst #fn("n1200r2e3:" #(aref)) doc-for #fn("\x8710002000W1000J60q?140B86;35040<;J404087R;3904208751;J5048786;35040=863H021222387e212389e2e4e2:21222387e21e3e2:" #(#fn(top-level-value)
void symbol-set-doc quote)) with-input-from #fn("z12021e1220e2e1e12315163:" #(#fn(nconc)
with-bindings
@@ -184,11 +184,11 @@
#fn("n370A3U0FEl23N071A72151523A0A182ML237023@4024751K~512602765:" #(princ >= 1- " >" " " hex5
": " " ") print-inst)
#fn(length) #fn(table-foldl) #fn("n382;J@041AF<Gl2;34040:" #()) Instructions #fn("n1702161:" #(princ
- "\t")) #fn(memq) (loadv.l loadg.l setg.l) ref-int32-LE (loadv loadg setg)
+ "\t")) #fn(memq) (loadv.l loadg.l setg.l) ref-s32-LE (loadv loadg setg)
(loada seta loadc call tcall list + - * / < = vector argc vargc loadi8 apply tapply closure box
shift aref) princ #fn(number->string) aref (loada.l seta.l loadc.l argc.l vargc.l call.l tcall.l
box.l) (optargs keyargs) keyargs " " brbound
- (jmp brne brnn brn) "@" hex5 ref-int16-LE (jmp.l brne.l brnn.l brn.l)) disassemble)
+ (jmp brne brnn brn) "@" hex5 ref-s16-LE (jmp.l brne.l brnn.l brn.l)) disassemble)
div #fn("n201k0EL2;3D041EL2;3404K;J504r/;J404EM:" #() div) emit
#fn("z2I2021?75140EG82Jk0122CB088<23C:08824_@R0125CE08788<513;00E88=p@900E188Pp@D126127523A078082<52e1?2@30q42912:52893D02;82<L23:089T?1@30q^142912<52893D02;82<L23:089T?1@30q^1412=C\\0822>d3=02??14q?2@F0822@d3=02A?14q?2@30q@30q412BC\\0822>d3=02C?14q?2@F0822@d3=02D?14q?2@30q@30q488<12EQ;3b04892FCB00E82<2G88=PPp@J0892HCB00E82<2I88=PPp@30q;J@040E7J182P8852p^140:" #(#0#
#fn("n17002162:" #(member (load0 load1 loadt loadf loadnil loadvoid)) load?) car cdr cadr pop #fn(memq)
@@ -201,12 +201,12 @@
encode-byte-code #fn("n17005171855172238651r3238651r2ki2M2452238651E255025502650qqI8988L23\xbc148689G?=48=27CP0288:8689KMG298<5153489r2M?9@\x8b12:8<2;7<873k08=8C2=C702>@X08C2?C702@@L08C2AC702B@@08C2CC702D@408=^1@408=5252489KM?948988L2;38048689G?>42E8=2F523`0288;298<518>5342:8<873707G@407HE5152489KM?9@\xeb08=2ICH02:8<2J8>5152489KM?9@\xce08>X3\xc708=2E8?2K523H02:8<2J8>5152489KM?9@\x9f02E8?2L523\x8102:8<2J8>5152489KM?942:8<2J8689G5152489KM?948=2MCK02:8<2J8689G5152489KM?9@30q@E02:8<2N8>5152489KM?9^1@30q@\x9f.42O2P8<878:>38;5242Q8<61:" #(reverse!
list->vector >= #fn(length) 65536 #fn(table) #fn(buffer) label #fn(put!)
#fn(sizeof) #fn(io-write) #fn(get) Instructions jmp jmp.l brne brne.l brnn brnn.l brn brn.l #fn(memq)
- (jmp brne brnn brn) int32 int16 brbound #fn(int32)
- (loadv.l loadg.l setg.l loada.l seta.l argc.l vargc.l call.l tcall.l loadc.l box.l) (optargs
+ (jmp brne brnn brn) s32 s16 brbound #fn(s32) (loadv.l loadg.l setg.l loada.l seta.l argc.l
+ vargc.l call.l tcall.l loadc.l box.l) (optargs
keyargs)
- keyargs #fn(uint8) #fn(for-each) #fn("n220A052421AF37072@407324921520~5162:" #(#fn(io-seek)
- #fn(io-write)
- int32 int16 #fn(get)))
+ keyargs #fn(u8) #fn(for-each) #fn("n220A052421AF37072@407324921520~5162:" #(#fn(io-seek)
+ #fn(io-write) s32 s16
+ #fn(get)))
#fn(iostream->string)) encode-byte-code)
error #fn("z020210P61:" #(#fn(raise) error) error) eval
#fn("n170710515160:" #(compile-thunk macroexpand) eval) even? #fn("n1200K52El2:" #(#fn(logand)) even?)
@@ -354,10 +354,10 @@
read-all #fn("n17071062:" #(read-all-of read) read-all) read-all-of
#fn("n2Ib686201860>3_486<^1q015162:" #(#fn("n220A5138071061:F<10P92A5162:" #(#fn(io-eof?)
reverse!))) read-all-of)
- ref-int16-LE #fn("n2202101EMGE522101KMGr852M61:" #(#fn(int16)
- #fn(ash)) ref-int16-LE)
- ref-int32-LE #fn("n2202101EMGE522101KMGr8522101r2MGr@522101r3MGrH52g461:" #(#fn(int32)
- #fn(ash)) ref-int32-LE)
+ ref-s16-LE #fn("n2202101EMGE522101KMGr852M61:" #(#fn(s16)
+ #fn(ash)) ref-s16-LE)
+ ref-s32-LE #fn("n2202101EMGE522101KMGr8522101r2MGr@522101r3MGrH52g461:" #(#fn(s32)
+ #fn(ash)) ref-s32-LE)
remprop #fn("n220711q5386;3F042286052;3:042386062:" #(#fn(get) *properties* #fn(has?)
#fn(del!)) remprop)
repl #fn("n0IIb4b5208421_5142085228485>2_51485<5047360:" #(#0#
--- a/src/builtins.c
+++ b/src/builtins.c
@@ -220,7 +220,7 @@
{
argcount(nargs, 1);
value_t v = args[0];
- if(isfixnum(v) || ismpint(v))
+ if(isfixnum(v) || ismp(v))
return sl_t;
if(iscprim(v)){
numerictype_t nt = cp_numtype(ptr(v));
@@ -250,7 +250,7 @@
{
argcount(nargs, 1);
value_t v = args[0];
- return (isfixnum(v) || ismpint(v) ||
+ return (isfixnum(v) || ismp(v) ||
(iscprim(v) && cp_numtype(ptr(v)) < T_FLOAT)) ?
sl_t : sl_nil;
}
@@ -259,7 +259,7 @@
BUILTIN("bignum?", bignump)
{
argcount(nargs, 1);
- return ismpint(args[0]) ? sl_t : sl_nil;
+ return ismp(args[0]) ? sl_t : sl_nil;
}
BUILTIN("fixnum", fixnum)
@@ -270,13 +270,13 @@
return v;
if(iscprim(v)){
void *p = ptr(v);
- return fixnum(conv_to_int64(cp_data(p), cp_numtype(p)));
+ return fixnum(conv_to_s64(cp_data(p), cp_numtype(p)));
}
- if(ismpint(v))
+ if(ismp(v))
#ifdef BITS64
- return fixnum(mptov(tompint(v)));
+ return fixnum(mptov(tomp(v)));
#else
- return fixnum(mptoi(tompint(v)));
+ return fixnum(mptoi(tomp(v)));
#endif
type_error("number", v);
}
@@ -285,7 +285,7 @@
{
argcount(nargs, 1);
value_t v = args[0];
- if(isfixnum(v) || ismpint(v))
+ if(isfixnum(v) || ismp(v))
return v;
if(iscprim(v)){
cprim_t *cp = ptr(v);
@@ -302,11 +302,11 @@
if(d > 0){
if(d > (double)INT64_MAX)
return v;
- return return_from_uint64((uint64_t)d);
+ return return_from_u64((uint64_t)d);
}
if(d > (double)INT64_MAX || d < (double)INT64_MIN)
return args[0];
- return return_from_int64((int64_t)d);
+ return return_from_s64((int64_t)d);
}
type_error("number", v);
}
@@ -338,7 +338,7 @@
{
argcount(nargs, 0);
USED(args);
- return mk_uint64(nanosec_monotonic());
+ return mk_u64(nanosec_monotonic());
}
double
@@ -351,8 +351,8 @@
numerictype_t nt = cp_numtype(cp);
return conv_to_double(cp_data(cp), nt);
}
- if(ismpint(a))
- return conv_to_double(cv_data(ptr(a)), T_MPINT);
+ if(ismp(a))
+ return conv_to_double(cv_data(ptr(a)), T_MP);
type_error("number", a);
}
--- a/src/compiler.lsp
+++ b/src/compiler.lsp
@@ -110,30 +110,30 @@
(set! nxt (and (< i n) (aref v i)))
(cond ((memq vi '(jmp brne brnn brn))
(put! fixup-to-label (sizeof bcode) nxt)
- (io-write bcode ((if long? int32 int16) 0))
+ (io-write bcode ((if long? s32 s16) 0))
(set! i (+ i 1)))
((eq? vi 'brbound)
- (io-write bcode (int32 nxt))
+ (io-write bcode (s32 nxt))
(set! i (+ i 1)))
((number? nxt)
(case vi
((loadv.l loadg.l setg.l loada.l seta.l
argc.l vargc.l call.l tcall.l loadc.l box.l)
- (io-write bcode (int32 nxt))
+ (io-write bcode (s32 nxt))
(set! i (+ i 1)))
- ((optargs keyargs) ; 2 int32 args
- (io-write bcode (int32 nxt))
+ ((optargs keyargs) ; 2 s32 args
+ (io-write bcode (s32 nxt))
(set! i (+ i 1))
- (io-write bcode (int32 (aref v i)))
+ (io-write bcode (s32 (aref v i)))
(set! i (+ i 1))
(if (eq? vi 'keyargs)
- (begin (io-write bcode (int32 (aref v i)))
+ (begin (io-write bcode (s32 (aref v i)))
(set! i (+ i 1)))))
(else
- ; other number arguments are always uint8
- (io-write bcode (uint8 nxt))
+ ; other number arguments are always u8
+ (io-write bcode (u8 nxt))
(set! i (+ i 1)))))
(else nil))))))
@@ -140,7 +140,7 @@
(for-each
(λ (addr labl)
(begin (io-seek bcode addr)
- (io-write bcode ((if long? int32 int16)
+ (io-write bcode ((if long? s32 s16)
(- (get label-to-loc labl)
addr)))))
fixup-to-label)
@@ -743,15 +743,15 @@
;; disassembler
-(def (ref-int32-LE a i)
- (int32 (+ (ash (aref a (+ i 0)) 0)
- (ash (aref a (+ i 1)) 8)
- (ash (aref a (+ i 2)) 16)
- (ash (aref a (+ i 3)) 24))))
+(def (ref-s32-LE a i)
+ (s32 (+ (ash (aref a (+ i 0)) 0)
+ (ash (aref a (+ i 1)) 8)
+ (ash (aref a (+ i 2)) 16)
+ (ash (aref a (+ i 3)) 24))))
-(def (ref-int16-LE a i)
- (int16 (+ (ash (aref a (+ i 0)) 0)
- (ash (aref a (+ i 1)) 8))))
+(def (ref-s16-LE a i)
+ (s16 (+ (ash (aref a (+ i 0)) 0)
+ (ash (aref a (+ i 1)) 8))))
(def (hex5 n)
(string-lpad (number->string n 16) 5 #\0))
@@ -788,7 +788,7 @@
(case inst
((loadv.l loadg.l setg.l)
(print-inst inst i 4)
- (print-val (aref vals (ref-int32-LE code i)))
+ (print-val (aref vals (ref-s32-LE code i)))
(set! i (+ i 4)))
((loadv loadg setg)
@@ -804,34 +804,34 @@
((loada.l seta.l loadc.l argc.l vargc.l call.l tcall.l box.l)
(print-inst inst i 4)
- (princ (number->string (ref-int32-LE code i)))
+ (princ (number->string (ref-s32-LE code i)))
(set! i (+ i 4)))
((optargs keyargs)
(print-inst inst i (+ 8 (if (eq? inst 'keyargs) 4 0)))
- (princ (number->string (ref-int32-LE code i)) " ")
+ (princ (number->string (ref-s32-LE code i)) " ")
(set! i (+ i 4))
- (princ (number->string (ref-int32-LE code i)))
+ (princ (number->string (ref-s32-LE code i)))
(set! i (+ i 4))
(if (eq? inst 'keyargs)
(begin
(princ " ")
- (princ (number->string (ref-int32-LE code i)) " ")
+ (princ (number->string (ref-s32-LE code i)) " ")
(set! i (+ i 4)))))
((brbound)
(print-inst inst i 4)
- (princ (number->string (ref-int32-LE code i)) " ")
+ (princ (number->string (ref-s32-LE code i)) " ")
(set! i (+ i 4)))
((jmp brne brnn brn)
(print-inst inst i 2)
- (princ "@" (hex5 (+ i (ref-int16-LE code i))))
+ (princ "@" (hex5 (+ i (ref-s16-LE code i))))
(set! i (+ i 2)))
((jmp.l brne.l brnn.l brn.l)
(print-inst inst i 4)
- (princ "@" (hex5 (+ i (ref-int32-LE code i))))
+ (princ "@" (hex5 (+ i (ref-s32-LE code i))))
(set! i (+ i 4)))
(else (print-inst inst i 0))))))))
--- a/src/cvalues.c
+++ b/src/cvalues.c
@@ -93,7 +93,7 @@
cvalue_(sltype_t *type, size_t sz, bool nofinalize)
{
assert(type != nil);
- if(valid_numtype(type->numtype) && type->numtype != T_MPINT)
+ if(valid_numtype(type->numtype) && type->numtype != T_MP)
return cprim(type, sz);
bool str = false;
@@ -211,22 +211,22 @@
cprim_t *cp = ptr(arg); \
void *p = cp_data(cp); \
n = (ctype)conv_to_##cnvt(p, cp_numtype(cp)); \
- }else if(ismpint(arg)){ \
+ }else if(ismp(arg)){ \
void *p = cv_data(ptr(arg)); \
- n = (ctype)conv_to_##cnvt(p, T_MPINT); \
+ n = (ctype)conv_to_##cnvt(p, T_MP); \
}else \
type_error("number", arg); \
*((ctype*)dest) = n; \
}
-num_init(int8_t, int32, T_INT8)
-num_init(uint8_t, uint32, T_UINT8)
-num_init(int16_t, int32, T_INT16)
-num_init(uint16_t, uint32, T_UINT16)
-num_init(int32_t, int32, T_INT32)
-num_init(uint32_t, uint32, T_UINT32)
-num_init(int64_t, int64, T_INT64)
-num_init(uint64_t, uint64, T_UINT64)
+num_init(int8_t, s32, T_S8)
+num_init(uint8_t, u32, T_U8)
+num_init(int16_t, s32, T_S16)
+num_init(uint16_t, u32, T_U16)
+num_init(int32_t, s32, T_S32)
+num_init(uint32_t, u32, T_U32)
+num_init(int64_t, s64, T_S64)
+num_init(uint64_t, u64, T_U64)
num_init(float, double, T_FLOAT)
num_init(double, double, T_DOUBLE)
@@ -255,21 +255,21 @@
num_ctor_init(typenam, ctype, tag) \
num_ctor_ctor(typenam, ctype, tag)
-num_ctor_init(int8, int8_t, T_INT8)
-num_ctor_init(uint8, uint8_t, T_UINT8)
-num_ctor_init(int16, int16_t, T_INT16)
-num_ctor_init(uint16, uint16_t, T_UINT16)
-num_ctor(int32, int32_t, T_INT32)
-num_ctor(uint32, uint32_t, T_UINT32)
-num_ctor(int64, int64_t, T_INT64)
-num_ctor(uint64, uint64_t, T_UINT64)
-num_ctor_init(byte, uint8_t, T_UINT8)
+num_ctor_init(s8, int8_t, T_S8)
+num_ctor_init(u8, uint8_t, T_U8)
+num_ctor_init(s16, int16_t, T_S16)
+num_ctor_init(u16, uint16_t, T_U16)
+num_ctor(s32, int32_t, T_S32)
+num_ctor(u32, uint32_t, T_U32)
+num_ctor(s64, int64_t, T_S64)
+num_ctor(u64, uint64_t, T_U64)
+num_ctor_init(byte, uint8_t, T_U8)
num_ctor(float, float, T_FLOAT)
num_ctor(double, double, T_DOUBLE)
-num_ctor(rune, uint32_t, T_UINT32)
+num_ctor(rune, uint32_t, T_U32)
static void
-cvalue_mpint_init(sltype_t *type, value_t arg, void *dest)
+cvalue_mp_init(sltype_t *type, value_t arg, void *dest)
{
mpint *n;
USED(type);
@@ -278,11 +278,11 @@
}else if(iscvalue(arg)){
cvalue_t *cv = ptr(arg);
void *p = cv_data(cv);
- n = conv_to_mpint(p, cp_numtype(cv));
+ n = conv_to_mp(p, cp_numtype(cv));
}else if(iscprim(arg)){
cprim_t *cp = ptr(arg);
void *p = cp_data(cp);
- n = conv_to_mpint(p, cp_numtype(cp));
+ n = conv_to_mp(p, cp_numtype(cp));
}else
type_error("number", arg);
*((mpint**)dest) = n;
@@ -294,22 +294,22 @@
PUSH(fixnum(0));
args = SL(sp)-1;
}
- value_t cv = cvalue(SL(mpinttype), sizeof(mpint*));
- cvalue_mpint_init(SL(mpinttype), args[0], cvalue_data(cv));
+ value_t cv = cvalue(SL(mptype), sizeof(mpint*));
+ cvalue_mp_init(SL(mptype), args[0], cvalue_data(cv));
return cv;
}
value_t
-mk_mpint(mpint *n)
+mk_mp(mpint *n)
{
- value_t cv = cvalue(SL(mpinttype), sizeof(mpint*));
+ value_t cv = cvalue(SL(mptype), sizeof(mpint*));
*(mpint**)cvalue_data(cv) = n;
return cv;
}
static void
-free_mpint(value_t self)
+free_mp(value_t self)
{
mpint **s = value2c(mpint**, self);
if(*s != mpzero && *s != mpone && *s != mptwo)
@@ -316,15 +316,15 @@
mpfree(*s);
}
-static cvtable_t mpint_vtable = { nil, nil, free_mpint, nil };
+static cvtable_t mp_vtable = { nil, nil, free_mp, nil };
value_t
size_wrap(size_t sz)
{
if(sizeof(size_t) == 8)
- return fits_fixnum(sz) ? fixnum(sz): mk_uint64(sz);
+ return fits_fixnum(sz) ? fixnum(sz): mk_u64(sz);
else
- return fits_fixnum(sz) ? fixnum(sz): mk_uint32(sz);
+ return fits_fixnum(sz) ? fixnum(sz): mk_u32(sz);
}
size_t
@@ -335,8 +335,8 @@
if(iscprim(n)){
cprim_t *cp = ptr(n);
if(sizeof(size_t) == 8)
- return conv_to_uint64(cp_data(cp), cp_numtype(cp));
- return conv_to_uint32(cp_data(cp), cp_numtype(cp));
+ return conv_to_u64(cp_data(cp), cp_numtype(cp));
+ return conv_to_u32(cp_data(cp), cp_numtype(cp));
}
type_error("number", n);
}
@@ -348,7 +348,7 @@
return numval(n);
if(iscprim(n)){
cprim_t *cp = ptr(n);
- return conv_to_int64(cp_data(cp), cp_numtype(cp));
+ return conv_to_s64(cp_data(cp), cp_numtype(cp));
}
type_error("number", n);
}
@@ -737,15 +737,15 @@
sltype_t *eltype = cv_class(ptr(args[0]))->eltype;
value_t el = 0;
numerictype_t nt = eltype->numtype;
- if(nt >= T_INT32)
+ if(nt >= T_S32)
el = cvalue(eltype, eltype->size);
check_addr_args(args[0], args[1], &data, &index);
- if(nt < T_INT32){
- if(nt == T_INT8)
+ if(nt < T_S32){
+ if(nt == T_S8)
return fixnum((int8_t)data[index]);
- if(nt == T_UINT8)
+ if(nt == T_U8)
return fixnum((uint8_t)data[index]);
- if(nt == T_INT16)
+ if(nt == T_S16)
return fixnum(((int16_t*)data)[index]);
return fixnum(((uint16_t*)data)[index]);
}
@@ -828,25 +828,25 @@
#define RETURN_NUM_AS(var, type) return(mk_##type(var))
value_t
-return_from_uint64(uint64_t Uaccum)
+return_from_u64(uint64_t Uaccum)
{
if(fits_fixnum(Uaccum))
return fixnum((fixnum_t)Uaccum);
if(Uaccum > (uint64_t)INT64_MAX)
- RETURN_NUM_AS(Uaccum, uint64);
+ RETURN_NUM_AS(Uaccum, u64);
if(Uaccum > (uint64_t)UINT32_MAX)
- RETURN_NUM_AS(Uaccum, int64);
+ RETURN_NUM_AS(Uaccum, s64);
if(Uaccum > (uint64_t)INT32_MAX)
- RETURN_NUM_AS(Uaccum, uint32);
- RETURN_NUM_AS(Uaccum, int32);
+ RETURN_NUM_AS(Uaccum, u32);
+ RETURN_NUM_AS(Uaccum, s32);
}
value_t
-return_from_int64(int64_t Saccum)
+return_from_s64(int64_t Saccum)
{
if(fits_fixnum(Saccum))
return fixnum((fixnum_t)Saccum);
- RETURN_NUM_AS(vtomp(Saccum, nil), mpint);
+ RETURN_NUM_AS(vtomp(Saccum, nil), mp);
}
#define ACCUM_DEFAULT 0
@@ -883,36 +883,36 @@
switch(pt){
case T_DOUBLE: return mk_double(-*(double*)a);
case T_FLOAT: return mk_float(-*(float*)a);
- case T_INT8: return fixnum(-(fixnum_t)*(int8_t*)a);
- case T_UINT8: return fixnum(-(fixnum_t)*(uint8_t*)a);
- case T_INT16: return fixnum(-(fixnum_t)*(int16_t*)a);
- case T_UINT16: return fixnum(-(fixnum_t)*(uint16_t*)a);
- case T_UINT32:
+ case T_S8: return fixnum(-(fixnum_t)*(int8_t*)a);
+ case T_U8: return fixnum(-(fixnum_t)*(uint8_t*)a);
+ case T_S16: return fixnum(-(fixnum_t)*(int16_t*)a);
+ case T_U16: return fixnum(-(fixnum_t)*(uint16_t*)a);
+ case T_U32:
i64 = -(int64_t)*(uint32_t*)a;
goto i64neg;
- case T_INT32:
+ case T_S32:
i64 = -(int64_t)*(int32_t*)a;
goto i64neg;
- case T_INT64:
+ case T_S64:
i64 = *(int64_t*)a;
if(i64 == INT64_MIN)
- return mk_mpint(uvtomp((uint64_t)INT64_MAX+1, nil));
+ return mk_mp(uvtomp((uint64_t)INT64_MAX+1, nil));
i64 = -i64;
i64neg:
- return fits_fixnum(i64) ? fixnum(i64) : mk_mpint(vtomp(i64, nil));
- case T_UINT64:
+ return fits_fixnum(i64) ? fixnum(i64) : mk_mp(vtomp(i64, nil));
+ case T_U64:
ui64 = *(uint64_t*)a;
if(ui64 >= (uint64_t)INT64_MAX+1){
mp = uvtomp(ui64, nil);
mp->sign = -1;
- return mk_mpint(mp);
+ return mk_mp(mp);
}
i64 = -(int64_t)ui64;
goto i64neg;
- case T_MPINT:
+ case T_MP:
mp = mpcopy(*(mpint**)a);
mp->sign = -mp->sign;
- return mk_mpint(mp);
+ return mk_mp(mp);
}
}
@@ -1014,7 +1014,7 @@
da = da/db;
if(ta < T_FLOAT && tb < T_FLOAT && (double)(int64_t)da == da)
- return return_from_int64((int64_t)da);
+ return return_from_s64((int64_t)da);
return mk_double(da);
}
@@ -1032,49 +1032,49 @@
if(!num_to_ptr(b, &bi, &tb, &bptr))
type_error("number", b);
- if(ta == T_MPINT){
- if(tb == T_MPINT){
+ if(ta == T_MP){
+ if(tb == T_MP){
if(mpsignif(*(mpint**)bptr) == 0)
goto div_error;
x = mpnew(0);
mpdiv(*(mpint**)aptr, *(mpint**)bptr, x, nil);
- return mk_mpint(x);
+ return mk_mp(x);
}else{
- b64 = conv_to_int64(bptr, tb);
+ b64 = conv_to_s64(bptr, tb);
if(b64 == 0)
goto div_error;
- x = tb == T_UINT64 ? uvtomp(b64, nil) : vtomp(b64, nil);
+ x = tb == T_U64 ? uvtomp(b64, nil) : vtomp(b64, nil);
mpdiv(*(mpint**)aptr, x, x, nil);
- return mk_mpint(x);
+ return mk_mp(x);
}
}
- if(ta == T_UINT64){
- if(tb == T_UINT64){
+ if(ta == T_U64){
+ if(tb == T_U64){
if(*(uint64_t*)bptr == 0)
goto div_error;
- return return_from_uint64(*(uint64_t*)aptr / *(uint64_t*)bptr);
+ return return_from_u64(*(uint64_t*)aptr / *(uint64_t*)bptr);
}
- b64 = conv_to_int64(bptr, tb);
+ b64 = conv_to_s64(bptr, tb);
if(b64 < 0)
- return return_from_int64(-(int64_t)(*(uint64_t*)aptr / (uint64_t)(-b64)));
+ return return_from_s64(-(int64_t)(*(uint64_t*)aptr / (uint64_t)(-b64)));
if(b64 == 0)
goto div_error;
- return return_from_uint64(*(uint64_t*)aptr / (uint64_t)b64);
+ return return_from_u64(*(uint64_t*)aptr / (uint64_t)b64);
}
- if(tb == T_UINT64){
+ if(tb == T_U64){
if(*(uint64_t*)bptr == 0)
goto div_error;
- a64 = conv_to_int64(aptr, ta);
+ a64 = conv_to_s64(aptr, ta);
if(a64 < 0)
- return return_from_int64(-((int64_t)((uint64_t)(-a64) / *(uint64_t*)bptr)));
- return return_from_uint64((uint64_t)a64 / *(uint64_t*)bptr);
+ return return_from_s64(-((int64_t)((uint64_t)(-a64) / *(uint64_t*)bptr)));
+ return return_from_u64((uint64_t)a64 / *(uint64_t*)bptr);
}
- b64 = conv_to_int64(bptr, tb);
+ b64 = conv_to_s64(bptr, tb);
if(b64 == 0)
goto div_error;
- return return_from_int64(conv_to_int64(aptr, ta) / b64);
+ return return_from_s64(conv_to_s64(aptr, ta) / b64);
div_error:
divide_by_0_error();
}
@@ -1098,29 +1098,29 @@
ptmp = aptr; aptr = bptr; bptr = ptmp;
}
// now a's type is larger than or same as b's
- if(ta == T_MPINT){
- if(tb == T_MPINT){
+ if(ta == T_MP){
+ if(tb == T_MP){
bmp = *(mpint**)bptr;
resmp = mpnew(0);
}else{
- bmp = conv_to_mpint(bptr, tb);
+ bmp = conv_to_mp(bptr, tb);
resmp = bmp;
}
b64 = 0;
}else
- b64 = conv_to_int64(bptr, tb);
+ b64 = conv_to_s64(bptr, tb);
switch(opcode){
case 0:
switch(ta){
- case T_INT8: return fixnum( *(int8_t *)aptr & (int8_t )b64);
- case T_UINT8: return fixnum( *(uint8_t *)aptr & (uint8_t )b64);
- case T_INT16: return fixnum( *(int16_t*)aptr & (int16_t )b64);
- case T_UINT16: return fixnum( *(uint16_t*)aptr & (uint16_t)b64);
- case T_INT32: return mk_int32( *(int32_t*)aptr & (int32_t )b64);
- case T_UINT32: return mk_uint32(*(uint32_t*)aptr & (uint32_t)b64);
- case T_INT64: return mk_int64( *(int64_t*)aptr & (int64_t )b64);
- case T_UINT64: return mk_uint64(*(uint64_t*)aptr & (uint64_t)b64);
- case T_MPINT: mpand(*(mpint**)aptr, bmp, resmp); return mk_mpint(resmp);
+ case T_S8: return fixnum( *(int8_t *)aptr & (int8_t )b64);
+ case T_U8: return fixnum( *(uint8_t *)aptr & (uint8_t )b64);
+ case T_S16: return fixnum( *(int16_t*)aptr & (int16_t )b64);
+ case T_U16: return fixnum( *(uint16_t*)aptr & (uint16_t)b64);
+ case T_S32: return mk_s32( *(int32_t*)aptr & (int32_t )b64);
+ case T_U32: return mk_u32(*(uint32_t*)aptr & (uint32_t)b64);
+ case T_S64: return mk_s64( *(int64_t*)aptr & (int64_t )b64);
+ case T_U64: return mk_u64(*(uint64_t*)aptr & (uint64_t)b64);
+ case T_MP: mpand(*(mpint**)aptr, bmp, resmp); return mk_mp(resmp);
case T_FLOAT:
case T_DOUBLE: assert(0);
}
@@ -1127,15 +1127,15 @@
break;
case 1:
switch(ta){
- case T_INT8: return fixnum( *(int8_t *)aptr | (int8_t )b64);
- case T_UINT8: return fixnum( *(uint8_t *)aptr | (uint8_t )b64);
- case T_INT16: return fixnum( *(int16_t*)aptr | (int16_t )b64);
- case T_UINT16: return fixnum( *(uint16_t*)aptr | (uint16_t)b64);
- case T_INT32: return mk_int32( *(int32_t*)aptr | (int32_t )b64);
- case T_UINT32: return mk_uint32(*(uint32_t*)aptr | (uint32_t)b64);
- case T_INT64: return mk_int64( *(int64_t*)aptr | (int64_t )b64);
- case T_UINT64: return mk_uint64(*(uint64_t*)aptr | (uint64_t)b64);
- case T_MPINT: mpor(*(mpint**)aptr, bmp, resmp); return mk_mpint(resmp);
+ case T_S8: return fixnum( *(int8_t *)aptr | (int8_t )b64);
+ case T_U8: return fixnum( *(uint8_t *)aptr | (uint8_t )b64);
+ case T_S16: return fixnum( *(int16_t*)aptr | (int16_t )b64);
+ case T_U16: return fixnum( *(uint16_t*)aptr | (uint16_t)b64);
+ case T_S32: return mk_s32( *(int32_t*)aptr | (int32_t )b64);
+ case T_U32: return mk_u32(*(uint32_t*)aptr | (uint32_t)b64);
+ case T_S64: return mk_s64( *(int64_t*)aptr | (int64_t )b64);
+ case T_U64: return mk_u64(*(uint64_t*)aptr | (uint64_t)b64);
+ case T_MP: mpor(*(mpint**)aptr, bmp, resmp); return mk_mp(resmp);
case T_FLOAT:
case T_DOUBLE: assert(0);
}
@@ -1142,15 +1142,15 @@
break;
case 2:
switch(ta){
- case T_INT8: return fixnum( *(int8_t *)aptr ^ (int8_t )b64);
- case T_UINT8: return fixnum( *(uint8_t *)aptr ^ (uint8_t )b64);
- case T_INT16: return fixnum( *(int16_t*)aptr ^ (int16_t )b64);
- case T_UINT16: return fixnum( *(uint16_t*)aptr ^ (uint16_t)b64);
- case T_INT32: return mk_int32( *(int32_t*)aptr ^ (int32_t )b64);
- case T_UINT32: return mk_uint32(*(uint32_t*)aptr ^ (uint32_t)b64);
- case T_INT64: return mk_int64( *(int64_t*)aptr ^ (int64_t )b64);
- case T_UINT64: return mk_uint64(*(uint64_t*)aptr ^ (uint64_t)b64);
- case T_MPINT: mpxor(*(mpint**)aptr, bmp, resmp); return mk_mpint(resmp);
+ case T_S8: return fixnum( *(int8_t *)aptr ^ (int8_t )b64);
+ case T_U8: return fixnum( *(uint8_t *)aptr ^ (uint8_t )b64);
+ case T_S16: return fixnum( *(int16_t*)aptr ^ (int16_t )b64);
+ case T_U16: return fixnum( *(uint16_t*)aptr ^ (uint16_t)b64);
+ case T_S32: return mk_s32( *(int32_t*)aptr ^ (int32_t )b64);
+ case T_U32: return mk_u32(*(uint32_t*)aptr ^ (uint32_t)b64);
+ case T_S64: return mk_s64( *(int64_t*)aptr ^ (int64_t )b64);
+ case T_U64: return mk_u64(*(uint64_t*)aptr ^ (uint64_t)b64);
+ case T_MP: mpxor(*(mpint**)aptr, bmp, resmp); return mk_mp(resmp);
case T_FLOAT:
case T_DOUBLE: assert(0);
}
@@ -1222,14 +1222,14 @@
ta = cp_numtype(cp);
aptr = cp_data(cp);
switch(ta){
- case T_INT8: return fixnum(~*(int8_t *)aptr);
- case T_UINT8: return fixnum(~*(uint8_t *)aptr & 0xff);
- case T_INT16: return fixnum(~*(int16_t *)aptr);
- case T_UINT16: return fixnum(~*(uint16_t*)aptr & 0xffff);
- case T_INT32: return mk_int32(~*(int32_t *)aptr);
- case T_UINT32: return mk_uint32(~*(uint32_t*)aptr);
- case T_INT64: return mk_int64(~*(int64_t *)aptr);
- case T_UINT64: return mk_uint64(~*(uint64_t*)aptr);
+ case T_S8: return fixnum(~*(int8_t *)aptr);
+ case T_U8: return fixnum(~*(uint8_t *)aptr & 0xff);
+ case T_S16: return fixnum(~*(int16_t *)aptr);
+ case T_U16: return fixnum(~*(uint16_t*)aptr & 0xffff);
+ case T_S32: return mk_s32(~*(int32_t *)aptr);
+ case T_U32: return mk_u32(~*(uint32_t*)aptr);
+ case T_S64: return mk_s64(~*(int64_t *)aptr);
+ case T_U64: return mk_u64(~*(uint64_t*)aptr);
}
}
if(iscvalue(a)){
@@ -1236,10 +1236,10 @@
cvalue_t *cv = ptr(a);
ta = cp_numtype(cv);
aptr = cv_data(cv);
- if(ta == T_MPINT){
+ if(ta == T_MP){
mpint *m = mpnew(0);
mpnot(*(mpint**)aptr, m);
- return mk_mpint(m);
+ return mk_mp(m);
}
}
type_error("integer", a);
@@ -1261,7 +1261,7 @@
if(n <= 0)
return fixnum(numval(a)>>(-n));
accum = ((int64_t)numval(a))<<n;
- return fits_fixnum(accum) ? fixnum(accum) : return_from_int64(accum);
+ return fits_fixnum(accum) ? fixnum(accum) : return_from_s64(accum);
}
if(iscprim(a) || iscvalue(a)){
if(n == 0)
@@ -1272,31 +1272,31 @@
if(n < 0){
n = -n;
switch(ta){
- case T_INT8: return fixnum((*(int8_t *)aptr) >> n);
- case T_UINT8: return fixnum((*(uint8_t *)aptr) >> n);
- case T_INT16: return fixnum((*(int16_t *)aptr) >> n);
- case T_UINT16: return fixnum((*(uint16_t*)aptr) >> n);
- case T_INT32: return mk_int32((*(int32_t *)aptr) >> n);
- case T_UINT32: return mk_uint32((*(uint32_t*)aptr) >> n);
- case T_INT64: return mk_int64((*(int64_t *)aptr) >> n);
- case T_UINT64: return mk_uint64((*(uint64_t*)aptr) >> n);
- case T_MPINT:
+ case T_S8: return fixnum((*(int8_t *)aptr) >> n);
+ case T_U8: return fixnum((*(uint8_t *)aptr) >> n);
+ case T_S16: return fixnum((*(int16_t *)aptr) >> n);
+ case T_U16: return fixnum((*(uint16_t*)aptr) >> n);
+ case T_S32: return mk_s32((*(int32_t *)aptr) >> n);
+ case T_U32: return mk_u32((*(uint32_t*)aptr) >> n);
+ case T_S64: return mk_s64((*(int64_t *)aptr) >> n);
+ case T_U64: return mk_u64((*(uint64_t*)aptr) >> n);
+ case T_MP:
aptr = cv_data(cp);
mp = mpnew(0);
mpright(*(mpint**)aptr, n, mp);
- return mk_mpint(mp);
+ return mk_mp(mp);
}
}
- if(ta == T_MPINT){
+ if(ta == T_MP){
aptr = cv_data(cp);
mp = mpnew(0);
mpleft(*(mpint**)aptr, n, mp);
- return mk_mpint(mp);
+ return mk_mp(mp);
}
- if(ta == T_UINT64)
- return return_from_uint64((*(uint64_t*)aptr)<<n);
+ if(ta == T_U64)
+ return return_from_u64((*(uint64_t*)aptr)<<n);
if(ta < T_FLOAT)
- return return_from_int64(conv_to_int64(aptr, ta)<<n);
+ return return_from_s64(conv_to_s64(aptr, ta)<<n);
}
type_error("integer", a);
}
@@ -1309,16 +1309,16 @@
SL(builtintype) = define_opaque_type(sl_builtinsym, sizeof(builtin_t), nil, nil);
- ctor_cv_intern(int8, T_INT8, int8_t);
- ctor_cv_intern(uint8, T_UINT8, uint8_t);
- ctor_cv_intern(int16, T_INT16, int16_t);
- ctor_cv_intern(uint16, T_UINT16, uint16_t);
- ctor_cv_intern(int32, T_INT32, int32_t);
- ctor_cv_intern(uint32, T_UINT32, uint32_t);
- ctor_cv_intern(int64, T_INT64, int64_t);
- ctor_cv_intern(uint64, T_UINT64, uint64_t);
- ctor_cv_intern(byte, T_UINT8, uint8_t);
- ctor_cv_intern(rune, T_UINT32, uint32_t);
+ ctor_cv_intern(s8, T_S8, int8_t);
+ ctor_cv_intern(u8, T_U8, uint8_t);
+ ctor_cv_intern(s16, T_S16, int16_t);
+ ctor_cv_intern(u16, T_U16, uint16_t);
+ ctor_cv_intern(s32, T_S32, int32_t);
+ ctor_cv_intern(u32, T_U32, uint32_t);
+ ctor_cv_intern(s64, T_S64, int64_t);
+ ctor_cv_intern(u64, T_U64, uint64_t);
+ ctor_cv_intern(byte, T_U8, uint8_t);
+ ctor_cv_intern(rune, T_U32, uint32_t);
ctor_cv_intern(float, T_FLOAT, float);
ctor_cv_intern(double, T_DOUBLE, double);
@@ -1330,23 +1330,23 @@
sl_runestringtypesym = csymbol("*runestring-type*");
setc(sl_runestringtypesym, sl_list2(sl_arraysym, sl_runesym));
- mk_primtype(int8, int8_t);
- mk_primtype(uint8, uint8_t);
- mk_primtype(int16, int16_t);
- mk_primtype(uint16, uint16_t);
- mk_primtype(int32, int32_t);
- mk_primtype(uint32, uint32_t);
- mk_primtype(int64, int64_t);
- mk_primtype(uint64, uint64_t);
+ mk_primtype(s8, int8_t);
+ mk_primtype(u8, uint8_t);
+ mk_primtype(s16, int16_t);
+ mk_primtype(u16, uint16_t);
+ mk_primtype(s32, int32_t);
+ mk_primtype(u32, uint32_t);
+ mk_primtype(s64, int64_t);
+ mk_primtype(u64, uint64_t);
mk_primtype(byte, uint8_t);
mk_primtype(rune, uint32_t);
mk_primtype(float, float);
mk_primtype(double, double);
- ctor_cv_intern(bignum, T_MPINT, mpint*);
- SL(mpinttype) = get_type(sl_bignumsym);
- SL(mpinttype)->init = cvalue_mpint_init;
- SL(mpinttype)->vtable = &mpint_vtable;
+ ctor_cv_intern(bignum, T_MP, mpint*);
+ SL(mptype) = get_type(sl_bignumsym);
+ SL(mptype)->init = cvalue_mp_init;
+ SL(mptype)->vtable = &mp_vtable;
SL(stringtype) = get_type(symbol_value(sl_stringtypesym));
SL(the_empty_string) = cvalue_from_ref(SL(stringtype), (char*)"", 0);
--- a/src/cvalues.h
+++ b/src/cvalues.h
@@ -33,8 +33,8 @@
value_t cvalue_array_aref(value_t *args);
value_t cvalue_array_aset(value_t *args);
value_t cbuiltin(const char *name, builtin_t f);
-value_t return_from_uint64(uint64_t Uaccum);
-value_t return_from_int64(int64_t Saccum);
+value_t return_from_u64(uint64_t Uaccum);
+value_t return_from_s64(int64_t Saccum);
value_t sl_add_any(value_t *args, uint32_t nargs);
value_t sl_neg(value_t n);
value_t sl_mul_any(value_t *args, uint32_t nargs);
@@ -46,11 +46,11 @@
value_t mk_double(double n);
value_t mk_float(float n);
-value_t mk_int32(int32_t n);
-value_t mk_uint32(uint32_t n);
-value_t mk_int64(int64_t n);
-value_t mk_uint64(uint64_t n);
+value_t mk_s32(int32_t n);
+value_t mk_u32(uint32_t n);
+value_t mk_s64(int64_t n);
+value_t mk_u64(uint64_t n);
value_t mk_rune(Rune n);
-value_t mk_mpint(mpint *n);
+value_t mk_mp(mpint *n);
size_t llength(value_t v) sl_purefn;
--- a/src/docs_extra.lsp
+++ b/src/docs_extra.lsp
@@ -35,10 +35,10 @@
(doc-for (rand)
"Return a random non-negative fixnum on its maximum range.")
-(doc-for (rand-uint64)
+(doc-for (rand-u64)
"Return a random integer on [0, 2⁶⁴-1] interval.")
-(doc-for (rand-uint32)
+(doc-for (rand-u32)
"Return a random integer on [0, 2³²-1] interval.")
(doc-for (rand-double)
--- a/src/equal.c
+++ b/src/equal.c
@@ -353,7 +353,7 @@
case TAG_CVALUE:
cv = ptr(a);
data = cv_data(cv);
- if(cv->type == SL(mpinttype)){
+ if(cv->type == SL(mptype)){
len = mptobe(*(mpint**)data, nil, 0, (uint8_t**)&data);
h = memhash(data, len);
MEM_FREE(data);
--- a/src/iostream.c
+++ b/src/iostream.c
@@ -167,7 +167,7 @@
off_t res = ios_skip(s, off);
if(res < 0)
return sl_nil;
- return sizeof(res) == sizeof(int64_t) ? mk_int64(res) : mk_int32(res);
+ return sizeof(res) == sizeof(int64_t) ? mk_s64(res) : mk_s32(res);
}
BUILTIN("io-flush", io_flush)
--- a/src/operators.c
+++ b/src/operators.c
@@ -2,18 +2,18 @@
#include "operators.h"
mpint *
-conv_to_mpint(void *data, numerictype_t tag)
+conv_to_mp(void *data, numerictype_t tag)
{
switch(tag){
- case T_INT8: return itomp(*(int8_t*)data, nil);
- case T_UINT8: return uitomp(*(uint8_t*)data, nil);
- case T_INT16: return itomp(*(int16_t*)data, nil);
- case T_UINT16: return uitomp(*(uint16_t*)data, nil);
- case T_INT32: return itomp(*(int32_t*)data, nil);
- case T_UINT32: return uitomp(*(uint32_t*)data, nil);
- case T_INT64: return vtomp(*(int64_t*)data, nil);
- case T_UINT64: return uvtomp(*(uint64_t*)data, nil);
- case T_MPINT: return mpcopy(*(mpint**)data);
+ case T_S8: return itomp(*(int8_t*)data, nil);
+ case T_U8: return uitomp(*(uint8_t*)data, nil);
+ case T_S16: return itomp(*(int16_t*)data, nil);
+ case T_U16: return uitomp(*(uint16_t*)data, nil);
+ case T_S32: return itomp(*(int32_t*)data, nil);
+ case T_U32: return uitomp(*(uint32_t*)data, nil);
+ case T_S64: return vtomp(*(int64_t*)data, nil);
+ case T_U64: return uvtomp(*(uint64_t*)data, nil);
+ case T_MP: return mpcopy(*(mpint**)data);
case T_FLOAT: return dtomp(*(float*)data, nil);
case T_DOUBLE: return dtomp(*(double*)data, nil);
}
@@ -26,19 +26,19 @@
{
double d;
switch(tag){
- case T_INT8: return *(int8_t*)data;
- case T_UINT8: return *(uint8_t*)data;
- case T_INT16: return *(int16_t*)data;
- case T_UINT16: return *(uint16_t*)data;
- case T_INT32: return *(int32_t*)data;
- case T_UINT32: return *(uint32_t*)data;
- case T_INT64:
+ case T_S8: return *(int8_t*)data;
+ case T_U8: return *(uint8_t*)data;
+ case T_S16: return *(int16_t*)data;
+ case T_U16: return *(uint16_t*)data;
+ case T_S32: return *(int32_t*)data;
+ case T_U32: return *(uint32_t*)data;
+ case T_S64:
d = *(int64_t*)data;
if(d > 0 && *(int64_t*)data < 0) // can happen!
d = -d;
return d;
- case T_UINT64: return *(uint64_t*)data;
- case T_MPINT: return mptod(*(mpint**)data);
+ case T_U64: return *(uint64_t*)data;
+ case T_MP: return mptod(*(mpint**)data);
case T_FLOAT: return *(float*)data;
case T_DOUBLE: return *(double*)data;
}
@@ -52,15 +52,15 @@
conv_to_##name(void *data, numerictype_t tag) \
{ \
switch(tag){ \
- case T_INT8: return (ctype)*(int8_t*)data; \
- case T_UINT8: return (ctype)*(uint8_t*)data; \
- case T_INT16: return (ctype)*(int16_t*)data; \
- case T_UINT16: return (ctype)*(uint16_t*)data; \
- case T_INT32: return (ctype)*(int32_t*)data; \
- case T_UINT32: return (ctype)*(uint32_t*)data; \
- case T_INT64: return (ctype)*(int64_t*)data; \
- case T_UINT64: return (ctype)*(uint64_t*)data; \
- case T_MPINT: return (ctype)mptov(*(mpint**)data); \
+ case T_S8: return (ctype)*(int8_t*)data; \
+ case T_U8: return (ctype)*(uint8_t*)data; \
+ case T_S16: return (ctype)*(int16_t*)data; \
+ case T_U16: return (ctype)*(uint16_t*)data; \
+ case T_S32: return (ctype)*(int32_t*)data; \
+ case T_U32: return (ctype)*(uint32_t*)data; \
+ case T_S64: return (ctype)*(int64_t*)data; \
+ case T_U64: return (ctype)*(uint64_t*)data; \
+ case T_MP: return (ctype)mptov(*(mpint**)data); \
case T_FLOAT: return (ctype)*(float*)data; \
case T_DOUBLE: return (ctype)*(double*)data; \
} \
@@ -67,9 +67,9 @@
return 0; \
}
-CONV_TO_INTTYPE(int64, int64_t)
-CONV_TO_INTTYPE(int32, int32_t)
-CONV_TO_INTTYPE(uint32, uint32_t)
+CONV_TO_INTTYPE(s64, int64_t)
+CONV_TO_INTTYPE(s32, int32_t)
+CONV_TO_INTTYPE(u32, uint32_t)
// this is needed to work around an UB casting negative
// floats and doubles to uint64. you need to cast to int64
@@ -76,19 +76,19 @@
// first.
sl_purefn
uint64_t
-conv_to_uint64(void *data, numerictype_t tag)
+conv_to_u64(void *data, numerictype_t tag)
{
int64_t s;
switch(tag){
- case T_INT8: return *(int8_t*)data; break;
- case T_UINT8: return *(uint8_t*)data; break;
- case T_INT16: return *(int16_t*)data; break;
- case T_UINT16: return *(uint16_t*)data; break;
- case T_INT32: return *(int32_t*)data; break;
- case T_UINT32: return *(uint32_t*)data; break;
- case T_INT64: return *(int64_t*)data; break;
- case T_UINT64: return *(uint64_t*)data; break;
- case T_MPINT: return mptouv(*(mpint**)data); break;
+ case T_S8: return *(int8_t*)data; break;
+ case T_U8: return *(uint8_t*)data; break;
+ case T_S16: return *(int16_t*)data; break;
+ case T_U16: return *(uint16_t*)data; break;
+ case T_S32: return *(int32_t*)data; break;
+ case T_U32: return *(uint32_t*)data; break;
+ case T_S64: return *(int64_t*)data; break;
+ case T_U64: return *(uint64_t*)data; break;
+ case T_MP: return mptouv(*(mpint**)data); break;
case T_FLOAT:
if(*(float*)data >= 0)
return *(float*)data;
@@ -108,15 +108,15 @@
cmp_same_lt(void *a, void *b, numerictype_t tag)
{
switch(tag){
- case T_INT8: return *(int8_t*)a < *(int8_t*)b;
- case T_UINT8: return *(uint8_t*)a < *(uint8_t*)b;
- case T_INT16: return *(int16_t*)a < *(int16_t*)b;
- case T_UINT16: return *(uint16_t*)a < *(uint16_t*)b;
- case T_INT32: return *(int32_t*)a < *(int32_t*)b;
- case T_UINT32: return *(uint32_t*)a < *(uint32_t*)b;
- case T_INT64: return *(int64_t*)a < *(int64_t*)b;
- case T_UINT64: return *(uint64_t*)a < *(uint64_t*)b;
- case T_MPINT: return mpcmp(*(mpint**)a, *(mpint**)b) < 0;
+ case T_S8: return *(int8_t*)a < *(int8_t*)b;
+ case T_U8: return *(uint8_t*)a < *(uint8_t*)b;
+ case T_S16: return *(int16_t*)a < *(int16_t*)b;
+ case T_U16: return *(uint16_t*)a < *(uint16_t*)b;
+ case T_S32: return *(int32_t*)a < *(int32_t*)b;
+ case T_U32: return *(uint32_t*)a < *(uint32_t*)b;
+ case T_S64: return *(int64_t*)a < *(int64_t*)b;
+ case T_U64: return *(uint64_t*)a < *(uint64_t*)b;
+ case T_MP: return mpcmp(*(mpint**)a, *(mpint**)b) < 0;
case T_FLOAT: return *(float*)a < *(float*)b;
case T_DOUBLE: return *(double*)a < *(double*)b;
}
@@ -128,15 +128,15 @@
cmp_same_eq(void *a, void *b, numerictype_t tag)
{
switch(tag){
- case T_INT8: return *(int8_t*)a == *(int8_t*)b;
- case T_UINT8: return *(uint8_t*)a == *(uint8_t*)b;
- case T_INT16: return *(int16_t*)a == *(int16_t*)b;
- case T_UINT16: return *(uint16_t*)a == *(uint16_t*)b;
- case T_INT32: return *(int32_t*)a == *(int32_t*)b;
- case T_UINT32: return *(uint32_t*)a == *(uint32_t*)b;
- case T_INT64: return *(int64_t*)a == *(int64_t*)b;
- case T_UINT64: return *(uint64_t*)a == *(uint64_t*)b;
- case T_MPINT: return mpcmp(*(mpint**)a, *(mpint**)b) == 0;
+ case T_S8: return *(int8_t*)a == *(int8_t*)b;
+ case T_U8: return *(uint8_t*)a == *(uint8_t*)b;
+ case T_S16: return *(int16_t*)a == *(int16_t*)b;
+ case T_U16: return *(uint16_t*)a == *(uint16_t*)b;
+ case T_S32: return *(int32_t*)a == *(int32_t*)b;
+ case T_U32: return *(uint32_t*)a == *(uint32_t*)b;
+ case T_S64: return *(int64_t*)a == *(int64_t*)b;
+ case T_U64: return *(uint64_t*)a == *(uint64_t*)b;
+ case T_MP: return mpcmp(*(mpint**)a, *(mpint**)b) == 0;
case T_FLOAT: return *(float*)a == *(float*)b && !isnan(*(float*)a);
case T_DOUBLE: return *(double*)a == *(double*)b && !isnan(*(double*)b);
}
@@ -165,35 +165,35 @@
if(db < da)
return false;
- if(cmpmpint == nil && (atag == T_MPINT || btag == T_MPINT))
+ if(cmpmpint == nil && (atag == T_MP || btag == T_MP))
cmpmpint = mpnew(0);
- if(atag == T_UINT64){
- if(btag == T_INT64)
+ if(atag == T_U64){
+ if(btag == T_S64)
return *(int64_t*)b >= 0 && *(uint64_t*)a < (uint64_t)*(int64_t*)b;
if(btag == T_DOUBLE)
return db >= 0 ? *(uint64_t*)a < (uint64_t)*(double*)b : 0;
- if(btag == T_MPINT)
+ if(btag == T_MP)
return mpcmp(uvtomp(*(uint64_t*)a, cmpmpint), *(mpint**)b) < 0;
}
- if(atag == T_INT64){
- if(btag == T_UINT64)
+ if(atag == T_S64){
+ if(btag == T_U64)
return *(int64_t*)a >= 0 && (uint64_t)*(int64_t*)a < *(uint64_t*)b;
if(btag == T_DOUBLE)
return db == db ? *(int64_t*)a < (int64_t)*(double*)b : 0;
- if(btag == T_MPINT)
+ if(btag == T_MP)
return mpcmp(vtomp(*(int64_t*)a, cmpmpint), *(mpint**)b) < 0;
}
- if(btag == T_UINT64){
+ if(btag == T_U64){
if(atag == T_DOUBLE)
return da >= 0 ? *(uint64_t*)b > (uint64_t)*(double*)a : 0;
- if(atag == T_MPINT)
+ if(atag == T_MP)
return mpcmp(*(mpint**)a, uvtomp(*(uint64_t*)b, cmpmpint)) < 0;
}
- if(btag == T_INT64){
+ if(btag == T_S64){
if(atag == T_DOUBLE)
return da == da ? *(int64_t*)b > (int64_t)*(double*)a : 0;
- if(atag == T_MPINT)
+ if(atag == T_MP)
return mpcmp(*(mpint**)a, vtomp(*(int64_t*)b, cmpmpint)) < 0;
}
return false;
@@ -224,41 +224,41 @@
if(da != db)
return false;
- if(cmpmpint == nil && (atag == T_MPINT || btag == T_MPINT))
+ if(cmpmpint == nil && (atag == T_MP || btag == T_MP))
cmpmpint = mpnew(0);
- if(atag == T_UINT64){
+ if(atag == T_U64){
// this is safe because if a had been bigger than INT64_MAX,
// we would already have concluded that it's bigger than b.
- if(btag == T_INT64)
+ if(btag == T_S64)
return *(int64_t*)b >= 0 && *(uint64_t*)a == *(uint64_t*)b;
if(btag == T_DOUBLE)
return *(double*)b >= 0 && *(uint64_t*)a == (uint64_t)*(double*)b;
- if(btag == T_MPINT)
+ if(btag == T_MP)
return mpcmp(uvtomp(*(uint64_t*)a, cmpmpint), *(mpint**)b) == 0;
}
- if(atag == T_INT64){
- if(btag == T_UINT64)
+ if(atag == T_S64){
+ if(btag == T_U64)
return *(int64_t*)a >= 0 && *(uint64_t*)a == *(uint64_t*)b;
if(btag == T_DOUBLE)
return *(int64_t*)a == (int64_t)*(double*)b;
- if(btag == T_MPINT)
+ if(btag == T_MP)
return mpcmp(vtomp(*(int64_t*)a, cmpmpint), *(mpint**)b) == 0;
}
- if(btag == T_UINT64){
- if(atag == T_INT64)
+ if(btag == T_U64){
+ if(atag == T_S64)
return *(int64_t*)a >= 0 && *(uint64_t*)b == *(uint64_t*)a;
if(atag == T_DOUBLE)
return *(double*)a >= 0 && *(uint64_t*)b == (uint64_t)*(double*)a;
- if(atag == T_MPINT)
+ if(atag == T_MP)
return mpcmp(*(mpint**)a, uvtomp(*(uint64_t*)b, cmpmpint)) == 0;
}
- if(btag == T_INT64){
- if(atag == T_UINT64)
+ if(btag == T_S64){
+ if(atag == T_U64)
return *(int64_t*)b >= 0 && *(uint64_t*)b == *(uint64_t*)a;
if(atag == T_DOUBLE)
return *(int64_t*)b == (int64_t)*(double*)a;
- if(atag == T_MPINT)
+ if(atag == T_MP)
return mpcmp(*(mpint**)a, vtomp(*(int64_t*)b, cmpmpint)) == 0;
}
return true;
--- a/src/operators.h
+++ b/src/operators.h
@@ -1,6 +1,6 @@
#pragma once
-mpint * conv_to_mpint(void *data, numerictype_t tag);
+mpint *conv_to_mp(void *data, numerictype_t tag);
double conv_to_double(void *data, numerictype_t tag);
bool cmp_same_lt(void *a, void *b, numerictype_t tag);
@@ -8,8 +8,8 @@
bool cmp_lt(void *a, numerictype_t atag, void *b, numerictype_t btag);
bool cmp_eq(void *a, numerictype_t atag, void *b, numerictype_t btag, bool equalnans);
-int64_t conv_to_int64(void *data, numerictype_t tag);
-uint64_t conv_to_uint64(void *data, numerictype_t tag);
-int32_t conv_to_int32(void *data, numerictype_t tag);
-uint32_t conv_to_uint32(void *data, numerictype_t tag);
+int64_t conv_to_s64(void *data, numerictype_t tag);
+uint64_t conv_to_u64(void *data, numerictype_t tag);
+int32_t conv_to_s32(void *data, numerictype_t tag);
+uint32_t conv_to_u32(void *data, numerictype_t tag);
Rune conv_to_Rune(void *data, numerictype_t tag);
--- a/src/print.c
+++ b/src/print.c
@@ -635,7 +635,7 @@
}
// 'weak' means we don't need to accurately reproduce the type, so
-// for example #int32(0) can be printed as just 0. this is used
+// for example #s32(0) can be printed as just 0. this is used
// printing in a context where a type is already implied, e.g. inside
// an array.
static void
@@ -717,7 +717,7 @@
if(type == sl_floatsym && !SL(print_princ) && !weak)
outc(f, 'f');
}
- }else if(type == sl_uint64sym){
+ }else if(type == sl_u64sym){
uint64_t ui64 = *(uint64_t*)data;
if(weak || SL(print_princ))
SL(hpos) += ios_printf(f, "%"PRIu64, ui64);
@@ -733,7 +733,7 @@
// at this point, so int64 is big enough to capture everything.
numerictype_t nt = sym_to_numtype(type);
if(valid_numtype(nt)){
- int64_t i64 = conv_to_int64(data, nt);
+ int64_t i64 = conv_to_s64(data, nt);
if(weak || SL(print_princ))
SL(hpos) += ios_printf(f, "%"PRId64, i64);
else
@@ -787,7 +787,7 @@
return;
}
if(!weak){
- if(eltype == sl_uint8sym){
+ if(eltype == sl_u8sym){
outsn(f, "#vu8(", 5);
}else{
outsn(f, "#array(", 7);
--- a/src/random.c
+++ b/src/random.c
@@ -23,16 +23,16 @@
#endif
}
-BUILTIN("rand-uint32", rand_uint32)
+BUILTIN("rand-u32", rand_u32)
{
USED(args); USED(nargs);
- return mk_uint32(genrand64_int64(&ctx) >> 32);
+ return mk_u32(genrand64_int64(&ctx) >> 32);
}
-BUILTIN("rand-uint64", rand_uint64)
+BUILTIN("rand-u64", rand_u64)
{
USED(args); USED(nargs);
- return mk_uint64(genrand64_int64(&ctx));
+ return mk_u64(genrand64_int64(&ctx));
}
BUILTIN("rand-double", rand_double)
--- a/src/read.c
+++ b/src/read.c
@@ -83,7 +83,7 @@
if(fits_fixnum(i64))
*pval = fixnum(i64);
else if((m = strtomp(tok, &end, base, nil)) != nil)
- *pval = mk_mpint(m);
+ *pval = mk_mp(m);
else
return false;
}
@@ -665,7 +665,7 @@
read_list(ctx, UNBOUND, TOK_CLOSE);
if(sym == sl_vu8sym){
sym = sl_arraysym;
- SL(sp)[-1] = sl_cons(sl_uint8sym, SL(sp)[-1]);
+ SL(sp)[-1] = sl_cons(sl_u8sym, SL(sp)[-1]);
}else if(sym == sl_fnsym){
sym = sl_function;
}
--- a/src/sl.c
+++ b/src/sl.c
@@ -26,8 +26,8 @@
value_t sl_tablesym, sl_arraysym;
value_t sl_iostreamsym, sl_rdsym, sl_wrsym, sl_apsym, sl_crsym, sl_truncsym;
value_t sl_instrsym, sl_outstrsym;
-value_t sl_int8sym, sl_uint8sym, sl_int16sym, sl_uint16sym, sl_int32sym, sl_uint32sym;
-value_t sl_int64sym, sl_uint64sym, sl_bignumsym;
+value_t sl_s8sym, sl_u8sym, sl_s16sym, sl_u16sym, sl_s32sym, sl_u32sym;
+value_t sl_s64sym, sl_u64sym, sl_bignumsym;
value_t sl_bytesym, sl_runesym, sl_floatsym, sl_doublesym;
value_t sl_stringtypesym, sl_runestringtypesym;
@@ -667,7 +667,7 @@
bool
sl_isnumber(value_t v)
{
- if(isfixnum(v) || ismpint(v))
+ if(isfixnum(v) || ismp(v))
return true;
if(iscprim(v)){
cprim_t *c = ptr(v);
@@ -822,11 +822,11 @@
}
#if BYTE_ORDER == LITTLE_ENDIAN && defined(MEM_UNALIGNED_ACCESS)
-#define GET_INT32(a) *(const int32_t*)(a)
-#define GET_INT16(a) *(const int16_t*)(a)
+#define GET_S32(a) *(const int32_t*)(a)
+#define GET_S16(a) *(const int16_t*)(a)
#else
-#define GET_INT32(a) (int32_t)((a)[0]<<0 | (a)[1]<<8 | (a)[2]<<16 | (uint32_t)(a)[3]<<24)
-#define GET_INT16(a) (int16_t)((a)[0]<<0 | (a)[1]<<8)
+#define GET_S32(a) (int32_t)((a)[0]<<0 | (a)[1]<<8 | (a)[2]<<16 | (uint32_t)(a)[3]<<24)
+#define GET_S16(a) (int16_t)((a)[0]<<0 | (a)[1]<<8)
#endif
/*
--- a/src/sl.h
+++ b/src/sl.h
@@ -30,11 +30,11 @@
};
typedef enum {
- T_INT8, T_UINT8,
- T_INT16, T_UINT16,
- T_INT32, T_UINT32,
- T_INT64, T_UINT64,
- T_MPINT,
+ T_S8, T_U8,
+ T_S16, T_U16,
+ T_S32, T_U32,
+ T_S64, T_U64,
+ T_MP,
T_FLOAT,
T_DOUBLE,
}numerictype_t;
@@ -45,13 +45,13 @@
typedef int64_t fixnum_t;
#define FIXNUM_BITS 62
#define TOP_BIT (1ULL<<63)
-#define T_FIXNUM T_INT64
+#define T_FIXNUM T_S64
#define PRIdFIXNUM PRId64
#else
typedef int32_t fixnum_t;
#define FIXNUM_BITS 30
#define TOP_BIT (1U<<31)
-#define T_FIXNUM T_INT32
+#define T_FIXNUM T_S32
#define PRIdFIXNUM PRId32
#endif
@@ -329,8 +329,8 @@
// WARNING: multiple evaluation!
#define cptr(v) (iscprim(v) ? cp_data(ptr(v)) : cvalue_data(v))
-#define ismpint(v) (iscvalue(v) && cp_numtype(ptr(v)) == T_MPINT)
-#define tompint(v) (*(mpint**)cv_data(ptr(v)))
+#define ismp(v) (iscvalue(v) && cp_numtype(ptr(v)) == T_MP)
+#define tomp(v) (*(mpint**)cv_data(ptr(v)))
#define BUILTIN(lname, cname) \
value_t fn_builtin_##cname(value_t *args, int nargs)
@@ -387,11 +387,11 @@
value_t the_empty_string;
value_t memory_exception_value;
- sltype_t *mpinttype;
- sltype_t *int8type, *uint8type;
- sltype_t *int16type, *uint16type;
- sltype_t *int32type, *uint32type;
- sltype_t *int64type, *uint64type;
+ sltype_t *mptype;
+ sltype_t *s8type, *u8type;
+ sltype_t *s16type, *u16type;
+ sltype_t *s32type, *u32type;
+ sltype_t *s64type, *u64type;
sltype_t *floattype, *doubletype;
sltype_t *bytetype, *runetype;
sltype_t *stringtype, *runestringtype;
@@ -444,8 +444,8 @@
extern value_t sl_arraysym;
extern value_t sl_iostreamsym, sl_rdsym, sl_wrsym, sl_apsym, sl_crsym, sl_truncsym;
extern value_t sl_instrsym, sl_outstrsym;
-extern value_t sl_int8sym, sl_uint8sym, sl_int16sym, sl_uint16sym, sl_int32sym, sl_uint32sym;
-extern value_t sl_int64sym, sl_uint64sym, sl_bignumsym;
+extern value_t sl_s8sym, sl_u8sym, sl_s16sym, sl_u16sym, sl_s32sym, sl_u32sym;
+extern value_t sl_s64sym, sl_u64sym, sl_bignumsym;
extern value_t sl_bytesym, sl_runesym, sl_floatsym, sl_doublesym;
extern value_t sl_stringtypesym, sl_runestringtypesym;
--- a/src/sl_arith_any.inc
+++ b/src/sl_arith_any.inc
@@ -37,14 +37,14 @@
switch(pt){
case T_DOUBLE: Faccum = ARITH_OP(Faccum, *(double*)a); inexact = true; continue;
case T_FLOAT: Faccum = ARITH_OP(Faccum, *(float*)a); inexact = true; continue;
- case T_INT8: x = *(int8_t*)a; break;
- case T_UINT8: x = *(uint8_t*)a; break;
- case T_INT16: x = *(int16_t*)a; break;
- case T_UINT16: x = *(uint16_t*)a; break;
- case T_INT32: x = *(int32_t*)a; break;
- case T_UINT32: x = *(uint32_t*)a; break;
- case T_INT64: x = *(int64_t*)a; break;
- case T_UINT64:
+ case T_S8: x = *(int8_t*)a; break;
+ case T_U8: x = *(uint8_t*)a; break;
+ case T_S16: x = *(int16_t*)a; break;
+ case T_U16: x = *(uint16_t*)a; break;
+ case T_S32: x = *(int32_t*)a; break;
+ case T_U32: x = *(uint32_t*)a; break;
+ case T_S64: x = *(int64_t*)a; break;
+ case T_U64:
u64 = *(uint64_t*)a;
if(u64 > INT64_MAX){
x = ACCUM_DEFAULT;
@@ -52,7 +52,7 @@
}
x = u64;
break;
- case T_MPINT:
+ case T_MP:
x = ACCUM_DEFAULT;
u64 = ACCUM_DEFAULT;
m = mpcopy(*(mpint**)a);
@@ -107,18 +107,18 @@
switch(pt){
case T_DOUBLE: Faccum = ARITH_OP(Faccum, *(double*)a); inexact = true; continue;
case T_FLOAT: Faccum = ARITH_OP(Faccum, *(float*)a); inexact = true; continue;
- case T_INT8: x = *(int8_t*)a; break;
- case T_UINT8: x = *(uint8_t*)a; break;
- case T_INT16: x = *(int16_t*)a; break;
- case T_UINT16: x = *(uint16_t*)a; break;
- case T_INT32: x = *(int32_t*)a; break;
- case T_UINT32: x = *(uint32_t*)a; break;
- case T_INT64: x = *(int64_t*)a; break;
- case T_UINT64:
+ case T_S8: x = *(int8_t*)a; break;
+ case T_U8: x = *(uint8_t*)a; break;
+ case T_S16: x = *(int16_t*)a; break;
+ case T_U16: x = *(uint16_t*)a; break;
+ case T_S32: x = *(int32_t*)a; break;
+ case T_U32: x = *(uint32_t*)a; break;
+ case T_S64: x = *(int64_t*)a; break;
+ case T_U64:
uvtomp(*(uint64_t*)a, m);
MP_OP(Maccum, m, Maccum);
continue;
- case T_MPINT:
+ case T_MP:
MP_OP(Maccum, *(mpint**)a, Maccum);
continue;
default:
@@ -140,7 +140,7 @@
}
}
mpfree(m);
- return mk_mpint(Maccum);
+ return mk_mp(Maccum);
}
down:
--- a/src/string.c
+++ b/src/string.c
@@ -378,15 +378,15 @@
else if(iscprim(n)){
void *data = ptr(n);
if(cp_numtype(data) < T_FLOAT)
- num = conv_to_uint64(cp_data(data), cp_numtype(data));
+ num = conv_to_u64(cp_data(data), cp_numtype(data));
else if(radix != 10)
lerrorf(sl_errarg, "invalid radix with floating point");
else
return fn_builtin_string(args, nargs);
- }else if(ismpint(n)){
+ }else if(ismp(n)){
if(radix != 16 && radix != 10 && radix != 8 && radix != 4 && radix != 2)
lerrorf(sl_errarg, "invalid radix with bignum");
- mpint *i = tompint(n);
+ mpint *i = tomp(n);
char *s = mptoa(i, radix, nil, 0);
assert(s != nil);
if(radix == 16){ /* FFFF → ffff */
--- a/src/vm.inc
+++ b/src/vm.inc
@@ -1,8 +1,8 @@
#define fixnum_neg(x) ( \
i64 = -(int64_t)(numval(x)), \
i64 == INT64_MIN \
- ? mk_mpint(uvtomp((uint64_t)INT64_MAX+1, nil)) \
- : (fits_fixnum(i64) ? fixnum(i64) : mk_mpint(vtomp(i64, nil))) \
+ ? mk_mp(uvtomp((uint64_t)INT64_MAX+1, nil)) \
+ : (fits_fixnum(i64) ? fixnum(i64) : mk_mp(vtomp(i64, nil))) \
)
OP(OP_LOADA0)
@@ -23,7 +23,7 @@
OP(OP_CALLL)
tail = false;
}
- n = GET_INT32(ip);
+ n = GET_S32(ip);
ip += 4;
}
LABEL(do_call):
@@ -101,7 +101,7 @@
int na = *ip++;
if(0){
OP(OP_ARGCL)
- na = GET_INT32(ip);
+ na = GET_S32(ip);
ip += 4;
}
if(sl_unlikely(nargs != na)){
@@ -142,7 +142,7 @@
NEXT_OP;
OP(OP_BRN)
- ip += *(--sp) == sl_nil ? GET_INT16(ip) : 2;
+ ip += *(--sp) == sl_nil ? GET_S16(ip) : 2;
NEXT_OP;
OP(OP_LOADG) {
@@ -153,7 +153,7 @@
if(0){
OP(OP_LOADGL)
v = fn_vals(bp[-1]);
- v = vector_elt(v, GET_INT32(ip));
+ v = vector_elt(v, GET_S32(ip));
ip += 4;
}
assert(issymbol(v));
@@ -238,7 +238,7 @@
NEXT_OP;
OP(OP_BRNN)
- ip += *(--sp) != sl_nil ? GET_INT16(ip) : 2;
+ ip += *(--sp) != sl_nil ? GET_S16(ip) : 2;
NEXT_OP;
OP(OP_DUP)
@@ -309,7 +309,7 @@
}
OP(OP_BRNE)
- ip += sp[-2] != sp[-1] ? GET_INT16(ip) : 2;
+ ip += sp[-2] != sp[-1] ? GET_S16(ip) : 2;
sp -= 2;
NEXT_OP;
@@ -342,7 +342,7 @@
int i = *ip++;
if(0){
OP(OP_VARGCL)
- i = GET_INT32(ip);
+ i = GET_S32(ip);
ip += 4;
}
fixnum_t s = (fixnum_t)nargs - (fixnum_t)i;
@@ -408,7 +408,7 @@
}
OP(OP_JMP)
- ip += GET_INT16(ip);
+ ip += GET_S16(ip);
NEXT_OP;
OP(OP_ATOMP)
@@ -604,14 +604,14 @@
NEXT_OP;
OP(OP_BRBOUND)
- *sp++ = bp[GET_INT32(ip)] != UNBOUND ? sl_t : sl_nil;
+ *sp++ = bp[GET_S32(ip)] != UNBOUND ? sl_t : sl_nil;
ip += 4;
NEXT_OP;
OP(OP_OPTARGS) {
- int i = GET_INT32(ip);
+ int i = GET_S32(ip);
ip += 4;
- int x = GET_INT32(ip);
+ int x = GET_S32(ip);
ip += 4;
if(sl_unlikely(nargs < i)){
*ipd = (uintptr_t)ip;
@@ -842,7 +842,7 @@
int i = *ip++;
if(0){
OP(OP_SETGL)
- i = GET_INT32(ip);
+ i = GET_S32(ip);
ip += 4;
}
value_t v = fn_vals(bp[-1]);
@@ -883,7 +883,7 @@
OP(OP_LOADAL)
assert(nargs > 0);
- *sp++ = bp[GET_INT32(ip)];
+ *sp++ = bp[GET_S32(ip)];
ip += 4;
NEXT_OP;
@@ -897,11 +897,11 @@
OP(OP_KEYARGS) {
value_t v = fn_vals(bp[-1]);
v = vector_elt(v, 0);
- int i = GET_INT32(ip);
+ int i = GET_S32(ip);
ip += 4;
- int x = GET_INT32(ip);
+ int x = GET_S32(ip);
ip += 4;
- fixnum_t s = GET_INT32(ip);
+ fixnum_t s = GET_S32(ip);
ip += 4;
*ipd = (uintptr_t)ip;
SL(sp) = sp;
@@ -935,16 +935,16 @@
}
OP(OP_BRNL)
- ip += *(--sp) == sl_nil ? GET_INT32(ip) : 4;
+ ip += *(--sp) == sl_nil ? GET_S32(ip) : 4;
NEXT_OP;
OP(OP_SETAL)
- bp[GET_INT32(ip)] = sp[-1];
+ bp[GET_S32(ip)] = sp[-1];
ip += 4;
NEXT_OP;
OP(OP_BOXL) {
- int i = GET_INT32(ip);
+ int i = GET_S32(ip);
ip += 4;
SL(sp) = sp;
value_t v = mk_cons();
@@ -964,27 +964,27 @@
}
OP(OP_JMPL)
- ip += GET_INT32(ip);
+ ip += GET_S32(ip);
NEXT_OP;
OP(OP_BRNEL)
- ip += sp[-2] != sp[-1] ? GET_INT32(ip) : 4;
+ ip += sp[-2] != sp[-1] ? GET_S32(ip) : 4;
sp -= 2;
NEXT_OP;
OP(OP_BRNNL)
- ip += *(--sp) != sl_nil ? GET_INT32(ip) : 4;
+ ip += *(--sp) != sl_nil ? GET_S32(ip) : 4;
NEXT_OP;
OP(OP_LOADCL)
ip += 4;
- *sp++ = vector_elt(bp[nargs], GET_INT32(ip));
+ *sp++ = vector_elt(bp[nargs], GET_S32(ip));
ip += 4;
NEXT_OP;
OP(OP_LOADVL) {
value_t v = fn_vals(bp[-1]);
- v = vector_elt(v, GET_INT32(ip));
+ v = vector_elt(v, GET_S32(ip));
ip += 4;
*sp++ = v;
NEXT_OP;
--- a/test/number-boundaries.lsp
+++ b/test/number-boundaries.lsp
@@ -25,33 +25,33 @@
; TESTS ------------------------------------------------------------------------
(princ "---\n")
-(princ "int8 : " (number-borders int8) "\n")
-(princ "int16 : " (number-borders int16) "\n")
-(princ "int32 : " (number-borders int32) "\n")
-(princ "int64 : " (number-borders int64) "\n")
-(princ "uint8 : " (number-borders uint8) "\n")
-(princ "uint16 : " (number-borders uint16) "\n")
-(princ "uint32 : " (number-borders uint32) "\n")
-(princ "uint64 : " (number-borders uint64) "\n")
+(princ "s8 " (number-borders s8) "\n")
+(princ "s16 " (number-borders s16) "\n")
+(princ "s32 " (number-borders s32) "\n")
+(princ "s64 " (number-borders s64) "\n")
+(princ "u8 " (number-borders u8) "\n")
+(princ "u16 " (number-borders u16) "\n")
+(princ "u32 " (number-borders u32) "\n")
+(princ "u64 " (number-borders u64) "\n")
(princ "---\n")
; add/sub signed
-(assert (= 128 (+ (high-border int8) 1)))
-(assert (= 128 (+ 1 (high-border int8))))
-(assert (= -129 (- (low-border int8) 1)))
-(assert (= 129 (- 1 (low-border int8))))
-(assert (= 32768 (+ (high-border int16) 1)))
-(assert (= 32768 (+ 1 (high-border int16))))
-(assert (= -32769 (- (low-border int16) 1)))
-(assert (= 32769 (- 1 (low-border int16))))
-(assert (= 2147483648 (+ (high-border int32) 1)))
-(assert (= 2147483648 (+ 1 (high-border int32))))
-(assert (= -2147483649 (- (low-border int32) 1)))
-(assert (= 2147483649 (- 1 (low-border int32))))
-(assert (= 9223372036854775808 (+ (high-border int64) 1)))
-(assert (= 9223372036854775808 (+ 1 (high-border int64))))
-(assert (= -9223372036854775809 (- (low-border int64) 1)))
-(assert (= 9223372036854775809 (- 1 (low-border int64))))
+(assert (= 128 (+ (high-border s8) 1)))
+(assert (= 128 (+ 1 (high-border s8))))
+(assert (= -129 (- (low-border s8) 1)))
+(assert (= 129 (- 1 (low-border s8))))
+(assert (= 32768 (+ (high-border s16) 1)))
+(assert (= 32768 (+ 1 (high-border s16))))
+(assert (= -32769 (- (low-border s16) 1)))
+(assert (= 32769 (- 1 (low-border s16))))
+(assert (= 2147483648 (+ (high-border s32) 1)))
+(assert (= 2147483648 (+ 1 (high-border s32))))
+(assert (= -2147483649 (- (low-border s32) 1)))
+(assert (= 2147483649 (- 1 (low-border s32))))
+(assert (= 9223372036854775808 (+ (high-border s64) 1)))
+(assert (= 9223372036854775808 (+ 1 (high-border s64))))
+(assert (= -9223372036854775809 (- (low-border s64) 1)))
+(assert (= 9223372036854775809 (- 1 (low-border s64))))
(assert (= 27670116110564327421 (+ 9223372036854775807 9223372036854775807 9223372036854775807)))
(assert (= -12297829382473033728 (+ -3074457345618258432 -3074457345618258432 -3074457345618258432 -3074457345618258432)))
(assert (= 6148914691236516864 (- -3074457345618258432 -3074457345618258432 -3074457345618258432 -3074457345618258432)))
@@ -80,15 +80,15 @@
(defmacro (int-conv smaller . biggers)
`(void ,@(map (λ (bigger) `(int-conv- ,smaller ,bigger)) biggers)))
-(int-conv int8 int8 uint8 int16 uint16 int32 uint32 int64 uint64 bignum)
-(int-conv int16 int16 uint16 int32 uint32 int64 uint64 bignum)
-(int-conv int32 int32 uint32 int64 uint64 bignum)
-(int-conv int64 int64 uint64 bignum)
+(int-conv s8 s8 u8 s16 u16 s32 u32 s64 u64 bignum)
+(int-conv s16 s16 u16 s32 u32 s64 u64 bignum)
+(int-conv s32 s32 u32 s64 u64 bignum)
+(int-conv s64 s64 u64 bignum)
-(int-conv uint8 uint8 uint16 int16 uint32 int32 uint64 int64 bignum)
-(int-conv uint16 uint16 uint32 int32 uint64 int64 bignum)
-(int-conv uint32 uint64 int64 bignum)
-(int-conv uint64 bignum)
+(int-conv u8 u8 u16 s16 u32 s32 u64 s64 bignum)
+(int-conv u16 u16 u32 s32 u64 s64 bignum)
+(int-conv u32 u64 s64 bignum)
+(int-conv u64 bignum)
(int-conv bignum bignum)
@@ -95,11 +95,11 @@
(defmacro (float-conv- type)
`(let ((l (low-border ,type))
(h (high-border ,type)))
- (if (member ,type (list int64 uint64))
+ (if (member ,type (list s64 u64))
(assert (= 12345 (,type (double 12345))))
(begin (assert (= l (,type (double l))))
(assert (= h (,type (double h))))))
- (if (member ,type (list int32 uint32 int64 uint64))
+ (if (member ,type (list s32 u32 s64 u64))
(assert (= 12345 (,type (float 12345))))
(begin
(assert (= l (,type (float l))))
@@ -108,15 +108,15 @@
(defmacro (float-conv . types)
`(void ,@(map (λ (type) `(float-conv- ,type)) types)))
-(float-conv int8 uint8 int16 uint16 int32 uint32 int64 uint64)
+(float-conv s8 u8 s16 u16 s32 u32 s64 u64)
-(assert (= (low-border int32) (bignum (double (low-border int32)))))
-(assert (= (high-border int32) (bignum (double (high-border int32)))))
-(assert (= (low-border int16) (bignum (float (low-border int16)))))
-(assert (= (high-border int16) (bignum (float (high-border int16)))))
+(assert (= (low-border s32) (bignum (double (low-border s32)))))
+(assert (= (high-border s32) (bignum (double (high-border s32)))))
+(assert (= (low-border s16) (bignum (float (low-border s16)))))
+(assert (= (high-border s16) (bignum (float (high-border s16)))))
-(assert (= (low-border int32) (double (int64 (low-border int32)))))
-(assert (= (high-border int32) (double (int64 (high-border int32)))))
+(assert (= (low-border s32) (double (s64 (low-border s32)))))
+(assert (= (high-border s32) (double (s64 (high-border s32)))))
(assert (= 0.5f (double (float 0.5))))
(assert (= 0.5 (float (double 0.5f))))
@@ -123,66 +123,66 @@
; comparison of different types
-(assert (< (uint64 (1- (high-border int64))) (int64 (high-border int64))))
-(assert (< (int64 (high-border int64)) (uint64 (1+ (high-border int64)))))
-(assert (< (int64 (high-border int64)) (uint64 (1+ (high-border int64)))))
-(assert (< (uint64 (1- (high-border int16))) (float (high-border int16))))
-(assert (< (float (high-border int16)) (uint64 (1+ (high-border int16)))))
-(assert (< (uint64 (1- (high-border int64))) (bignum (high-border int64))))
-(assert (> (uint64 (1+ (high-border int64))) (bignum (high-border int64))))
-(assert (< (int64 (1- (high-border int64))) (bignum (high-border int64))))
-(assert (> (int64 (high-border int64)) (bignum (1- (high-border int64)))))
+(assert (< (u64 (1- (high-border s64))) (s64 (high-border s64))))
+(assert (< (s64 (high-border s64)) (u64 (1+ (high-border s64)))))
+(assert (< (s64 (high-border s64)) (u64 (1+ (high-border s64)))))
+(assert (< (u64 (1- (high-border s16))) (float (high-border s16))))
+(assert (< (float (high-border s16)) (u64 (1+ (high-border s16)))))
+(assert (< (u64 (1- (high-border s64))) (bignum (high-border s64))))
+(assert (> (u64 (1+ (high-border s64))) (bignum (high-border s64))))
+(assert (< (s64 (1- (high-border s64))) (bignum (high-border s64))))
+(assert (> (s64 (high-border s64)) (bignum (1- (high-border s64)))))
-(assert (< (uint64 0) (int64 1)))
-(assert (< (int64 0) (uint64 1)))
-(assert (> (uint64 0) (int64 -1)))
-(assert (< (int64 -1) (uint64 0)))
-(assert (< (uint64 0) (bignum 1)))
-(assert (< (int64 0) (bignum 1)))
-(assert (> (uint64 0) (bignum -1)))
-(assert (> (int64 0) (bignum -1)))
-(assert (< (int64 -1) (bignum 0)))
-(assert (> (uint64 (+ 10 (high-border int64))) (int64 (low-border int64))))
+(assert (< (u64 0) (s64 1)))
+(assert (< (s64 0) (u64 1)))
+(assert (> (u64 0) (s64 -1)))
+(assert (< (s64 -1) (u64 0)))
+(assert (< (u64 0) (bignum 1)))
+(assert (< (s64 0) (bignum 1)))
+(assert (> (u64 0) (bignum -1)))
+(assert (> (s64 0) (bignum -1)))
+(assert (< (s64 -1) (bignum 0)))
+(assert (> (u64 (+ 10 (high-border s64))) (s64 (low-border s64))))
-(assert (= (uint64 1) (int64 1)))
-(assert (= (int64 1) (uint64 1)))
-(assert (/= (uint64 (high-border uint64)) (int64 -1)))
-(assert (/= (int64 -1) (uint64 (high-border uint64))))
+(assert (= (u64 1) (s64 1)))
+(assert (= (s64 1) (u64 1)))
+(assert (/= (u64 (high-border u64)) (s64 -1)))
+(assert (/= (s64 -1) (u64 (high-border u64))))
; add/sub unsigned
-(assert (= 256 (+ (high-border uint8) 1)))
-(assert (= 256 (+ 1 (high-border uint8))))
-(assert (= -1 (- (low-border uint8) 1)))
-(assert (= 1 (- 1 (low-border uint8))))
-(assert (= 65536 (+ (high-border uint16) 1)))
-(assert (= 65536 (+ 1 (high-border uint16))))
-(assert (= -1 (- (low-border uint16) 1)))
-(assert (= 1 (- 1 (low-border uint16))))
-(assert (= 4294967296 (+ (high-border uint32) 1)))
-(assert (= 4294967296 (+ 1 (high-border uint32))))
-(assert (= -1 (- (low-border uint32) 1)))
-(assert (= 1 (- 1 (low-border uint32))))
-(assert (= 18446744073709551616 (+ (high-border uint64) 1)))
-(assert (= 18446744073709551616 (+ 1 (high-border uint64))))
-(assert (= 36893488147419103230 (+ (high-border uint64) (high-border uint64))))
-(assert (= 36893488147419103231 (+ 1 (high-border uint64) (high-border uint64))))
-(assert (= 36893488147419103231 (+ (high-border uint64) 1 (high-border uint64))))
-(assert (= 36893488147419103231 (+ (high-border uint64) (high-border uint64) 1)))
-(assert (= -1 (- (low-border uint64) 1)))
-(assert (= 1 (- 1 (low-border uint64))))
+(assert (= 256 (+ (high-border u8) 1)))
+(assert (= 256 (+ 1 (high-border u8))))
+(assert (= -1 (- (low-border u8) 1)))
+(assert (= 1 (- 1 (low-border u8))))
+(assert (= 65536 (+ (high-border u16) 1)))
+(assert (= 65536 (+ 1 (high-border u16))))
+(assert (= -1 (- (low-border u16) 1)))
+(assert (= 1 (- 1 (low-border u16))))
+(assert (= 4294967296 (+ (high-border u32) 1)))
+(assert (= 4294967296 (+ 1 (high-border u32))))
+(assert (= -1 (- (low-border u32) 1)))
+(assert (= 1 (- 1 (low-border u32))))
+(assert (= 18446744073709551616 (+ (high-border u64) 1)))
+(assert (= 18446744073709551616 (+ 1 (high-border u64))))
+(assert (= 36893488147419103230 (+ (high-border u64) (high-border u64))))
+(assert (= 36893488147419103231 (+ 1 (high-border u64) (high-border u64))))
+(assert (= 36893488147419103231 (+ (high-border u64) 1 (high-border u64))))
+(assert (= 36893488147419103231 (+ (high-border u64) (high-border u64) 1)))
+(assert (= -1 (- (low-border u64) 1)))
+(assert (= 1 (- 1 (low-border u64))))
; mul signed
-(assert (= 18446744073709551614 (* (high-border int64) 2)))
-(assert (= -18446744073709551614 (* (high-border int64) -2)))
-(assert (= 18446744073709551614 (* 2 (high-border int64))))
-(assert (= -18446744073709551616 (* (low-border int64) 2)))
-(assert (= -18446744073709551616 (* 2 (low-border int64))))
+(assert (= 18446744073709551614 (* (high-border s64) 2)))
+(assert (= -18446744073709551614 (* (high-border s64) -2)))
+(assert (= 18446744073709551614 (* 2 (high-border s64))))
+(assert (= -18446744073709551616 (* (low-border s64) 2)))
+(assert (= -18446744073709551616 (* 2 (low-border s64))))
; mul unsigned
-(assert (= 36893488147419103230 (* (high-border uint64) 2)))
-(assert (= 36893488147419103230 (* 2 (high-border uint64))))
-(assert (= -36893488147419103230 (* (high-border uint64) -2)))
-(assert (= -36893488147419103230 (* -2 (high-border uint64))))
+(assert (= 36893488147419103230 (* (high-border u64) 2)))
+(assert (= 36893488147419103230 (* 2 (high-border u64))))
+(assert (= -36893488147419103230 (* (high-border u64) -2)))
+(assert (= -36893488147419103230 (* -2 (high-border u64))))
(princ "all number boundaries tests pass")
(newline)
--- a/test/unittest.lsp
+++ b/test/unittest.lsp
@@ -4,11 +4,11 @@
`(eq? (car e) ',(car what)))))))
(def (every-int n)
- (list (fixnum n) (int8 n) (uint8 n) (int16 n) (uint16 n) (int32 n) (uint32 n)
- (int64 n) (uint64 n) (float n) (double n) (bignum n)))
+ (list (fixnum n) (s8 n) (u8 n) (s16 n) (u16 n) (s32 n) (u32 n)
+ (s64 n) (u64 n) (float n) (double n) (bignum n)))
(def (every-sint n)
- (list (fixnum n) (int8 n) (int16 n) (int32 n) (int64 n) (float n) (double n) (bignum n)))
+ (list (fixnum n) (s8 n) (s16 n) (s32 n) (s64 n) (float n) (double n) (bignum n)))
(def (each f l)
(if (atom? l) ()
@@ -62,21 +62,21 @@
(assert (not (eqv? #\newline 10)))
; tricky cases involving INT32_MIN
-(assert (< (- #uint32(0x80000000)) 0))
-(assert (> (- #int32(0x80000000)) 0))
-(assert (< (- #uint64(0x8000000000000000)) 0))
-(assert (< (- #int64(0x8000000000000000)) 0))
+(assert (< (- #u32(0x80000000)) 0))
+(assert (> (- #s32(0x80000000)) 0))
+(assert (< (- #u64(0x8000000000000000)) 0))
+(assert (< (- #s64(0x8000000000000000)) 0))
; fixnum versions
(assert (= (- -536870912) 536870912))
(assert (= (- -2305843009213693952) 2305843009213693952))
-(assert (not (equal? #int64(0x8000000000000000) #uint64(0x8000000000000000))))
-(assert (equal? (+ #int64(0x4000000000000000) #int64(0x4000000000000000))
- #uint64(0x8000000000000000)))
-(assert (equal? (* 2 #int64(0x4000000000000000))
- #uint64(0x8000000000000000)))
+(assert (not (equal? #s64(0x8000000000000000) #u64(0x8000000000000000))))
+(assert (equal? (+ #s64(0x4000000000000000) #s64(0x4000000000000000))
+ #u64(0x8000000000000000)))
+(assert (equal? (* 2 #s64(0x4000000000000000))
+ #u64(0x8000000000000000)))
-(assert (equal? (uint64 (double -123)) #uint64(0xffffffffffffff85)))
+(assert (equal? (u64 (double -123)) #u64(0xffffffffffffff85)))
(assert (equal? (string 'sym #byte(65) #rune(945) "blah") "symA\u03B1blah"))
(assert (= (length (string #\x0)) 1))
@@ -279,9 +279,9 @@
; cvalues and arrays
(assert (equal? (typeof "") '(array byte)))
(assert-fail (aref #(1) 3) bounds-error)
-(def iarr (array 'int64 32 16 8 7 1))
+(def iarr (array 's64 32 16 8 7 1))
(assert (equal? (aref iarr 0) 32))
-(assert (equal? (aref iarr #int8(3)) 7))
+(assert (equal? (aref iarr #s8(3)) 7))
; gensyms
(assert (gensym? (gensym)))
@@ -619,7 +619,7 @@
(assert-fail (string-find s 0))
(assert (equal? "1.5" (number->string 1.5)))
-(assert (equal? "-3039" (number->string (int16 -12345) 16)))
+(assert (equal? "-3039" (number->string (s16 -12345) 16)))
(assert (equal? "111111111111111111111111111111111" (number->string 111111111111111111111111111111111)))
(assert (equal? "fffffffffffffffffffffffffffffffff" (number->string 0xfffffffffffffffffffffffffffffffff 16)))
@@ -634,10 +634,10 @@
(assert (= (length (byte #\f)) 1))
(assert (= (length #\я) 2))
(assert (= (length #\⁹) 3))
-(assert-fail (= (length (uint8 0)) 1))
-(assert-fail (= (length (uint16 0)) 2))
-(assert-fail (= (length (uint32 0)) 4))
-(assert-fail (= (length (uint64 0)) 4))
+(assert-fail (= (length (u8 0)) 1))
+(assert-fail (= (length (u16 0)) 2))
+(assert-fail (= (length (u32 0)) 4))
+(assert-fail (= (length (u64 0)) 4))
(assert-fail (= (length (bignum 0)) 0))
(assert-fail (symbol 1))
@@ -672,8 +672,8 @@
(assert (= -1.0 (truncate -1.3f)))
(assert (= 1 (truncate (bignum 1))))
(assert (= -1 (truncate (bignum -1))))
-(assert (= 123 (truncate (int64 123))))
-(assert (= -123 (truncate (int8 -123))))
+(assert (= 123 (truncate (s64 123))))
+(assert (= -123 (truncate (s8 -123))))
(assert-fail (truncate "blah"))
(assert-fail (truncate 'blah))
(assert-fail (truncate truncate))
@@ -681,7 +681,7 @@
(assert (= 0 (sin 0)))
(assert (= 0 (sin 0.0)))
(assert (= 0 (sin 0.0f)))
-(assert (= 0 (sin (int64 0))))
+(assert (= 0 (sin (s64 0))))
(assert (= 0 (sin (bignum 0))))
(let ((x (cos 0)))
(assert (and (>= x 0.999999999999999) (<= x 1.0))))
@@ -745,17 +745,17 @@
(assert (and (< Δt 1010000000 ) (> Δt 999000000)))
(gc)
-(let ((ruint32 (table))
- (ruint64 (table))
+(let ((ru32 (table))
+ (ru64 (table))
(rdouble (table))
(rfloat (table)))
(dotimes (i 100)
- (put! ruint32 (rand-uint32) 1)
- (put! ruint64 (rand-uint64) 1)
+ (put! ru32 (rand-u32) 1)
+ (put! ru64 (rand-u64) 1)
(put! rdouble (rand-double) 1)
(put! rfloat (rand-float) 1))
- (assert (< 50 (length ruint32)))
- (assert (< 50 (length ruint64)))
+ (assert (< 50 (length ru32)))
+ (assert (< 50 (length ru64)))
(assert (< 50 (length rdouble)))
(assert (< 50 (length rfloat))))