Changeset 863


Ignore:
Timestamp:
Jun 22, 2003, 10:51:01 AM (18 years ago)
Author:
orlov
Message:
  • Use Term::cast_to() instead of Term::get_object() and dynamic_cast.
Location:
to-imperative/trunk/library
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • to-imperative/trunk/library/Box/get.cc

    r503 r863  
    1616  if (_box.get_len() == 1) {
    1717    Term* t = _box.get_first();
    18     if (t->get_type() == type_box) {
    19       try {
    20         rftype::Box& b = dynamic_cast<rftype::Box&>(t->get_object());
    21         _expr = b.get();
    22       } catch (std::bad_cast&) {
    23         FATAL("Box::?(): An object does not seem to be a box");
    24       }
     18    rftype::Box* b = t->cast_to<rftype::Box>(type_box);
     19    if (b) {
     20        _expr = b->get();
    2521    } else {
    2622      FATAL("Box::?(): Symbol does not have a box type");
  • to-imperative/trunk/library/Box/put.cc

    r503 r863  
    1616  if (_box.get_len() == 1) {
    1717    Term* t = _box.get_first();
    18     if (t->get_type() == type_box) {
    19       try {
    20         rftype::Box& b = dynamic_cast<rftype::Box&>(t->get_object());
    21         b.put(_expr);
    22       } catch (std::bad_cast&) {
    23         FATAL("Box::Store(): An object does not seem to be a box");
    24       }
     18    rftype::Box* b = t->cast_to<rftype::Box>(type_box);
     19    if (b) {
     20        b->put(_expr);
    2521    } else {
    2622      FATAL("Box::Store(): Symbol does not have a box type");
  • to-imperative/trunk/library/StdIO/open_file.cc

    r839 r863  
    2626  if (_channel.get_len() == 1) {
    2727    Term* p = _channel.get_first();
    28     if (p->get_type() == type_object) {
    29       Channel& ch = dynamic_cast<Channel&>(p->get_object());
     28    Channel* ch = p->cast_to<Channel>(type_channel);
     29    if (ch) {
    3030      if (_mode.get_len() == 1) {
    3131        Term* p = _mode.get_first();
     
    4040          wcstombs(mode, ws.get_data(), len + 1);
    4141          mode[len] = 0;
    42           if (!ch.open(fname, mode)) {
     42          if (!ch->open(fname, mode)) {
    4343            throw Word::create_expr(L"Open-File") +
    4444              Word::create_expr(strerror(errno));
  • to-imperative/trunk/library/StdIO/print_e_.cc

    r840 r863  
    1616  if (_channel.get_len() == 1) {
    1717    Term* p = _channel.get_first();
    18     if (p->get_type() == type_object) {
    19       Channel& ch = dynamic_cast<Channel&>(p->get_object());
    20       FILE* fp = ch.get_fp();
     18    Channel* ch = p->cast_to<Channel>(type_channel);
     19    if (ch) {
     20      FILE* fp = ch->get_fp();
    2121      if (fp == NULL) {
    2222        throw Word::create_expr(L"Print!") +
  • to-imperative/trunk/library/StdIO/write_e_.cc

    r840 r863  
    1717  if (_channel.get_len() == 1) {
    1818    Term* p = _channel.get_first();
    19     if (p->get_type() == type_object) {
    20       Channel& ch = dynamic_cast<Channel&>(p->get_object());
    21       FILE* fp = ch.get_fp();
     19    Channel* ch = p->cast_to<Channel>(type_channel);
     20    if (ch) {
     21      FILE* fp = ch->get_fp();
    2222      if (fp == NULL) {
    2323        throw Word::create_expr(L"Write!") +
Note: See TracChangeset for help on using the changeset viewer.