Changeset 1685


Ignore:
Timestamp:
Jan 31, 2005, 3:37:20 PM (16 years ago)
Author:
orlov
Message:
  • Print names for static objects.
Location:
to-imperative/trunk
Files:
1 added
8 edited

Legend:

Unmodified
Added
Removed
  • to-imperative/trunk/compiler/rfp_asail.rf

    r1680 r1685  
    175175      <RFP-Extract-Qualifiers t.name> :: (e.qualifiers) e.name,
    176176      <Rfp2Cpp e.name> :: e.cpp-name,
    177       <Put &Const-Exprs (e.cpp-name ('new rftype::' s1 <To-Lower e2> ' ()'))>,
     177      <Put &Const-Exprs (e.cpp-name
     178        ('new rftype::StaticObject<rftype::' s1 <To-Lower e2> '>(L"'e.name'")'))>,
    178179      <Namespace-Control e.qualifiers>
    179180      (e.linkage 'Expr ' e.cpp-name ';');
     
    389390    (REF t.name) =
    390391      ' + ' <Name-To-CPP t.name>;
     392//      ' + Expr::create<ObjectRef>(' <Name-To-CPP t.name> ')';
    391393    (STATIC e) =
    392394      ' + ' <Rfp2Cpp t.item>;
    393395    (FUNC t.name) =
    394       ' + Expr::create<ObjectRef>(' <Name-To-CPP t.name> ')';
     396      ' + Expr (' <Name-To-CPP t.name> ')';
    395397    s.sym, {
    396398      <Int? s.sym> =
  • to-imperative/trunk/library/Static/Static.cc

    r1679 r1685  
    2626      wchar_t const* name;
    2727      size_t length = ref->get_obj_ptr()->get_name(&name);
    28       _v_res1 = Expr::create<Word>(name, length);
     28      _v_res1 = Expr::create<Word>(name, length - 1);
    2929      return true;
    3030    }
  • to-imperative/trunk/runtime/rf_common.cc

    r1479 r1685  
    4040#endif
    4141
     42//const static_object_t static_object;
     43
    4244}
  • to-imperative/trunk/runtime/rf_common.hh

    r1490 r1685  
    6262//inline bool is_refal_upper (wint_t _wc) ;
    6363
     64struct static_object_t {};
     65extern const static_object_t static_object;
     66
    6467}
    6568
  • to-imperative/trunk/runtime/rf_macros.hh

    r1678 r1685  
    154154#define RF_FUNC(f,args,ress) \
    155155  namespace rffunc { RetVal _rf_##f (void); } \
    156   StaticObject<rftype::Func>* f = \
    157       new StaticObject<rftype::Func>(rffunc::_rf_##f, L"" #f); \
     156  rftype::StaticObject<rftype::Func>* f = \
     157      new (static_object) \
     158        rftype::StaticObject<rftype::Func>(rffunc::_rf_##f, L"" #f); \
    158159  RetVal rffunc::_rf_##f (void) { \
    159160    RF_start_args; \
     
    174175#endif
    175176#define RF_DECL(f) \
    176   extern StaticObject<rftype::Func>* f;
     177  extern rftype::StaticObject<rftype::Func>* f;
    177178
    178179#define RF_ARG rfrt::Arg
     
    244245    wchar_t const* fname; \
    245246    size_t len = stack->get_func(stack->get_depth())->get_name(&fname); \
    246     throw Expr::create<Word>(fname, len) + Expr::create<Word>(msg); \
     247    throw Expr::create<Word>(fname, len - 1) + Expr::create<Word>(msg); \
    247248  } while (0)
    248249
  • to-imperative/trunk/runtime/rf_static_object.hh

    r1678 r1685  
    88
    99#include "pxx_string.hh"
     10#include "rf_common.hh"
    1011
    1112namespace rftype
     
    2930  inline StaticObject (ObjClass const& _obj, wchar_t const* _name) ;
    3031
     32  inline StaticObject (wchar_t const* _name) ;
     33
    3134  inline ~StaticObject () ;
    3235
    3336  inline void* operator new (size_t _size) ;
    3437  inline void  operator delete (void* _ptr) ;
     38
     39  inline void* operator new (size_t _size, rfrt::static_object_t) ;
     40  inline void  operator delete (void* _ptr, rfrt::static_object_t) ;
    3541
    3642  virtual inline pxx::WString to_string () const;
  • to-imperative/trunk/runtime/rf_static_object.ih

    r1678 r1685  
    88
    99#include "rf_static_object.hh"
     10#include "rf_string.ih"
    1011
    1112namespace rftype
     
    2627) :
    2728  ObjClass (_obj),
     29//  name     (_name),
    2830  length   (_length)
    2931{
     
    4244
    4345template <class ObjClass>
     46inline StaticObject<ObjClass>::StaticObject (wchar_t const* _name) :
     47  ObjClass (),
     48  length   (wcslen(_name) + 1)
     49{
     50  init_name(const_cast<wchar_t**>(&name), _name, length);
     51}
     52
     53template <class ObjClass>
    4454inline StaticObject<ObjClass>::~StaticObject ()
    4555{
     
    4858
    4959template <class ObjClass>
    50 inline void* StaticObject<ObjClass>::operator new (size_t _size)
     60inline void*
     61StaticObject<ObjClass>::operator new (size_t _size)
    5162{
    52 //  return ::new StaticObject<ObjClass>;
    53   return malloc(_size);
     63  return ObjClass::operator new(_size);
    5464}
    5565
    5666template <class ObjClass>
    57 inline void StaticObject<ObjClass>::operator delete (void*)
     67inline void
     68StaticObject<ObjClass>::operator delete (void* _ptr)
     69{
     70  ObjClass::operator delete(_ptr);
     71}
     72
     73template <class ObjClass>
     74inline void*
     75StaticObject<ObjClass>::operator new (size_t _size, rfrt::static_object_t)
     76{
     77  void* p = malloc(_size);
     78  if (!p) FATAL("Out of memory");
     79  return p;
     80}
     81
     82template <class ObjClass>
     83inline void
     84StaticObject<ObjClass>::operator delete (void*, rfrt::static_object_t)
    5885{
    5986  FATAL("Static objects are never deleted");
     
    6491{
    6592  return pxx::WString(name, length, const_data);
     93}
     94
     95template <>
     96inline pxx::WString StaticObject<String>::to_string() const
     97{
     98  return String::to_string();
    6699}
    67100
  • to-imperative/trunk/samples/Static/name1.rf

    r1656 r1685  
    1 $use Box Static StdIO;
     1$use Box Convert Static StdIO;
    22
    33$box B;
    44
    55Main =
    6   <WriteLN <Box &B>>,
     6  <To-Chars <Box &B>> : '<Box|' e '|' e '>',
    77  <PrintLN &B>,
    88  <PrintLN <Name &B>>;
Note: See TracChangeset for help on using the changeset viewer.