source: to-imperative/trunk/library/Arithm/div_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: 802 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 (Div_m_Rem, (RF_ARG s_Int1, s_Int2), (RF_RES s_Quo, s_Rem))
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    Expr r = Integer::create_expr(0);
26    Integer* rp = static_cast<Integer*>(r.get_first());
27    if (p_Int2->get_type() == type_int) {
28      Integer* i2 = static_cast<Integer*>(p_Int2);
29      s_Quo = Integer::create_expr(i1->div_rem(*i2, rp));
30      s_Rem = r;
31    } else {
32      RF_LIB_ERROR("Invalid argument");
33    }
34  } else {
35    RF_LIB_ERROR("Invalid argument");
36  }
37RF_END
38}
39
40}
Note: See TracBrowser for help on using the repository browser.