Changeset 1031


Ignore:
Timestamp:
Jul 17, 2003, 5:06:45 PM (17 years ago)
Author:
pooh
Message:
  • Additional constructors added.
Location:
to-imperative/trunk/runtime
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • to-imperative/trunk/runtime/rf_integer.hh

    r1027 r1031  
    77#include "pxx_string.hh"
    88#include <gmp.h>
     9#include <wchar.h>
    910
    1011namespace rftype
     
    2122  inline Integer (intptr_t _n) ;
    2223  inline Integer (Integer const& _n) ;
     24  inline Integer (char const* _str) ;
     25  inline Integer (wchar_t const* _str) ;
    2326  inline Integer (pxx::WString& _str) ;
    2427  inline ~Integer () ;
     
    4750
    4851  static inline Expr create_expr (intptr_t _n) ;
     52  static inline Expr create_expr (char const* _str) ;
     53  static inline Expr create_expr (wchar_t const* _str) ;
    4954  static inline Expr create_expr (pxx::WString& _str) ;
    5055  static inline Expr create_expr (Integer const& _n) ;
  • to-imperative/trunk/runtime/rf_integer.ih

    r1027 r1031  
    1919  ptr_data2 = p;
    2020  mpz_init_set_si(*p, _n);
     21}
     22
     23inline Integer::Integer (char const* _str) :
     24  Term(type_int)
     25{
     26  mpz_t* p = mpz_allocator.allocate();
     27  ptr_data2 = p;
     28  mpz_init_set_str(*p, _str, 0);
     29}
     30
     31inline Integer::Integer (wchar_t const* _str) :
     32  Term(type_int)
     33{
     34  mpz_t* p = mpz_allocator.allocate();
     35  ptr_data2 = p;
     36  size_t len = wcstombs(null, _str, 0);
     37  char* s = static_cast<char*>(alloca(len + 1));
     38  wcstombs(s, _str, len);
     39  s[len] = 0;
     40  mpz_init_set_str(*p, s, 0);
    2141}
    2242
     
    224244}
    225245
     246inline Expr Integer::create_expr (char const* _str)
     247{
     248  Expr e = Term::create_expr(1);
     249  new(e.get_first()) Integer(_str);
     250  return e;
     251}
     252
     253inline Expr Integer::create_expr (wchar_t const* _str)
     254{
     255  Expr e = Term::create_expr(1);
     256  new(e.get_first()) Integer(_str);
     257  return e;
     258}
     259
    226260inline mpz_t* Integer::get_mpz_ptr () const
    227261{
Note: See TracChangeset for help on using the changeset viewer.