source: to-imperative/trunk/library/Vector/subvector_fill.cc @ 1045

Last change on this file since 1045 was 1045, checked in by sveta, 18 years ago
  • Methods for Vector are added.
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 947 bytes
Line 
1#include <rf_core.hh>
2#include <rf_types.hh>
3
4using namespace rfrt;
5
6namespace refal
7{
8
9namespace Vector
10{
11
12RF_DECL(Subvector_m_Fill);
13
14RF_FUNC (Subvector_m_Fill, (RF_ARG _vector, _index, _length, _fill), ())
15
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    Term* t = _index.get_first();
22    rftype::ShortInt* p = t->cast_to<rftype::ShortInt>(type_short_int);
23    if (!p)
24      RF_LIB_ERROR("Invalid argument"); 
25    size_t ind = p->to_int();
26    t = _length.get_first();
27    p = t->cast_to<rftype::ShortInt>(type_short_int);
28    if (!p)
29      RF_LIB_ERROR("Invalid argument");
30    size_t len = p->to_int();   
31    if (ind + len > v->get_length())
32      RF_LIB_ERROR("Index out of range");
33    v->subvector_fill(ind, len, _fill);
34  } else
35      RF_LIB_ERROR("Invalid argument");
36
37RF_END
38
39}
40}
Note: See TracBrowser for help on using the repository browser.