Changeset 1040


Ignore:
Timestamp:
Jul 18, 2003, 10:22:19 PM (17 years ago)
Author:
sveta
Message:
  • Library VECTOR.
Location:
to-imperative/trunk
Files:
8 added
4 edited

Legend:

Unmodified
Added
Removed
  • to-imperative/trunk/library/Makefile

    r1012 r1040  
    11SUBDIRS = \
    2   Access Arithm Box Class Convert StdIO String Table Compare Dos
     2  Access Arithm Box Class Convert StdIO String Table Compare Dos Vector
    33
    44TOPDIR = ..
  • to-imperative/trunk/runtime/rf_vector.hh

    r583 r1040  
    2323  inline Vector (size_t _length = 0) ;
    2424  inline Vector (size_t _length, Expr const& _fill) ;
    25   inline Vector (Expr const& _expr) ;
     25  inline Vector (Expr const& _expr, size_t _length) ;
    2626
    2727  inline unsigned get_type () const ;
     
    3030  inline bool operator == (Object const& _obj) const ;
    3131
     32  inline void vector_to_exp (Expr& _exp);
     33  inline void vector_init (size_t _length, Expr const& _fill);
     34  inline void vector_fill (Expr const& _fill);
     35
    3236};
    3337
  • to-imperative/trunk/runtime/rf_vector.ih

    r862 r1040  
    77#include "pxx_vector.ih"
    88#include <typeinfo>
     9
     10// using namespace rfrt;
    911
    1012namespace rftype
     
    2325    self[i] = _fill;
    2426  }
    25 }
     27} 
    2628
    27 inline Vector::Vector (Expr const& _expr) :
     29inline Vector::Vector (Expr const& _expr, size_t _length) :
    2830  Object (),
    29   pxx::Vector<Expr> (0)
     31  pxx::Vector<Expr> (_length)
    3032{
    3133  Term* p = _expr.get_first();
     
    3436  for (; p < q; p++) {
    3537    if (p->is_ref()) {
    36       self[index++] = Expr(p);
     38      self[index++] = (Expr(p))();
    3739    } else {
    3840      Vector* v = p->cast_to<Vector>(type_vector);
    39       if (!v)
    40         FATAL("Vector(): Argument expression contains non-vector object");
     41//      if (!v)
     42//        FATAL("Invalid argument");               //  RF_LIB_ERROR - ??????
    4143      for (size_t i = 0; i < v->get_length(); i++) {
    4244        self[index++] = (*v)[i];
     
    7476}
    7577
     78inline void Vector::vector_to_exp (Expr& _exp)
     79{
     80  for (size_t i = 0; i < get_length(); i++)
     81    _exp = _exp + self[i];
     82}
     83
     84inline void Vector::vector_init (size_t _length, Expr const& _fill)
     85{
     86  size_t n = get_length();
     87  if (n < _length) 
     88      expand (_length-n);
     89  else
     90    if (n > _length) {
     91      decrease(n-_length);
     92      n = _length;
     93    }
     94   for (  ; n  ; n--)
     95     self[n-1] = _fill();
     96}
     97
     98inline void Vector::vector_fill (Expr const& _fill)
     99{
     100  for (size_t i = 0; i < get_length(); i++)
     101    self[i] = _fill();
     102}
     103
    76104}
    77105
  • to-imperative/trunk/samples/Makefile

    r1014 r1040  
    1414  Table \
    1515  Compare \
    16   Dos
     16  Dos \
     17  Vector
    1718
    1819samples : override SUBDIRS =
Note: See TracChangeset for help on using the changeset viewer.