Changeset 1198


Ignore:
Timestamp:
Aug 13, 2003, 5:21:16 PM (17 years ago)
Author:
sveta
Message:
  • Code is modified.
Location:
to-imperative/trunk/library/Vector
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • to-imperative/trunk/library/Vector/vector.cc

    r1121 r1198  
    1515RF_FUNC (Vector, (RF_ARG _source), (RF_RES _vector))
    1616
    17   Expr expr;
    1817  size_t length = 0;
    1918  Term* p = _source.get_first();
  • to-imperative/trunk/library/Vector/vector_fill.cc

    r1121 r1198  
    1414RF_FUNC (Vector_m_Fill, (RF_ARG _vector, _fill), ())
    1515
    16   if (_vector.get_len() == 1) {
    17     Term* p_vector = _vector.get_first();
    18     rftype::Vector* v = p_vector->cast_to<rftype::Vector>(type_vector);
    19     if (!v)
    20       RF_LIB_ERROR("Invalid argument");
    21     else
    22       for (size_t i = 0; i < v->get_length(); i++)
    23         (*v)[i] = _fill();
    24   } else
    25       RF_LIB_ERROR("Invalid argument");
     16  if (_vector.get_len() != 1)
     17    RF_LIB_ERROR("Invalid argument");
     18  Term* p_vector = _vector.get_first();
     19  rftype::Vector* v = p_vector->cast_to<rftype::Vector>(type_vector);
     20  if (!v)
     21    RF_LIB_ERROR("Invalid argument");
     22  else
     23    for (size_t i = 0; i < v->get_length(); i++)
     24      (*v)[i] = _fill();
    2625
    2726RF_END
  • to-imperative/trunk/library/Vector/vector_init.cc

    r1168 r1198  
    3636    len = i;
    3737  }
    38   rftype::Vector temp((size_t)len,_fill());
    39   (*v) = temp;
     38  (*v) = rftype::Vector((size_t)len,_fill());
     39
    4040 
    4141RF_END
  • to-imperative/trunk/library/Vector/vector_length.cc

    r1114 r1198  
    1414RF_FUNC (Vector_m_Length, (RF_ARG _vector), (RF_RES _len))
    1515
    16   if (_vector.get_len() == 1) {
    17     Term* p_vector = _vector.get_first();
    18     rftype::Vector* v = p_vector->cast_to<rftype::Vector>(type_vector);
    19     if (!v)
    20       RF_LIB_ERROR("Invalid argument");
    21     _len = Int32::create_expr(v->get_length());
    22   } else
    23       RF_LIB_ERROR("Invalid argument");
    24 
     16  if (_vector.get_len() != 1)
     17    RF_LIB_ERROR("Invalid argument");
     18  Term* p_vector = _vector.get_first();
     19  rftype::Vector* v = p_vector->cast_to<rftype::Vector>(type_vector);
     20  if (!v)
     21    RF_LIB_ERROR("Invalid argument");
     22  _len = Int32::create_expr(v->get_length());
     23 
    2524RF_END
    2625
  • to-imperative/trunk/library/Vector/vector_replace.cc

    r1168 r1198  
    1515RF_FUNC (Vector_m_Replace, (RF_ARG _vector, _source), ())
    1616
    17   if (_vector.get_len() ==1) {
    18     Term* t = _vector.get_first();
    19     rftype::Vector* p_vector = t->cast_to<rftype::Vector>(type_vector);
    20     if (!p_vector)
    21       RF_LIB_ERROR("Invalid argument");
    22     size_t length = 0;
    23     Term* p = _source.get_first();
    24     Term* q = _source.get_last();
    25     for ( ; p < q; p++) {
    26       if (p->is_ref()) {
    27         if (SIZE_MAX - length < 1)
    28           RF_LIB_ERROR("Size limit exceeded");
    29         length++;
    30       } else {
    31         rftype::Vector* v = p->cast_to<rftype::Vector> (type_vector);
    32         if (!v)
    33           RF_LIB_ERROR ("Invalid argument");
    34         size_t v_length = v->get_length();
    35         if (SIZE_MAX - length < v_length)
    36           RF_LIB_ERROR("Size limit exceeded");
    37         length += v_length;
    38       }
     17  if (_vector.get_len() !=1)
     18    RF_LIB_ERROR("Invalid argument");
     19  Term* t = _vector.get_first();
     20  rftype::Vector* p_vector = t->cast_to<rftype::Vector>(type_vector);
     21  if (!p_vector)
     22    RF_LIB_ERROR("Invalid argument");
     23  size_t length = 0;
     24  Term* p = _source.get_first();
     25  Term* q = _source.get_last();
     26  for ( ; p < q; p++) {
     27    if (p->is_ref()) {
     28      if (SIZE_MAX - length < 1)
     29        RF_LIB_ERROR("Size limit exceeded");
     30      length++;
     31    } else {
     32      rftype::Vector* v = p->cast_to<rftype::Vector> (type_vector);
     33      if (!v)
     34        RF_LIB_ERROR ("Invalid argument");
     35      size_t v_length = v->get_length();
     36      if (SIZE_MAX - length < v_length)
     37        RF_LIB_ERROR("Size limit exceeded");
     38      length += v_length;
    3939    }
    40     rftype::Vector temp(_source, length);
    41     (*p_vector) = temp;
    42     temp.decrease(length);
    43   } else
    44     RF_LIB_ERROR("Invalid argument");
     40  }
     41  *p_vector = rftype::Vector(_source, length);
    4542 
    4643
  • to-imperative/trunk/library/Vector/vector_to_exp.cc

    r1121 r1198  
    1414RF_FUNC (Vector_m_To_m_Exp, (RF_ARG _vector), (RF_RES _exp))
    1515
    16   if (_vector.get_len() == 1) {
    17     Term* p = _vector.get_first();
    18     rftype::Vector* v = p->cast_to<rftype::Vector>(type_vector);
    19     if (!v)
    20       RF_LIB_ERROR("Invalid argument");
    21     Expr result;
    22     for (size_t i = 0; i < v->get_length(); i++)
    23       result = result + (*v)[i];
    24     _exp = result;     
    25   } else
    26       RF_LIB_ERROR("Invalid argument");
     16  if (_vector.get_len() != 1)
     17    RF_LIB_ERROR("Invalid argument");
     18  Term* p = _vector.get_first();
     19  rftype::Vector* v = p->cast_to<rftype::Vector>(type_vector);
     20  if (!v)
     21    RF_LIB_ERROR("Invalid argument");
     22  Expr result;
     23  for (size_t i = 0; i < v->get_length(); i++)
     24    result = result + (*v)[i];
     25  _exp = result;     
     26
    2727
    2828RF_END
Note: See TracChangeset for help on using the changeset viewer.