Changeset 678
- Timestamp:
- Apr 27, 2003, 1:32:08 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
to-imperative/trunk/runtime/rf_short_int.cc
r675 r678 26 26 //othewise _flag == 0 27 27 28 Expr e = Term::create_expr(1); 28 Term* p = _expr.get_first(); 29 Term* q = _expr.get_last(); 29 30 30 Term* t = _expr.get_last() - 1;31 Term* p = _expr.get_first();32 33 31 intptr_t n = 0; 34 32 35 //the following two variables are for computing the position 36 //of digit in number 37 38 intptr_t n_temp = 0; 39 uintptr_t k = 1; 40 41 for (; t > _expr.get_first(); t--){ 42 if (t->get_type() == type_short_int) { 43 n_temp = (((ShortInt*)t)->to_int()); 44 n = n + n_temp * k; 45 46 while (n_temp!=0) { 47 n_temp = n_temp/10; 48 k = k*10; 49 } 33 if (p->get_type() == type_short_int) { 34 n = ((ShortInt*)p)->to_int(); 35 if (n < 0) { 36 n = -n; 37 _flag = -1; 50 38 } 51 39 else 52 if (t->get_type() == type_char) { 53 n += (((Char*)t)->to_wchar_t() - 48)*k; 54 k = k*10; 55 } 56 } 57 if (t->get_type() == type_char && ((Char*)t)->is_digit()) { 58 n += (((Char*)t)->to_wchar_t() - 48)*k; 59 k = k*10; 60 } 61 intptr_t temp = 0; 62 63 if (p->get_type() == type_short_int){ 64 temp = ( (ShortInt*)_expr.get_first() )->to_int(); 65 if (temp < 0) 66 n = -n + temp * k; 67 else 68 n = n + temp * k; 40 _flag = 1; 69 41 } 70 42 71 if (_flag == -1) n = -n; 43 for (p += _flag * _flag; p < q; p++) { 44 if (p->get_type() == type_short_int) { 45 intptr_t n_temp = ((ShortInt*)p)->to_int() / 10; 46 intptr_t k = 10; 47 48 while (n_temp) { 49 n_temp /= 10; 50 k *= 10; 51 } 72 52 53 n = n * k + ((ShortInt*)p)->to_int(); 54 } 55 else 56 if (p->get_type() == type_char) { 57 n = n * 10 + (((Char*)p)->to_wchar_t() - 48); 58 } 59 } 60 61 if (-1 == _flag) n = -n; 62 63 Expr e = Term::create_expr(1); 73 64 74 65 new(e.get_first()) ShortInt(n);
Note: See TracChangeset
for help on using the changeset viewer.