Changeset 731


Ignore:
Timestamp:
May 16, 2003, 11:47:17 AM (18 years ago)
Author:
luba
Message:
  • type word is registered
Location:
to-imperative/trunk/runtime
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • to-imperative/trunk/runtime/rf_char.ih

    r667 r731  
    3030  return uint_data2;
    3131};
     32
     33
    3234#if 0
    3335inline Char::Char(const Char& _ch) :
  • to-imperative/trunk/runtime/rf_core.cc

    r583 r731  
    7878TypeRegister rftype::Char::reg(&Char::funcs, type_char) ;
    7979TypeRegister rftype::ShortInt::reg(&ShortInt::funcs, type_short_int) ;
     80TypeRegister rftype::Word::reg(&Word::funcs, type_word) ;
    8081
    8182ObjectRegister rftype::Box::reg(type_box) ;
  • to-imperative/trunk/runtime/rf_core.hh

    r583 r731  
    3434#include "rf_char.ih"
    3535#include "rf_short_int.ih"
     36#include "rf_word.ih"
    3637#include "rf_box.ih"
    3738#include "rf_vector.ih"
  • to-imperative/trunk/runtime/rf_word.cc

    r723 r731  
    11#include "rf_word.ih"
     2#include "rf_expr.ih"
     3#include "rf_types.ih"
    24
    35namespace rftype
     
    3032    else return false;
    3133  }
     34}
     35 
     36Expr Word::create_expr (wchar_t const* _wstr)
     37 {
     38  Expr e = Term::create_expr(1);
     39  Term* p = e.get_first();
     40  new(p) Word(_wstr);
     41  return e;
     42}
     43
     44Expr Word::create_expr (char const* _str, char const* _locale /* = null */)
     45{
     46  Expr e = Term::create_expr(1);
     47  Term* p = e.get_first();
     48  new(p) Word(_str, _locale);
     49  return e;
    3250}
    3351
     
    6381  Word::compare,
    6482  Word::hash,
    65   Word::to_string
     83  null // Word::to_string
    6684};
    6785
  • to-imperative/trunk/runtime/rf_word.hh

    r723 r731  
    3535  ///
    3636  /// Destructor
     37
    3738  inline ~Word () ;
    3839  ///
    3940  /// Assignment operator
    4041  inline Word& operator = (Word const& _word) ;
     42
     43  inline size_t get_len ();
     44
     45  inline int is_number ();
    4146
    4247  static Expr create_expr (wchar_t const* _wstr) ;
     
    5257  static short_type_funcs_t funcs ;
    5358  static TypeRegister reg ;
    54 
    5559};
    5660
  • to-imperative/trunk/runtime/rf_word.ih

    r705 r731  
    4242  mbstate_t ps;
    4343  size_t len = mbsrtowcs(null, &s, 0, &ps);
    44   if (len == (size_t)(-1)) throw_sys_error(errno);
     44//  if (len == (size_t)(-1)) throw_sys_error(errno);
    4545  Header* h = static_cast<Header*>(
    4646    allocator.allocate(sizeof(Header) + len * sizeof(wchar_t)));
     
    5858  if (_locale != null) setlocale(LC_CTYPE, saved_locale);
    5959}
    60 
     60 
    6161inline Word::Word (Word const& _word) :
    6262  Term (term_sym, type_word)
     
    6666  h->ref_count++;
    6767}
    68 
     68 
    6969inline Word::~Word ()
    70 {
     70{ 
    7171  Header* h = static_cast<Header*>(ptr_data2);
    7272  if (--(h->ref_count) == 0) allocator.deallocate(h);
     
    8585}
    8686
     87inline size_t Word::get_len () {
     88  return static_cast<Header*>(ptr_data2)->length;
     89}
     90
     91inline int Word::is_number () {
     92  int res = 1;
     93  size_t i = 0;
     94  Header* h = static_cast<Header*>(ptr_data2);
     95
     96  if ((h->content[i]) == '-') res = -1; //если отрицательное число
     97  if ((h->content[i]) == '+') res = 1; //если положительное с "+" число
     98  if (res) i = 1;
     99  for (; i < h->length; i++)
     100    if (iswdigit(h->content[i]) == 0) {
     101      res = 0; break;
     102    }
     103  return res;
     104}
     105#if 0
    87106Expr Word::create_expr (wchar_t const* _wstr)
    88 {
     107 {
    89108  Expr e = Term::create_expr(1);
    90109  Term* p = e.get_first();
     
    100119  return e;
    101120}
    102 
     121#endif
    103122}
    104123
Note: See TracChangeset for help on using the changeset viewer.