Last change
on this file since 674 was
674,
checked in by luba, 18 years ago
|
- examinig first symbol in input expression is corrected
|
-
Property svn:eol-style set to
native
-
Property svn:keywords set to
Author Date Id Revision
|
File size:
1.5 KB
|
Line | |
---|
1 | // $Source$ |
---|
2 | // $Revision: 674 $ |
---|
3 | // $Date: 2003-04-26 07:37:26 +0000 (Sat, 26 Apr 2003) $ |
---|
4 | // $Author: luba $ |
---|
5 | |
---|
6 | #include <rf_core.hh> |
---|
7 | #include <rf_short_int.hh> |
---|
8 | |
---|
9 | namespace refal |
---|
10 | { |
---|
11 | |
---|
12 | using namespace rfrt; |
---|
13 | using namespace rftype; |
---|
14 | |
---|
15 | namespace Convert |
---|
16 | { |
---|
17 | |
---|
18 | RF_FUNC (To_m_Int, (RF_ARG e_Exp), (RF_RES s_Int)) |
---|
19 | uintptr_t len = 0; |
---|
20 | int flag = 0; |
---|
21 | |
---|
22 | Term* t = e_Exp.get_first(); |
---|
23 | |
---|
24 | if (t->get_type() == type_char) { |
---|
25 | if (((Char*)t)->to_wchar_t() == '-') |
---|
26 | flag = -1; |
---|
27 | |
---|
28 | if (((Char*)t)->to_wchar_t() == '+') |
---|
29 | flag = 1; |
---|
30 | }; |
---|
31 | |
---|
32 | //добавить для Word проверку первого символа |
---|
33 | |
---|
34 | if (flag || t->get_type() == type_short_int) |
---|
35 | t++; |
---|
36 | |
---|
37 | for (; t < e_Exp.get_last(); t++) { |
---|
38 | if (t->get_type() == type_char && ((Char*)t)->is_digit()) |
---|
39 | if (len > UINTPTR_MAX - 1) |
---|
40 | RF_LIB_ERROR("Argument too large for conversion"); |
---|
41 | else |
---|
42 | len += 1; |
---|
43 | else |
---|
44 | if (t->get_type() == type_short_int) { |
---|
45 | if (((ShortInt*)t)->to_int() < 0) |
---|
46 | retfail; |
---|
47 | else |
---|
48 | if (len > UINTPTR_MAX - ShortInt::get_char_len(((ShortInt*)t)->to_int())) |
---|
49 | RF_LIB_ERROR("Argument too large for conversion"); |
---|
50 | else |
---|
51 | len += ShortInt::get_char_len(((ShortInt*)t)->to_int()); |
---|
52 | } |
---|
53 | #if 0 |
---|
54 | else |
---|
55 | if (t->get_type() == type_word && ((Word*)t)->is_number()) |
---|
56 | if (len > UINTPTR_MAX - длина слова )) |
---|
57 | RF_LIB_ERROR("Argument too large for conversion"); |
---|
58 | else |
---|
59 | len += ((Word*)t)->get_len(); |
---|
60 | #endif |
---|
61 | else |
---|
62 | retfail; |
---|
63 | }; |
---|
64 | s_Int = ShortInt::create_expr(e_Exp, flag); |
---|
65 | |
---|
66 | RF_END |
---|
67 | } |
---|
68 | } |
---|
69 | |
---|
Note: See
TracBrowser
for help on using the repository browser.