source: to-imperative/trunk/library/Vector/vector_init.cc @ 1098

Last change on this file since 1098 was 1098, checked in by sveta, 17 years ago
  • Method "Vector-Replace" is changed.
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 741 bytes
Line 
1#include <rf_core.hh>
2#include <rf_types.hh>
3#include <stdint.h>
4
5using namespace rfrt;
6
7namespace refal
8{
9
10namespace Vector
11{
12
13RF_DECL(Vector_m_Init);
14
15RF_FUNC (Vector_m_Init, (RF_ARG _vector, _length, _fill), ())
16 
17  if (_vector.get_len() == 1) {
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    Term* p_length = _length.get_first();
23    rftype::ShortInt* len = p_length->cast_to<rftype::ShortInt>(type_short_int);
24    if (!len)
25      RF_LIB_ERROR("Invalid argument"); 
26    else { 
27      size_t l = len->to_int(); 
28      v-> vector_init(l, _fill);
29    }
30  } else
31      RF_LIB_ERROR("Invalid argument");
32
33RF_END
34
35}
36}
Note: See TracBrowser for help on using the repository browser.