Changeset 1605


Ignore:
Timestamp:
Nov 23, 2004, 8:50:38 AM (16 years ago)
Author:
orlov
Message:
  • Unified interface for creating expressions from arrays.
Location:
to-imperative/trunk/runtime
Files:
5 edited

Legend:

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

    r1539 r1605  
    4444  while (len-- > 0) {
    4545    wchar_t wc;
    46     size_t l = mbrtowc(&wc, s, MB_CUR_MAX, &ps);
     46    size_t l = mbrtowc(&wc, s, MB_CUR_MAX * 8, &ps);
    4747    new(p) Char(wc);
    4848    p++; s += l;
  • to-imperative/trunk/runtime/rf_char.hh

    r1381 r1605  
    7070#endif
    7171
     72  static inline bool is_flat () ;
     73
    7274  static int compare (Char const* _char1, Char const* _char2) ;
    7375  static uint32_t hash (Char const* _char) ;
  • to-imperative/trunk/runtime/rf_char.ih

    r1381 r1605  
    4646}
    4747
     48inline bool Char::is_flat()
     49{
     50  return true;
     51}
     52
    4853#if 0
    4954inline Char::Char(const Char& _ch) :
  • to-imperative/trunk/runtime/rf_expr.hh

    r1517 r1605  
    204204  /// whether a result expression was already constructed and delete it.
    205205  static inline void clear (Expr* _ptr) ;
     206
     207  template<class TermClass, typename CppType>
     208  static inline Expr create (CppType const* _array, size_t _size) ;
    206209
    207210private:
  • to-imperative/trunk/runtime/rf_expr.ih

    r1588 r1605  
    454454{
    455455  memset(_ptr, '\0', sizeof(Expr));
     456}
     457
     458template<class TermClass, typename CppType>
     459inline Expr Expr::create (CppType const* _array, size_t _size)
     460{
     461  Expr e(_size);
     462  if (TermClass::is_flat()) e.flags |= FLAT_BIT;
     463  Term* p = e.get_first();
     464  while (_size--)
     465    new(p++) TermClass(*_array++);
     466  return e;
    456467}
    457468
Note: See TracChangeset for help on using the changeset viewer.