Changeset 1098


Ignore:
Timestamp:
Aug 6, 2003, 10:54:04 AM (17 years ago)
Author:
sveta
Message:
  • Method "Vector-Replace" is changed.
Location:
to-imperative/trunk
Files:
5 edited

Legend:

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

    r1072 r1098  
    1616
    1717  Expr expr;
    18   vector_meaning(_source, expr);
    19   size_t length = expr.get_len();
    20   if (length > SIZE_MAX)
    21     RF_LIB_ERROR("Size limit exceeded");
    22   _vector = Expr (new rftype::Vector(expr, length));
     18  size_t length = 0;
     19  Term* p = _source.get_first();
     20  Term* q = _source.get_last();
     21  for ( ; p < q; p++) {
     22    if (p->is_ref()) {
     23      length++;
     24    } else {
     25      rftype::Vector* v = p->cast_to<rftype::Vector> (type_vector);
     26      if (!v)
     27        RF_LIB_ERROR ("Invalid argument");
     28      length += v->get_length();
     29    }
     30  }
     31  _vector = Expr (new rftype::Vector(_source, length));
    2332
    2433RF_END
  • to-imperative/trunk/library/Vector/vector_init.cc

    r1072 r1098  
    2525      RF_LIB_ERROR("Invalid argument");
    2626    else {
    27       size_t l = len->to_int();
    28       if (l > SIZE_MAX)
    29         RF_LIB_ERROR("Size limit exceeded"); 
     27      size_t l = len->to_int(); 
    3028      v-> vector_init(l, _fill);
    3129    }
  • to-imperative/trunk/library/Vector/vector_replace.cc

    r1072 r1098  
    2020    if (!p_vector)
    2121      RF_LIB_ERROR("Invalid argument");
     22    size_t length = 0;
    2223    Expr expr_vector;
    23     vector_meaning(_source, expr_vector);
    24     size_t len = expr_vector.get_len();
    25     if (len > SIZE_MAX)
    26       RF_LIB_ERROR("Size limit exceeded");
    27     p_vector->vector_replace(len, expr_vector);
     24    Term* p = _source.get_first();
     25    Term* q = _source.get_last();
     26    for ( ; p < q; p++) {
     27      if (p->is_ref()) {
     28        length++;
     29        expr_vector = expr_vector + (Expr(p))();
     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        length += v_length;
     36        for (size_t i=0; i < v_length; i++)
     37          expr_vector = expr_vector + (*v)[i];
     38      }
     39    }
     40    p_vector->vector_replace(length, expr_vector);
    2841  } else
    2942    RF_LIB_ERROR("Invalid argument");
  • to-imperative/trunk/runtime/rf_vector.hh

    r1045 r1098  
    3838};
    3939
    40   inline void vector_meaning (Expr const& _exp, Expr& _result);
    41 
    4240}
    4341
  • to-imperative/trunk/runtime/rf_vector.ih

    r1048 r1098  
    3232  Term* q = _expr.get_last();
    3333  size_t index = 0;
    34   for (; p < q; p++) {
     34  for ( ; p < q; p++) {
    3535    if (p->is_ref()) {
    3636      self[index++] = (Expr(p))();
    3737    } else {
    38       FATAL("Invalid argument");               //  RF_LIB_ERROR - ??????
     38      Vector* v = p->cast_to<Vector> (type_vector);
     39      if (!v)
     40        FATAL ("Invalid argument");
     41      for (size_t i = 0; i < (v->get_length()); i++)
     42        self[index++] = (*v)[i];
    3943    }
    4044  }
    41 }
     45}     
    4246
    4347inline Vector::Vector(Vector const& _vector, size_t _index, size_t _length) :
     
    108112  Term* q = _exp.get_last();
    109113  n = 0;
    110   for ( ; p < q ; p++) {
    111     if (p->is_ref()) {
     114  for ( ; p < q ; p++)
    112115      self[n++] = (Expr(p))();
    113     } else {
    114       FATAL("Invalid argument");     
    115     }
    116   }
    117116}   
    118 
    119 inline void  vector_meaning (Expr const& _exp, Expr& _result)
    120 {
    121   Term* p = _exp.get_first();
    122   Term* q = _exp.get_last();
    123   for ( ; p < q; p++) {
    124     if (p->is_ref()) {
    125       _result = _result + (Expr(p))();
    126     } else {
    127       Vector* v = p->cast_to<Vector> (type_vector);
    128       if (!v)
    129         FATAL ("Invalid argument");
    130       for (size_t i = 0; i < v->get_length(); i++)
    131         _result = _result + (*v)[i];
    132     }
    133   }
    134 }     
    135117 
    136118inline void Vector::vector_fill (Expr const& _fill)
Note: See TracChangeset for help on using the changeset viewer.