diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2012-03-19 02:00:45 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2012-03-19 02:00:45 -0700 |
commit | 16414f430caa17fccb2e15611a367bb9236ac0ee (patch) | |
tree | a7245ff2952647a5106406f99c0dcf243a9a9d58 /lib.h | |
parent | 9d06c8e9b36e94295c62eb0598cff7afae0c5a45 (diff) | |
download | txr-16414f430caa17fccb2e15611a367bb9236ac0ee.tar.gz txr-16414f430caa17fccb2e15611a367bb9236ac0ee.tar.bz2 txr-16414f430caa17fccb2e15611a367bb9236ac0ee.zip |
* configure (uintptr): New variable. Indicates whether unsigned
version of intptr_t is available and should be generated in config.h
as uintptr_t.
* eval.c (eval_init): New intrinsic functions floatp,
integerp, flo-str.
* gc.c (finalize): Handle FLNUM case. Rearranged
cases so that all trivially returning cases are
together.
(mark): Handle FLNUM case.
* hash.c (hash_double): New function.
(equal_hash): Handle FLNUM via hash_double.
(eql_hash): Likewise.
* lib.c: <math.h> is included.
(float_s): New symbol variable.
(code2type, equal): Handle FLNUM case in switch.
(integerp): New function; does the same thing
as integerp before.
(numberp): Returns t for floats.
(flo, floatp, flo_str): New functions.
(obj_init): Initialize new float_s variable.
(obj_print, obj_pprint): Handle FLNUM case in switch.
Printing does not work yet; needs work in stream.c.
* lib.h (enum type): New enumeration FLNUM.
(struct flonum): New struct type.
(union obj): New member, fl.
(float_s, flo, floatp, integerp, flo_str): Declared.
* parser.l (FLO): New token pattern definition.
Scans to a NUMBER token.
Corrected uses of yylval.num to yylval.val.
* parser.y (%union): Removed num member from yystype.
Diffstat (limited to 'lib.h')
-rw-r--r-- | lib.h | 14 |
1 files changed, 12 insertions, 2 deletions
@@ -40,7 +40,7 @@ typedef int_ptr_t cnum; typedef enum type { NIL, NUM = TAG_NUM, CHR = TAG_CHR, LIT = TAG_LIT, CONS, STR, SYM, PKG, FUN, VEC, LCONS, LSTR, COBJ, ENV, - BGNUM + BGNUM, FLNUM } type_t; typedef enum functype @@ -193,6 +193,11 @@ struct bignum { mp_int mp; }; +struct flonum { + type_t type; + double n; +}; + union obj { struct any t; struct cons c; @@ -206,6 +211,7 @@ union obj { struct cobj co; struct env e; struct bignum bn; + struct flonum fl; }; INLINE cnum tag(val obj) { return ((cnum) obj) & TAG_MASK; } @@ -280,7 +286,7 @@ INLINE val chr(wchar_t ch) extern val keyword_package, system_package, user_package; extern val null, t, cons_s, str_s, chr_s, fixnum_s, sym_s, pkg_s, fun_s, vec_s; extern val stream_s, hash_s, hash_iter_s, lcons_s, lstr_s, cobj_s, cptr_s; -extern val env_s, bignum_s; +extern val env_s, bignum_s, float_s; extern val var_s, expr_s, regex_s, chset_s, set_s, cset_s, wild_s, oneplus_s; extern val nongreedy_s, compiled_regex_s; extern val quote_s, qquote_s, unquote_s, splice_s; @@ -378,9 +384,12 @@ val getplist_f(val list, val key, val *found); val proper_plist_to_alist(val list); val improper_plist_to_alist(val list, val boolean_keys); val num(cnum val); +val flo(double val); cnum c_num(val num); val fixnump(val num); val bignump(val num); +val floatp(val num); +val integerp(val num); val numberp(val num); val plus(val anum, val bnum); val plusv(val nlist); @@ -439,6 +448,7 @@ val list_str(val str); val trim_str(val str); val string_lt(val astr, val bstr); val int_str(val str, val base); +val flo_str(val str); val chrp(val chr); wchar_t c_chr(val chr); val chr_isalnum(val ch); |