source: to-imperative/trunk/runtime/rf_integer.cc @ 1010

Last change on this file since 1010 was 1010, checked in by pooh, 18 years ago
  • More work on long arithmetic.
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 981 bytes
Line 
1#include "rf_integer.ih"
2
3namespace rftype
4{
5
6using namespace rfrt;
7
8void Integer::ctor (Integer* _to, Integer const* _from)
9{
10  new(_to) Integer(*_from);
11}
12
13void Integer::dtor (Integer* _n)
14{
15  mpz_t* p = _n->get_mpz_ptr();
16  mpz_clear(*p);
17  mpz_allocator.deallocate(p);
18}
19
20bool Integer::eq (Integer const* _n1, Integer const* _n2)
21{
22  return *_n1 == *_n2;
23}
24
25int Integer::compare (Integer const* _n1, Integer const* _n2)
26{
27  return _n1->cmp(*_n2);
28}
29
30//
31// FIXME: Not implemented
32uint32_t Integer::hash (Integer const* _n)
33{
34  (void)_n;
35  return 0;
36}
37
38pxx::WString Integer::to_string (Integer const* _n)
39{
40  return (pxx::WString)(*_n);
41}
42
43short_type_funcs_t Integer::funcs = {
44  (void (*)(Term*, Term const*))(Integer::ctor),
45  (void (*)(Term*))(Integer::dtor),
46  (bool (*)(Term const*, Term const*))(Integer::eq),
47  (int (*)(Term const*, Term const*))(Integer::compare),
48  (uint32_t (*)(Term const*))(Integer::hash),
49  (pxx::WString (*)(Term const*))(Integer::to_string)
50};
51
52}
Note: See TracBrowser for help on using the repository browser.