Changeset 773


Ignore:
Timestamp:
May 28, 2003, 9:16:27 AM (18 years ago)
Author:
luba
Message:
  • is_number() method is corrected;
  • has_spaces() method is added;
Location:
to-imperative/trunk/runtime
Files:
2 edited

Legend:

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

    r762 r773  
    4545  inline int is_number () const;
    4646
     47  inline int has_space () const ;
     48
    4749  static Expr create_expr (wchar_t const* _wstr) ;
    4850
    4951  static Expr create_expr (char const* _str, char const* _locale = null) ;
     52
     53  static Expr create_expr (Expr const& _expr) ;
     54
    5055
    5156  static uintptr_t ctor (uintptr_t _data) ;
     
    5762  static short_type_funcs_t funcs ;
    5863  static TypeRegister reg ;
     64
    5965 
    60   class NumIterator {
     66  class NumIterator
     67  {
    6168  private:
    6269    const wchar_t* iter;
     
    7077  };
    7178 
     79};
    7280
    7381
    74 };
    7582
    7683}
  • to-imperative/trunk/runtime/rf_word.ih

    r762 r773  
    9595//
    9696
     97enum is_number_res {plus, minus, positive_number, not_a_number};
     98
    9799inline int Word::is_number () const
    98100{
    99   int res = 0;
     101  enum is_number_res res = not_a_number;
    100102  size_t i = 0;
    101103  Header* h = static_cast<Header*>(ptr_data2);
    102104
    103105  for (; ;)
    104     if ((h->content[i]) != ' ')
     106    if (((h->content[i]) != ' '))
    105107      break;
    106108    else
    107109      i++;
    108110   
    109   if ((h->content[i]) == '-') res = -1;
    110   if ((h->content[i]) == '+') res = 1;
    111   if (iswdigit(h->content[i])) res = 2;
     111  if ((h->content[i]) == '-') res = minus;
     112  if ((h->content[i]) == '+') res = plus;
     113  if (iswdigit(h->content[i])) res = positive_number;
    112114 
    113   if (res)
     115  if (res != not_a_number)
    114116    i++;
    115117
     
    124126
    125127      else {
    126         res = 0;
     128        res = not_a_number;
    127129        break;
    128130      }
     
    130132    else
    131133      if (prev) {
    132         res = 0;
     134        res = not_a_number;
    133135        break;
    134136      }
     
    139141  return res;
    140142}
     143
     144
     145//the method returns 1, if the word has spaces at the beginning,
     146//and returns 2, if the word has spaces at the end
     147//
     148inline int Word::has_space () const {
     149  Header* h = static_cast<Header*>(ptr_data2);
     150  if ( *(h->content) == ' ')
     151    return 1;
     152  else
     153  if ( *(h->content + h->length) == ' ')
     154    return 2;
     155
     156}
     157
     158
    141159
    142160//the method is called only if is_number() function
Note: See TracChangeset for help on using the changeset viewer.