Changeset 1376
- Timestamp:
- Mar 18, 2004, 10:04:11 PM (17 years ago)
- Location:
- to-imperative/branches/parenth_term/runtime
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
to-imperative/branches/parenth_term/runtime/rf_box.hh
r502 r1376 34 34 35 35 inline void put (Expr const& _expr) ; 36 inline Expr get () ;36 inline Expr get () const ; 37 37 38 inline pxx::WString to_string () const ; 38 39 39 40 }; -
to-imperative/branches/parenth_term/runtime/rf_box.ih
r502 r1376 65 65 } 66 66 67 inline Expr Box::get () 67 inline Expr Box::get () const 68 68 { 69 69 return content; 70 } 71 72 inline pxx::WString Box::to_string () const 73 { 74 size_t max_len = hex_ptr_len + 10; 75 wchar_t str[max_len]; 76 int len = swprintf(str, max_len, L"<Box|%p|", this); 77 if (-1 == len) 78 FATAL("<Box|%p| is more then %u wide characters", this, max_len); 79 return pxx::WString(str, len) + pxx::WString(content) + pxx::WString(L">"); 70 80 } 71 81 -
to-imperative/branches/parenth_term/runtime/rf_channel.hh
r1363 r1376 34 34 inline bool operator == (Object const& _obj) const ; 35 35 36 inline pxx::WString to_string () const ; 37 36 38 inline bool open (char const* _fname, char const* _mode) ; 37 39 inline void close () ; -
to-imperative/branches/parenth_term/runtime/rf_channel.ih
r1363 r1376 82 82 } 83 83 84 inline pxx::WString Channel::to_string () const 85 { 86 size_t max_len = hex_ptr_len + max_int_len + 15; 87 wchar_t str[max_len]; 88 int len = 89 swprintf(str, max_len, L"<Channel|%p|%d>", this, fp ? fileno(fp) : -1); 90 if (-1 == len) { 91 FATAL("<Channel|%p|%d> is more then %u wide characters", 92 this, fp ? fileno(fp) : -1, max_len); 93 } 94 return pxx::WString(str, len); 95 } 96 84 97 } 85 98 -
to-imperative/branches/parenth_term/runtime/rf_common.hh
r1312 r1376 32 32 extern uintptr_t stack_size ; 33 33 34 #if UINTPTR_MAX == UINT32_MAX 35 static const uint8_t hex_ptr_len = 8; 36 #elif UINTPTR_MAX == UINT64_MAX 37 static const uint8_t hex_ptr_len = 16; 38 #else 39 #error "Unsupported pointer size" 40 #endif 41 42 static const uint8_t max_int_len = 10; 43 // FIXME: Is int 32 bits everywhere? 44 34 45 #if DEBUG 35 46 extern uintptr_t empty_copy ; -
to-imperative/branches/parenth_term/runtime/rf_expr.ih
r1367 r1376 862 862 if (fprintf(_fp, "%" PRIdPTR, ((Int32 const&)(*p)).to_int()) == -1) 863 863 return false; 864 } else if (p->get_type() == type_int) {864 } else { // if (p->get_type() == type_int) { 865 865 // mpz_t* z = static_cast<Integer*>(p)->get_mpz_ptr(); 866 866 // if (!mpz_out_str(_fp, 10, *z)) return false; 867 867 if (!write_wstr(_fp, (WString)(*p))) return false; 868 } else {869 fprintf(_fp, " <%u|%p> ", p->get_type(), p->ptr_data2);868 // } else { 869 // fprintf(_fp, " <%u|%p> ", p->get_type(), p->ptr_data2); 870 870 // FATAL("Not supported yet"); 871 871 } … … 882 882 for (Term* p = first; p < last; p++) { 883 883 if (p->is_sym()) { 884 if (!(p->is_dynamic())) { 885 WString s = (WString)(*p); 886 size_t len = s.get_length(); 887 char buf[MB_CUR_MAX + 1]; 888 for (size_t i = 0; i < len; i++) { 889 size_t n = wctomb(buf, s[i]); 890 if (n != (size_t)(-1)) { 891 buf[n] = 0; 892 if (fputs(buf, _fp) == EOF) return false; 893 } else { 894 if (fputc('?', _fp) == EOF) return false; 895 } 896 } 897 } else { 898 if (fprintf(_fp,"<%u|%p>", p->get_type(), p->ptr_data2) < 0) 899 return false; 900 } 884 WString s = (WString)(*p); 885 size_t len = s.get_length(); 886 char buf[MB_CUR_MAX + 1]; 887 for (size_t i = 0; i < len; i++) { 888 size_t n = wctomb(buf, s[i]); 889 if (n != (size_t)(-1)) { 890 buf[n] = 0; 891 if (fputs(buf, _fp) == EOF) return false; 892 } else { 893 if (fputc('?', _fp) == EOF) return false; 894 } 895 } 901 896 } else if (p->is_ref()) { 902 897 if (fputc('(', _fp) == EOF) return false; -
to-imperative/branches/parenth_term/runtime/rf_object.ih
r1287 r1376 111 111 inline pxx::WString Object::to_string () const 112 112 { 113 return (pxx::WString(L"")); 113 size_t max_len = hex_ptr_len + 15; 114 wchar_t str[max_len]; 115 int len = swprintf(str, max_len, L"<Object|%p>", this); 116 if (-1 == len) 117 FATAL("<Object|%p> is more then %u wide characters", this, max_len); 118 return pxx::WString(str, len); 114 119 } 115 120 -
to-imperative/branches/parenth_term/runtime/rf_table.hh
r1288 r1376 44 44 inline uint32_t hash () const; 45 45 inline bool operator == (Object const&) const; 46 inline pxx::WString to_string () const; 46 47 }; 47 48 -
to-imperative/branches/parenth_term/runtime/rf_table.ih
r1288 r1376 151 151 } 152 152 153 inline pxx::WString Table::to_string () const 154 { 155 size_t max_len = hex_ptr_len + 15; 156 wchar_t str[max_len]; 157 int len = swprintf(str, max_len, L"<Table|%p>", this, root); 158 if (-1 == len) 159 FATAL("<Table|%p> is more then %u wide characters", this, max_len); 160 return pxx::WString(str, len); 161 } 153 162 154 163 } -
to-imperative/branches/parenth_term/runtime/rf_term.hh
r1367 r1376 133 133 inline bool is_ref () const ; 134 134 /// 135 /// Check whether a term is a dynamic symbol136 inline bool is_dynamic() const;137 ///138 135 /// Check whether a term is a border symbol 139 136 inline bool is_border () const ; -
to-imperative/branches/parenth_term/runtime/rf_term.ih
r1367 r1376 77 77 return get_short_type() > type_parenth; 78 78 } 79 80 inline bool Term::is_dynamic() const81 {82 unsigned obj = get_type();83 return (obj==type_box) || (obj==type_vector) || (obj==type_table) || (obj==type_channel);84 }85 86 79 87 80 inline bool Term::is_ref () const -
to-imperative/branches/parenth_term/runtime/rf_vector.hh
r1287 r1376 24 24 inline Vector (size_t _length, Expr const& _fill) ; 25 25 inline Vector (Expr const& _expr, size_t _length) ; 26 inline Vector (Vector const& _vector, size_t _index, size_t _length) ;26 inline Vector (Vector const& _vector, size_t _index, size_t _length) ; 27 27 28 28 inline unsigned get_type () const ; … … 30 30 31 31 inline bool operator == (Object const& _obj) const ; 32 inline const Vector& operator = (Vector const&); 32 inline const Vector& operator = (Vector const&) ; 33 34 inline pxx::WString to_string () const ; 33 35 }; 34 36 -
to-imperative/branches/parenth_term/runtime/rf_vector.ih
r1287 r1376 97 97 } 98 98 99 inline pxx::WString Vector::to_string () const 100 { 101 size_t max_len = hex_ptr_len * 2 + 15; 102 wchar_t str[max_len]; 103 int len = swprintf(str, max_len, L"<Vector|%p|%p>", this, get_data()); 104 if (-1 == len) { 105 FATAL("<Vector|%p|%p> is more then %u wide characters", 106 this, get_data(), max_len); 107 } 108 return pxx::WString(str, len); 109 } 99 110 100 111 }
Note: See TracChangeset
for help on using the changeset viewer.