diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2011-09-26 11:20:08 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2011-09-26 11:20:08 -0700 |
commit | f3fe0151fc4116f0fec40e7454d8866f11908560 (patch) | |
tree | af1a4cee2e429f295b26587ee55463917860b341 /lib.c | |
parent | d8e2644d5ebb3783660b2c9cb7e1d09dac2230f1 (diff) | |
download | txr-f3fe0151fc4116f0fec40e7454d8866f11908560.tar.gz txr-f3fe0151fc4116f0fec40e7454d8866f11908560.tar.bz2 txr-f3fe0151fc4116f0fec40e7454d8866f11908560.zip |
Trie compression. Hash table iteration.
Bugfix in typeof.
* filter.c (trie_compress): New function.
(trie_value_at, trie_lookup_feed_char, filter_string): Handle cons cell
nodes in trie.
(build_filter): Call trie_compress.
* gc.c (cobj_destroy_op): Function renamed to cobj_destroy_stub_op
since it doesn't do anything.
(cobj_destroy_free_op): New function.
* hash.c (struct hash_iter): New type.
(hash_destroy): Function removed.
(hash_ops): Reference to hash_destroy replaced with
cobj_destroy_free_op.
(hash_count, hash_iter_mark, hash_begin, hash_next): New functions.
(hash_iter_ops): New static structure.
* hash.h (hash_count, hash_begin, hash_next): New functions declared.
* lib.c (hash_iter_s): New symbol variable.
(typeof): Bugfix: TAG_LIT type tag not handled.
(vecref): New function.
(obj_init): Initialize hash_iter_s.
* lib.h (cobj_destroy_op): Declaration renamed.
(cobj_destroy_free_op, vecref): New functions declared.
(hash_iter_s): New variable declared.
* stream.c (string_in_ops, byte_in_ops): cobj_destroy_op
renamed to cobj_destroy_stub_op.
Diffstat (limited to 'lib.c')
-rw-r--r-- | lib.c | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -51,7 +51,7 @@ val packages; val system_package, keyword_package, user_package; val null, t, cons_s, str_s, chr_s, num_s, sym_s, pkg_s, fun_s, vec_s; -val stream_s, hash_s, lcons_s, lstr_s, cobj_s; +val stream_s, hash_s, hash_iter_s, lcons_s, lstr_s, cobj_s; val var_s, regex_s, chset_s, set_s, cset_s, wild_s, oneplus_s; val nongreedy_s, compiled_regex_s; val zeroplus_s, optional_s, compl_s, compound_s, or_s, and_s, quasi_s; @@ -117,6 +117,8 @@ val typeof(val obj) return num_s; case TAG_CHR: return chr_s; + case TAG_LIT: + return str_s; case TAG_PTR: if (obj == nil) { return null; @@ -1542,6 +1544,12 @@ val vec_set_fill(val vec, val fill) return vec; } +val vecref(val vec, val ind) +{ + type_check(vec, VEC); + range_bug_unless (c_num(ind) < c_num(vec->v.vec[vec_fill])); + return vec->v.vec[c_num(ind)]; +} val *vecref_l(val vec, val ind) { @@ -2023,6 +2031,7 @@ static void obj_init(void) vec_s = intern(lit("vec"), user_package); stream_s = intern(lit("stream"), user_package); hash_s = intern(lit("hash"), user_package); + hash_iter_s = intern(lit("hash-iter"), user_package); lcons_s = intern(lit("lcons"), user_package); lstr_s = intern(lit("lstr"), user_package); cobj_s = intern(lit("cobj"), user_package); |