3 * Copyright 2006,2009 Free Software Foundation, Inc.
5 * This file is part of GNU Radio
7 * GNU Radio is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3, or (at your option)
12 * GNU Radio is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with GNU Radio; see the file COPYING. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street,
20 * Boston, MA 02110-1301, USA.
27 #include <gruel/pmt.h>
29 #include <gruel/msg_accepter.h>
30 #include <gruel/pmt_pool.h>
36 static const int CACHE_LINE_SIZE = 64; // good guess
38 # if (PMT_LOCAL_ALLOCATOR)
40 static pmt_pool global_pmt_pool(sizeof(pmt_pair), CACHE_LINE_SIZE);
43 pmt_base::operator new(size_t size)
45 void *p = global_pmt_pool.malloc();
47 // fprintf(stderr, "pmt_base::new p = %p\n", p);
48 assert((reinterpret_cast<intptr_t>(p) & (CACHE_LINE_SIZE - 1)) == 0);
53 pmt_base::operator delete(void *p, size_t size)
55 global_pmt_pool.free(p);
60 void intrusive_ptr_add_ref(pmt_base* p) { ++(p->count_); }
61 void intrusive_ptr_release(pmt_base* p) { if (--(p->count_) == 0 ) delete p; }
65 // nop -- out of line virtual destructor
68 ////////////////////////////////////////////////////////////////////////////
70 ////////////////////////////////////////////////////////////////////////////
72 pmt_exception::pmt_exception(const std::string &msg, pmt_t obj)
73 : logic_error(msg + ": " + pmt_write_string(obj))
77 pmt_wrong_type::pmt_wrong_type(const std::string &msg, pmt_t obj)
78 : pmt_exception(msg + ": wrong_type ", obj)
82 pmt_out_of_range::pmt_out_of_range(const std::string &msg, pmt_t obj)
83 : pmt_exception(msg + ": out of range ", obj)
87 pmt_notimplemented::pmt_notimplemented(const std::string &msg, pmt_t obj)
88 : pmt_exception(msg + ": notimplemented ", obj)
92 ////////////////////////////////////////////////////////////////////////////
94 ////////////////////////////////////////////////////////////////////////////
99 return dynamic_cast<pmt_symbol*>(x.get());
105 return dynamic_cast<pmt_integer*>(x.get());
111 return dynamic_cast<pmt_real*>(x.get());
117 return dynamic_cast<pmt_complex*>(x.get());
123 return dynamic_cast<pmt_pair*>(x.get());
129 return dynamic_cast<pmt_vector*>(x.get());
135 return dynamic_cast<pmt_tuple*>(x.get());
138 static pmt_uniform_vector *
139 _uniform_vector(pmt_t x)
141 return dynamic_cast<pmt_uniform_vector*>(x.get());
147 return dynamic_cast<pmt_dict*>(x.get());
153 return dynamic_cast<pmt_any*>(x.get());
156 ////////////////////////////////////////////////////////////////////////////
158 ////////////////////////////////////////////////////////////////////////////
160 const pmt_t PMT_T = pmt_t(new pmt_bool()); // singleton
161 const pmt_t PMT_F = pmt_t(new pmt_bool()); // singleton
162 const pmt_t PMT_NIL = pmt_t(new pmt_null()); // singleton
163 const pmt_t PMT_EOF = pmt_cons(PMT_NIL, PMT_NIL); // singleton
165 ////////////////////////////////////////////////////////////////////////////
167 ////////////////////////////////////////////////////////////////////////////
169 pmt_bool::pmt_bool(){}
172 pmt_is_true(pmt_t obj)
178 pmt_is_false(pmt_t obj)
184 pmt_is_bool(pmt_t obj)
186 return obj->is_bool();
190 pmt_from_bool(bool val)
192 return val ? PMT_T : PMT_F;
196 pmt_to_bool(pmt_t val)
202 throw pmt_wrong_type("pmt_to_bool", val);
205 ////////////////////////////////////////////////////////////////////////////
207 ////////////////////////////////////////////////////////////////////////////
209 static const unsigned int SYMBOL_HASH_TABLE_SIZE = 701;
210 static std::vector<pmt_t> s_symbol_hash_table(SYMBOL_HASH_TABLE_SIZE);
212 pmt_symbol::pmt_symbol(const std::string &name) : d_name(name){}
216 hash_string(const std::string &s)
221 for (std::string::const_iterator p = s.begin(); p != s.end(); ++p){
222 h = (h << 4) + (*p & 0xff);
233 pmt_is_symbol(const pmt_t& obj)
235 return obj->is_symbol();
239 pmt_string_to_symbol(const std::string &name)
241 unsigned hash = hash_string(name) % SYMBOL_HASH_TABLE_SIZE;
243 // Does a symbol with this name already exist?
244 for (pmt_t sym = s_symbol_hash_table[hash]; sym; sym = _symbol(sym)->next()){
245 if (name == _symbol(sym)->name())
246 return sym; // Yes. Return it
249 // Nope. Make a new one.
250 pmt_t sym = pmt_t(new pmt_symbol(name));
251 _symbol(sym)->set_next(s_symbol_hash_table[hash]);
252 s_symbol_hash_table[hash] = sym;
258 pmt_intern(const std::string &name)
260 return pmt_string_to_symbol(name);
264 pmt_symbol_to_string(const pmt_t& sym)
266 if (!sym->is_symbol())
267 throw pmt_wrong_type("pmt_symbol_to_string", sym);
269 return _symbol(sym)->name();
274 ////////////////////////////////////////////////////////////////////////////
276 ////////////////////////////////////////////////////////////////////////////
279 pmt_is_number(pmt_t x)
281 return x->is_number();
284 ////////////////////////////////////////////////////////////////////////////
286 ////////////////////////////////////////////////////////////////////////////
288 pmt_integer::pmt_integer(long value) : d_value(value) {}
291 pmt_is_integer(pmt_t x)
293 return x->is_integer();
298 pmt_from_long(long x)
300 return pmt_t(new pmt_integer(x));
306 pmt_integer* i = dynamic_cast<pmt_integer*>(x.get());
310 throw pmt_wrong_type("pmt_to_long", x);
313 ////////////////////////////////////////////////////////////////////////////
315 ////////////////////////////////////////////////////////////////////////////
317 pmt_real::pmt_real(double value) : d_value(value) {}
326 pmt_from_double(double x)
328 return pmt_t(new pmt_real(x));
332 pmt_to_double(pmt_t x)
335 return _real(x)->value();
337 return _integer(x)->value();
339 throw pmt_wrong_type("pmt_to_double", x);
342 ////////////////////////////////////////////////////////////////////////////
344 ////////////////////////////////////////////////////////////////////////////
346 pmt_complex::pmt_complex(std::complex<double> value) : d_value(value) {}
349 pmt_is_complex(pmt_t x)
351 return x->is_complex();
355 pmt_make_rectangular(double re, double im)
357 return pmt_t(new pmt_complex(std::complex<double>(re, im)));
361 pmt_to_complex(pmt_t x)
364 return _complex(x)->value();
366 return _real(x)->value();
368 return _integer(x)->value();
370 throw pmt_wrong_type("pmt_to_complex", x);
373 ////////////////////////////////////////////////////////////////////////////
375 ////////////////////////////////////////////////////////////////////////////
377 pmt_null::pmt_null() {}
378 pmt_pair::pmt_pair(const pmt_t& car, const pmt_t& cdr) : d_car(car), d_cdr(cdr) {}
381 pmt_is_null(const pmt_t& x)
387 pmt_is_pair(const pmt_t& obj)
389 return obj->is_pair();
393 pmt_cons(const pmt_t& x, const pmt_t& y)
395 return pmt_t(new pmt_pair(x, y));
399 pmt_car(const pmt_t& pair)
401 pmt_pair* p = dynamic_cast<pmt_pair*>(pair.get());
405 throw pmt_wrong_type("pmt_car", pair);
409 pmt_cdr(const pmt_t& pair)
411 pmt_pair* p = dynamic_cast<pmt_pair*>(pair.get());
415 throw pmt_wrong_type("pmt_cdr", pair);
419 pmt_set_car(pmt_t pair, pmt_t obj)
422 _pair(pair)->set_car(obj);
424 throw pmt_wrong_type("pmt_set_car", pair);
428 pmt_set_cdr(pmt_t pair, pmt_t obj)
431 _pair(pair)->set_cdr(obj);
433 throw pmt_wrong_type("pmt_set_cdr", pair);
436 ////////////////////////////////////////////////////////////////////////////
438 ////////////////////////////////////////////////////////////////////////////
440 pmt_vector::pmt_vector(size_t len, pmt_t fill)
443 for (size_t i = 0; i < len; i++)
448 pmt_vector::ref(size_t k) const
451 throw pmt_out_of_range("pmt_vector_ref", pmt_from_long(k));
456 pmt_vector::set(size_t k, pmt_t obj)
459 throw pmt_out_of_range("pmt_vector_set", pmt_from_long(k));
464 pmt_vector::fill(pmt_t obj)
466 for (size_t i = 0; i < length(); i++)
471 pmt_is_vector(pmt_t obj)
473 return obj->is_vector();
477 pmt_make_vector(size_t k, pmt_t fill)
479 return pmt_t(new pmt_vector(k, fill));
483 pmt_vector_ref(pmt_t vector, size_t k)
485 if (!vector->is_vector())
486 throw pmt_wrong_type("pmt_vector_ref", vector);
487 return _vector(vector)->ref(k);
491 pmt_vector_set(pmt_t vector, size_t k, pmt_t obj)
493 if (!vector->is_vector())
494 throw pmt_wrong_type("pmt_vector_set", vector);
495 _vector(vector)->set(k, obj);
499 pmt_vector_fill(pmt_t vector, pmt_t obj)
501 if (!vector->is_vector())
502 throw pmt_wrong_type("pmt_vector_set", vector);
503 _vector(vector)->fill(obj);
506 ////////////////////////////////////////////////////////////////////////////
508 ////////////////////////////////////////////////////////////////////////////
510 pmt_tuple::pmt_tuple(size_t len)
516 pmt_tuple::ref(size_t k) const
519 throw pmt_out_of_range("pmt_tuple_ref", pmt_from_long(k));
524 pmt_is_tuple(pmt_t obj)
526 return obj->is_tuple();
530 pmt_tuple_ref(const pmt_t &tuple, size_t k)
532 if (!tuple->is_tuple())
533 throw pmt_wrong_type("pmt_tuple_ref", tuple);
534 return _tuple(tuple)->ref(k);
537 // for (i=0; i < 10; i++)
538 // make_constructor()
543 return pmt_t(new pmt_tuple(0));
547 pmt_make_tuple(const pmt_t &e0)
549 pmt_tuple *t = new pmt_tuple(1);
555 pmt_make_tuple(const pmt_t &e0, const pmt_t &e1)
557 pmt_tuple *t = new pmt_tuple(2);
564 pmt_make_tuple(const pmt_t &e0, const pmt_t &e1, const pmt_t &e2)
566 pmt_tuple *t = new pmt_tuple(3);
574 pmt_make_tuple(const pmt_t &e0, const pmt_t &e1, const pmt_t &e2, const pmt_t &e3)
576 pmt_tuple *t = new pmt_tuple(4);
585 pmt_make_tuple(const pmt_t &e0, const pmt_t &e1, const pmt_t &e2, const pmt_t &e3, const pmt_t &e4)
587 pmt_tuple *t = new pmt_tuple(5);
597 pmt_make_tuple(const pmt_t &e0, const pmt_t &e1, const pmt_t &e2, const pmt_t &e3, const pmt_t &e4, const pmt_t &e5)
599 pmt_tuple *t = new pmt_tuple(6);
610 pmt_make_tuple(const pmt_t &e0, const pmt_t &e1, const pmt_t &e2, const pmt_t &e3, const pmt_t &e4, const pmt_t &e5, const pmt_t &e6)
612 pmt_tuple *t = new pmt_tuple(7);
624 pmt_make_tuple(const pmt_t &e0, const pmt_t &e1, const pmt_t &e2, const pmt_t &e3, const pmt_t &e4, const pmt_t &e5, const pmt_t &e6, const pmt_t &e7)
626 pmt_tuple *t = new pmt_tuple(8);
639 pmt_make_tuple(const pmt_t &e0, const pmt_t &e1, const pmt_t &e2, const pmt_t &e3, const pmt_t &e4, const pmt_t &e5, const pmt_t &e6, const pmt_t &e7, const pmt_t &e8)
641 pmt_tuple *t = new pmt_tuple(9);
655 pmt_make_tuple(const pmt_t &e0, const pmt_t &e1, const pmt_t &e2, const pmt_t &e3, const pmt_t &e4, const pmt_t &e5, const pmt_t &e6, const pmt_t &e7, const pmt_t &e8, const pmt_t &e9)
657 pmt_tuple *t = new pmt_tuple(10);
672 pmt_to_tuple(const pmt_t &x)
674 if (x->is_tuple()) // already one
677 size_t len = pmt_length(x);
678 pmt_tuple *t = new pmt_tuple(len);
682 for (size_t i = 0; i < len; i++)
683 t->_set(i, _vector(x)->ref(i));
689 for (size_t i = 0; i < len; i++){
690 t->_set(i, pmt_car(y));
696 throw pmt_wrong_type("pmt_to_tuple", x);
701 ////////////////////////////////////////////////////////////////////////////
702 // Uniform Numeric Vectors
703 ////////////////////////////////////////////////////////////////////////////
706 pmt_is_uniform_vector(pmt_t x)
708 return x->is_uniform_vector();
712 pmt_uniform_vector_elements(pmt_t vector, size_t &len)
714 if (!vector->is_uniform_vector())
715 throw pmt_wrong_type("pmt_uniform_vector_elements", vector);
716 return _uniform_vector(vector)->uniform_elements(len);
720 pmt_uniform_vector_writable_elements(pmt_t vector, size_t &len)
722 if (!vector->is_uniform_vector())
723 throw pmt_wrong_type("pmt_uniform_vector_writable_elements", vector);
724 return _uniform_vector(vector)->uniform_writable_elements(len);
727 ////////////////////////////////////////////////////////////////////////////
729 ////////////////////////////////////////////////////////////////////////////
737 pmt_dict::set(pmt_t key, pmt_t value)
739 pmt_t p = pmt_assv(key, d_alist); // look for (key . value) pair
740 if (pmt_is_pair(p)){ // found existing pair...
741 pmt_set_cdr(p, value); // overrwrite cdr with new value
743 else { // not in the dict
744 d_alist = pmt_cons(pmt_cons(key, value), d_alist); // add new (key . value) pair
749 pmt_dict::ref(pmt_t key, pmt_t not_found) const
751 pmt_t p = pmt_assv(key, d_alist); // look for (key . value) pair
759 pmt_dict::has_key(pmt_t key) const
761 return pmt_is_pair(pmt_assv(key, d_alist));
765 pmt_dict::items() const
771 pmt_dict::keys() const
773 return pmt_map(pmt_car, d_alist);
777 pmt_dict::values() const
779 return pmt_map(pmt_cdr, d_alist);
783 pmt_is_dict(pmt_t obj)
785 return obj->is_dict();
791 return pmt_t(new pmt_dict());
795 pmt_dict_set(pmt_t dict, pmt_t key, pmt_t value)
797 pmt_dict* d = _dict(dict);
799 throw pmt_wrong_type("pmt_dict_set", dict);
805 pmt_dict_has_key(pmt_t dict, pmt_t key)
807 pmt_dict* d = _dict(dict);
809 throw pmt_wrong_type("pmt_dict_has_key", dict);
811 return d->has_key(key);
815 pmt_dict_ref(pmt_t dict, pmt_t key, pmt_t not_found)
817 pmt_dict* d = _dict(dict);
819 throw pmt_wrong_type("pmt_dict_ref", dict);
821 return d->ref(key, not_found);
825 pmt_dict_items(pmt_t dict)
827 if (!dict->is_dict())
828 throw pmt_wrong_type("pmt_dict_items", dict);
830 return _dict(dict)->items();
834 pmt_dict_keys(pmt_t dict)
836 if (!dict->is_dict())
837 throw pmt_wrong_type("pmt_dict_keys", dict);
839 return _dict(dict)->keys();
843 pmt_dict_values(pmt_t dict)
845 if (!dict->is_dict())
846 throw pmt_wrong_type("pmt_dict_values", dict);
848 return _dict(dict)->values();
851 ////////////////////////////////////////////////////////////////////////////
853 ////////////////////////////////////////////////////////////////////////////
855 pmt_any::pmt_any(const boost::any &any) : d_any(any) {}
858 pmt_is_any(pmt_t obj)
860 return obj->is_any();
864 pmt_make_any(const boost::any &any)
866 return pmt_t(new pmt_any(any));
870 pmt_any_ref(pmt_t obj)
873 throw pmt_wrong_type("pmt_any_ref", obj);
874 return _any(obj)->ref();
878 pmt_any_set(pmt_t obj, const boost::any &any)
881 throw pmt_wrong_type("pmt_any_set", obj);
885 ////////////////////////////////////////////////////////////////////////////
886 // msg_accepter -- built from "any"
887 ////////////////////////////////////////////////////////////////////////////
890 pmt_is_msg_accepter(const pmt_t &obj)
892 if (!pmt_is_any(obj))
895 boost::any r = pmt_any_ref(obj);
896 return boost::any_cast<gruel::msg_accepter_sptr>(&r) != 0;
899 //! make a msg_accepter
901 pmt_make_msg_accepter(gruel::msg_accepter_sptr ma)
903 return pmt_make_any(ma);
906 //! Return underlying msg_accepter
907 gruel::msg_accepter_sptr
908 pmt_msg_accepter_ref(const pmt_t &obj)
911 return boost::any_cast<gruel::msg_accepter_sptr>(pmt_any_ref(obj));
913 catch (boost::bad_any_cast &e){
914 throw pmt_wrong_type("pmt_msg_accepter_ref", obj);
919 ////////////////////////////////////////////////////////////////////////////
921 ////////////////////////////////////////////////////////////////////////////
924 pmt_eq(const pmt_t& x, const pmt_t& y)
930 pmt_eqv(const pmt_t& x, const pmt_t& y)
935 if (x->is_integer() && y->is_integer())
936 return _integer(x)->value() == _integer(y)->value();
938 if (x->is_real() && y->is_real())
939 return _real(x)->value() == _real(y)->value();
941 if (x->is_complex() && y->is_complex())
942 return _complex(x)->value() == _complex(y)->value();
948 pmt_equal(const pmt_t& x, const pmt_t& y)
953 if (x->is_pair() && y->is_pair())
954 return pmt_equal(pmt_car(x), pmt_car(y)) && pmt_equal(pmt_cdr(x), pmt_cdr(y));
956 if (x->is_vector() && y->is_vector()){
957 pmt_vector *xv = _vector(x);
958 pmt_vector *yv = _vector(y);
959 if (xv->length() != yv->length())
962 for (unsigned i = 0; i < xv->length(); i++)
963 if (!pmt_equal(xv->_ref(i), yv->_ref(i)))
969 if (x->is_tuple() && y->is_tuple()){
970 pmt_tuple *xv = _tuple(x);
971 pmt_tuple *yv = _tuple(y);
972 if (xv->length() != yv->length())
975 for (unsigned i = 0; i < xv->length(); i++)
976 if (!pmt_equal(xv->_ref(i), yv->_ref(i)))
982 if (x->is_uniform_vector() && y->is_uniform_vector()){
983 pmt_uniform_vector *xv = _uniform_vector(x);
984 pmt_uniform_vector *yv = _uniform_vector(y);
985 if (xv->length() != yv->length())
989 if (memcmp(xv->uniform_elements(len_x),
990 yv->uniform_elements(len_y),
997 // FIXME add other cases here...
1003 pmt_length(const pmt_t& x)
1006 return _vector(x)->length();
1008 if (x->is_uniform_vector())
1009 return _uniform_vector(x)->length();
1012 return _tuple(x)->length();
1019 pmt_t it = pmt_cdr(x);
1020 while (pmt_is_pair(it)){
1024 if (pmt_is_null(it))
1027 // not a proper list
1028 throw pmt_wrong_type("pmt_length", x);
1031 // FIXME dictionary length (number of entries)
1033 throw pmt_wrong_type("pmt_length", x);
1037 pmt_assq(pmt_t obj, pmt_t alist)
1039 while (pmt_is_pair(alist)){
1040 pmt_t p = pmt_car(alist);
1041 if (!pmt_is_pair(p)) // malformed alist
1044 if (pmt_eq(obj, pmt_car(p)))
1047 alist = pmt_cdr(alist);
1053 pmt_assv(pmt_t obj, pmt_t alist)
1055 while (pmt_is_pair(alist)){
1056 pmt_t p = pmt_car(alist);
1057 if (!pmt_is_pair(p)) // malformed alist
1060 if (pmt_eqv(obj, pmt_car(p)))
1063 alist = pmt_cdr(alist);
1069 pmt_assoc(pmt_t obj, pmt_t alist)
1071 while (pmt_is_pair(alist)){
1072 pmt_t p = pmt_car(alist);
1073 if (!pmt_is_pair(p)) // malformed alist
1076 if (pmt_equal(obj, pmt_car(p)))
1079 alist = pmt_cdr(alist);
1085 pmt_map(pmt_t proc(const pmt_t&), pmt_t list)
1089 while(pmt_is_pair(list)){
1090 r = pmt_cons(proc(pmt_car(list)), r);
1091 list = pmt_cdr(list);
1094 return pmt_reverse_x(r);
1098 pmt_reverse(pmt_t listx)
1103 while(pmt_is_pair(list)){
1104 r = pmt_cons(pmt_car(list), r);
1105 list = pmt_cdr(list);
1107 if (pmt_is_null(list))
1110 throw pmt_wrong_type("pmt_reverse", listx);
1114 pmt_reverse_x(pmt_t list)
1116 // FIXME do it destructively
1117 return pmt_reverse(list);
1121 pmt_nth(size_t n, pmt_t list)
1123 pmt_t t = pmt_nthcdr(n, list);
1131 pmt_nthcdr(size_t n, pmt_t list)
1133 if (!(pmt_is_pair(list) || pmt_is_null(list)))
1134 throw pmt_wrong_type("pmt_nthcdr", list);
1137 if (pmt_is_pair(list)){
1138 list = pmt_cdr(list);
1142 if (pmt_is_null(list))
1145 throw pmt_wrong_type("pmt_nthcdr: not a LIST", list);
1151 pmt_memq(pmt_t obj, pmt_t list)
1153 while (pmt_is_pair(list)){
1154 if (pmt_eq(obj, pmt_car(list)))
1156 list = pmt_cdr(list);
1162 pmt_memv(pmt_t obj, pmt_t list)
1164 while (pmt_is_pair(list)){
1165 if (pmt_eqv(obj, pmt_car(list)))
1167 list = pmt_cdr(list);
1173 pmt_member(pmt_t obj, pmt_t list)
1175 while (pmt_is_pair(list)){
1176 if (pmt_equal(obj, pmt_car(list)))
1178 list = pmt_cdr(list);
1184 pmt_subsetp(pmt_t list1, pmt_t list2)
1186 while (pmt_is_pair(list1)){
1187 pmt_t p = pmt_car(list1);
1188 if (pmt_is_false(pmt_memv(p, list2)))
1190 list1 = pmt_cdr(list1);
1196 pmt_list1(const pmt_t& x1)
1198 return pmt_cons(x1, PMT_NIL);
1202 pmt_list2(const pmt_t& x1, const pmt_t& x2)
1204 return pmt_cons(x1, pmt_cons(x2, PMT_NIL));
1208 pmt_list3(const pmt_t& x1, const pmt_t& x2, const pmt_t& x3)
1210 return pmt_cons(x1, pmt_cons(x2, pmt_cons(x3, PMT_NIL)));
1214 pmt_list4(const pmt_t& x1, const pmt_t& x2, const pmt_t& x3, const pmt_t& x4)
1216 return pmt_cons(x1, pmt_cons(x2, pmt_cons(x3, pmt_cons(x4, PMT_NIL))));
1220 pmt_list5(const pmt_t& x1, const pmt_t& x2, const pmt_t& x3, const pmt_t& x4, const pmt_t& x5)
1222 return pmt_cons(x1, pmt_cons(x2, pmt_cons(x3, pmt_cons(x4, pmt_cons(x5, PMT_NIL)))));
1226 pmt_list6(const pmt_t& x1, const pmt_t& x2, const pmt_t& x3, const pmt_t& x4, const pmt_t& x5, const pmt_t& x6)
1228 return pmt_cons(x1, pmt_cons(x2, pmt_cons(x3, pmt_cons(x4, pmt_cons(x5, pmt_cons(x6, PMT_NIL))))));
1232 pmt_list_add(pmt_t list, const pmt_t& item)
1234 return pmt_reverse(pmt_cons(item, pmt_reverse(list)));
1238 pmt_caar(pmt_t pair)
1240 return (pmt_car(pmt_car(pair)));
1244 pmt_cadr(pmt_t pair)
1246 return pmt_car(pmt_cdr(pair));
1250 pmt_cdar(pmt_t pair)
1252 return pmt_cdr(pmt_car(pair));
1256 pmt_cddr(pmt_t pair)
1258 return pmt_cdr(pmt_cdr(pair));
1262 pmt_caddr(pmt_t pair)
1264 return pmt_car(pmt_cdr(pmt_cdr(pair)));
1268 pmt_cadddr(pmt_t pair)
1270 return pmt_car(pmt_cdr(pmt_cdr(pmt_cdr(pair))));
1274 pmt_is_eof_object(pmt_t obj)
1276 return pmt_eq(obj, PMT_EOF);
1282 printf("sizeof(pmt_t) = %3zd\n", sizeof(pmt_t));
1283 printf("sizeof(pmt_base) = %3zd\n", sizeof(pmt_base));
1284 printf("sizeof(pmt_bool) = %3zd\n", sizeof(pmt_bool));
1285 printf("sizeof(pmt_symbol) = %3zd\n", sizeof(pmt_symbol));
1286 printf("sizeof(pmt_integer) = %3zd\n", sizeof(pmt_integer));
1287 printf("sizeof(pmt_real) = %3zd\n", sizeof(pmt_real));
1288 printf("sizeof(pmt_complex) = %3zd\n", sizeof(pmt_complex));
1289 printf("sizeof(pmt_null) = %3zd\n", sizeof(pmt_null));
1290 printf("sizeof(pmt_pair) = %3zd\n", sizeof(pmt_pair));
1291 printf("sizeof(pmt_vector) = %3zd\n", sizeof(pmt_vector));
1292 printf("sizeof(pmt_dict) = %3zd\n", sizeof(pmt_dict));
1293 printf("sizeof(pmt_uniform_vector) = %3zd\n", sizeof(pmt_uniform_vector));
1296 } /* namespace pmt */