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

Last change on this file since 1114 was 1114, checked in by luba, 17 years ago
  • type_short_int is replaced by type_int32
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 731 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::Int32* len = p_length->cast_to<rftype::Int32>(type_int32);
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.