source: to-imperative/trunk/library/Arithm/rem.cc @ 1105

Last change on this file since 1105 was 1105, checked in by luba, 17 years ago
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 671 bytes
Line 
1// $Source$
2// $Revision: 1105 $
3// $Date: 2003-08-06 13:27:37 +0000 (Wed, 06 Aug 2003) $
4// $Author: luba $
5
6#include <rf_core.hh>
7#include <rf_integer.ih>
8
9namespace refal
10{
11
12using namespace rfrt;
13using namespace rftype;
14
15namespace Arithm
16{
17
18RF_FUNC (Rem, (RF_ARG s_Int1, s_Int2), (RF_RES s_Res))
19
20  Term* p_Int1 = s_Int1.get_first();
21  Term* p_Int2 = s_Int2.get_first();
22
23  if (p_Int1->get_type() == type_int) {
24    Integer* i1 = static_cast<Integer*>(p_Int1);
25    if (p_Int2->get_type() == type_int) {
26      Integer* i2 = static_cast<Integer*>(p_Int2);
27      s_Res = Integer::create_expr((*i1) % (*i2));
28    } else {
29      RF_LIB_ERROR("Invalid argument");
30    }
31  } else {
32    RF_LIB_ERROR("Invalid argument");
33  }
34RF_END
35}
36
37}
Note: See TracBrowser for help on using the repository browser.