Johnny Chen | 5016669 | 2012-08-04 01:36:57 +0000 | [diff] [blame] | 1 | //===-------------------------- cxa_demangle.cpp --------------------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is dual licensed under the MIT and the University of Illinois Open |
| 6 | // Source Licenses. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
Filipe Cabecinhas | fd953a2 | 2012-08-07 16:33:49 +0000 | [diff] [blame] | 10 | #include "lldb/Core/cxa_demangle.h" |
Johnny Chen | 5016669 | 2012-08-04 01:36:57 +0000 | [diff] [blame] | 11 | |
| 12 | #include <stdlib.h> |
| 13 | #include <string.h> |
| 14 | #include <ctype.h> |
| 15 | #include <stdio.h> |
| 16 | #include <new> |
| 17 | #include <algorithm> |
| 18 | #include <assert.h> |
| 19 | |
| 20 | #ifdef DEBUGGING |
| 21 | |
| 22 | #include <string> |
| 23 | #include <typeinfo> |
| 24 | |
| 25 | #endif |
| 26 | |
| 27 | namespace lldb_cxxabiv1 |
| 28 | { |
| 29 | |
| 30 | namespace __libcxxabi |
| 31 | { |
| 32 | |
| 33 | #pragma GCC visibility push(hidden) |
| 34 | |
| 35 | class __node |
| 36 | { |
| 37 | __node(const __node&); |
| 38 | __node& operator=(const __node&); |
| 39 | public: |
| 40 | const char* __name_; |
| 41 | size_t __size_; |
| 42 | __node* __left_; |
| 43 | __node* __right_; |
| 44 | long __cached_size_; |
| 45 | long double __value_; |
| 46 | public: |
| 47 | __node() |
| 48 | : __name_(0), __size_(0), __left_(0), __right_(0), __cached_size_(-1) |
| 49 | {} |
| 50 | virtual ~__node() {}; |
| 51 | |
| 52 | void reset_cached_size() |
| 53 | { |
| 54 | __cached_size_ = -1; |
| 55 | if (__left_) |
| 56 | __left_->reset_cached_size(); |
| 57 | if (__right_) |
| 58 | __right_->reset_cached_size(); |
| 59 | } |
| 60 | |
| 61 | virtual size_t first_size() const {return 0;} |
| 62 | virtual size_t second_size() const {return 0;} |
| 63 | virtual size_t size() const |
| 64 | { |
| 65 | if (__cached_size_ == -1) |
| 66 | const_cast<long&>(__cached_size_) = static_cast<long>(first_size() + second_size()); |
| 67 | return static_cast<size_t>(__cached_size_); |
| 68 | } |
| 69 | virtual char* first_demangled_name(char* buf) const {return buf;} |
| 70 | virtual char* second_demangled_name(char* buf) const {return buf;} |
| 71 | virtual char* get_demangled_name(char* buf) const |
| 72 | { |
| 73 | return second_demangled_name(first_demangled_name(buf)); |
| 74 | } |
| 75 | virtual size_t base_size() const {return size();} |
| 76 | virtual char* get_base_name(char* buf) const |
| 77 | { |
| 78 | return get_demangled_name(buf); |
| 79 | } |
| 80 | |
| 81 | virtual bool ends_with_template(bool /*parsing*/ = false) const |
| 82 | { |
| 83 | return false; |
| 84 | } |
| 85 | virtual bool is_ctor_dtor_conv() const |
| 86 | { |
| 87 | return false; |
| 88 | } |
| 89 | virtual __node* base_name() const |
| 90 | { |
| 91 | return const_cast<__node*>(this); |
| 92 | } |
| 93 | virtual bool is_reference_or_pointer_to_function_or_array() const |
| 94 | { |
| 95 | return false; |
| 96 | } |
| 97 | virtual bool is_function() const |
| 98 | { |
| 99 | return false; |
| 100 | } |
| 101 | virtual bool is_cv_qualifer() const |
| 102 | { |
| 103 | return false; |
| 104 | } |
| 105 | virtual bool is_array() const |
| 106 | { |
| 107 | return false; |
| 108 | } |
| 109 | |
| 110 | virtual bool fix_forward_references(__node**, __node**) |
| 111 | { |
| 112 | return true; |
| 113 | } |
| 114 | virtual __node* extract_cv(__node*&) const |
| 115 | { |
| 116 | return 0; |
| 117 | } |
| 118 | virtual size_t list_len() const |
| 119 | { |
| 120 | return 0; |
| 121 | } |
| 122 | virtual bool is_sub() const |
| 123 | { |
| 124 | return false; |
| 125 | } |
| 126 | }; |
| 127 | |
| 128 | #ifdef DEBUGGING |
| 129 | |
| 130 | void display(__node* x, int indent = 0) |
| 131 | { |
| 132 | if (x) |
| 133 | { |
| 134 | for (int i = 0; i < 2*indent; ++i) |
| 135 | printf(" "); |
Greg Clayton | 5292b44 | 2012-12-03 17:50:07 +0000 | [diff] [blame] | 136 | size_t sz = x->size(); |
| 137 | char* buf = (char*)calloc(sz+10, 1); |
Johnny Chen | 5016669 | 2012-08-04 01:36:57 +0000 | [diff] [blame] | 138 | x->get_demangled_name(buf); |
Greg Clayton | 5292b44 | 2012-12-03 17:50:07 +0000 | [diff] [blame] | 139 | printf("%s [%ld] %s, %p\n", typeid(*x).name(), sz, buf, x); |
| 140 | if (strlen(buf) != sz) |
| 141 | { |
| 142 | printf("strlen(buf) = %ld and size = %ld\n", strlen(buf), sz); |
| 143 | } |
Johnny Chen | 5016669 | 2012-08-04 01:36:57 +0000 | [diff] [blame] | 144 | free(buf); |
| 145 | display(x->__left_, indent+1); |
| 146 | display(x->__right_, indent+1); |
| 147 | } |
| 148 | } |
| 149 | |
| 150 | #endif |
| 151 | |
| 152 | class __vtable |
| 153 | : public __node |
| 154 | { |
| 155 | static const ptrdiff_t n = sizeof("vtable for ") - 1; |
| 156 | public: |
| 157 | __vtable(__node* type) |
| 158 | { |
| 159 | __right_ = type; |
| 160 | } |
| 161 | |
| 162 | virtual size_t first_size() const |
| 163 | { |
| 164 | if (__cached_size_ == -1) |
| 165 | const_cast<long&>(__cached_size_) = n + static_cast<long>(__right_->size()); |
| 166 | return static_cast<size_t>(__cached_size_); |
| 167 | } |
| 168 | virtual char* first_demangled_name(char* buf) const |
| 169 | { |
| 170 | strncpy(buf, "vtable for ", n); |
| 171 | return __right_->get_demangled_name(buf+n); |
| 172 | } |
| 173 | virtual __node* base_name() const |
| 174 | { |
| 175 | return __right_->base_name(); |
| 176 | } |
| 177 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 178 | { |
| 179 | return __right_->fix_forward_references(t_begin, t_end); |
| 180 | } |
| 181 | }; |
| 182 | |
| 183 | class __VTT |
| 184 | : public __node |
| 185 | { |
| 186 | static const ptrdiff_t n = sizeof("VTT for ") - 1; |
| 187 | public: |
| 188 | __VTT(__node* type) |
| 189 | { |
| 190 | __right_ = type; |
| 191 | } |
| 192 | |
| 193 | virtual size_t first_size() const |
| 194 | { |
| 195 | if (__cached_size_ == -1) |
| 196 | const_cast<long&>(__cached_size_) = n + static_cast<long>(__right_->size()); |
| 197 | return static_cast<size_t>(__cached_size_); |
| 198 | } |
| 199 | virtual char* first_demangled_name(char* buf) const |
| 200 | { |
| 201 | strncpy(buf, "VTT for ", n); |
| 202 | return __right_->get_demangled_name(buf+n); |
| 203 | } |
| 204 | virtual __node* base_name() const |
| 205 | { |
| 206 | return __right_->base_name(); |
| 207 | } |
| 208 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 209 | { |
| 210 | return __right_->fix_forward_references(t_begin, t_end); |
| 211 | } |
| 212 | }; |
| 213 | |
| 214 | class __construction_vtable |
| 215 | : public __node |
| 216 | { |
| 217 | static const ptrdiff_t n = sizeof("construction vtable for ") - 1 + 4; |
| 218 | public: |
| 219 | __construction_vtable(__node* left, __node* right) |
| 220 | { |
| 221 | __left_ = left; |
| 222 | __right_ = right; |
| 223 | } |
| 224 | |
| 225 | virtual size_t first_size() const |
| 226 | { |
| 227 | if (__cached_size_ == -1) |
| 228 | const_cast<long&>(__cached_size_) = n + static_cast<long>(__left_->size() |
| 229 | + __right_->size()); |
| 230 | return static_cast<size_t>(__cached_size_); |
| 231 | } |
| 232 | virtual char* first_demangled_name(char* buf) const |
| 233 | { |
| 234 | strncpy(buf, "construction vtable for ", n-4); |
| 235 | buf = __left_->get_demangled_name(buf+n-4); |
| 236 | *buf++ = '-'; |
| 237 | *buf++ = 'i'; |
| 238 | *buf++ = 'n'; |
| 239 | *buf++ = '-'; |
| 240 | return __right_->get_demangled_name(buf); |
| 241 | } |
| 242 | virtual __node* base_name() const |
| 243 | { |
| 244 | return __right_->base_name(); |
| 245 | } |
| 246 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 247 | { |
| 248 | bool r = true; |
| 249 | if (__left_) |
| 250 | r = __left_->fix_forward_references(t_begin, t_end); |
| 251 | return r && __right_->fix_forward_references(t_begin, t_end); |
| 252 | } |
| 253 | }; |
| 254 | |
| 255 | class __typeinfo |
| 256 | : public __node |
| 257 | { |
| 258 | static const ptrdiff_t n = sizeof("typeinfo for ") - 1; |
| 259 | public: |
| 260 | __typeinfo(__node* type) |
| 261 | { |
| 262 | __right_ = type; |
| 263 | } |
| 264 | |
| 265 | virtual size_t first_size() const |
| 266 | { |
| 267 | if (__cached_size_ == -1) |
| 268 | const_cast<long&>(__cached_size_) = n + static_cast<long>(__right_->size()); |
| 269 | return static_cast<size_t>(__cached_size_); |
| 270 | } |
| 271 | virtual char* first_demangled_name(char* buf) const |
| 272 | { |
| 273 | strncpy(buf, "typeinfo for ", n); |
| 274 | return __right_->get_demangled_name(buf+n); |
| 275 | } |
| 276 | virtual __node* base_name() const |
| 277 | { |
| 278 | return __right_->base_name(); |
| 279 | } |
| 280 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 281 | { |
| 282 | return __right_->fix_forward_references(t_begin, t_end); |
| 283 | } |
| 284 | }; |
| 285 | |
| 286 | class __typeinfo_name |
| 287 | : public __node |
| 288 | { |
| 289 | static const ptrdiff_t n = sizeof("typeinfo name for ") - 1; |
| 290 | public: |
| 291 | __typeinfo_name(__node* type) |
| 292 | { |
| 293 | __right_ = type; |
| 294 | } |
| 295 | |
| 296 | virtual size_t first_size() const |
| 297 | { |
| 298 | if (__cached_size_ == -1) |
| 299 | const_cast<long&>(__cached_size_) = n + static_cast<long>(__right_->size()); |
| 300 | return static_cast<size_t>(__cached_size_); |
| 301 | } |
| 302 | virtual char* first_demangled_name(char* buf) const |
| 303 | { |
| 304 | strncpy(buf, "typeinfo name for ", n); |
| 305 | return __right_->get_demangled_name(buf+n); |
| 306 | } |
| 307 | virtual __node* base_name() const |
| 308 | { |
| 309 | return __right_->base_name(); |
| 310 | } |
| 311 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 312 | { |
| 313 | return __right_->fix_forward_references(t_begin, t_end); |
| 314 | } |
| 315 | }; |
| 316 | |
| 317 | class __covariant_return_thunk |
| 318 | : public __node |
| 319 | { |
| 320 | static const ptrdiff_t n = sizeof("covariant return thunk to ") - 1; |
| 321 | public: |
| 322 | __covariant_return_thunk(__node* type) |
| 323 | { |
| 324 | __right_ = type; |
| 325 | } |
| 326 | |
| 327 | virtual size_t first_size() const |
| 328 | { |
| 329 | if (__cached_size_ == -1) |
| 330 | const_cast<long&>(__cached_size_) = n + static_cast<long>(__right_->size()); |
| 331 | return static_cast<size_t>(__cached_size_); |
| 332 | } |
| 333 | virtual char* first_demangled_name(char* buf) const |
| 334 | { |
| 335 | strncpy(buf, "covariant return thunk to ", n); |
| 336 | return __right_->get_demangled_name(buf+n); |
| 337 | } |
| 338 | virtual __node* base_name() const |
| 339 | { |
| 340 | return __right_->base_name(); |
| 341 | } |
| 342 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 343 | { |
| 344 | return __right_->fix_forward_references(t_begin, t_end); |
| 345 | } |
| 346 | }; |
| 347 | |
| 348 | class __virtual_thunk |
| 349 | : public __node |
| 350 | { |
| 351 | static const size_t n = sizeof("virtual thunk to ") - 1; |
| 352 | public: |
| 353 | __virtual_thunk(__node* type) |
| 354 | { |
| 355 | __right_ = type; |
| 356 | } |
| 357 | |
| 358 | virtual size_t first_size() const |
| 359 | { |
| 360 | if (__cached_size_ == -1) |
| 361 | const_cast<long&>(__cached_size_) = static_cast<long>(n + __right_->size()); |
| 362 | return static_cast<size_t>(__cached_size_); |
| 363 | } |
| 364 | virtual char* first_demangled_name(char* buf) const |
| 365 | { |
| 366 | strncpy(buf, "virtual thunk to ", n); |
| 367 | return __right_->get_demangled_name(buf+n); |
| 368 | } |
| 369 | virtual __node* base_name() const |
| 370 | { |
| 371 | return __right_->base_name(); |
| 372 | } |
| 373 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 374 | { |
| 375 | return __right_->fix_forward_references(t_begin, t_end); |
| 376 | } |
| 377 | }; |
| 378 | |
| 379 | class __non_virtual_thunk |
| 380 | : public __node |
| 381 | { |
| 382 | static const size_t n = sizeof("non-virtual thunk to ") - 1; |
| 383 | public: |
| 384 | __non_virtual_thunk(__node* type) |
| 385 | { |
| 386 | __right_ = type; |
| 387 | } |
| 388 | |
| 389 | virtual size_t first_size() const |
| 390 | { |
| 391 | if (__cached_size_ == -1) |
| 392 | const_cast<long&>(__cached_size_) = static_cast<long>(n + __right_->size()); |
| 393 | return static_cast<size_t>(__cached_size_); |
| 394 | } |
| 395 | virtual char* first_demangled_name(char* buf) const |
| 396 | { |
| 397 | strncpy(buf, "non-virtual thunk to ", n); |
| 398 | return __right_->get_demangled_name(buf+n); |
| 399 | } |
| 400 | virtual __node* base_name() const |
| 401 | { |
| 402 | return __right_->base_name(); |
| 403 | } |
| 404 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 405 | { |
| 406 | return __right_->fix_forward_references(t_begin, t_end); |
| 407 | } |
| 408 | }; |
| 409 | |
| 410 | class __guard_variable |
| 411 | : public __node |
| 412 | { |
| 413 | static const size_t n = sizeof("guard variable for ") - 1; |
| 414 | public: |
| 415 | __guard_variable(__node* type) |
| 416 | { |
| 417 | __right_ = type; |
| 418 | } |
| 419 | |
| 420 | virtual size_t first_size() const |
| 421 | { |
| 422 | if (__cached_size_ == -1) |
| 423 | const_cast<long&>(__cached_size_) = static_cast<long>(n + __right_->size()); |
| 424 | return static_cast<size_t>(__cached_size_); |
| 425 | } |
| 426 | virtual char* first_demangled_name(char* buf) const |
| 427 | { |
| 428 | strncpy(buf, "guard variable for ", n); |
| 429 | return __right_->get_demangled_name(buf+n); |
| 430 | } |
| 431 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 432 | { |
| 433 | return __right_->fix_forward_references(t_begin, t_end); |
| 434 | } |
| 435 | }; |
| 436 | |
| 437 | class __reference_temporary |
| 438 | : public __node |
| 439 | { |
| 440 | static const size_t n = sizeof("reference temporary for ") - 1; |
| 441 | public: |
| 442 | __reference_temporary(__node* type) |
| 443 | { |
| 444 | __right_ = type; |
| 445 | } |
| 446 | |
| 447 | virtual size_t first_size() const |
| 448 | { |
| 449 | if (__cached_size_ == -1) |
| 450 | const_cast<long&>(__cached_size_) = static_cast<long>(n + __right_->size()); |
| 451 | return static_cast<size_t>(__cached_size_); |
| 452 | } |
| 453 | virtual char* first_demangled_name(char* buf) const |
| 454 | { |
| 455 | strncpy(buf, "reference temporary for ", n); |
| 456 | return __right_->get_demangled_name(buf+n); |
| 457 | } |
| 458 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 459 | { |
| 460 | return __right_->fix_forward_references(t_begin, t_end); |
| 461 | } |
| 462 | }; |
| 463 | |
| 464 | class __source_name |
| 465 | : public __node |
| 466 | { |
| 467 | public: |
| 468 | __source_name(const char* __name, size_t __size) |
| 469 | { |
| 470 | __name_ = __name; |
| 471 | __size_ = __size; |
| 472 | } |
| 473 | |
| 474 | virtual size_t first_size() const |
| 475 | { |
| 476 | if (__cached_size_ == -1) |
| 477 | { |
| 478 | if (__size_ >= 10 && strncmp(__name_, "_GLOBAL__N", 10) == 0) |
| 479 | const_cast<long&>(__cached_size_) = 21; |
| 480 | else |
| 481 | const_cast<long&>(__cached_size_) = static_cast<long>(__size_); |
| 482 | } |
| 483 | return static_cast<size_t>(__cached_size_); |
| 484 | } |
| 485 | virtual char* first_demangled_name(char* buf) const |
| 486 | { |
| 487 | if (__size_ >= 10 && strncmp(__name_, "_GLOBAL__N", 10) == 0) |
| 488 | return strncpy(buf, "(anonymous namespace)", 21) + 21; |
| 489 | return strncpy(buf, __name_, __size_) + __size_; |
| 490 | } |
| 491 | }; |
| 492 | |
| 493 | class __operator_new |
| 494 | : public __node |
| 495 | { |
| 496 | public: |
| 497 | |
| 498 | virtual size_t first_size() const {return sizeof("operator new") - 1;} |
| 499 | virtual char* first_demangled_name(char* buf) const |
| 500 | { |
| 501 | return strncpy(buf, "operator new", sizeof("operator new") - 1) + |
| 502 | sizeof("operator new") - 1; |
| 503 | } |
| 504 | }; |
| 505 | |
| 506 | class __operator_new_array |
| 507 | : public __node |
| 508 | { |
| 509 | public: |
| 510 | |
| 511 | virtual size_t first_size() const {return sizeof("operator new[]") - 1;} |
| 512 | virtual char* first_demangled_name(char* buf) const |
| 513 | { |
| 514 | return strncpy(buf, "operator new[]", sizeof("operator new[]") - 1) + |
| 515 | sizeof("operator new[]") - 1; |
| 516 | } |
| 517 | }; |
| 518 | |
| 519 | class __operator_delete |
| 520 | : public __node |
| 521 | { |
| 522 | public: |
| 523 | |
| 524 | virtual size_t first_size() const {return sizeof("operator delete") - 1;} |
| 525 | virtual char* first_demangled_name(char* buf) const |
| 526 | { |
| 527 | return strncpy(buf, "operator delete", sizeof("operator delete") - 1) + |
| 528 | sizeof("operator delete") - 1; |
| 529 | } |
| 530 | }; |
| 531 | |
| 532 | class __operator_delete_array |
| 533 | : public __node |
| 534 | { |
| 535 | public: |
| 536 | |
| 537 | virtual size_t first_size() const {return sizeof("operator delete[]") - 1;} |
| 538 | virtual char* first_demangled_name(char* buf) const |
| 539 | { |
| 540 | return strncpy(buf, "operator delete[]", sizeof("operator delete[]") - 1) + |
| 541 | sizeof("operator delete[]") - 1; |
| 542 | } |
| 543 | }; |
| 544 | |
| 545 | class __operator_logical_and |
| 546 | : public __node |
| 547 | { |
| 548 | public: |
| 549 | |
| 550 | __operator_logical_and() {} |
| 551 | __operator_logical_and(__node* op1, __node* op2) |
| 552 | { |
| 553 | __left_ = op1; |
| 554 | __right_ = op2; |
| 555 | } |
| 556 | virtual size_t first_size() const |
| 557 | { |
| 558 | if (__cached_size_ == -1) |
| 559 | { |
| 560 | if (__left_) |
| 561 | const_cast<long&>(__cached_size_) = static_cast<long>( |
| 562 | __left_->size() + 8 + |
| 563 | __right_->size()); |
| 564 | else |
| 565 | const_cast<long&>(__cached_size_) = sizeof("operator&&") - 1; |
| 566 | } |
| 567 | return static_cast<size_t>(__cached_size_); |
| 568 | } |
| 569 | virtual char* first_demangled_name(char* buf) const |
| 570 | { |
| 571 | if (__left_) |
| 572 | { |
| 573 | *buf++ = '('; |
| 574 | buf = __left_->get_demangled_name(buf); |
| 575 | strncpy(buf, ") && (", 6); |
| 576 | buf += 6; |
| 577 | buf = __right_->get_demangled_name(buf); |
| 578 | *buf++ = ')'; |
| 579 | } |
| 580 | else |
| 581 | { |
| 582 | strncpy(buf, "operator&&", sizeof("operator&&") - 1); |
| 583 | buf += sizeof("operator&&") - 1; |
| 584 | } |
| 585 | return buf; |
| 586 | } |
| 587 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 588 | { |
| 589 | bool r = true; |
| 590 | if (__left_) |
| 591 | r = r && __left_->fix_forward_references(t_begin, t_end); |
| 592 | if (__right_) |
| 593 | r = r && __right_->fix_forward_references(t_begin, t_end); |
| 594 | return r; |
| 595 | } |
| 596 | }; |
| 597 | |
| 598 | class __operator_addressof |
| 599 | : public __node |
| 600 | { |
| 601 | public: |
| 602 | |
| 603 | __operator_addressof() {} |
| 604 | explicit __operator_addressof(__node* op) |
| 605 | { |
| 606 | __left_ = op; |
| 607 | } |
| 608 | virtual size_t first_size() const |
| 609 | { |
| 610 | if (__cached_size_ == -1) |
| 611 | { |
| 612 | if (__left_) |
| 613 | const_cast<long&>(__cached_size_) = static_cast<long>(3 + __left_->size()); |
| 614 | else |
| 615 | const_cast<long&>(__cached_size_) = sizeof("operator&") - 1; |
| 616 | } |
| 617 | return static_cast<size_t>(__cached_size_); |
| 618 | } |
| 619 | virtual char* first_demangled_name(char* buf) const |
| 620 | { |
| 621 | if (__left_) |
| 622 | { |
| 623 | *buf++ = '&'; |
| 624 | *buf++ = '('; |
| 625 | buf = __left_->get_demangled_name(buf); |
| 626 | *buf++ = ')'; |
| 627 | } |
| 628 | else |
| 629 | { |
| 630 | strncpy(buf, "operator&", sizeof("operator&") - 1); |
| 631 | buf += sizeof("operator&") - 1; |
| 632 | } |
| 633 | return buf; |
| 634 | } |
| 635 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 636 | { |
| 637 | if (__left_) |
| 638 | return __left_->fix_forward_references(t_begin, t_end); |
| 639 | return true; |
| 640 | } |
| 641 | }; |
| 642 | |
| 643 | class __operator_bit_and |
| 644 | : public __node |
| 645 | { |
| 646 | public: |
| 647 | |
| 648 | __operator_bit_and() {} |
| 649 | __operator_bit_and(__node* op1, __node* op2) |
| 650 | { |
| 651 | __left_ = op1; |
| 652 | __right_ = op2; |
| 653 | } |
| 654 | virtual size_t first_size() const |
| 655 | { |
| 656 | if (__cached_size_ == -1) |
| 657 | { |
| 658 | if (__left_) |
| 659 | const_cast<long&>(__cached_size_) = static_cast<long>( |
| 660 | __left_->size() + 7 + |
| 661 | __right_->size()); |
| 662 | else |
| 663 | const_cast<long&>(__cached_size_) = sizeof("operator&") - 1; |
| 664 | } |
| 665 | return static_cast<size_t>(__cached_size_); |
| 666 | } |
| 667 | virtual char* first_demangled_name(char* buf) const |
| 668 | { |
| 669 | if (__left_) |
| 670 | { |
| 671 | *buf++ = '('; |
| 672 | buf = __left_->get_demangled_name(buf); |
| 673 | strncpy(buf, ") & (", 5); |
| 674 | buf += 5; |
| 675 | buf = __right_->get_demangled_name(buf); |
| 676 | *buf++ = ')'; |
| 677 | } |
| 678 | else |
| 679 | { |
| 680 | strncpy(buf, "operator&", sizeof("operator&") - 1); |
| 681 | buf += sizeof("operator&") - 1; |
| 682 | } |
| 683 | return buf; |
| 684 | } |
| 685 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 686 | { |
| 687 | bool r = true; |
| 688 | if (__left_) |
| 689 | r = r && __left_->fix_forward_references(t_begin, t_end); |
| 690 | if (__right_) |
| 691 | r = r && __right_->fix_forward_references(t_begin, t_end); |
| 692 | return r; |
| 693 | } |
| 694 | }; |
| 695 | |
| 696 | class __operator_and_equal |
| 697 | : public __node |
| 698 | { |
| 699 | public: |
| 700 | |
| 701 | __operator_and_equal() {} |
| 702 | __operator_and_equal(__node* op1, __node* op2) |
| 703 | { |
| 704 | __left_ = op1; |
| 705 | __right_ = op2; |
| 706 | } |
| 707 | virtual size_t first_size() const |
| 708 | { |
| 709 | if (__cached_size_ == -1) |
| 710 | { |
| 711 | if (__left_) |
| 712 | const_cast<long&>(__cached_size_) = static_cast<long>( |
| 713 | __left_->size() + 8 + |
| 714 | __right_->size()); |
| 715 | else |
| 716 | const_cast<long&>(__cached_size_) = sizeof("operator&=") - 1; |
| 717 | } |
| 718 | return static_cast<size_t>(__cached_size_); |
| 719 | } |
| 720 | virtual char* first_demangled_name(char* buf) const |
| 721 | { |
| 722 | if (__left_) |
| 723 | { |
| 724 | *buf++ = '('; |
| 725 | buf = __left_->get_demangled_name(buf); |
| 726 | strncpy(buf, ") &= (", 6); |
| 727 | buf += 6; |
| 728 | buf = __right_->get_demangled_name(buf); |
| 729 | *buf++ = ')'; |
| 730 | } |
| 731 | else |
| 732 | { |
| 733 | strncpy(buf, "operator&=", sizeof("operator&=") - 1); |
| 734 | buf += sizeof("operator&=") - 1; |
| 735 | } |
| 736 | return buf; |
| 737 | } |
| 738 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 739 | { |
| 740 | bool r = true; |
| 741 | if (__left_) |
| 742 | r = r && __left_->fix_forward_references(t_begin, t_end); |
| 743 | if (__right_) |
| 744 | r = r && __right_->fix_forward_references(t_begin, t_end); |
| 745 | return r; |
| 746 | } |
| 747 | }; |
| 748 | |
| 749 | class __operator_equal |
| 750 | : public __node |
| 751 | { |
| 752 | public: |
| 753 | |
| 754 | __operator_equal() {} |
| 755 | __operator_equal(__node* op1, __node* op2) |
| 756 | { |
| 757 | __left_ = op1; |
| 758 | __right_ = op2; |
| 759 | } |
| 760 | virtual size_t first_size() const |
| 761 | { |
| 762 | if (__cached_size_ == -1) |
| 763 | { |
| 764 | if (__left_) |
| 765 | const_cast<long&>(__cached_size_) = static_cast<long>( |
| 766 | __left_->size() + 7 + |
| 767 | __right_->size()); |
| 768 | else |
| 769 | const_cast<long&>(__cached_size_) = sizeof("operator=") - 1; |
| 770 | } |
| 771 | return static_cast<size_t>(__cached_size_); |
| 772 | } |
| 773 | virtual char* first_demangled_name(char* buf) const |
| 774 | { |
| 775 | if (__left_) |
| 776 | { |
| 777 | *buf++ = '('; |
| 778 | buf = __left_->get_demangled_name(buf); |
| 779 | strncpy(buf, ") = (", 5); |
| 780 | buf += 5; |
| 781 | buf = __right_->get_demangled_name(buf); |
| 782 | *buf++ = ')'; |
| 783 | } |
| 784 | else |
| 785 | { |
| 786 | strncpy(buf, "operator=", sizeof("operator=") - 1); |
| 787 | buf += sizeof("operator=") - 1; |
| 788 | } |
| 789 | return buf; |
| 790 | } |
| 791 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 792 | { |
| 793 | bool r = true; |
| 794 | if (__left_) |
| 795 | r = r && __left_->fix_forward_references(t_begin, t_end); |
| 796 | if (__right_) |
| 797 | r = r && __right_->fix_forward_references(t_begin, t_end); |
| 798 | return r; |
| 799 | } |
| 800 | }; |
| 801 | |
| 802 | class __operator_alignof_type |
| 803 | : public __node |
| 804 | { |
| 805 | public: |
| 806 | |
| 807 | __operator_alignof_type() {} |
| 808 | __operator_alignof_type(__node* op) |
| 809 | { |
| 810 | __right_ = op; |
| 811 | } |
| 812 | virtual size_t first_size() const |
| 813 | { |
| 814 | if (__cached_size_ == -1) |
| 815 | { |
| 816 | if (__right_) |
| 817 | const_cast<long&>(__cached_size_) = static_cast<long>(__right_->size() + 10); |
| 818 | else |
| 819 | const_cast<long&>(__cached_size_) = sizeof("operator alignof") - 1; |
| 820 | } |
| 821 | return static_cast<size_t>(__cached_size_); |
| 822 | } |
| 823 | virtual char* first_demangled_name(char* buf) const |
| 824 | { |
| 825 | if (__right_) |
| 826 | { |
| 827 | strncpy(buf, "alignof (", 9); |
| 828 | buf += 9; |
| 829 | buf = __right_->get_demangled_name(buf); |
| 830 | *buf++ = ')'; |
| 831 | } |
| 832 | else |
| 833 | { |
| 834 | strncpy(buf, "operator alignof", sizeof("operator alignof") - 1); |
| 835 | buf += sizeof("operator alignof") - 1; |
| 836 | } |
| 837 | return buf; |
| 838 | } |
| 839 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 840 | { |
| 841 | if (__right_) |
| 842 | return __right_->fix_forward_references(t_begin, t_end); |
| 843 | return true; |
| 844 | } |
| 845 | }; |
| 846 | |
| 847 | class __operator_alignof_expression |
| 848 | : public __node |
| 849 | { |
| 850 | public: |
| 851 | |
| 852 | __operator_alignof_expression() {} |
| 853 | __operator_alignof_expression(__node* op) |
| 854 | { |
| 855 | __right_ = op; |
| 856 | } |
| 857 | virtual size_t first_size() const |
| 858 | { |
| 859 | if (__cached_size_ == -1) |
| 860 | { |
| 861 | if (__right_) |
| 862 | const_cast<long&>(__cached_size_) = static_cast<long>(__right_->size() + 10); |
| 863 | else |
| 864 | const_cast<long&>(__cached_size_) = sizeof("operator alignof") - 1; |
| 865 | } |
| 866 | return static_cast<size_t>(__cached_size_); |
| 867 | } |
| 868 | virtual char* first_demangled_name(char* buf) const |
| 869 | { |
| 870 | if (__right_) |
| 871 | { |
| 872 | strncpy(buf, "alignof (", 9); |
| 873 | buf += 9; |
| 874 | buf = __right_->get_demangled_name(buf); |
| 875 | *buf++ = ')'; |
| 876 | } |
| 877 | else |
| 878 | { |
| 879 | strncpy(buf, "operator alignof", sizeof("operator alignof") - 1); |
| 880 | buf += sizeof("operator alignof") - 1; |
| 881 | } |
| 882 | return buf; |
| 883 | } |
| 884 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 885 | { |
| 886 | if (__right_) |
| 887 | return __right_->fix_forward_references(t_begin, t_end); |
| 888 | return true; |
| 889 | } |
| 890 | }; |
| 891 | |
| 892 | class __operator_paren |
| 893 | : public __node |
| 894 | { |
| 895 | public: |
| 896 | |
| 897 | virtual size_t first_size() const {return sizeof("operator()") - 1;} |
| 898 | virtual char* first_demangled_name(char* buf) const |
| 899 | { |
| 900 | strncpy(buf, "operator()", sizeof("operator()") - 1); |
| 901 | return buf + sizeof("operator()") - 1; |
| 902 | } |
| 903 | }; |
| 904 | |
| 905 | class __operator_comma |
| 906 | : public __node |
| 907 | { |
| 908 | public: |
| 909 | |
| 910 | __operator_comma() {} |
| 911 | __operator_comma(__node* op1, __node* op2) |
| 912 | { |
| 913 | __left_ = op1; |
| 914 | __right_ = op2; |
| 915 | } |
| 916 | virtual size_t first_size() const |
| 917 | { |
| 918 | if (__cached_size_ == -1) |
| 919 | { |
| 920 | if (__left_) |
| 921 | const_cast<long&>(__cached_size_) = static_cast<long>( |
| 922 | __left_->size() + 7 + |
| 923 | __right_->size()); |
| 924 | else |
| 925 | const_cast<long&>(__cached_size_) = sizeof("operator,") - 1; |
| 926 | } |
| 927 | return static_cast<size_t>(__cached_size_); |
| 928 | } |
| 929 | virtual char* first_demangled_name(char* buf) const |
| 930 | { |
| 931 | if (__left_) |
| 932 | { |
| 933 | *buf++ = '('; |
| 934 | buf = __left_->get_demangled_name(buf); |
| 935 | strncpy(buf, ") , (", 5); |
| 936 | buf += 5; |
| 937 | buf = __right_->get_demangled_name(buf); |
| 938 | *buf++ = ')'; |
| 939 | } |
| 940 | else |
| 941 | { |
| 942 | strncpy(buf, "operator,", sizeof("operator,") - 1); |
| 943 | buf += sizeof("operator,") - 1; |
| 944 | } |
| 945 | return buf; |
| 946 | } |
| 947 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 948 | { |
| 949 | bool r = true; |
| 950 | if (__left_) |
| 951 | r = r && __left_->fix_forward_references(t_begin, t_end); |
| 952 | if (__right_) |
| 953 | r = r && __right_->fix_forward_references(t_begin, t_end); |
| 954 | return r; |
| 955 | } |
| 956 | }; |
| 957 | |
| 958 | class __operator_tilda |
| 959 | : public __node |
| 960 | { |
| 961 | public: |
| 962 | |
| 963 | __operator_tilda() {} |
| 964 | explicit __operator_tilda(__node* op) |
| 965 | { |
| 966 | __left_ = op; |
| 967 | } |
| 968 | virtual size_t first_size() const |
| 969 | { |
| 970 | if (__cached_size_ == -1) |
| 971 | { |
| 972 | if (__left_) |
| 973 | const_cast<long&>(__cached_size_) = static_cast<long>(3 + __left_->size()); |
| 974 | else |
| 975 | const_cast<long&>(__cached_size_) = sizeof("operator~") - 1; |
| 976 | } |
| 977 | return static_cast<size_t>(__cached_size_); |
| 978 | } |
| 979 | virtual char* first_demangled_name(char* buf) const |
| 980 | { |
| 981 | if (__left_) |
| 982 | { |
| 983 | *buf++ = '~'; |
| 984 | *buf++ = '('; |
| 985 | buf = __left_->get_demangled_name(buf); |
| 986 | *buf++ = ')'; |
| 987 | } |
| 988 | else |
| 989 | { |
| 990 | strncpy(buf, "operator~", sizeof("operator~") - 1); |
| 991 | buf += sizeof("operator~") - 1; |
| 992 | } |
| 993 | return buf; |
| 994 | } |
| 995 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 996 | { |
| 997 | if (__left_) |
| 998 | return __left_->fix_forward_references(t_begin, t_end); |
| 999 | return true; |
| 1000 | } |
| 1001 | }; |
| 1002 | |
| 1003 | class __operator_cast |
| 1004 | : public __node |
| 1005 | { |
| 1006 | static const size_t n = sizeof("operator ") - 1; |
| 1007 | public: |
| 1008 | |
| 1009 | explicit __operator_cast(__node* type) |
| 1010 | { |
| 1011 | __right_ = type; |
| 1012 | } |
| 1013 | __operator_cast(__node* type, __node* arg) |
| 1014 | { |
| 1015 | __size_ = 1; |
| 1016 | __right_ = type; |
| 1017 | __left_ = arg; |
| 1018 | } |
| 1019 | virtual size_t first_size() const |
| 1020 | { |
| 1021 | if (__cached_size_ == -1) |
| 1022 | { |
| 1023 | size_t off; |
| 1024 | if (__size_) |
| 1025 | { |
| 1026 | off = 4; |
| 1027 | off += __right_->size(); |
| 1028 | if (__left_) |
| 1029 | off += __left_->size(); |
| 1030 | } |
| 1031 | else |
| 1032 | off = n + __right_->size();; |
| 1033 | const_cast<long&>(__cached_size_) = static_cast<long>(off); |
| 1034 | } |
| 1035 | return static_cast<size_t>(__cached_size_); |
| 1036 | } |
| 1037 | virtual char* first_demangled_name(char* buf) const |
| 1038 | { |
| 1039 | if (__size_) |
| 1040 | { |
| 1041 | *buf++ = '('; |
| 1042 | buf = __right_->get_demangled_name(buf); |
| 1043 | *buf++ = ')'; |
| 1044 | *buf++ = '('; |
| 1045 | if (__left_) |
| 1046 | buf = __left_->get_demangled_name(buf); |
| 1047 | *buf++ = ')'; |
| 1048 | } |
| 1049 | else |
| 1050 | { |
| 1051 | strncpy(buf, "operator ", n); |
| 1052 | buf = __right_->get_demangled_name(buf+n); |
| 1053 | } |
| 1054 | return buf; |
| 1055 | } |
| 1056 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 1057 | { |
| 1058 | bool r = true; |
| 1059 | if (__left_) |
| 1060 | r = r && __left_->fix_forward_references(t_begin, t_end); |
| 1061 | r = r && __right_->fix_forward_references(t_begin, t_end); |
| 1062 | return r; |
| 1063 | } |
| 1064 | virtual bool is_ctor_dtor_conv() const |
| 1065 | { |
| 1066 | return true; |
| 1067 | } |
| 1068 | }; |
| 1069 | |
| 1070 | class __cast_literal |
| 1071 | : public __node |
| 1072 | { |
| 1073 | public: |
| 1074 | |
| 1075 | __cast_literal(__node* type, const char* f, const char* l) |
| 1076 | { |
| 1077 | __left_ = type; |
| 1078 | __name_ = f; |
| 1079 | __size_ = static_cast<size_t>(l - f); |
| 1080 | } |
| 1081 | virtual size_t first_size() const |
| 1082 | { |
| 1083 | if (__cached_size_ == -1) |
| 1084 | const_cast<long&>(__cached_size_) = static_cast<long>(2 + |
| 1085 | __left_->size() + __size_); |
| 1086 | return static_cast<size_t>(__cached_size_); |
| 1087 | } |
| 1088 | virtual char* first_demangled_name(char* buf) const |
| 1089 | { |
| 1090 | *buf++ = '('; |
| 1091 | buf = __left_->get_demangled_name(buf); |
| 1092 | *buf++ = ')'; |
| 1093 | strncpy(buf, __name_, __size_); |
| 1094 | return buf + __size_; |
| 1095 | } |
| 1096 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 1097 | { |
| 1098 | return __left_->fix_forward_references(t_begin, t_end); |
| 1099 | } |
| 1100 | }; |
| 1101 | |
| 1102 | class __operator_dereference |
| 1103 | : public __node |
| 1104 | { |
| 1105 | public: |
| 1106 | |
| 1107 | __operator_dereference() {} |
| 1108 | explicit __operator_dereference(__node* op) |
| 1109 | { |
| 1110 | __left_ = op; |
| 1111 | } |
| 1112 | virtual size_t first_size() const |
| 1113 | { |
| 1114 | if (__cached_size_ == -1) |
| 1115 | { |
| 1116 | if (__left_) |
| 1117 | const_cast<long&>(__cached_size_) = static_cast<long>(3 + __left_->size()); |
| 1118 | else |
| 1119 | const_cast<long&>(__cached_size_) = sizeof("operator*") - 1; |
| 1120 | } |
| 1121 | return static_cast<size_t>(__cached_size_); |
| 1122 | } |
| 1123 | virtual char* first_demangled_name(char* buf) const |
| 1124 | { |
| 1125 | if (__left_) |
| 1126 | { |
| 1127 | *buf++ = '*'; |
| 1128 | *buf++ = '('; |
| 1129 | buf = __left_->get_demangled_name(buf); |
| 1130 | *buf++ = ')'; |
| 1131 | } |
| 1132 | else |
| 1133 | { |
| 1134 | strncpy(buf, "operator*", sizeof("operator*") - 1); |
| 1135 | buf += sizeof("operator*") - 1; |
| 1136 | } |
| 1137 | return buf; |
| 1138 | } |
| 1139 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 1140 | { |
| 1141 | if (__left_) |
| 1142 | return __left_->fix_forward_references(t_begin, t_end); |
| 1143 | return true; |
| 1144 | } |
| 1145 | }; |
| 1146 | |
| 1147 | class __operator_divide |
| 1148 | : public __node |
| 1149 | { |
| 1150 | public: |
| 1151 | |
| 1152 | __operator_divide() {} |
| 1153 | __operator_divide(__node* op1, __node* op2) |
| 1154 | { |
| 1155 | __left_ = op1; |
| 1156 | __right_ = op2; |
| 1157 | } |
| 1158 | virtual size_t first_size() const |
| 1159 | { |
| 1160 | if (__cached_size_ == -1) |
| 1161 | { |
| 1162 | if (__left_) |
| 1163 | const_cast<long&>(__cached_size_) = static_cast<long>( |
| 1164 | __left_->size() + 7 + |
| 1165 | __right_->size()); |
| 1166 | else |
| 1167 | const_cast<long&>(__cached_size_) = sizeof("operator/") - 1; |
| 1168 | } |
| 1169 | return static_cast<size_t>(__cached_size_); |
| 1170 | } |
| 1171 | virtual char* first_demangled_name(char* buf) const |
| 1172 | { |
| 1173 | if (__left_) |
| 1174 | { |
| 1175 | *buf++ = '('; |
| 1176 | buf = __left_->get_demangled_name(buf); |
| 1177 | strncpy(buf, ") / (", 5); |
| 1178 | buf += 5; |
| 1179 | buf = __right_->get_demangled_name(buf); |
| 1180 | *buf++ = ')'; |
| 1181 | } |
| 1182 | else |
| 1183 | { |
| 1184 | strncpy(buf, "operator/", sizeof("operator/") - 1); |
| 1185 | buf += sizeof("operator/") - 1; |
| 1186 | } |
| 1187 | return buf; |
| 1188 | } |
| 1189 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 1190 | { |
| 1191 | bool r = true; |
| 1192 | if (__left_) |
| 1193 | r = r && __left_->fix_forward_references(t_begin, t_end); |
| 1194 | if (__right_) |
| 1195 | r = r && __right_->fix_forward_references(t_begin, t_end); |
| 1196 | return r; |
| 1197 | } |
| 1198 | }; |
| 1199 | |
| 1200 | class __operator_divide_equal |
| 1201 | : public __node |
| 1202 | { |
| 1203 | public: |
| 1204 | |
| 1205 | __operator_divide_equal() {} |
| 1206 | __operator_divide_equal(__node* op1, __node* op2) |
| 1207 | { |
| 1208 | __left_ = op1; |
| 1209 | __right_ = op2; |
| 1210 | } |
| 1211 | virtual size_t first_size() const |
| 1212 | { |
| 1213 | if (__cached_size_ == -1) |
| 1214 | { |
| 1215 | if (__left_) |
| 1216 | const_cast<long&>(__cached_size_) = static_cast<long>( |
| 1217 | __left_->size() + 8 + |
| 1218 | __right_->size()); |
| 1219 | else |
| 1220 | const_cast<long&>(__cached_size_) = sizeof("operator/=") - 1; |
| 1221 | } |
| 1222 | return static_cast<size_t>(__cached_size_); |
| 1223 | } |
| 1224 | virtual char* first_demangled_name(char* buf) const |
| 1225 | { |
| 1226 | if (__left_) |
| 1227 | { |
| 1228 | *buf++ = '('; |
| 1229 | buf = __left_->get_demangled_name(buf); |
| 1230 | strncpy(buf, ") /= (", 6); |
| 1231 | buf += 6; |
| 1232 | buf = __right_->get_demangled_name(buf); |
| 1233 | *buf++ = ')'; |
| 1234 | } |
| 1235 | else |
| 1236 | { |
| 1237 | strncpy(buf, "operator/=", sizeof("operator/=") - 1); |
| 1238 | buf += sizeof("operator/=") - 1; |
| 1239 | } |
| 1240 | return buf; |
| 1241 | } |
| 1242 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 1243 | { |
| 1244 | bool r = true; |
| 1245 | if (__left_) |
| 1246 | r = r && __left_->fix_forward_references(t_begin, t_end); |
| 1247 | if (__right_) |
| 1248 | r = r && __right_->fix_forward_references(t_begin, t_end); |
| 1249 | return r; |
| 1250 | } |
| 1251 | }; |
| 1252 | |
| 1253 | class __operator_xor |
| 1254 | : public __node |
| 1255 | { |
| 1256 | public: |
| 1257 | |
| 1258 | __operator_xor() {} |
| 1259 | __operator_xor(__node* op1, __node* op2) |
| 1260 | { |
| 1261 | __left_ = op1; |
| 1262 | __right_ = op2; |
| 1263 | } |
| 1264 | virtual size_t first_size() const |
| 1265 | { |
| 1266 | if (__cached_size_ == -1) |
| 1267 | { |
| 1268 | if (__left_) |
| 1269 | const_cast<long&>(__cached_size_) = static_cast<long>( |
| 1270 | __left_->size() + 7 + |
| 1271 | __right_->size()); |
| 1272 | else |
| 1273 | const_cast<long&>(__cached_size_) = sizeof("operator^") - 1; |
| 1274 | } |
| 1275 | return static_cast<size_t>(__cached_size_); |
| 1276 | } |
| 1277 | virtual char* first_demangled_name(char* buf) const |
| 1278 | { |
| 1279 | if (__left_) |
| 1280 | { |
| 1281 | *buf++ = '('; |
| 1282 | buf = __left_->get_demangled_name(buf); |
| 1283 | strncpy(buf, ") ^ (", 5); |
| 1284 | buf += 5; |
| 1285 | buf = __right_->get_demangled_name(buf); |
| 1286 | *buf++ = ')'; |
| 1287 | } |
| 1288 | else |
| 1289 | { |
| 1290 | strncpy(buf, "operator^", sizeof("operator^") - 1); |
| 1291 | buf += sizeof("operator^") - 1; |
| 1292 | } |
| 1293 | return buf; |
| 1294 | } |
| 1295 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 1296 | { |
| 1297 | bool r = true; |
| 1298 | if (__left_) |
| 1299 | r = r && __left_->fix_forward_references(t_begin, t_end); |
| 1300 | if (__right_) |
| 1301 | r = r && __right_->fix_forward_references(t_begin, t_end); |
| 1302 | return r; |
| 1303 | } |
| 1304 | }; |
| 1305 | |
| 1306 | class __operator_xor_equal |
| 1307 | : public __node |
| 1308 | { |
| 1309 | public: |
| 1310 | |
| 1311 | __operator_xor_equal() {} |
| 1312 | __operator_xor_equal(__node* op1, __node* op2) |
| 1313 | { |
| 1314 | __left_ = op1; |
| 1315 | __right_ = op2; |
| 1316 | } |
| 1317 | virtual size_t first_size() const |
| 1318 | { |
| 1319 | if (__cached_size_ == -1) |
| 1320 | { |
| 1321 | if (__left_) |
| 1322 | const_cast<long&>(__cached_size_) = static_cast<long>( |
| 1323 | __left_->size() + 8 + |
| 1324 | __right_->size()); |
| 1325 | else |
| 1326 | const_cast<long&>(__cached_size_) = sizeof("operator^=") - 1; |
| 1327 | } |
| 1328 | return static_cast<size_t>(__cached_size_); |
| 1329 | } |
| 1330 | virtual char* first_demangled_name(char* buf) const |
| 1331 | { |
| 1332 | if (__left_) |
| 1333 | { |
| 1334 | *buf++ = '('; // strncpy(buf, "(", 1); |
| 1335 | buf = __left_->get_demangled_name(buf); |
| 1336 | strncpy(buf, ") ^= (", 6); |
| 1337 | buf += 6; |
| 1338 | buf = __right_->get_demangled_name(buf); |
| 1339 | *buf++ = ')'; |
| 1340 | } |
| 1341 | else |
| 1342 | { |
| 1343 | strncpy(buf, "operator^=", sizeof("operator^=") - 1); |
| 1344 | buf += sizeof("operator^=") - 1; |
| 1345 | } |
| 1346 | return buf; |
| 1347 | } |
| 1348 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 1349 | { |
| 1350 | bool r = true; |
| 1351 | if (__left_) |
| 1352 | r = r && __left_->fix_forward_references(t_begin, t_end); |
| 1353 | if (__right_) |
| 1354 | r = r && __right_->fix_forward_references(t_begin, t_end); |
| 1355 | return r; |
| 1356 | } |
| 1357 | }; |
| 1358 | |
| 1359 | class __operator_equality |
| 1360 | : public __node |
| 1361 | { |
| 1362 | public: |
| 1363 | |
| 1364 | __operator_equality() {} |
| 1365 | __operator_equality(__node* op1, __node* op2) |
| 1366 | { |
| 1367 | __left_ = op1; |
| 1368 | __right_ = op2; |
| 1369 | } |
| 1370 | virtual size_t first_size() const |
| 1371 | { |
| 1372 | if (__cached_size_ == -1) |
| 1373 | { |
| 1374 | if (__left_) |
| 1375 | const_cast<long&>(__cached_size_) = static_cast<long>( |
| 1376 | __left_->size() + 8 + |
| 1377 | __right_->size()); |
| 1378 | else |
| 1379 | const_cast<long&>(__cached_size_) = sizeof("operator==") - 1; |
| 1380 | } |
| 1381 | return static_cast<size_t>(__cached_size_); |
| 1382 | } |
| 1383 | virtual char* first_demangled_name(char* buf) const |
| 1384 | { |
| 1385 | if (__left_) |
| 1386 | { |
| 1387 | *buf++ = '('; |
| 1388 | buf = __left_->get_demangled_name(buf); |
| 1389 | strncpy(buf, ") == (", 6); |
| 1390 | buf += 6; |
| 1391 | buf = __right_->get_demangled_name(buf); |
| 1392 | *buf++ = ')'; |
| 1393 | } |
| 1394 | else |
| 1395 | { |
| 1396 | strncpy(buf, "operator==", sizeof("operator==") - 1); |
| 1397 | buf += sizeof("operator==") - 1; |
| 1398 | } |
| 1399 | return buf; |
| 1400 | } |
| 1401 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 1402 | { |
| 1403 | bool r = true; |
| 1404 | if (__left_) |
| 1405 | r = r && __left_->fix_forward_references(t_begin, t_end); |
| 1406 | if (__right_) |
| 1407 | r = r && __right_->fix_forward_references(t_begin, t_end); |
| 1408 | return r; |
| 1409 | } |
| 1410 | }; |
| 1411 | |
| 1412 | class __operator_greater_equal |
| 1413 | : public __node |
| 1414 | { |
| 1415 | public: |
| 1416 | |
| 1417 | __operator_greater_equal() {} |
| 1418 | __operator_greater_equal(__node* op1, __node* op2) |
| 1419 | { |
| 1420 | __left_ = op1; |
| 1421 | __right_ = op2; |
| 1422 | } |
| 1423 | virtual size_t first_size() const |
| 1424 | { |
| 1425 | if (__cached_size_ == -1) |
| 1426 | { |
| 1427 | if (__left_) |
| 1428 | const_cast<long&>(__cached_size_) = static_cast<long>( |
| 1429 | __left_->size() + 8 + |
| 1430 | __right_->size()); |
| 1431 | else |
| 1432 | const_cast<long&>(__cached_size_) = sizeof("operator>=") - 1; |
| 1433 | } |
| 1434 | return static_cast<size_t>(__cached_size_); |
| 1435 | } |
| 1436 | virtual char* first_demangled_name(char* buf) const |
| 1437 | { |
| 1438 | if (__left_) |
| 1439 | { |
| 1440 | *buf++ = '('; |
| 1441 | buf = __left_->get_demangled_name(buf); |
| 1442 | strncpy(buf, ") >= (", 6); |
| 1443 | buf += 6; |
| 1444 | buf = __right_->get_demangled_name(buf); |
| 1445 | *buf++ = ')'; |
| 1446 | } |
| 1447 | else |
| 1448 | { |
| 1449 | strncpy(buf, "operator>=", sizeof("operator>=") - 1); |
| 1450 | buf += sizeof("operator>=") - 1; |
| 1451 | } |
| 1452 | return buf; |
| 1453 | } |
| 1454 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 1455 | { |
| 1456 | bool r = true; |
| 1457 | if (__left_) |
| 1458 | r = r && __left_->fix_forward_references(t_begin, t_end); |
| 1459 | if (__right_) |
| 1460 | r = r && __right_->fix_forward_references(t_begin, t_end); |
| 1461 | return r; |
| 1462 | } |
| 1463 | }; |
| 1464 | |
| 1465 | class __operator_greater |
| 1466 | : public __node |
| 1467 | { |
| 1468 | public: |
| 1469 | |
| 1470 | __operator_greater() {} |
| 1471 | __operator_greater(__node* op1, __node* op2) |
| 1472 | { |
| 1473 | __left_ = op1; |
| 1474 | __right_ = op2; |
| 1475 | } |
| 1476 | virtual size_t first_size() const |
| 1477 | { |
| 1478 | if (__cached_size_ == -1) |
| 1479 | { |
| 1480 | if (__left_) |
| 1481 | const_cast<long&>(__cached_size_) = static_cast<long>( |
| 1482 | __left_->size() + 9 + |
| 1483 | __right_->size()); |
| 1484 | else |
| 1485 | const_cast<long&>(__cached_size_) = sizeof("operator>") - 1; |
| 1486 | } |
| 1487 | return static_cast<size_t>(__cached_size_); |
| 1488 | } |
| 1489 | virtual char* first_demangled_name(char* buf) const |
| 1490 | { |
| 1491 | if (__left_) |
| 1492 | { |
| 1493 | *buf++ = '('; |
| 1494 | *buf++ = '('; |
| 1495 | buf = __left_->get_demangled_name(buf); |
| 1496 | strncpy(buf, ") > (", 5); |
| 1497 | buf += 5; |
| 1498 | buf = __right_->get_demangled_name(buf); |
| 1499 | *buf++ = ')'; |
| 1500 | *buf++ = ')'; |
| 1501 | } |
| 1502 | else |
| 1503 | { |
| 1504 | strncpy(buf, "operator>", sizeof("operator>") - 1); |
| 1505 | buf += sizeof("operator>") - 1; |
| 1506 | } |
| 1507 | return buf; |
| 1508 | } |
| 1509 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 1510 | { |
| 1511 | bool r = true; |
| 1512 | if (__left_) |
| 1513 | r = r && __left_->fix_forward_references(t_begin, t_end); |
| 1514 | if (__right_) |
| 1515 | r = r && __right_->fix_forward_references(t_begin, t_end); |
| 1516 | return r; |
| 1517 | } |
| 1518 | }; |
| 1519 | |
| 1520 | class __operator_brackets |
| 1521 | : public __node |
| 1522 | { |
| 1523 | public: |
| 1524 | |
| 1525 | virtual size_t first_size() const {return sizeof("operator[]") - 1;} |
| 1526 | virtual char* first_demangled_name(char* buf) const |
| 1527 | { |
| 1528 | strncpy(buf, "operator[]", sizeof("operator[]") - 1); |
| 1529 | return buf + sizeof("operator[]") - 1; |
| 1530 | } |
| 1531 | }; |
| 1532 | |
| 1533 | class __operator_less_equal |
| 1534 | : public __node |
| 1535 | { |
| 1536 | public: |
| 1537 | |
| 1538 | __operator_less_equal() {} |
| 1539 | __operator_less_equal(__node* op1, __node* op2) |
| 1540 | { |
| 1541 | __left_ = op1; |
| 1542 | __right_ = op2; |
| 1543 | } |
| 1544 | virtual size_t first_size() const |
| 1545 | { |
| 1546 | if (__cached_size_ == -1) |
| 1547 | { |
| 1548 | if (__left_) |
| 1549 | const_cast<long&>(__cached_size_) = static_cast<long>( |
| 1550 | __left_->size() + 8 + |
| 1551 | __right_->size()); |
| 1552 | else |
| 1553 | const_cast<long&>(__cached_size_) = sizeof("operator<=") - 1; |
| 1554 | } |
| 1555 | return static_cast<size_t>(__cached_size_); |
| 1556 | } |
| 1557 | virtual char* first_demangled_name(char* buf) const |
| 1558 | { |
| 1559 | if (__left_) |
| 1560 | { |
| 1561 | *buf++ = '('; |
| 1562 | buf = __left_->get_demangled_name(buf); |
| 1563 | strncpy(buf, ") <= (", 6); |
| 1564 | buf += 6; |
| 1565 | buf = __right_->get_demangled_name(buf); |
| 1566 | *buf++ = ')'; |
| 1567 | } |
| 1568 | else |
| 1569 | { |
| 1570 | strncpy(buf, "operator<=", sizeof("operator<=") - 1); |
| 1571 | buf += sizeof("operator<=") - 1; |
| 1572 | } |
| 1573 | return buf; |
| 1574 | } |
| 1575 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 1576 | { |
| 1577 | bool r = true; |
| 1578 | if (__left_) |
| 1579 | r = r && __left_->fix_forward_references(t_begin, t_end); |
| 1580 | if (__right_) |
| 1581 | r = r && __right_->fix_forward_references(t_begin, t_end); |
| 1582 | return r; |
| 1583 | } |
| 1584 | }; |
| 1585 | |
| 1586 | class __operator_less |
| 1587 | : public __node |
| 1588 | { |
| 1589 | public: |
| 1590 | |
| 1591 | __operator_less() {} |
| 1592 | __operator_less(__node* op1, __node* op2) |
| 1593 | { |
| 1594 | __left_ = op1; |
| 1595 | __right_ = op2; |
| 1596 | } |
| 1597 | virtual size_t first_size() const |
| 1598 | { |
| 1599 | if (__cached_size_ == -1) |
| 1600 | { |
| 1601 | if (__left_) |
| 1602 | const_cast<long&>(__cached_size_) = static_cast<long>( |
| 1603 | __left_->size() + 7 + |
| 1604 | __right_->size()); |
| 1605 | else |
| 1606 | const_cast<long&>(__cached_size_) = sizeof("operator<") - 1; |
| 1607 | } |
| 1608 | return static_cast<size_t>(__cached_size_); |
| 1609 | } |
| 1610 | virtual char* first_demangled_name(char* buf) const |
| 1611 | { |
| 1612 | if (__left_) |
| 1613 | { |
| 1614 | *buf++ = '('; |
| 1615 | buf = __left_->get_demangled_name(buf); |
| 1616 | strncpy(buf, ") < (", 5); |
| 1617 | buf += 5; |
| 1618 | buf = __right_->get_demangled_name(buf); |
| 1619 | *buf++ = ')'; |
| 1620 | } |
| 1621 | else |
| 1622 | { |
| 1623 | strncpy(buf, "operator<", sizeof("operator<") - 1); |
| 1624 | buf += sizeof("operator<") - 1; |
| 1625 | } |
| 1626 | return buf; |
| 1627 | } |
| 1628 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 1629 | { |
| 1630 | bool r = true; |
| 1631 | if (__left_) |
| 1632 | r = r && __left_->fix_forward_references(t_begin, t_end); |
| 1633 | if (__right_) |
| 1634 | r = r && __right_->fix_forward_references(t_begin, t_end); |
| 1635 | return r; |
| 1636 | } |
| 1637 | }; |
| 1638 | |
| 1639 | class __operator_left_shift |
| 1640 | : public __node |
| 1641 | { |
| 1642 | public: |
| 1643 | |
| 1644 | __operator_left_shift() {} |
| 1645 | __operator_left_shift(__node* op1, __node* op2) |
| 1646 | { |
| 1647 | __left_ = op1; |
| 1648 | __right_ = op2; |
| 1649 | } |
| 1650 | virtual size_t first_size() const |
| 1651 | { |
| 1652 | if (__cached_size_ == -1) |
| 1653 | { |
| 1654 | if (__left_) |
| 1655 | const_cast<long&>(__cached_size_) = static_cast<long>( |
| 1656 | __left_->size() + 8 + |
| 1657 | __right_->size()); |
| 1658 | else |
| 1659 | const_cast<long&>(__cached_size_) = sizeof("operator<<") - 1; |
| 1660 | } |
| 1661 | return static_cast<size_t>(__cached_size_); |
| 1662 | } |
| 1663 | virtual char* first_demangled_name(char* buf) const |
| 1664 | { |
| 1665 | if (__left_) |
| 1666 | { |
| 1667 | *buf++ = '('; |
| 1668 | buf = __left_->get_demangled_name(buf); |
| 1669 | strncpy(buf, ") << (", 6); |
| 1670 | buf += 6; |
| 1671 | buf = __right_->get_demangled_name(buf); |
| 1672 | *buf++ = ')'; |
| 1673 | } |
| 1674 | else |
| 1675 | { |
| 1676 | strncpy(buf, "operator<<", sizeof("operator<<") - 1); |
| 1677 | buf += sizeof("operator<<") - 1; |
| 1678 | } |
| 1679 | return buf; |
| 1680 | } |
| 1681 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 1682 | { |
| 1683 | bool r = true; |
| 1684 | if (__left_) |
| 1685 | r = r && __left_->fix_forward_references(t_begin, t_end); |
| 1686 | if (__right_) |
| 1687 | r = r && __right_->fix_forward_references(t_begin, t_end); |
| 1688 | return r; |
| 1689 | } |
| 1690 | }; |
| 1691 | |
| 1692 | class __operator_left_shift_equal |
| 1693 | : public __node |
| 1694 | { |
| 1695 | public: |
| 1696 | |
| 1697 | __operator_left_shift_equal() {} |
| 1698 | __operator_left_shift_equal(__node* op1, __node* op2) |
| 1699 | { |
| 1700 | __left_ = op1; |
| 1701 | __right_ = op2; |
| 1702 | } |
| 1703 | virtual size_t first_size() const |
| 1704 | { |
| 1705 | if (__cached_size_ == -1) |
| 1706 | { |
| 1707 | if (__left_) |
| 1708 | const_cast<long&>(__cached_size_) = static_cast<long>( |
| 1709 | __left_->size() + 9 + |
| 1710 | __right_->size()); |
| 1711 | else |
| 1712 | const_cast<long&>(__cached_size_) = sizeof("operator<<=") - 1; |
| 1713 | } |
| 1714 | return static_cast<size_t>(__cached_size_); |
| 1715 | } |
| 1716 | virtual char* first_demangled_name(char* buf) const |
| 1717 | { |
| 1718 | if (__left_) |
| 1719 | { |
| 1720 | *buf++ = '('; |
| 1721 | buf = __left_->get_demangled_name(buf); |
| 1722 | strncpy(buf, ") <<= (", 7); |
| 1723 | buf += 7; |
| 1724 | buf = __right_->get_demangled_name(buf); |
| 1725 | *buf++ = ')'; |
| 1726 | } |
| 1727 | else |
| 1728 | { |
| 1729 | strncpy(buf, "operator<<=", sizeof("operator<<=") - 1); |
| 1730 | buf += sizeof("operator<<=") - 1; |
| 1731 | } |
| 1732 | return buf; |
| 1733 | } |
| 1734 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 1735 | { |
| 1736 | bool r = true; |
| 1737 | if (__left_) |
| 1738 | r = r && __left_->fix_forward_references(t_begin, t_end); |
| 1739 | if (__right_) |
| 1740 | r = r && __right_->fix_forward_references(t_begin, t_end); |
| 1741 | return r; |
| 1742 | } |
| 1743 | }; |
| 1744 | |
| 1745 | class __operator_minus |
| 1746 | : public __node |
| 1747 | { |
| 1748 | public: |
| 1749 | |
| 1750 | __operator_minus() {} |
| 1751 | __operator_minus(__node* op1, __node* op2) |
| 1752 | { |
| 1753 | __left_ = op1; |
| 1754 | __right_ = op2; |
| 1755 | } |
| 1756 | virtual size_t first_size() const |
| 1757 | { |
| 1758 | if (__cached_size_ == -1) |
| 1759 | { |
| 1760 | if (__left_) |
| 1761 | const_cast<long&>(__cached_size_) = static_cast<long>( |
| 1762 | __left_->size() + 7 + |
| 1763 | __right_->size()); |
| 1764 | else |
| 1765 | const_cast<long&>(__cached_size_) = sizeof("operator-") - 1; |
| 1766 | } |
| 1767 | return static_cast<size_t>(__cached_size_); |
| 1768 | } |
| 1769 | virtual char* first_demangled_name(char* buf) const |
| 1770 | { |
| 1771 | if (__left_) |
| 1772 | { |
| 1773 | *buf++ = '('; |
| 1774 | buf = __left_->get_demangled_name(buf); |
| 1775 | strncpy(buf, ") - (", 5); |
| 1776 | buf += 5; |
| 1777 | buf = __right_->get_demangled_name(buf); |
| 1778 | *buf++ = ')'; |
| 1779 | } |
| 1780 | else |
| 1781 | { |
| 1782 | strncpy(buf, "operator-", sizeof("operator-") - 1); |
| 1783 | buf += sizeof("operator-") - 1; |
| 1784 | } |
| 1785 | return buf; |
| 1786 | } |
| 1787 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 1788 | { |
| 1789 | bool r = true; |
| 1790 | if (__left_) |
| 1791 | r = r && __left_->fix_forward_references(t_begin, t_end); |
| 1792 | if (__right_) |
| 1793 | r = r && __right_->fix_forward_references(t_begin, t_end); |
| 1794 | return r; |
| 1795 | } |
| 1796 | }; |
| 1797 | |
| 1798 | class __operator_minus_equal |
| 1799 | : public __node |
| 1800 | { |
| 1801 | public: |
| 1802 | |
| 1803 | __operator_minus_equal() {} |
| 1804 | __operator_minus_equal(__node* op1, __node* op2) |
| 1805 | { |
| 1806 | __left_ = op1; |
| 1807 | __right_ = op2; |
| 1808 | } |
| 1809 | virtual size_t first_size() const |
| 1810 | { |
| 1811 | if (__cached_size_ == -1) |
| 1812 | { |
| 1813 | if (__left_) |
| 1814 | const_cast<long&>(__cached_size_) = static_cast<long>( |
| 1815 | __left_->size() + 8 + |
| 1816 | __right_->size()); |
| 1817 | else |
| 1818 | const_cast<long&>(__cached_size_) = sizeof("operator-=") - 1; |
| 1819 | } |
| 1820 | return static_cast<size_t>(__cached_size_); |
| 1821 | } |
| 1822 | virtual char* first_demangled_name(char* buf) const |
| 1823 | { |
| 1824 | if (__left_) |
| 1825 | { |
| 1826 | *buf++ = '('; |
| 1827 | buf = __left_->get_demangled_name(buf); |
| 1828 | strncpy(buf, ") -= (", 6); |
| 1829 | buf += 6; |
| 1830 | buf = __right_->get_demangled_name(buf); |
| 1831 | *buf++ = ')'; |
| 1832 | } |
| 1833 | else |
| 1834 | { |
| 1835 | strncpy(buf, "operator-=", sizeof("operator-=") - 1); |
| 1836 | buf += sizeof("operator-=") - 1; |
| 1837 | } |
| 1838 | return buf; |
| 1839 | } |
| 1840 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 1841 | { |
| 1842 | bool r = true; |
| 1843 | if (__left_) |
| 1844 | r = r && __left_->fix_forward_references(t_begin, t_end); |
| 1845 | if (__right_) |
| 1846 | r = r && __right_->fix_forward_references(t_begin, t_end); |
| 1847 | return r; |
| 1848 | } |
| 1849 | }; |
| 1850 | |
| 1851 | class __operator_times |
| 1852 | : public __node |
| 1853 | { |
| 1854 | public: |
| 1855 | |
| 1856 | __operator_times() {} |
| 1857 | __operator_times(__node* op1, __node* op2) |
| 1858 | { |
| 1859 | __left_ = op1; |
| 1860 | __right_ = op2; |
| 1861 | } |
| 1862 | virtual size_t first_size() const |
| 1863 | { |
| 1864 | if (__cached_size_ == -1) |
| 1865 | { |
| 1866 | if (__left_) |
| 1867 | const_cast<long&>(__cached_size_) = static_cast<long>( |
| 1868 | __left_->size() + 7 + |
| 1869 | __right_->size()); |
| 1870 | else |
| 1871 | const_cast<long&>(__cached_size_) = sizeof("operator*") - 1; |
| 1872 | } |
| 1873 | return static_cast<size_t>(__cached_size_); |
| 1874 | } |
| 1875 | virtual char* first_demangled_name(char* buf) const |
| 1876 | { |
| 1877 | if (__left_) |
| 1878 | { |
| 1879 | *buf++ = '('; |
| 1880 | buf = __left_->get_demangled_name(buf); |
| 1881 | strncpy(buf, ") * (", 5); |
| 1882 | buf += 5; |
| 1883 | buf = __right_->get_demangled_name(buf); |
| 1884 | *buf++ = ')'; |
| 1885 | } |
| 1886 | else |
| 1887 | { |
| 1888 | strncpy(buf, "operator*", sizeof("operator*") - 1); |
| 1889 | buf += sizeof("operator*") - 1; |
| 1890 | } |
| 1891 | return buf; |
| 1892 | } |
| 1893 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 1894 | { |
| 1895 | bool r = true; |
| 1896 | if (__left_) |
| 1897 | r = r && __left_->fix_forward_references(t_begin, t_end); |
| 1898 | if (__right_) |
| 1899 | r = r && __right_->fix_forward_references(t_begin, t_end); |
| 1900 | return r; |
| 1901 | } |
| 1902 | }; |
| 1903 | |
| 1904 | class __operator_times_equal |
| 1905 | : public __node |
| 1906 | { |
| 1907 | public: |
| 1908 | |
| 1909 | __operator_times_equal() {} |
| 1910 | __operator_times_equal(__node* op1, __node* op2) |
| 1911 | { |
| 1912 | __left_ = op1; |
| 1913 | __right_ = op2; |
| 1914 | } |
| 1915 | virtual size_t first_size() const |
| 1916 | { |
| 1917 | if (__cached_size_ == -1) |
| 1918 | { |
| 1919 | if (__left_) |
| 1920 | const_cast<long&>(__cached_size_) = static_cast<long>( |
| 1921 | __left_->size() + 8 + |
| 1922 | __right_->size()); |
| 1923 | else |
| 1924 | const_cast<long&>(__cached_size_) = sizeof("operator*=") - 1; |
| 1925 | } |
| 1926 | return static_cast<size_t>(__cached_size_); |
| 1927 | } |
| 1928 | virtual char* first_demangled_name(char* buf) const |
| 1929 | { |
| 1930 | if (__left_) |
| 1931 | { |
| 1932 | *buf++ = '('; |
| 1933 | buf = __left_->get_demangled_name(buf); |
| 1934 | strncpy(buf, ") *= (", 6); |
| 1935 | buf += 6; |
| 1936 | buf = __right_->get_demangled_name(buf); |
| 1937 | *buf++ = ')'; |
| 1938 | } |
| 1939 | else |
| 1940 | { |
| 1941 | strncpy(buf, "operator*=", sizeof("operator*=") - 1); |
| 1942 | buf += sizeof("operator*=") - 1; |
| 1943 | } |
| 1944 | return buf; |
| 1945 | } |
| 1946 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 1947 | { |
| 1948 | bool r = true; |
| 1949 | if (__left_) |
| 1950 | r = r && __left_->fix_forward_references(t_begin, t_end); |
| 1951 | if (__right_) |
| 1952 | r = r && __right_->fix_forward_references(t_begin, t_end); |
| 1953 | return r; |
| 1954 | } |
| 1955 | }; |
| 1956 | |
| 1957 | class __operator_decrement |
| 1958 | : public __node |
| 1959 | { |
| 1960 | public: |
| 1961 | |
| 1962 | __operator_decrement() {} |
| 1963 | explicit __operator_decrement(bool prefix, __node* op) |
| 1964 | { |
| 1965 | __size_ = prefix; |
| 1966 | __left_ = op; |
| 1967 | } |
| 1968 | virtual size_t first_size() const |
| 1969 | { |
| 1970 | if (__cached_size_ == -1) |
| 1971 | { |
| 1972 | if (__left_) |
| 1973 | const_cast<long&>(__cached_size_) = static_cast<long>(4 + __left_->size()); |
| 1974 | else |
| 1975 | const_cast<long&>(__cached_size_) = sizeof("operator--") - 1; |
| 1976 | } |
| 1977 | return static_cast<size_t>(__cached_size_); |
| 1978 | } |
| 1979 | virtual char* first_demangled_name(char* buf) const |
| 1980 | { |
| 1981 | if (__left_) |
| 1982 | { |
| 1983 | if (__size_) |
| 1984 | { |
| 1985 | *buf++ = '-'; |
| 1986 | *buf++ = '-'; |
| 1987 | *buf++ = '('; |
| 1988 | } |
| 1989 | else |
| 1990 | *buf++ = '('; |
| 1991 | buf = __left_->get_demangled_name(buf); |
| 1992 | if (__size_) |
| 1993 | *buf++ = ')'; |
| 1994 | else |
| 1995 | { |
| 1996 | *buf++ = ')'; |
| 1997 | *buf++ = '-'; |
| 1998 | *buf++ = '-'; |
| 1999 | } |
| 2000 | } |
| 2001 | else |
| 2002 | { |
| 2003 | strncpy(buf, "operator--", sizeof("operator--") - 1); |
| 2004 | buf += sizeof("operator--") - 1; |
| 2005 | } |
| 2006 | return buf; |
| 2007 | } |
| 2008 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 2009 | { |
| 2010 | if (__left_) |
| 2011 | return __left_->fix_forward_references(t_begin, t_end); |
| 2012 | return true; |
| 2013 | } |
| 2014 | }; |
| 2015 | |
| 2016 | class __operator_not_equal |
| 2017 | : public __node |
| 2018 | { |
| 2019 | public: |
| 2020 | |
| 2021 | __operator_not_equal() {} |
| 2022 | __operator_not_equal(__node* op1, __node* op2) |
| 2023 | { |
| 2024 | __left_ = op1; |
| 2025 | __right_ = op2; |
| 2026 | } |
| 2027 | virtual size_t first_size() const |
| 2028 | { |
| 2029 | if (__cached_size_ == -1) |
| 2030 | { |
| 2031 | if (__left_) |
| 2032 | const_cast<long&>(__cached_size_) = static_cast<long>( |
| 2033 | __left_->size() + 8 + |
| 2034 | __right_->size()); |
| 2035 | else |
| 2036 | const_cast<long&>(__cached_size_) = sizeof("operator!=") - 1; |
| 2037 | } |
| 2038 | return static_cast<size_t>(__cached_size_); |
| 2039 | } |
| 2040 | virtual char* first_demangled_name(char* buf) const |
| 2041 | { |
| 2042 | if (__left_) |
| 2043 | { |
| 2044 | *buf++ = '('; |
| 2045 | buf = __left_->get_demangled_name(buf); |
| 2046 | strncpy(buf, ") != (", 6); |
| 2047 | buf += 6; |
| 2048 | buf = __right_->get_demangled_name(buf); |
| 2049 | *buf++ = ')'; |
| 2050 | } |
| 2051 | else |
| 2052 | { |
| 2053 | strncpy(buf, "operator!=", sizeof("operator!=") - 1); |
| 2054 | buf += sizeof("operator!=") - 1; |
| 2055 | } |
| 2056 | return buf; |
| 2057 | } |
| 2058 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 2059 | { |
| 2060 | bool r = true; |
| 2061 | if (__left_) |
| 2062 | r = r && __left_->fix_forward_references(t_begin, t_end); |
| 2063 | if (__right_) |
| 2064 | r = r && __right_->fix_forward_references(t_begin, t_end); |
| 2065 | return r; |
| 2066 | } |
| 2067 | }; |
| 2068 | |
| 2069 | class __operator_negate |
| 2070 | : public __node |
| 2071 | { |
| 2072 | public: |
| 2073 | |
| 2074 | __operator_negate() {} |
| 2075 | explicit __operator_negate(__node* op) |
| 2076 | { |
| 2077 | __left_ = op; |
| 2078 | } |
| 2079 | virtual size_t first_size() const |
| 2080 | { |
| 2081 | if (__cached_size_ == -1) |
| 2082 | { |
| 2083 | if (__left_) |
| 2084 | const_cast<long&>(__cached_size_) = static_cast<long>(3 + __left_->size()); |
| 2085 | else |
| 2086 | const_cast<long&>(__cached_size_) = sizeof("operator-") - 1; |
| 2087 | } |
| 2088 | return static_cast<size_t>(__cached_size_); |
| 2089 | } |
| 2090 | virtual char* first_demangled_name(char* buf) const |
| 2091 | { |
| 2092 | if (__left_) |
| 2093 | { |
| 2094 | *buf++ = '-'; |
| 2095 | *buf++ = '('; |
| 2096 | buf = __left_->get_demangled_name(buf); |
| 2097 | *buf++ = ')'; |
| 2098 | } |
| 2099 | else |
| 2100 | { |
| 2101 | strncpy(buf, "operator-", sizeof("operator-") - 1); |
| 2102 | buf += sizeof("operator-") - 1; |
| 2103 | } |
| 2104 | return buf; |
| 2105 | } |
| 2106 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 2107 | { |
| 2108 | if (__left_) |
| 2109 | return __left_->fix_forward_references(t_begin, t_end); |
| 2110 | return true; |
| 2111 | } |
| 2112 | }; |
| 2113 | |
| 2114 | class __operator_logical_not |
| 2115 | : public __node |
| 2116 | { |
| 2117 | public: |
| 2118 | |
| 2119 | __operator_logical_not() {} |
| 2120 | explicit __operator_logical_not(__node* op) |
| 2121 | { |
| 2122 | __left_ = op; |
| 2123 | } |
| 2124 | virtual size_t first_size() const |
| 2125 | { |
| 2126 | if (__cached_size_ == -1) |
| 2127 | { |
| 2128 | if (__left_) |
| 2129 | const_cast<long&>(__cached_size_) = static_cast<long>(3 + __left_->size()); |
| 2130 | else |
| 2131 | const_cast<long&>(__cached_size_) = sizeof("operator!") - 1; |
| 2132 | } |
| 2133 | return static_cast<size_t>(__cached_size_); |
| 2134 | } |
| 2135 | virtual char* first_demangled_name(char* buf) const |
| 2136 | { |
| 2137 | if (__left_) |
| 2138 | { |
| 2139 | *buf++ = '!'; |
| 2140 | *buf++ = '('; |
| 2141 | buf = __left_->get_demangled_name(buf); |
| 2142 | *buf++ = ')'; |
| 2143 | } |
| 2144 | else |
| 2145 | { |
| 2146 | strncpy(buf, "operator!", sizeof("operator!") - 1); |
| 2147 | buf += sizeof("operator!") - 1; |
| 2148 | } |
| 2149 | return buf; |
| 2150 | } |
| 2151 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 2152 | { |
| 2153 | if (__left_) |
| 2154 | return __left_->fix_forward_references(t_begin, t_end); |
| 2155 | return true; |
| 2156 | } |
| 2157 | }; |
| 2158 | |
| 2159 | class __operator_logical_or |
| 2160 | : public __node |
| 2161 | { |
| 2162 | public: |
| 2163 | |
| 2164 | __operator_logical_or() {} |
| 2165 | __operator_logical_or(__node* op1, __node* op2) |
| 2166 | { |
| 2167 | __left_ = op1; |
| 2168 | __right_ = op2; |
| 2169 | } |
| 2170 | virtual size_t first_size() const |
| 2171 | { |
| 2172 | if (__cached_size_ == -1) |
| 2173 | { |
| 2174 | if (__left_) |
| 2175 | const_cast<long&>(__cached_size_) = static_cast<long>( |
| 2176 | __left_->size() + 8 + |
| 2177 | __right_->size()); |
| 2178 | else |
| 2179 | const_cast<long&>(__cached_size_) = sizeof("operator||") - 1; |
| 2180 | } |
| 2181 | return static_cast<size_t>(__cached_size_); |
| 2182 | } |
| 2183 | virtual char* first_demangled_name(char* buf) const |
| 2184 | { |
| 2185 | if (__left_) |
| 2186 | { |
| 2187 | *buf++ = '('; |
| 2188 | buf = __left_->get_demangled_name(buf); |
| 2189 | strncpy(buf, ") || (", 6); |
| 2190 | buf += 6; |
| 2191 | buf = __right_->get_demangled_name(buf); |
| 2192 | *buf++ = ')'; |
| 2193 | } |
| 2194 | else |
| 2195 | { |
| 2196 | strncpy(buf, "operator||", sizeof("operator||") - 1); |
| 2197 | buf += sizeof("operator||") - 1; |
| 2198 | } |
| 2199 | return buf; |
| 2200 | } |
| 2201 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 2202 | { |
| 2203 | bool r = true; |
| 2204 | if (__left_) |
| 2205 | r = r && __left_->fix_forward_references(t_begin, t_end); |
| 2206 | if (__right_) |
| 2207 | r = r && __right_->fix_forward_references(t_begin, t_end); |
| 2208 | return r; |
| 2209 | } |
| 2210 | }; |
| 2211 | |
| 2212 | class __operator_bit_or |
| 2213 | : public __node |
| 2214 | { |
| 2215 | public: |
| 2216 | |
| 2217 | __operator_bit_or() {} |
| 2218 | __operator_bit_or(__node* op1, __node* op2) |
| 2219 | { |
| 2220 | __left_ = op1; |
| 2221 | __right_ = op2; |
| 2222 | } |
| 2223 | virtual size_t first_size() const |
| 2224 | { |
| 2225 | if (__cached_size_ == -1) |
| 2226 | { |
| 2227 | if (__left_) |
| 2228 | const_cast<long&>(__cached_size_) = static_cast<long>( |
| 2229 | __left_->size() + 7 + |
| 2230 | __right_->size()); |
| 2231 | else |
| 2232 | const_cast<long&>(__cached_size_) = sizeof("operator|") - 1; |
| 2233 | } |
| 2234 | return static_cast<size_t>(__cached_size_); |
| 2235 | } |
| 2236 | virtual char* first_demangled_name(char* buf) const |
| 2237 | { |
| 2238 | if (__left_) |
| 2239 | { |
| 2240 | *buf++ = '('; |
| 2241 | buf = __left_->get_demangled_name(buf); |
| 2242 | strncpy(buf, ") | (", 5); |
| 2243 | buf += 5; |
| 2244 | buf = __right_->get_demangled_name(buf); |
| 2245 | *buf++ = ')'; |
| 2246 | } |
| 2247 | else |
| 2248 | { |
| 2249 | strncpy(buf, "operator|", sizeof("operator|") - 1); |
| 2250 | buf += sizeof("operator|") - 1; |
| 2251 | } |
| 2252 | return buf; |
| 2253 | } |
| 2254 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 2255 | { |
| 2256 | bool r = true; |
| 2257 | if (__left_) |
| 2258 | r = r && __left_->fix_forward_references(t_begin, t_end); |
| 2259 | if (__right_) |
| 2260 | r = r && __right_->fix_forward_references(t_begin, t_end); |
| 2261 | return r; |
| 2262 | } |
| 2263 | }; |
| 2264 | |
| 2265 | class __operator_or_equal |
| 2266 | : public __node |
| 2267 | { |
| 2268 | public: |
| 2269 | |
| 2270 | __operator_or_equal() {} |
| 2271 | __operator_or_equal(__node* op1, __node* op2) |
| 2272 | { |
| 2273 | __left_ = op1; |
| 2274 | __right_ = op2; |
| 2275 | } |
| 2276 | virtual size_t first_size() const |
| 2277 | { |
| 2278 | if (__cached_size_ == -1) |
| 2279 | { |
| 2280 | if (__left_) |
| 2281 | const_cast<long&>(__cached_size_) = static_cast<long>( |
| 2282 | __left_->size() + 8 + |
| 2283 | __right_->size()); |
| 2284 | else |
| 2285 | const_cast<long&>(__cached_size_) = sizeof("operator|=") - 1; |
| 2286 | } |
| 2287 | return static_cast<size_t>(__cached_size_); |
| 2288 | } |
| 2289 | virtual char* first_demangled_name(char* buf) const |
| 2290 | { |
| 2291 | if (__left_) |
| 2292 | { |
| 2293 | *buf++ = '('; |
| 2294 | buf = __left_->get_demangled_name(buf); |
| 2295 | strncpy(buf, ") |= (", 6); |
| 2296 | buf += 6; |
| 2297 | buf = __right_->get_demangled_name(buf); |
| 2298 | *buf++ = ')'; |
| 2299 | } |
| 2300 | else |
| 2301 | { |
| 2302 | strncpy(buf, "operator|=", sizeof("operator|=") - 1); |
| 2303 | buf += sizeof("operator|=") - 1; |
| 2304 | } |
| 2305 | return buf; |
| 2306 | } |
| 2307 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 2308 | { |
| 2309 | bool r = true; |
| 2310 | if (__left_) |
| 2311 | r = r && __left_->fix_forward_references(t_begin, t_end); |
| 2312 | if (__right_) |
| 2313 | r = r && __right_->fix_forward_references(t_begin, t_end); |
| 2314 | return r; |
| 2315 | } |
| 2316 | }; |
| 2317 | |
| 2318 | class __operator_pointer_to_member |
| 2319 | : public __node |
| 2320 | { |
| 2321 | public: |
| 2322 | |
| 2323 | __operator_pointer_to_member() {} |
| 2324 | __operator_pointer_to_member(__node* op1, __node* op2) |
| 2325 | { |
| 2326 | __left_ = op1; |
| 2327 | __right_ = op2; |
| 2328 | } |
| 2329 | virtual size_t first_size() const |
| 2330 | { |
| 2331 | if (__cached_size_ == -1) |
| 2332 | { |
| 2333 | if (__left_) |
| 2334 | const_cast<long&>(__cached_size_) = static_cast<long>( |
| 2335 | __left_->size() + 9 + |
| 2336 | __right_->size()); |
| 2337 | else |
| 2338 | const_cast<long&>(__cached_size_) = sizeof("operator->*") - 1; |
| 2339 | } |
| 2340 | return static_cast<size_t>(__cached_size_); |
| 2341 | } |
| 2342 | virtual char* first_demangled_name(char* buf) const |
| 2343 | { |
| 2344 | if (__left_) |
| 2345 | { |
| 2346 | *buf++ = '('; |
| 2347 | buf = __left_->get_demangled_name(buf); |
| 2348 | strncpy(buf, ") ->* (", 7); |
| 2349 | buf += 7; |
| 2350 | buf = __right_->get_demangled_name(buf); |
| 2351 | *buf++ = ')'; |
| 2352 | } |
| 2353 | else |
| 2354 | { |
| 2355 | strncpy(buf, "operator->*", sizeof("operator->*") - 1); |
| 2356 | buf += sizeof("operator->*") - 1; |
| 2357 | } |
| 2358 | return buf; |
| 2359 | } |
| 2360 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 2361 | { |
| 2362 | bool r = true; |
| 2363 | if (__left_) |
| 2364 | r = r && __left_->fix_forward_references(t_begin, t_end); |
| 2365 | if (__right_) |
| 2366 | r = r && __right_->fix_forward_references(t_begin, t_end); |
| 2367 | return r; |
| 2368 | } |
| 2369 | }; |
| 2370 | |
| 2371 | class __operator_plus |
| 2372 | : public __node |
| 2373 | { |
| 2374 | public: |
| 2375 | |
| 2376 | __operator_plus() {} |
| 2377 | __operator_plus(__node* op1, __node* op2) |
| 2378 | { |
| 2379 | __left_ = op1; |
| 2380 | __right_ = op2; |
| 2381 | } |
| 2382 | virtual size_t first_size() const |
| 2383 | { |
| 2384 | if (__cached_size_ == -1) |
| 2385 | { |
| 2386 | if (__left_) |
| 2387 | const_cast<long&>(__cached_size_) = static_cast<long>( |
| 2388 | __left_->size() + 7 + |
| 2389 | __right_->size()); |
| 2390 | else |
| 2391 | const_cast<long&>(__cached_size_) = sizeof("operator+") - 1; |
| 2392 | } |
| 2393 | return static_cast<size_t>(__cached_size_); |
| 2394 | } |
| 2395 | virtual char* first_demangled_name(char* buf) const |
| 2396 | { |
| 2397 | if (__left_) |
| 2398 | { |
| 2399 | *buf++ = '('; |
| 2400 | buf = __left_->get_demangled_name(buf); |
| 2401 | strncpy(buf, ") + (", 5); |
| 2402 | buf += 5; |
| 2403 | buf = __right_->get_demangled_name(buf); |
| 2404 | *buf++ = ')'; |
| 2405 | } |
| 2406 | else |
| 2407 | { |
| 2408 | strncpy(buf, "operator+", sizeof("operator+") - 1); |
| 2409 | buf += sizeof("operator+") - 1; |
| 2410 | } |
| 2411 | return buf; |
| 2412 | } |
| 2413 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 2414 | { |
| 2415 | bool r = true; |
| 2416 | if (__left_) |
| 2417 | r = r && __left_->fix_forward_references(t_begin, t_end); |
| 2418 | if (__right_) |
| 2419 | r = r && __right_->fix_forward_references(t_begin, t_end); |
| 2420 | return r; |
| 2421 | } |
| 2422 | }; |
| 2423 | |
| 2424 | class __operator_plus_equal |
| 2425 | : public __node |
| 2426 | { |
| 2427 | public: |
| 2428 | |
| 2429 | __operator_plus_equal() {} |
| 2430 | __operator_plus_equal(__node* op1, __node* op2) |
| 2431 | { |
| 2432 | __left_ = op1; |
| 2433 | __right_ = op2; |
| 2434 | } |
| 2435 | virtual size_t first_size() const |
| 2436 | { |
| 2437 | if (__cached_size_ == -1) |
| 2438 | { |
| 2439 | if (__left_) |
| 2440 | const_cast<long&>(__cached_size_) = static_cast<long>( |
| 2441 | __left_->size() + 8 + |
| 2442 | __right_->size()); |
| 2443 | else |
| 2444 | const_cast<long&>(__cached_size_) = sizeof("operator+=") - 1; |
| 2445 | } |
| 2446 | return static_cast<size_t>(__cached_size_); |
| 2447 | } |
| 2448 | virtual char* first_demangled_name(char* buf) const |
| 2449 | { |
| 2450 | if (__left_) |
| 2451 | { |
| 2452 | *buf++ = '('; |
| 2453 | buf = __left_->get_demangled_name(buf); |
| 2454 | strncpy(buf, ") += (", 6); |
| 2455 | buf += 6; |
| 2456 | buf = __right_->get_demangled_name(buf); |
| 2457 | *buf++ = ')'; |
| 2458 | } |
| 2459 | else |
| 2460 | { |
| 2461 | strncpy(buf, "operator+=", sizeof("operator+=") - 1); |
| 2462 | buf += sizeof("operator+=") - 1; |
| 2463 | } |
| 2464 | return buf; |
| 2465 | } |
| 2466 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 2467 | { |
| 2468 | bool r = true; |
| 2469 | if (__left_) |
| 2470 | r = r && __left_->fix_forward_references(t_begin, t_end); |
| 2471 | if (__right_) |
| 2472 | r = r && __right_->fix_forward_references(t_begin, t_end); |
| 2473 | return r; |
| 2474 | } |
| 2475 | }; |
| 2476 | |
| 2477 | class __operator_increment |
| 2478 | : public __node |
| 2479 | { |
| 2480 | public: |
| 2481 | |
| 2482 | __operator_increment() {} |
| 2483 | explicit __operator_increment(bool prefix, __node* op) |
| 2484 | { |
| 2485 | __size_ = prefix; |
| 2486 | __left_ = op; |
| 2487 | } |
| 2488 | virtual size_t first_size() const |
| 2489 | { |
| 2490 | if (__cached_size_ == -1) |
| 2491 | { |
| 2492 | if (__left_) |
| 2493 | const_cast<long&>(__cached_size_) = static_cast<long>(4 + __left_->size()); |
| 2494 | else |
| 2495 | const_cast<long&>(__cached_size_) = sizeof("operator++") - 1; |
| 2496 | } |
| 2497 | return static_cast<size_t>(__cached_size_); |
| 2498 | } |
| 2499 | virtual char* first_demangled_name(char* buf) const |
| 2500 | { |
| 2501 | if (__left_) |
| 2502 | { |
| 2503 | if (__size_) |
| 2504 | { |
| 2505 | *buf++ = '+'; |
| 2506 | *buf++ = '+'; |
| 2507 | *buf++ = '('; |
| 2508 | } |
| 2509 | else |
| 2510 | *buf++ = '('; |
| 2511 | buf = __left_->get_demangled_name(buf); |
| 2512 | if (__size_) |
| 2513 | *buf++ = ')'; |
| 2514 | else |
| 2515 | { |
| 2516 | *buf++ = ')'; |
| 2517 | *buf++ = '+'; |
| 2518 | *buf++ = '+'; |
| 2519 | } |
| 2520 | } |
| 2521 | else |
| 2522 | { |
| 2523 | strncpy(buf, "operator++", sizeof("operator++") - 1); |
| 2524 | buf += sizeof("operator++") - 1; |
| 2525 | } |
| 2526 | return buf; |
| 2527 | } |
| 2528 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 2529 | { |
| 2530 | if (__left_) |
| 2531 | return __left_->fix_forward_references(t_begin, t_end); |
| 2532 | return true; |
| 2533 | } |
| 2534 | }; |
| 2535 | |
| 2536 | class __operator_unary_plus |
| 2537 | : public __node |
| 2538 | { |
| 2539 | public: |
| 2540 | |
| 2541 | __operator_unary_plus() {} |
| 2542 | explicit __operator_unary_plus(__node* op) |
| 2543 | { |
| 2544 | __left_ = op; |
| 2545 | } |
| 2546 | virtual size_t first_size() const |
| 2547 | { |
| 2548 | if (__cached_size_ == -1) |
| 2549 | { |
| 2550 | if (__left_) |
| 2551 | const_cast<long&>(__cached_size_) = static_cast<long>(3 + __left_->size()); |
| 2552 | else |
| 2553 | const_cast<long&>(__cached_size_) = sizeof("operator+") - 1; |
| 2554 | } |
| 2555 | return static_cast<size_t>(__cached_size_); |
| 2556 | } |
| 2557 | virtual char* first_demangled_name(char* buf) const |
| 2558 | { |
| 2559 | if (__left_) |
| 2560 | { |
| 2561 | *buf++ = '+'; |
| 2562 | *buf++ = '('; |
| 2563 | buf = __left_->get_demangled_name(buf); |
| 2564 | *buf++ = ')'; |
| 2565 | } |
| 2566 | else |
| 2567 | { |
| 2568 | strncpy(buf, "operator+", sizeof("operator+") - 1); |
| 2569 | buf += sizeof("operator+") - 1; |
| 2570 | } |
| 2571 | return buf; |
| 2572 | } |
| 2573 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 2574 | { |
| 2575 | if (__left_) |
| 2576 | return __left_->fix_forward_references(t_begin, t_end); |
| 2577 | return true; |
| 2578 | } |
| 2579 | }; |
| 2580 | |
| 2581 | class __operator_arrow |
| 2582 | : public __node |
| 2583 | { |
| 2584 | public: |
| 2585 | |
| 2586 | __operator_arrow() {} |
| 2587 | __operator_arrow(__node* op1, __node* op2) |
| 2588 | { |
| 2589 | __left_ = op1; |
| 2590 | __right_ = op2; |
| 2591 | } |
| 2592 | virtual size_t first_size() const |
| 2593 | { |
| 2594 | if (__cached_size_ == -1) |
| 2595 | { |
| 2596 | if (__left_) |
| 2597 | const_cast<long&>(__cached_size_) = static_cast<long>( |
| 2598 | __left_->size() + 8 + |
| 2599 | __right_->size()); |
| 2600 | else |
| 2601 | const_cast<long&>(__cached_size_) = sizeof("operator->") - 1; |
| 2602 | } |
| 2603 | return static_cast<size_t>(__cached_size_); |
| 2604 | } |
| 2605 | virtual char* first_demangled_name(char* buf) const |
| 2606 | { |
| 2607 | if (__left_) |
| 2608 | { |
| 2609 | *buf++ = '('; |
| 2610 | buf = __left_->get_demangled_name(buf); |
| 2611 | strncpy(buf, ") -> (", 6); |
| 2612 | buf += 6; |
| 2613 | buf = __right_->get_demangled_name(buf); |
| 2614 | *buf++ = ')'; |
| 2615 | } |
| 2616 | else |
| 2617 | { |
| 2618 | strncpy(buf, "operator->", sizeof("operator->") - 1); |
| 2619 | buf += sizeof("operator->") - 1; |
| 2620 | } |
| 2621 | return buf; |
| 2622 | } |
| 2623 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 2624 | { |
| 2625 | bool r = true; |
| 2626 | if (__left_) |
| 2627 | r = r && __left_->fix_forward_references(t_begin, t_end); |
| 2628 | if (__right_) |
| 2629 | r = r && __right_->fix_forward_references(t_begin, t_end); |
| 2630 | return r; |
| 2631 | } |
| 2632 | }; |
| 2633 | |
| 2634 | class __operator_conditional |
| 2635 | : public __node |
| 2636 | { |
| 2637 | public: |
| 2638 | |
| 2639 | __operator_conditional() {} |
| 2640 | __operator_conditional(__node* op1, __node* op2, __node* op3) |
| 2641 | { |
| 2642 | __name_ = (const char*)op1; |
| 2643 | __left_ = op2; |
| 2644 | __right_ = op3; |
| 2645 | } |
| 2646 | virtual size_t first_size() const |
| 2647 | { |
| 2648 | if (__cached_size_ == -1) |
| 2649 | { |
| 2650 | if (__left_) |
| 2651 | { |
| 2652 | __node* op1 = (__node*)__name_; |
| 2653 | const_cast<long&>(__cached_size_) = static_cast<long>( |
| 2654 | op1->size() + |
| 2655 | __left_->size() + 12 + |
| 2656 | __right_->size()); |
| 2657 | } |
| 2658 | else |
| 2659 | const_cast<long&>(__cached_size_) = sizeof("operator?") - 1; |
| 2660 | } |
| 2661 | return static_cast<size_t>(__cached_size_); |
| 2662 | } |
| 2663 | virtual char* first_demangled_name(char* buf) const |
| 2664 | { |
| 2665 | if (__left_) |
| 2666 | { |
| 2667 | __node* op1 = (__node*)__name_; |
| 2668 | *buf++ = '('; |
| 2669 | buf = op1->get_demangled_name(buf); |
| 2670 | strncpy(buf, ") ? (", 5); |
| 2671 | buf += 5; |
| 2672 | buf = __left_->get_demangled_name(buf); |
| 2673 | strncpy(buf, ") : (", 5); |
| 2674 | buf += 5; |
| 2675 | buf = __right_->get_demangled_name(buf); |
| 2676 | *buf++ = ')'; |
| 2677 | } |
| 2678 | else |
| 2679 | { |
| 2680 | strncpy(buf, "operator?", sizeof("operator?") - 1); |
| 2681 | buf += sizeof("operator?") - 1; |
| 2682 | } |
| 2683 | return buf; |
| 2684 | } |
| 2685 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 2686 | { |
| 2687 | bool r = true; |
| 2688 | if (__name_) |
| 2689 | r = r && ((__node*)__name_)->fix_forward_references(t_begin, t_end); |
| 2690 | if (__left_) |
| 2691 | r = r && __left_->fix_forward_references(t_begin, t_end); |
| 2692 | if (__right_) |
| 2693 | r = r && __right_->fix_forward_references(t_begin, t_end); |
| 2694 | return r; |
| 2695 | } |
| 2696 | }; |
| 2697 | |
| 2698 | class __operator_mod |
| 2699 | : public __node |
| 2700 | { |
| 2701 | public: |
| 2702 | |
| 2703 | __operator_mod() {} |
| 2704 | __operator_mod(__node* op1, __node* op2) |
| 2705 | { |
| 2706 | __left_ = op1; |
| 2707 | __right_ = op2; |
| 2708 | } |
| 2709 | virtual size_t first_size() const |
| 2710 | { |
| 2711 | if (__cached_size_ == -1) |
| 2712 | { |
| 2713 | if (__left_) |
| 2714 | const_cast<long&>(__cached_size_) = static_cast<long>( |
| 2715 | __left_->size() + 7 + |
| 2716 | __right_->size()); |
| 2717 | else |
| 2718 | const_cast<long&>(__cached_size_) = sizeof("operator%") - 1; |
| 2719 | } |
| 2720 | return static_cast<size_t>(__cached_size_); |
| 2721 | } |
| 2722 | virtual char* first_demangled_name(char* buf) const |
| 2723 | { |
| 2724 | if (__left_) |
| 2725 | { |
| 2726 | *buf++ = '('; |
| 2727 | buf = __left_->get_demangled_name(buf); |
| 2728 | strncpy(buf, ") % (", 5); |
| 2729 | buf += 5; |
| 2730 | buf = __right_->get_demangled_name(buf); |
| 2731 | *buf++ = ')'; |
| 2732 | } |
| 2733 | else |
| 2734 | { |
| 2735 | strncpy(buf, "operator%", sizeof("operator%") - 1); |
| 2736 | buf += sizeof("operator%") - 1; |
| 2737 | } |
| 2738 | return buf; |
| 2739 | } |
| 2740 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 2741 | { |
| 2742 | bool r = true; |
| 2743 | if (__left_) |
| 2744 | r = r && __left_->fix_forward_references(t_begin, t_end); |
| 2745 | if (__right_) |
| 2746 | r = r && __right_->fix_forward_references(t_begin, t_end); |
| 2747 | return r; |
| 2748 | } |
| 2749 | }; |
| 2750 | |
| 2751 | class __operator_mod_equal |
| 2752 | : public __node |
| 2753 | { |
| 2754 | public: |
| 2755 | |
| 2756 | __operator_mod_equal() {} |
| 2757 | __operator_mod_equal(__node* op1, __node* op2) |
| 2758 | { |
| 2759 | __left_ = op1; |
| 2760 | __right_ = op2; |
| 2761 | } |
| 2762 | virtual size_t first_size() const |
| 2763 | { |
| 2764 | if (__cached_size_ == -1) |
| 2765 | { |
| 2766 | if (__left_) |
| 2767 | const_cast<long&>(__cached_size_) = static_cast<long>( |
| 2768 | __left_->size() + 8 + |
| 2769 | __right_->size()); |
| 2770 | else |
| 2771 | const_cast<long&>(__cached_size_) = sizeof("operator%=") - 1; |
| 2772 | } |
| 2773 | return static_cast<size_t>(__cached_size_); |
| 2774 | } |
| 2775 | virtual char* first_demangled_name(char* buf) const |
| 2776 | { |
| 2777 | if (__left_) |
| 2778 | { |
| 2779 | *buf++ = '('; |
| 2780 | buf = __left_->get_demangled_name(buf); |
| 2781 | strncpy(buf, ") %= (", 6); |
| 2782 | buf += 6; |
| 2783 | buf = __right_->get_demangled_name(buf); |
| 2784 | *buf++ = ')'; |
| 2785 | } |
| 2786 | else |
| 2787 | { |
| 2788 | strncpy(buf, "operator%=", sizeof("operator%=") - 1); |
| 2789 | buf += sizeof("operator%=") - 1; |
| 2790 | } |
| 2791 | return buf; |
| 2792 | } |
| 2793 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 2794 | { |
| 2795 | bool r = true; |
| 2796 | if (__left_) |
| 2797 | r = r && __left_->fix_forward_references(t_begin, t_end); |
| 2798 | if (__right_) |
| 2799 | r = r && __right_->fix_forward_references(t_begin, t_end); |
| 2800 | return r; |
| 2801 | } |
| 2802 | }; |
| 2803 | |
| 2804 | class __operator_right_shift |
| 2805 | : public __node |
| 2806 | { |
| 2807 | public: |
| 2808 | |
| 2809 | __operator_right_shift() {} |
| 2810 | __operator_right_shift(__node* op1, __node* op2) |
| 2811 | { |
| 2812 | __left_ = op1; |
| 2813 | __right_ = op2; |
| 2814 | } |
| 2815 | virtual size_t first_size() const |
| 2816 | { |
| 2817 | if (__cached_size_ == -1) |
| 2818 | { |
| 2819 | if (__left_) |
| 2820 | const_cast<long&>(__cached_size_) = static_cast<long>( |
| 2821 | __left_->size() + 8 + |
| 2822 | __right_->size()); |
| 2823 | else |
| 2824 | const_cast<long&>(__cached_size_) = sizeof("operator>>") - 1; |
| 2825 | } |
| 2826 | return static_cast<size_t>(__cached_size_); |
| 2827 | } |
| 2828 | virtual char* first_demangled_name(char* buf) const |
| 2829 | { |
| 2830 | if (__left_) |
| 2831 | { |
| 2832 | *buf++ = '('; |
| 2833 | buf = __left_->get_demangled_name(buf); |
| 2834 | strncpy(buf, ") >> (", 6); |
| 2835 | buf += 6; |
| 2836 | buf = __right_->get_demangled_name(buf); |
| 2837 | *buf++ = ')'; |
| 2838 | } |
| 2839 | else |
| 2840 | { |
| 2841 | strncpy(buf, "operator>>", sizeof("operator>>") - 1); |
| 2842 | buf += sizeof("operator>>") - 1; |
| 2843 | } |
| 2844 | return buf; |
| 2845 | } |
| 2846 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 2847 | { |
| 2848 | bool r = true; |
| 2849 | if (__left_) |
| 2850 | r = r && __left_->fix_forward_references(t_begin, t_end); |
| 2851 | if (__right_) |
| 2852 | r = r && __right_->fix_forward_references(t_begin, t_end); |
| 2853 | return r; |
| 2854 | } |
| 2855 | }; |
| 2856 | |
| 2857 | class __operator_right_shift_equal |
| 2858 | : public __node |
| 2859 | { |
| 2860 | public: |
| 2861 | |
| 2862 | __operator_right_shift_equal() {} |
| 2863 | __operator_right_shift_equal(__node* op1, __node* op2) |
| 2864 | { |
| 2865 | __left_ = op1; |
| 2866 | __right_ = op2; |
| 2867 | } |
| 2868 | virtual size_t first_size() const |
| 2869 | { |
| 2870 | if (__cached_size_ == -1) |
| 2871 | { |
| 2872 | if (__left_) |
| 2873 | const_cast<long&>(__cached_size_) = static_cast<long>( |
| 2874 | __left_->size() + 9 + |
| 2875 | __right_->size()); |
| 2876 | else |
| 2877 | const_cast<long&>(__cached_size_) = sizeof("operator>>=") - 1; |
| 2878 | } |
| 2879 | return static_cast<size_t>(__cached_size_); |
| 2880 | } |
| 2881 | virtual char* first_demangled_name(char* buf) const |
| 2882 | { |
| 2883 | if (__left_) |
| 2884 | { |
| 2885 | *buf++ = '('; |
| 2886 | buf = __left_->get_demangled_name(buf); |
| 2887 | strncpy(buf, ") >>= (", 7); |
| 2888 | buf += 7; |
| 2889 | buf = __right_->get_demangled_name(buf); |
| 2890 | *buf++ = ')'; |
| 2891 | } |
| 2892 | else |
| 2893 | { |
| 2894 | strncpy(buf, "operator>>=", sizeof("operator>>=") - 1); |
| 2895 | buf += sizeof("operator>>=") - 1; |
| 2896 | } |
| 2897 | return buf; |
| 2898 | } |
| 2899 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 2900 | { |
| 2901 | bool r = true; |
| 2902 | if (__left_) |
| 2903 | r = r && __left_->fix_forward_references(t_begin, t_end); |
| 2904 | if (__right_) |
| 2905 | r = r && __right_->fix_forward_references(t_begin, t_end); |
| 2906 | return r; |
| 2907 | } |
| 2908 | }; |
| 2909 | |
| 2910 | class __operator_sizeof_type |
| 2911 | : public __node |
| 2912 | { |
| 2913 | public: |
| 2914 | |
| 2915 | __operator_sizeof_type() {} |
| 2916 | __operator_sizeof_type(__node* op) |
| 2917 | { |
| 2918 | __right_ = op; |
| 2919 | } |
| 2920 | virtual size_t first_size() const |
| 2921 | { |
| 2922 | if (__cached_size_ == -1) |
| 2923 | { |
| 2924 | if (__right_) |
| 2925 | const_cast<long&>(__cached_size_) = static_cast<long>(__right_->size() + 9); |
| 2926 | else |
| 2927 | const_cast<long&>(__cached_size_) = sizeof("operator sizeof") - 1; |
| 2928 | } |
| 2929 | return static_cast<size_t>(__cached_size_); |
| 2930 | } |
| 2931 | virtual char* first_demangled_name(char* buf) const |
| 2932 | { |
| 2933 | if (__right_) |
| 2934 | { |
| 2935 | strncpy(buf, "sizeof (", 8); |
| 2936 | buf += 8; |
| 2937 | buf = __right_->get_demangled_name(buf); |
| 2938 | *buf++ = ')'; |
| 2939 | } |
| 2940 | else |
| 2941 | { |
| 2942 | strncpy(buf, "operator sizeof", sizeof("operator sizeof") - 1); |
| 2943 | buf += sizeof("operator sizeof") - 1; |
| 2944 | } |
| 2945 | return buf; |
| 2946 | } |
| 2947 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 2948 | { |
| 2949 | if (__right_) |
| 2950 | return __right_->fix_forward_references(t_begin, t_end); |
| 2951 | return true; |
| 2952 | } |
| 2953 | }; |
| 2954 | |
| 2955 | class __operator_sizeof_expression |
| 2956 | : public __node |
| 2957 | { |
| 2958 | public: |
| 2959 | |
| 2960 | __operator_sizeof_expression() {} |
| 2961 | __operator_sizeof_expression(__node* op) |
| 2962 | { |
| 2963 | __right_ = op; |
| 2964 | } |
| 2965 | virtual size_t first_size() const |
| 2966 | { |
| 2967 | if (__cached_size_ == -1) |
| 2968 | { |
| 2969 | if (__right_) |
| 2970 | const_cast<long&>(__cached_size_) = static_cast<long>(__right_->size() + 9); |
| 2971 | else |
| 2972 | const_cast<long&>(__cached_size_) = sizeof("operator sizeof") - 1; |
| 2973 | } |
| 2974 | return static_cast<size_t>(__cached_size_); |
| 2975 | } |
| 2976 | virtual char* first_demangled_name(char* buf) const |
| 2977 | { |
| 2978 | if (__right_) |
| 2979 | { |
| 2980 | strncpy(buf, "sizeof (", 8); |
| 2981 | buf += 8; |
| 2982 | buf = __right_->get_demangled_name(buf); |
| 2983 | *buf++ = ')'; |
| 2984 | } |
| 2985 | else |
| 2986 | { |
| 2987 | strncpy(buf, "operator sizeof", sizeof("operator sizeof") - 1); |
| 2988 | buf += sizeof("operator sizeof") - 1; |
| 2989 | } |
| 2990 | return buf; |
| 2991 | } |
| 2992 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 2993 | { |
| 2994 | if (__right_) |
| 2995 | return __right_->fix_forward_references(t_begin, t_end); |
| 2996 | return true; |
| 2997 | } |
| 2998 | }; |
| 2999 | |
| 3000 | class __typeid |
| 3001 | : public __node |
| 3002 | { |
| 3003 | public: |
| 3004 | |
| 3005 | __typeid(__node* op) |
| 3006 | { |
| 3007 | __right_ = op; |
| 3008 | } |
| 3009 | virtual size_t first_size() const |
| 3010 | { |
| 3011 | if (__cached_size_ == -1) |
| 3012 | const_cast<long&>(__cached_size_) = static_cast<long>(__right_->size() + 8); |
| 3013 | return static_cast<size_t>(__cached_size_); |
| 3014 | } |
| 3015 | virtual char* first_demangled_name(char* buf) const |
| 3016 | { |
| 3017 | strncpy(buf, "typeid(", 7); |
| 3018 | buf += 7; |
| 3019 | buf = __right_->get_demangled_name(buf); |
| 3020 | *buf++ = ')'; |
| 3021 | return buf; |
| 3022 | } |
| 3023 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 3024 | { |
| 3025 | return __right_->fix_forward_references(t_begin, t_end); |
| 3026 | } |
| 3027 | }; |
| 3028 | |
| 3029 | class __throw |
| 3030 | : public __node |
| 3031 | { |
| 3032 | public: |
| 3033 | |
| 3034 | __throw(__node* op) |
| 3035 | { |
| 3036 | __right_ = op; |
| 3037 | } |
| 3038 | virtual size_t first_size() const |
| 3039 | { |
| 3040 | if (__cached_size_ == -1) |
| 3041 | const_cast<long&>(__cached_size_) = static_cast<long>(__right_->size() + 6); |
| 3042 | return static_cast<size_t>(__cached_size_); |
| 3043 | } |
| 3044 | virtual char* first_demangled_name(char* buf) const |
| 3045 | { |
| 3046 | strncpy(buf, "throw ", 6); |
| 3047 | return __right_->get_demangled_name(buf+6); |
| 3048 | } |
| 3049 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 3050 | { |
| 3051 | return __right_->fix_forward_references(t_begin, t_end); |
| 3052 | } |
| 3053 | }; |
| 3054 | |
| 3055 | class __rethrow |
| 3056 | : public __node |
| 3057 | { |
| 3058 | static const ptrdiff_t n = sizeof("throw") - 1; |
| 3059 | public: |
| 3060 | |
| 3061 | virtual size_t first_size() const {return n;} |
| 3062 | virtual char* first_demangled_name(char* buf) const |
| 3063 | { |
| 3064 | strncpy(buf, "throw", n); |
| 3065 | return buf+n; |
| 3066 | } |
| 3067 | }; |
| 3068 | |
| 3069 | class __operator_sizeof_param_pack |
| 3070 | : public __node |
| 3071 | { |
| 3072 | public: |
| 3073 | |
| 3074 | __operator_sizeof_param_pack(__node* op) |
| 3075 | { |
| 3076 | __right_ = op; |
| 3077 | } |
| 3078 | virtual size_t first_size() const |
| 3079 | { |
| 3080 | if (__cached_size_ == -1) |
| 3081 | const_cast<long&>(__cached_size_) = static_cast<long>(__right_->size() + 11); |
| 3082 | return static_cast<size_t>(__cached_size_); |
| 3083 | } |
| 3084 | virtual char* first_demangled_name(char* buf) const |
| 3085 | { |
| 3086 | strncpy(buf, "sizeof...(", 10); |
| 3087 | buf += 10; |
| 3088 | buf = __right_->get_demangled_name(buf); |
| 3089 | *buf++ = ')'; |
| 3090 | return buf; |
| 3091 | } |
| 3092 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 3093 | { |
| 3094 | return __right_->fix_forward_references(t_begin, t_end); |
| 3095 | } |
| 3096 | }; |
| 3097 | |
| 3098 | class __const_cast |
| 3099 | : public __node |
| 3100 | { |
| 3101 | public: |
| 3102 | |
| 3103 | __const_cast(__node* op1, __node* op2) |
| 3104 | { |
| 3105 | __left_ = op1; |
| 3106 | __right_ = op2; |
| 3107 | } |
| 3108 | virtual size_t first_size() const |
| 3109 | { |
| 3110 | if (__cached_size_ == -1) |
| 3111 | const_cast<long&>(__cached_size_) = static_cast<long>(__left_->size() + |
| 3112 | 14 + __right_->size()); |
| 3113 | return static_cast<size_t>(__cached_size_); |
| 3114 | } |
| 3115 | virtual char* first_demangled_name(char* buf) const |
| 3116 | { |
| 3117 | strncpy(buf, "const_cast<", 11); |
| 3118 | buf += 11; |
| 3119 | buf = __left_->get_demangled_name(buf); |
| 3120 | *buf++ = '>'; |
| 3121 | *buf++ = '('; |
| 3122 | buf = __right_->get_demangled_name(buf); |
| 3123 | *buf++ = ')'; |
| 3124 | return buf; |
| 3125 | } |
| 3126 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 3127 | { |
| 3128 | return __left_->fix_forward_references(t_begin, t_end) && |
| 3129 | __right_->fix_forward_references(t_begin, t_end); |
| 3130 | } |
| 3131 | }; |
| 3132 | |
| 3133 | class __dynamic_cast |
| 3134 | : public __node |
| 3135 | { |
| 3136 | public: |
| 3137 | |
| 3138 | __dynamic_cast(__node* op1, __node* op2) |
| 3139 | { |
| 3140 | __left_ = op1; |
| 3141 | __right_ = op2; |
| 3142 | } |
| 3143 | virtual size_t first_size() const |
| 3144 | { |
| 3145 | if (__cached_size_ == -1) |
| 3146 | const_cast<long&>(__cached_size_) = static_cast<long>(__left_->size() + |
| 3147 | 16 + __right_->size()); |
| 3148 | return static_cast<size_t>(__cached_size_); |
| 3149 | } |
| 3150 | virtual char* first_demangled_name(char* buf) const |
| 3151 | { |
| 3152 | strncpy(buf, "dynamic_cast<", 13); |
| 3153 | buf += 13; |
| 3154 | buf = __left_->get_demangled_name(buf); |
| 3155 | *buf++ = '>'; |
| 3156 | *buf++ = '('; |
| 3157 | buf = __right_->get_demangled_name(buf); |
| 3158 | *buf++ = ')'; |
| 3159 | return buf; |
| 3160 | } |
| 3161 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 3162 | { |
| 3163 | return __left_->fix_forward_references(t_begin, t_end) && |
| 3164 | __right_->fix_forward_references(t_begin, t_end); |
| 3165 | } |
| 3166 | }; |
| 3167 | |
| 3168 | class __reinterpret_cast |
| 3169 | : public __node |
| 3170 | { |
| 3171 | public: |
| 3172 | |
| 3173 | __reinterpret_cast(__node* op1, __node* op2) |
| 3174 | { |
| 3175 | __left_ = op1; |
| 3176 | __right_ = op2; |
| 3177 | } |
| 3178 | virtual size_t first_size() const |
| 3179 | { |
| 3180 | if (__cached_size_ == -1) |
| 3181 | const_cast<long&>(__cached_size_) = static_cast<long>(__left_->size() + |
| 3182 | 20 + __right_->size()); |
| 3183 | return static_cast<size_t>(__cached_size_); |
| 3184 | } |
| 3185 | virtual char* first_demangled_name(char* buf) const |
| 3186 | { |
| 3187 | strncpy(buf, "reinterpret_cast<", 17); |
| 3188 | buf += 17; |
| 3189 | buf = __left_->get_demangled_name(buf); |
| 3190 | *buf++ = '>'; |
| 3191 | *buf++ = '('; |
| 3192 | buf = __right_->get_demangled_name(buf); |
| 3193 | *buf++ = ')'; |
| 3194 | return buf; |
| 3195 | } |
| 3196 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 3197 | { |
| 3198 | return __left_->fix_forward_references(t_begin, t_end) && |
| 3199 | __right_->fix_forward_references(t_begin, t_end); |
| 3200 | } |
| 3201 | }; |
| 3202 | |
| 3203 | class __static_cast |
| 3204 | : public __node |
| 3205 | { |
| 3206 | public: |
| 3207 | |
| 3208 | __static_cast(__node* op1, __node* op2) |
| 3209 | { |
| 3210 | __left_ = op1; |
| 3211 | __right_ = op2; |
| 3212 | } |
| 3213 | virtual size_t first_size() const |
| 3214 | { |
| 3215 | if (__cached_size_ == -1) |
| 3216 | const_cast<long&>(__cached_size_) = static_cast<long>(__left_->size() + |
| 3217 | 15 + __right_->size()); |
| 3218 | return static_cast<size_t>(__cached_size_); |
| 3219 | } |
| 3220 | virtual char* first_demangled_name(char* buf) const |
| 3221 | { |
| 3222 | strncpy(buf, "static_cast<", 12); |
| 3223 | buf += 12; |
| 3224 | buf = __left_->get_demangled_name(buf); |
| 3225 | *buf++ = '>'; |
| 3226 | *buf++ = '('; |
| 3227 | buf = __right_->get_demangled_name(buf); |
| 3228 | *buf++ = ')'; |
| 3229 | return buf; |
| 3230 | } |
| 3231 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 3232 | { |
| 3233 | return __left_->fix_forward_references(t_begin, t_end) && |
| 3234 | __right_->fix_forward_references(t_begin, t_end); |
| 3235 | } |
| 3236 | }; |
| 3237 | |
| 3238 | class __call_expr |
| 3239 | : public __node |
| 3240 | { |
| 3241 | public: |
| 3242 | |
| 3243 | __call_expr(__node* op1, __node* op2) |
| 3244 | { |
| 3245 | __left_ = op1; |
| 3246 | __right_ = op2; |
| 3247 | } |
| 3248 | virtual size_t first_size() const |
| 3249 | { |
| 3250 | if (__cached_size_ == -1) |
| 3251 | { |
| 3252 | size_t off = __left_->size() + 2; |
| 3253 | if (__right_) |
| 3254 | off += __right_->size(); |
| 3255 | const_cast<long&>(__cached_size_) = static_cast<long>(off); |
| 3256 | } |
| 3257 | return static_cast<size_t>(__cached_size_); |
| 3258 | } |
| 3259 | virtual char* first_demangled_name(char* buf) const |
| 3260 | { |
| 3261 | buf = __left_->get_demangled_name(buf); |
| 3262 | *buf++ = '('; |
| 3263 | if (__right_) |
| 3264 | buf = __right_->get_demangled_name(buf); |
| 3265 | *buf++ = ')'; |
| 3266 | return buf; |
| 3267 | } |
| 3268 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 3269 | { |
| 3270 | bool r = __left_->fix_forward_references(t_begin, t_end); |
| 3271 | if (__right_) |
| 3272 | r = r && __right_->fix_forward_references(t_begin, t_end); |
| 3273 | return r; |
| 3274 | } |
| 3275 | }; |
| 3276 | |
| 3277 | class __delete_array_expr |
| 3278 | : public __node |
| 3279 | { |
| 3280 | public: |
| 3281 | |
| 3282 | __delete_array_expr(bool global, __node* op) |
| 3283 | { |
| 3284 | __size_ = global; |
| 3285 | __right_ = op; |
| 3286 | } |
| 3287 | virtual size_t first_size() const |
| 3288 | { |
| 3289 | if (__cached_size_ == -1) |
| 3290 | const_cast<long&>(__cached_size_) = static_cast<long>((__size_ ? 2 : 0) + |
| 3291 | 9 + __right_->size()); |
| 3292 | return static_cast<size_t>(__cached_size_); |
| 3293 | } |
| 3294 | virtual char* first_demangled_name(char* buf) const |
| 3295 | { |
| 3296 | if (__size_) |
| 3297 | { |
| 3298 | *buf++ = ':'; |
| 3299 | *buf++ = ':'; |
| 3300 | } |
| 3301 | strncpy(buf, "delete[] ", 9); |
| 3302 | return __right_->get_demangled_name(buf+9); |
| 3303 | } |
| 3304 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 3305 | { |
| 3306 | return __right_->fix_forward_references(t_begin, t_end); |
| 3307 | } |
| 3308 | }; |
| 3309 | |
| 3310 | class __delete_expr |
| 3311 | : public __node |
| 3312 | { |
| 3313 | public: |
| 3314 | |
| 3315 | __delete_expr(bool global, __node* op) |
| 3316 | { |
| 3317 | __size_ = global; |
| 3318 | __right_ = op; |
| 3319 | } |
| 3320 | virtual size_t first_size() const |
| 3321 | { |
| 3322 | if (__cached_size_ == -1) |
| 3323 | const_cast<long&>(__cached_size_) = static_cast<long>((__size_ ? 2 : 0) + |
| 3324 | 7 + __right_->size()); |
| 3325 | return static_cast<size_t>(__cached_size_); |
| 3326 | } |
| 3327 | virtual char* first_demangled_name(char* buf) const |
| 3328 | { |
| 3329 | if (__size_) |
| 3330 | { |
| 3331 | *buf++ = ':'; |
| 3332 | *buf++ = ':'; |
| 3333 | } |
| 3334 | strncpy(buf, "delete ", 7); |
| 3335 | return __right_->get_demangled_name(buf+7); |
| 3336 | } |
| 3337 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 3338 | { |
| 3339 | return __right_->fix_forward_references(t_begin, t_end); |
| 3340 | } |
| 3341 | }; |
| 3342 | |
| 3343 | class __new_expr |
| 3344 | : public __node |
| 3345 | { |
| 3346 | public: |
| 3347 | |
| 3348 | __new_expr(bool global, bool is_array, bool has_init, |
| 3349 | __node* expr, __node* type, __node* init) |
| 3350 | { |
| 3351 | __size_ = (unsigned)global | |
| 3352 | ((unsigned)is_array << 1) | |
| 3353 | ((unsigned)has_init << 2); |
| 3354 | __left_ = expr; |
| 3355 | __name_ = (const char*)type; |
| 3356 | __right_ = init; |
| 3357 | } |
| 3358 | virtual size_t first_size() const |
| 3359 | { |
| 3360 | if (__cached_size_ == -1) |
| 3361 | { |
| 3362 | size_t off = 4; |
| 3363 | if (__size_ & 1) |
| 3364 | off += 2; |
| 3365 | if (__size_ & 2) |
| 3366 | off += 2; |
| 3367 | if (__left_) |
| 3368 | { |
| 3369 | off += 2; |
| 3370 | off += __left_->size(); |
| 3371 | } |
| 3372 | __node* type = (__node*)__name_; |
| 3373 | off += type->size(); |
| 3374 | if (__size_ & 4) |
| 3375 | { |
| 3376 | off += 2; |
| 3377 | if (__right_) |
| 3378 | off += __right_->size(); |
| 3379 | } |
| 3380 | const_cast<long&>(__cached_size_) = static_cast<long>(off); |
| 3381 | } |
| 3382 | return static_cast<size_t>(__cached_size_); |
| 3383 | } |
| 3384 | virtual char* first_demangled_name(char* buf) const |
| 3385 | { |
| 3386 | if (__size_ & 1) |
| 3387 | { |
| 3388 | *buf++ = ':'; |
| 3389 | *buf++ = ':'; |
| 3390 | } |
| 3391 | *buf++ = 'n'; |
| 3392 | *buf++ = 'e'; |
| 3393 | *buf++ = 'w'; |
| 3394 | if (__size_ & 2) |
| 3395 | { |
| 3396 | *buf++ = '['; |
| 3397 | *buf++ = ']'; |
| 3398 | } |
| 3399 | if (__left_) |
| 3400 | { |
| 3401 | *buf++ = '('; |
| 3402 | buf = __left_->get_demangled_name(buf); |
| 3403 | *buf++ = ')'; |
| 3404 | } |
| 3405 | *buf++ = ' '; |
| 3406 | __node* type = (__node*)__name_; |
| 3407 | buf = type->get_demangled_name(buf); |
| 3408 | if (__size_ & 4) |
| 3409 | { |
| 3410 | *buf++ = '('; |
| 3411 | if (__right_) |
| 3412 | buf = __right_->get_demangled_name(buf); |
| 3413 | *buf++ = ')'; |
| 3414 | } |
| 3415 | return buf; |
| 3416 | } |
| 3417 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 3418 | { |
| 3419 | __node* type = (__node*)__name_; |
| 3420 | bool r = type->fix_forward_references(t_begin, t_end); |
| 3421 | if (__left_) |
| 3422 | r = r && __left_->fix_forward_references(t_begin, t_end);; |
| 3423 | if (__right_) |
| 3424 | r = r && __right_->fix_forward_references(t_begin, t_end);; |
| 3425 | return r; |
| 3426 | } |
| 3427 | }; |
| 3428 | |
| 3429 | class __dot_star_expr |
| 3430 | : public __node |
| 3431 | { |
| 3432 | public: |
| 3433 | |
| 3434 | __dot_star_expr(__node* op1, __node* op2) |
| 3435 | { |
| 3436 | __left_ = op1; |
| 3437 | __right_ = op2; |
| 3438 | } |
| 3439 | virtual size_t first_size() const |
| 3440 | { |
| 3441 | if (__cached_size_ == -1) |
| 3442 | const_cast<long&>(__cached_size_) = static_cast<long>(__left_->size() + |
| 3443 | 2 + __right_->size()); |
| 3444 | return static_cast<size_t>(__cached_size_); |
| 3445 | } |
| 3446 | virtual char* first_demangled_name(char* buf) const |
| 3447 | { |
| 3448 | buf = __left_->get_demangled_name(buf); |
| 3449 | *buf++ = '.'; |
| 3450 | *buf++ = '*'; |
| 3451 | return __right_->get_demangled_name(buf); |
| 3452 | } |
| 3453 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 3454 | { |
| 3455 | return __left_->fix_forward_references(t_begin, t_end) && |
| 3456 | __right_->fix_forward_references(t_begin, t_end); |
| 3457 | } |
| 3458 | }; |
| 3459 | |
| 3460 | class __dot_expr |
| 3461 | : public __node |
| 3462 | { |
| 3463 | public: |
| 3464 | |
| 3465 | __dot_expr(__node* op1, __node* op2) |
| 3466 | { |
| 3467 | __left_ = op1; |
| 3468 | __right_ = op2; |
| 3469 | } |
| 3470 | virtual size_t first_size() const |
| 3471 | { |
| 3472 | if (__cached_size_ == -1) |
| 3473 | const_cast<long&>(__cached_size_) = static_cast<long>(__left_->size() + |
| 3474 | 1 + __right_->size()); |
| 3475 | return static_cast<size_t>(__cached_size_); |
| 3476 | } |
| 3477 | virtual char* first_demangled_name(char* buf) const |
| 3478 | { |
| 3479 | buf = __left_->get_demangled_name(buf); |
| 3480 | *buf++ = '.'; |
| 3481 | return __right_->get_demangled_name(buf); |
| 3482 | } |
| 3483 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 3484 | { |
| 3485 | return __left_->fix_forward_references(t_begin, t_end) && |
| 3486 | __right_->fix_forward_references(t_begin, t_end); |
| 3487 | } |
| 3488 | }; |
| 3489 | |
| 3490 | class __arrow_expr |
| 3491 | : public __node |
| 3492 | { |
| 3493 | public: |
| 3494 | |
| 3495 | __arrow_expr(__node* op1, __node* op2) |
| 3496 | { |
| 3497 | __left_ = op1; |
| 3498 | __right_ = op2; |
| 3499 | } |
| 3500 | virtual size_t first_size() const |
| 3501 | { |
| 3502 | if (__cached_size_ == -1) |
| 3503 | const_cast<long&>(__cached_size_) = static_cast<long>(__left_->size() + |
| 3504 | 2 + __right_->size()); |
| 3505 | return static_cast<size_t>(__cached_size_); |
| 3506 | } |
| 3507 | virtual char* first_demangled_name(char* buf) const |
| 3508 | { |
| 3509 | buf = __left_->get_demangled_name(buf); |
| 3510 | *buf++ = '-'; |
| 3511 | *buf++ = '>'; |
| 3512 | return __right_->get_demangled_name(buf); |
| 3513 | } |
| 3514 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 3515 | { |
| 3516 | return __left_->fix_forward_references(t_begin, t_end) && |
| 3517 | __right_->fix_forward_references(t_begin, t_end); |
| 3518 | } |
| 3519 | }; |
| 3520 | |
| 3521 | class __std_qualified_name |
| 3522 | : public __node |
| 3523 | { |
| 3524 | static const ptrdiff_t n = sizeof("std") - 1; |
| 3525 | public: |
| 3526 | |
| 3527 | __std_qualified_name() |
| 3528 | { |
| 3529 | } |
| 3530 | virtual size_t first_size() const |
| 3531 | { |
| 3532 | return n; |
| 3533 | } |
| 3534 | |
| 3535 | virtual char* first_demangled_name(char* buf) const |
| 3536 | { |
| 3537 | *buf++ = 's'; |
| 3538 | *buf++ = 't'; |
| 3539 | *buf++ = 'd'; |
| 3540 | return buf; |
| 3541 | } |
| 3542 | }; |
| 3543 | |
| 3544 | class __sub_allocator |
| 3545 | : public __node |
| 3546 | { |
| 3547 | static const ptrdiff_t n = sizeof("std::allocator") - 1; |
| 3548 | public: |
| 3549 | |
| 3550 | virtual size_t first_size() const |
| 3551 | { |
| 3552 | return n; |
| 3553 | } |
| 3554 | virtual char* first_demangled_name(char* buf) const |
| 3555 | { |
| 3556 | strncpy(buf, "std::allocator", n); |
| 3557 | return buf + n; |
| 3558 | } |
| 3559 | }; |
| 3560 | |
| 3561 | class __sub_basic_string |
| 3562 | : public __node |
| 3563 | { |
| 3564 | static const ptrdiff_t n = sizeof("std::basic_string") - 1; |
| 3565 | public: |
| 3566 | |
| 3567 | virtual size_t first_size() const |
| 3568 | { |
| 3569 | return n; |
| 3570 | } |
| 3571 | virtual char* first_demangled_name(char* buf) const |
| 3572 | { |
| 3573 | strncpy(buf, "std::basic_string", n); |
| 3574 | return buf + n; |
| 3575 | } |
| 3576 | }; |
| 3577 | |
| 3578 | class __sub_string |
| 3579 | : public __node |
| 3580 | { |
| 3581 | static const size_t n = sizeof("std::string") - 1; |
| 3582 | static const size_t ne = sizeof("std::basic_string<char, std::char_traits<char>, std::allocator<char> >") - 1; |
| 3583 | public: |
| 3584 | |
| 3585 | virtual size_t first_size() const |
| 3586 | { |
| 3587 | if (__size_) |
| 3588 | return ne; |
| 3589 | return n; |
| 3590 | } |
| 3591 | virtual char* first_demangled_name(char* buf) const |
| 3592 | { |
| 3593 | if (__size_) |
| 3594 | { |
| 3595 | strncpy(buf, "std::basic_string<char, std::char_traits<char>, std::allocator<char> >", ne); |
| 3596 | buf += ne; |
| 3597 | } |
| 3598 | else |
| 3599 | { |
| 3600 | strncpy(buf, "std::string", n); |
| 3601 | buf += n; |
| 3602 | } |
| 3603 | return buf; |
| 3604 | } |
| 3605 | |
| 3606 | virtual size_t base_size() const |
| 3607 | { |
| 3608 | return 12; |
| 3609 | } |
| 3610 | virtual char* get_base_name(char* buf) const |
| 3611 | { |
| 3612 | strncpy(buf, "basic_string", 12); |
| 3613 | return buf + 12; |
| 3614 | } |
| 3615 | |
| 3616 | virtual __node* base_name() const |
| 3617 | { |
| 3618 | const_cast<size_t&>(__size_) = true; |
| 3619 | return const_cast<__node*>(static_cast<const __node*>(this)); |
| 3620 | } |
| 3621 | }; |
| 3622 | |
| 3623 | class __sub_istream |
| 3624 | : public __node |
| 3625 | { |
| 3626 | static const ptrdiff_t n = sizeof("std::istream") - 1; |
| 3627 | public: |
| 3628 | |
| 3629 | virtual size_t first_size() const {return n;} |
| 3630 | virtual char* first_demangled_name(char* buf) const |
| 3631 | { |
| 3632 | strncpy(buf, "std::istream", n); |
| 3633 | return buf + n; |
| 3634 | } |
| 3635 | }; |
| 3636 | |
| 3637 | class __sub_ostream |
| 3638 | : public __node |
| 3639 | { |
| 3640 | static const ptrdiff_t n = sizeof("std::ostream") - 1; |
| 3641 | public: |
| 3642 | |
| 3643 | virtual size_t first_size() const {return n;} |
| 3644 | virtual char* first_demangled_name(char* buf) const |
| 3645 | { |
| 3646 | strncpy(buf, "std::ostream", n); |
| 3647 | return buf + n; |
| 3648 | } |
| 3649 | }; |
| 3650 | |
| 3651 | class __sub_iostream |
| 3652 | : public __node |
| 3653 | { |
| 3654 | static const ptrdiff_t n = sizeof("std::iostream") - 1; |
| 3655 | public: |
| 3656 | |
| 3657 | virtual size_t first_size() const {return n;} |
| 3658 | virtual char* first_demangled_name(char* buf) const |
| 3659 | { |
| 3660 | strncpy(buf, "std::iostream", n); |
| 3661 | return buf + n; |
| 3662 | } |
| 3663 | }; |
| 3664 | |
| 3665 | class __sub |
| 3666 | : public __node |
| 3667 | { |
| 3668 | public: |
| 3669 | |
| 3670 | explicit __sub(__node* arg) |
| 3671 | { |
| 3672 | __left_ = arg; |
| 3673 | } |
| 3674 | explicit __sub(size_t arg) |
| 3675 | { |
| 3676 | __size_ = arg; |
| 3677 | } |
| 3678 | virtual size_t first_size() const |
| 3679 | { |
| 3680 | return __left_->first_size(); |
| 3681 | } |
| 3682 | virtual char* first_demangled_name(char* buf) const |
| 3683 | { |
| 3684 | return __left_->first_demangled_name(buf); |
| 3685 | } |
| 3686 | virtual size_t second_size() const |
| 3687 | { |
| 3688 | return __left_->second_size(); |
| 3689 | } |
| 3690 | virtual char* second_demangled_name(char* buf) const |
| 3691 | { |
| 3692 | return __left_->second_demangled_name(buf); |
| 3693 | } |
| 3694 | virtual bool ends_with_template(bool parsing = false) const |
| 3695 | { |
| 3696 | return __left_->ends_with_template(parsing); |
| 3697 | } |
| 3698 | virtual __node* base_name() const |
| 3699 | { |
| 3700 | return __left_->base_name(); |
| 3701 | } |
| 3702 | virtual bool is_reference_or_pointer_to_function_or_array() const |
| 3703 | { |
| 3704 | return __left_->is_reference_or_pointer_to_function_or_array(); |
| 3705 | } |
| 3706 | virtual bool is_function() const |
| 3707 | { |
| 3708 | if (__left_ == 0) |
| 3709 | return false; |
| 3710 | return __left_->is_function(); |
| 3711 | } |
| 3712 | virtual bool is_cv_qualifer() const |
| 3713 | { |
| 3714 | return __left_->is_cv_qualifer(); |
| 3715 | } |
| 3716 | virtual bool is_ctor_dtor_conv() const |
| 3717 | { |
| 3718 | return __left_->is_ctor_dtor_conv(); |
| 3719 | } |
| 3720 | virtual bool is_array() const |
| 3721 | { |
| 3722 | return __left_->is_array(); |
| 3723 | } |
| 3724 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 3725 | { |
| 3726 | if (__left_ == 0) |
| 3727 | { |
| 3728 | if (__size_ < static_cast<size_t>(t_end - t_begin)) |
| 3729 | { |
| 3730 | __left_ = t_begin[__size_]; |
| 3731 | __size_ = 0; |
| 3732 | } |
| 3733 | else |
| 3734 | return false; |
| 3735 | } |
| 3736 | return true; |
| 3737 | } |
| 3738 | virtual size_t list_len() const |
| 3739 | { |
| 3740 | return __left_->list_len(); |
| 3741 | } |
| 3742 | virtual bool is_sub() const |
| 3743 | { |
| 3744 | return true; |
| 3745 | } |
| 3746 | }; |
| 3747 | |
| 3748 | class __unscoped_template_name |
| 3749 | : public __node |
| 3750 | { |
| 3751 | public: |
| 3752 | __unscoped_template_name(__node* name, __node* args) |
| 3753 | {__left_ = name; __right_ = args;} |
| 3754 | |
| 3755 | virtual size_t first_size() const |
| 3756 | { |
| 3757 | if (__cached_size_ == -1) |
| 3758 | const_cast<long&>(__cached_size_) = static_cast<long>(__left_->size() + |
| 3759 | __right_->size()); |
| 3760 | return static_cast<size_t>(__cached_size_); |
| 3761 | } |
| 3762 | virtual char* first_demangled_name(char* buf) const |
| 3763 | { |
| 3764 | buf = __left_->get_demangled_name(buf); |
| 3765 | return __right_->get_demangled_name(buf); |
| 3766 | } |
| 3767 | virtual bool ends_with_template(bool parsing = false) const |
| 3768 | { |
| 3769 | return __right_->ends_with_template(parsing); |
| 3770 | } |
| 3771 | virtual __node* base_name() const |
| 3772 | { |
| 3773 | return __left_->base_name(); |
| 3774 | } |
| 3775 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 3776 | { |
| 3777 | return __left_->fix_forward_references(t_begin, t_end) && |
| 3778 | __right_->fix_forward_references(t_begin, t_end); |
| 3779 | } |
| 3780 | }; |
| 3781 | |
| 3782 | // length == 0: __left_ == NULL |
| 3783 | // length == 1: __left_ != NULL, __right_ == NULL |
| 3784 | // length > 1: __left_ != NULL, __right_ != NULL |
| 3785 | class __list |
| 3786 | : public __node |
| 3787 | { |
| 3788 | public: |
| 3789 | explicit __list(__node* type) |
| 3790 | {__left_ = type;} |
| 3791 | |
| 3792 | virtual size_t first_size() const |
| 3793 | { |
| 3794 | if (__cached_size_ == -1) |
| 3795 | { |
| 3796 | if (__left_ == NULL) |
| 3797 | const_cast<long&>(__cached_size_) = 0; |
| 3798 | else if (__right_ == NULL) |
| 3799 | const_cast<long&>(__cached_size_) = static_cast<long>(__left_->size()); |
| 3800 | else |
| 3801 | { |
| 3802 | size_t off = __right_->size(); |
| 3803 | if (off > 0) |
| 3804 | off += 2; |
| 3805 | const_cast<long&>(__cached_size_) = static_cast<long>(__left_->size() + off); |
| 3806 | } |
| 3807 | } |
| 3808 | return static_cast<size_t>(__cached_size_); |
| 3809 | } |
| 3810 | virtual char* first_demangled_name(char* buf) const |
| 3811 | { |
| 3812 | if (__left_ != NULL) |
| 3813 | { |
| 3814 | char* t = __left_->get_demangled_name(buf + (__size_ ? 2 : 0)); |
| 3815 | if (__size_ == 0) |
| 3816 | buf = t; |
| 3817 | else if (t != buf+2) |
| 3818 | { |
| 3819 | *buf++ = ','; |
| 3820 | *buf++ = ' '; |
| 3821 | buf = t; |
| 3822 | } |
| 3823 | if (__right_) |
| 3824 | buf = __right_->get_demangled_name(buf); |
| 3825 | } |
| 3826 | return buf; |
| 3827 | } |
| 3828 | virtual bool ends_with_template(bool parsing = false) const |
| 3829 | { |
Greg Clayton | 5292b44 | 2012-12-03 17:50:07 +0000 | [diff] [blame] | 3830 | if (__right_ && __right_->size() > 0) |
| 3831 | { |
Johnny Chen | 5016669 | 2012-08-04 01:36:57 +0000 | [diff] [blame] | 3832 | return __right_->ends_with_template(parsing); |
Greg Clayton | 5292b44 | 2012-12-03 17:50:07 +0000 | [diff] [blame] | 3833 | } |
| 3834 | else if (__left_ && __left_->size() > 0) |
| 3835 | { |
Johnny Chen | 5016669 | 2012-08-04 01:36:57 +0000 | [diff] [blame] | 3836 | return __left_->ends_with_template(parsing); |
Greg Clayton | 5292b44 | 2012-12-03 17:50:07 +0000 | [diff] [blame] | 3837 | } |
Johnny Chen | 5016669 | 2012-08-04 01:36:57 +0000 | [diff] [blame] | 3838 | return false; |
| 3839 | } |
| 3840 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 3841 | { |
| 3842 | bool r = true; |
| 3843 | if (__left_) |
| 3844 | r = r && __left_->fix_forward_references(t_begin, t_end); |
| 3845 | if (__right_) |
| 3846 | r = r && __right_->fix_forward_references(t_begin, t_end); |
| 3847 | return r; |
| 3848 | } |
| 3849 | virtual size_t list_len() const |
| 3850 | { |
| 3851 | if (!__left_) |
| 3852 | return 0; |
| 3853 | if (!__right_) |
| 3854 | return 1; |
| 3855 | return 1 + __right_->list_len(); |
| 3856 | } |
| 3857 | }; |
| 3858 | |
| 3859 | class __template_args |
| 3860 | : public __node |
| 3861 | { |
| 3862 | public: |
| 3863 | __template_args(__node* name, __node* list) |
| 3864 | { |
| 3865 | __left_ = name; |
| 3866 | __right_ = list; |
| 3867 | } |
| 3868 | |
| 3869 | virtual size_t first_size() const |
| 3870 | { |
| 3871 | if (__cached_size_ == -1) |
| 3872 | { |
| 3873 | size_t off = 2; |
| 3874 | if (__right_) |
| 3875 | { |
| 3876 | if (__right_->ends_with_template()) |
| 3877 | ++off; |
| 3878 | off += __right_->size(); |
| 3879 | } |
| 3880 | const_cast<long&>(__cached_size_) = static_cast<long>(__left_->size() + off); |
| 3881 | } |
| 3882 | return static_cast<size_t>(__cached_size_); |
| 3883 | } |
| 3884 | virtual char* first_demangled_name(char* buf) const |
| 3885 | { |
| 3886 | buf = __left_->get_demangled_name(buf); |
| 3887 | *buf++ = '<'; |
| 3888 | if (__right_) |
| 3889 | { |
| 3890 | buf = __right_->get_demangled_name(buf); |
| 3891 | if (buf[-1] == '>') |
| 3892 | *buf++ = ' '; |
| 3893 | } |
| 3894 | *buf++ = '>'; |
| 3895 | return buf; |
| 3896 | } |
| 3897 | virtual bool ends_with_template(bool /*parsing*/ = false) const |
| 3898 | { |
| 3899 | return true; |
| 3900 | } |
| 3901 | virtual __node* base_name() const |
| 3902 | { |
| 3903 | return __left_->base_name(); |
| 3904 | } |
| 3905 | virtual bool is_ctor_dtor_conv() const |
| 3906 | { |
| 3907 | return __left_->is_ctor_dtor_conv(); |
| 3908 | } |
| 3909 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 3910 | { |
| 3911 | bool r = __left_->fix_forward_references(t_begin, t_end); |
| 3912 | if (__right_) |
| 3913 | r = r && __right_->fix_forward_references(t_begin, t_end); |
| 3914 | return r; |
| 3915 | } |
| 3916 | }; |
| 3917 | |
| 3918 | class __function_args |
| 3919 | : public __node |
| 3920 | { |
| 3921 | public: |
| 3922 | __function_args(__node* list) |
| 3923 | {__right_ = list;} |
| 3924 | |
| 3925 | virtual size_t first_size() const |
| 3926 | { |
| 3927 | if (__cached_size_ == -1) |
| 3928 | const_cast<long&>(__cached_size_) = static_cast<long>(2 + __right_->size()); |
| 3929 | return static_cast<size_t>(__cached_size_); |
| 3930 | } |
| 3931 | virtual char* first_demangled_name(char* buf) const |
| 3932 | { |
| 3933 | *buf++ = '('; |
| 3934 | buf = __right_->get_demangled_name(buf); |
| 3935 | *buf++ = ')'; |
| 3936 | return buf; |
| 3937 | } |
| 3938 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 3939 | { |
| 3940 | return __right_->fix_forward_references(t_begin, t_end); |
| 3941 | } |
| 3942 | }; |
| 3943 | |
Daniel Malea | 81b78ca | 2012-12-06 16:52:09 +0000 | [diff] [blame] | 3944 | class ___lambda_node |
Johnny Chen | 5016669 | 2012-08-04 01:36:57 +0000 | [diff] [blame] | 3945 | : public __node |
| 3946 | { |
| 3947 | public: |
Daniel Malea | 81b78ca | 2012-12-06 16:52:09 +0000 | [diff] [blame] | 3948 | ___lambda_node(__node* params, const char *number, size_t number_size) |
Johnny Chen | 5016669 | 2012-08-04 01:36:57 +0000 | [diff] [blame] | 3949 | { |
| 3950 | __right_ = params; |
| 3951 | __name_ = number; |
| 3952 | __size_ = number_size; |
| 3953 | } |
| 3954 | |
| 3955 | virtual size_t first_size() const |
| 3956 | { |
| 3957 | if (__cached_size_ == -1) |
| 3958 | { |
| 3959 | size_t r = 2; |
| 3960 | r += sizeof("'lambda'")-1; |
| 3961 | if (__right_) |
| 3962 | r += __right_->size(); |
| 3963 | r += __size_; |
| 3964 | const_cast<long&>(__cached_size_) = static_cast<long>(r); |
| 3965 | } |
| 3966 | return static_cast<size_t>(__cached_size_); |
| 3967 | } |
| 3968 | virtual char* first_demangled_name(char* buf) const |
| 3969 | { |
| 3970 | size_t n = sizeof("'lambda") - 1; |
| 3971 | strncpy(buf, "'lambda", n); |
| 3972 | buf += n; |
| 3973 | if (__size_) |
| 3974 | { |
| 3975 | strncpy(buf, __name_, __size_); |
| 3976 | buf += __size_; |
| 3977 | } |
| 3978 | *buf++ = '\''; |
| 3979 | *buf++ = '('; |
| 3980 | if (__right_) |
| 3981 | buf = __right_->get_demangled_name(buf); |
| 3982 | *buf++ = ')'; |
| 3983 | return buf; |
| 3984 | } |
| 3985 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 3986 | { |
| 3987 | if (__right_) |
| 3988 | return __right_->fix_forward_references(t_begin, t_end); |
| 3989 | return true; |
| 3990 | } |
| 3991 | }; |
| 3992 | |
| 3993 | class __unnamed |
| 3994 | : public __node |
| 3995 | { |
| 3996 | public: |
| 3997 | __unnamed(const char *number, size_t number_size) |
| 3998 | { |
| 3999 | __name_ = number; |
| 4000 | __size_ = number_size; |
| 4001 | } |
| 4002 | |
| 4003 | virtual size_t first_size() const |
| 4004 | { |
| 4005 | if (__cached_size_ == -1) |
| 4006 | { |
| 4007 | size_t r = 0; |
| 4008 | r += sizeof("'unnamed'")-1; |
| 4009 | r += __size_; |
| 4010 | const_cast<long&>(__cached_size_) = static_cast<long>(r); |
| 4011 | } |
| 4012 | return static_cast<size_t>(__cached_size_); |
| 4013 | } |
| 4014 | virtual char* first_demangled_name(char* buf) const |
| 4015 | { |
| 4016 | size_t n = sizeof("'unnamed") - 1; |
| 4017 | strncpy(buf, "'unnamed", n); |
| 4018 | buf += n; |
| 4019 | if (__size_) |
| 4020 | { |
| 4021 | strncpy(buf, __name_, __size_); |
| 4022 | buf += __size_; |
| 4023 | } |
| 4024 | *buf++ = '\''; |
| 4025 | return buf; |
| 4026 | } |
| 4027 | }; |
| 4028 | |
| 4029 | class __cv_qualifiers |
| 4030 | : public __node |
| 4031 | { |
| 4032 | public: |
| 4033 | __cv_qualifiers(size_t cv, __node* type) |
| 4034 | { |
| 4035 | __left_ = type; |
| 4036 | __size_ = __left_->is_function() ? cv << 5 : cv; |
| 4037 | } |
| 4038 | |
| 4039 | virtual size_t first_size() const |
| 4040 | { |
| 4041 | size_t s = __left_->first_size(); |
| 4042 | if (__size_ & 4) |
| 4043 | s += sizeof(" restrict")-1; |
| 4044 | if (__size_ & 2) |
| 4045 | s += sizeof(" volatile")-1; |
| 4046 | if (__size_ & 1) |
| 4047 | s += sizeof(" const")-1; |
| 4048 | if (__size_ & 8) |
| 4049 | s += sizeof(" &")-1; |
| 4050 | if (__size_ & 16) |
| 4051 | s += sizeof(" &&")-1; |
| 4052 | return s; |
| 4053 | } |
| 4054 | virtual char* first_demangled_name(char* buf) const |
| 4055 | { |
| 4056 | buf = __left_->first_demangled_name(buf); |
| 4057 | if (__size_ & 1) |
| 4058 | { |
| 4059 | const size_t n = sizeof(" const")-1; |
| 4060 | strncpy(buf, " const", n); |
| 4061 | buf += n; |
| 4062 | } |
| 4063 | if (__size_ & 2) |
| 4064 | { |
| 4065 | const size_t n = sizeof(" volatile")-1; |
| 4066 | strncpy(buf, " volatile", n); |
| 4067 | buf += n; |
| 4068 | } |
| 4069 | if (__size_ & 4) |
| 4070 | { |
| 4071 | const size_t n = sizeof(" restrict")-1; |
| 4072 | strncpy(buf, " restrict", n); |
| 4073 | buf += n; |
| 4074 | } |
| 4075 | if (__size_ & 8) |
| 4076 | { |
| 4077 | *buf++ = ' '; |
| 4078 | *buf++ = '&'; |
| 4079 | } |
| 4080 | if (__size_ & 16) |
| 4081 | { |
| 4082 | *buf++ = ' '; |
| 4083 | *buf++ = '&'; |
| 4084 | *buf++ = '&'; |
| 4085 | } |
| 4086 | return buf; |
| 4087 | } |
| 4088 | virtual size_t second_size() const |
| 4089 | { |
| 4090 | size_t s = __left_->second_size(); |
| 4091 | if (__size_ & 128) |
| 4092 | s += sizeof(" restrict")-1; |
| 4093 | if (__size_ & 64) |
| 4094 | s += sizeof(" volatile")-1; |
| 4095 | if (__size_ & 32) |
| 4096 | s += sizeof(" const")-1; |
| 4097 | if (__size_ & 256) |
| 4098 | s += sizeof(" &")-1; |
| 4099 | if (__size_ & 512) |
| 4100 | s += sizeof(" &&")-1; |
| 4101 | return s; |
| 4102 | } |
| 4103 | virtual char* second_demangled_name(char* buf) const |
| 4104 | { |
| 4105 | buf = __left_->second_demangled_name(buf); |
| 4106 | if (__size_ & 32) |
| 4107 | { |
| 4108 | const size_t n = sizeof(" const")-1; |
| 4109 | strncpy(buf, " const", n); |
| 4110 | buf += n; |
| 4111 | } |
| 4112 | if (__size_ & 64) |
| 4113 | { |
| 4114 | const size_t n = sizeof(" volatile")-1; |
| 4115 | strncpy(buf, " volatile", n); |
| 4116 | buf += n; |
| 4117 | } |
| 4118 | if (__size_ & 128) |
| 4119 | { |
| 4120 | const size_t n = sizeof(" restrict")-1; |
| 4121 | strncpy(buf, " restrict", n); |
| 4122 | buf += n; |
| 4123 | } |
| 4124 | if (__size_ & 256) |
| 4125 | { |
| 4126 | *buf++ = ' '; |
| 4127 | *buf++ = '&'; |
| 4128 | } |
| 4129 | if (__size_ & 512) |
| 4130 | { |
| 4131 | *buf++ = ' '; |
| 4132 | *buf++ = '&'; |
| 4133 | *buf++ = '&'; |
| 4134 | } |
| 4135 | return buf; |
| 4136 | } |
| 4137 | virtual __node* base_name() const |
| 4138 | { |
| 4139 | return __left_->base_name(); |
| 4140 | } |
| 4141 | virtual bool is_reference_or_pointer_to_function_or_array() const |
| 4142 | { |
| 4143 | return __left_->is_reference_or_pointer_to_function_or_array(); |
| 4144 | } |
| 4145 | virtual bool is_function() const |
| 4146 | { |
| 4147 | return __left_->is_function(); |
| 4148 | } |
| 4149 | virtual bool is_cv_qualifer() const |
| 4150 | { |
| 4151 | return true; |
| 4152 | } |
| 4153 | virtual __node* extract_cv(__node*& rt) const |
| 4154 | { |
| 4155 | if (rt == this) |
| 4156 | { |
| 4157 | rt = __left_; |
| 4158 | return const_cast<__node*>(static_cast<const __node*>(this)); |
| 4159 | } |
| 4160 | return 0; |
| 4161 | } |
| 4162 | virtual bool ends_with_template(bool parsing = false) const |
| 4163 | { |
| 4164 | if (parsing) |
| 4165 | return __left_->ends_with_template(parsing); |
| 4166 | return false; |
| 4167 | } |
| 4168 | virtual bool is_ctor_dtor_conv() const |
| 4169 | { |
| 4170 | return __left_->is_ctor_dtor_conv(); |
| 4171 | } |
| 4172 | virtual bool is_array() const |
| 4173 | { |
| 4174 | return __left_->is_array(); |
| 4175 | } |
| 4176 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 4177 | { |
| 4178 | return __left_->fix_forward_references(t_begin, t_end); |
| 4179 | } |
| 4180 | virtual size_t list_len() const |
| 4181 | { |
| 4182 | return __left_->list_len(); |
| 4183 | } |
| 4184 | }; |
| 4185 | |
| 4186 | class __extended_qualifier |
| 4187 | : public __node |
| 4188 | { |
| 4189 | public: |
| 4190 | __extended_qualifier(__node* name, __node* type) |
| 4191 | { |
| 4192 | __left_ = type; |
| 4193 | __right_ = name; |
| 4194 | __size_ = __left_->is_function() ? 1 : 0; |
| 4195 | } |
| 4196 | |
| 4197 | virtual size_t first_size() const |
| 4198 | { |
| 4199 | size_t s = __left_->first_size(); |
| 4200 | if (__size_ == 0) |
| 4201 | s += __right_->size() + 1; |
| 4202 | return s; |
| 4203 | } |
| 4204 | virtual char* first_demangled_name(char* buf) const |
| 4205 | { |
| 4206 | buf = __left_->first_demangled_name(buf); |
| 4207 | if (__size_ == 0) |
| 4208 | { |
| 4209 | *buf++ = ' '; |
| 4210 | buf = __right_->get_demangled_name(buf); |
| 4211 | } |
| 4212 | return buf; |
| 4213 | } |
| 4214 | virtual size_t second_size() const |
| 4215 | { |
| 4216 | size_t s = __left_->second_size(); |
| 4217 | if (__size_ == 1) |
| 4218 | s += __right_->size() + 1; |
| 4219 | return s; |
| 4220 | } |
| 4221 | virtual char* second_demangled_name(char* buf) const |
| 4222 | { |
| 4223 | buf = __left_->second_demangled_name(buf); |
| 4224 | if (__size_ == 1) |
| 4225 | { |
| 4226 | *buf++ = ' '; |
| 4227 | buf = __right_->get_demangled_name(buf); |
| 4228 | } |
| 4229 | return buf; |
| 4230 | } |
| 4231 | virtual __node* base_name() const |
| 4232 | { |
| 4233 | return __left_->base_name(); |
| 4234 | } |
| 4235 | virtual bool is_reference_or_pointer_to_function_or_array() const |
| 4236 | { |
| 4237 | return __left_->is_reference_or_pointer_to_function_or_array(); |
| 4238 | } |
| 4239 | virtual bool is_function() const |
| 4240 | { |
| 4241 | return __left_->is_function(); |
| 4242 | } |
| 4243 | virtual bool is_cv_qualifer() const |
| 4244 | { |
| 4245 | return true; |
| 4246 | } |
| 4247 | virtual __node* extract_cv(__node*& rt) const |
| 4248 | { |
| 4249 | if (rt == this) |
| 4250 | { |
| 4251 | rt = __left_; |
| 4252 | return const_cast<__node*>(static_cast<const __node*>(this)); |
| 4253 | } |
| 4254 | return 0; |
| 4255 | } |
| 4256 | virtual bool ends_with_template(bool parsing = false) const |
| 4257 | { |
| 4258 | return __left_->ends_with_template(parsing); |
| 4259 | } |
| 4260 | virtual bool is_ctor_dtor_conv() const |
| 4261 | { |
| 4262 | return __left_->is_ctor_dtor_conv(); |
| 4263 | } |
| 4264 | virtual bool is_array() const |
| 4265 | { |
| 4266 | return __left_->is_array(); |
| 4267 | } |
| 4268 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 4269 | { |
| 4270 | return __left_->fix_forward_references(t_begin, t_end); |
| 4271 | } |
| 4272 | virtual size_t list_len() const |
| 4273 | { |
| 4274 | return __left_->list_len(); |
| 4275 | } |
| 4276 | }; |
| 4277 | |
| 4278 | class __function |
| 4279 | : public __node |
| 4280 | { |
| 4281 | public: |
| 4282 | |
| 4283 | __function(__node* name, __node* signature, size_t ret_goes_first = true) |
| 4284 | { |
| 4285 | __size_ = ret_goes_first; |
| 4286 | __left_ = name; |
| 4287 | __right_ = signature; |
| 4288 | } |
| 4289 | |
| 4290 | virtual size_t first_size() const |
| 4291 | { |
| 4292 | size_t off = 0; |
| 4293 | if (__size_) |
| 4294 | { |
| 4295 | off = __right_->first_size(); |
| 4296 | if (off > 0 && (__left_ == NULL || |
| 4297 | !__right_->__left_->is_reference_or_pointer_to_function_or_array())) |
| 4298 | ++off; |
| 4299 | } |
| 4300 | else |
| 4301 | off = 5; |
| 4302 | if (__left_) |
| 4303 | off += __left_->first_size(); |
| 4304 | else |
| 4305 | ++off; |
| 4306 | return off; |
| 4307 | } |
| 4308 | |
| 4309 | virtual size_t second_size() const |
| 4310 | { |
| 4311 | size_t off = 0; |
| 4312 | if (__left_ == NULL) |
| 4313 | off = 1; |
| 4314 | off += __right_->second_size(); |
| 4315 | if (!__size_) |
| 4316 | { |
| 4317 | off += 2; |
| 4318 | off += __right_->first_size(); |
| 4319 | } |
| 4320 | return off; |
| 4321 | } |
| 4322 | |
| 4323 | virtual char* first_demangled_name(char* buf) const |
| 4324 | { |
| 4325 | if (__size_) |
| 4326 | { |
| 4327 | const char* t = buf; |
| 4328 | buf = __right_->first_demangled_name(buf); |
| 4329 | if (buf != t && (__left_ == NULL || |
| 4330 | !__right_->__left_->is_reference_or_pointer_to_function_or_array())) |
| 4331 | *buf++ = ' '; |
| 4332 | } |
| 4333 | else |
| 4334 | { |
| 4335 | strncpy(buf, "auto ", 5); |
| 4336 | buf += 5; |
| 4337 | } |
| 4338 | if (__left_) |
| 4339 | buf = __left_->first_demangled_name(buf); |
| 4340 | else |
| 4341 | *buf++ = '('; |
| 4342 | return buf; |
| 4343 | } |
| 4344 | virtual char* second_demangled_name(char* buf) const |
| 4345 | { |
| 4346 | if (__left_ == NULL) |
| 4347 | *buf++ = ')'; |
| 4348 | buf = __right_->second_demangled_name(buf); |
| 4349 | if (!__size_) |
| 4350 | { |
| 4351 | *buf++ = '-'; |
| 4352 | *buf++ = '>'; |
| 4353 | buf = __right_->first_demangled_name(buf); |
| 4354 | } |
| 4355 | return buf; |
| 4356 | } |
| 4357 | virtual char* get_demangled_name(char* buf) const |
| 4358 | { |
| 4359 | if (__size_) |
| 4360 | { |
| 4361 | const char* t = buf; |
| 4362 | buf = __right_->first_demangled_name(buf); |
| 4363 | if (buf != t && (__left_ == NULL || |
| 4364 | !__right_->__left_->is_reference_or_pointer_to_function_or_array())) |
| 4365 | *buf++ = ' '; |
| 4366 | } |
| 4367 | else |
| 4368 | { |
| 4369 | strncpy(buf, "auto ", 5); |
| 4370 | buf += 5; |
| 4371 | } |
| 4372 | if (__left_) |
| 4373 | buf = __left_->first_demangled_name(buf); |
| 4374 | buf = __right_->second_demangled_name(buf); |
| 4375 | if (!__size_) |
| 4376 | { |
| 4377 | *buf++ = '-'; |
| 4378 | *buf++ = '>'; |
| 4379 | buf = __right_->first_demangled_name(buf); |
| 4380 | } |
| 4381 | return buf; |
| 4382 | } |
| 4383 | |
| 4384 | virtual size_t size() const |
| 4385 | { |
| 4386 | if (__cached_size_ == -1) |
| 4387 | { |
| 4388 | size_t off = 0; |
| 4389 | if (__size_) |
| 4390 | { |
| 4391 | off = __right_->first_size(); |
| 4392 | if (off > 0 && (__left_ == NULL || |
| 4393 | !__right_->__left_->is_reference_or_pointer_to_function_or_array())) |
| 4394 | ++off; |
| 4395 | } |
| 4396 | else |
| 4397 | off = 5; |
| 4398 | if (__left_) |
| 4399 | off += __left_->first_size(); |
| 4400 | off += __right_->second_size(); |
| 4401 | if (!__size_) |
| 4402 | { |
| 4403 | off += 2; |
| 4404 | off += __right_->first_size(); |
| 4405 | } |
| 4406 | const_cast<long&>(__cached_size_) = static_cast<long>(off); |
| 4407 | } |
| 4408 | return static_cast<size_t>(__cached_size_); |
| 4409 | } |
| 4410 | |
| 4411 | virtual bool is_function() const |
| 4412 | { |
| 4413 | return true; |
| 4414 | } |
| 4415 | virtual bool is_ctor_dtor_conv() const |
| 4416 | { |
| 4417 | return __left_->is_ctor_dtor_conv(); |
| 4418 | } |
| 4419 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 4420 | { |
| 4421 | bool r = true; |
| 4422 | if (__left_) |
| 4423 | r = r && __left_->fix_forward_references(t_begin, t_end); |
| 4424 | r = r && __right_->fix_forward_references(t_begin, t_end); |
| 4425 | return r; |
| 4426 | } |
| 4427 | }; |
| 4428 | |
| 4429 | class __function_signature |
| 4430 | : public __node |
| 4431 | { |
| 4432 | public: |
| 4433 | __function_signature(__node* ret, __node* args) |
| 4434 | { |
| 4435 | __left_ = ret; |
| 4436 | __right_ = args; |
| 4437 | } |
| 4438 | virtual size_t first_size() const |
| 4439 | { |
| 4440 | return __left_ ? __left_->first_size() : 0; |
| 4441 | } |
| 4442 | |
| 4443 | virtual size_t second_size() const |
| 4444 | { |
| 4445 | return 2 + (__right_ ? __right_->size() : 0) |
| 4446 | + (__left_ ? __left_->second_size() : 0); |
| 4447 | } |
| 4448 | |
| 4449 | virtual char* first_demangled_name(char* buf) const |
| 4450 | { |
| 4451 | if (__left_) |
| 4452 | buf = __left_->first_demangled_name(buf); |
| 4453 | return buf; |
| 4454 | } |
| 4455 | |
| 4456 | virtual char* second_demangled_name(char* buf) const |
| 4457 | { |
| 4458 | *buf++ = '('; |
| 4459 | if (__right_) |
| 4460 | buf = __right_->get_demangled_name(buf); |
| 4461 | *buf++ = ')'; |
| 4462 | if (__left_) |
| 4463 | buf = __left_->second_demangled_name(buf); |
| 4464 | return buf; |
| 4465 | } |
| 4466 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 4467 | { |
| 4468 | bool r = true; |
| 4469 | if (__left_) |
| 4470 | r = r && __left_->fix_forward_references(t_begin, t_end); |
| 4471 | if (__right_) |
| 4472 | r = r && __right_->fix_forward_references(t_begin, t_end); |
| 4473 | return r; |
| 4474 | } |
| 4475 | }; |
| 4476 | |
| 4477 | class __pointer_to |
| 4478 | : public __node |
| 4479 | { |
| 4480 | public: |
| 4481 | |
| 4482 | explicit __pointer_to(__node* type) |
| 4483 | { |
| 4484 | __left_ = type; |
| 4485 | } |
| 4486 | virtual size_t first_size() const |
| 4487 | { |
| 4488 | return __left_->first_size() + (__left_->is_array() ? 3 : 1); |
| 4489 | } |
| 4490 | virtual size_t second_size() const |
| 4491 | { |
| 4492 | return __left_->second_size() + (__left_->is_array() ? 1 : 0); |
| 4493 | } |
| 4494 | virtual char* first_demangled_name(char* buf) const |
| 4495 | { |
| 4496 | buf = __left_->first_demangled_name(buf); |
| 4497 | if (__left_->is_array()) |
| 4498 | { |
| 4499 | *buf++ = ' '; |
| 4500 | *buf++ = '('; |
| 4501 | *buf++ = '*'; |
| 4502 | } |
| 4503 | else |
| 4504 | *buf++ = '*'; |
| 4505 | return buf; |
| 4506 | } |
| 4507 | virtual char* second_demangled_name(char* buf) const |
| 4508 | { |
| 4509 | if (__left_->is_array()) |
| 4510 | *buf++ = ')'; |
| 4511 | return __left_->second_demangled_name(buf); |
| 4512 | } |
| 4513 | virtual __node* base_name() const |
| 4514 | { |
| 4515 | return __left_->base_name(); |
| 4516 | } |
| 4517 | virtual bool is_reference_or_pointer_to_function_or_array() const |
| 4518 | { |
| 4519 | return __left_->is_function() || |
| 4520 | __left_->is_reference_or_pointer_to_function_or_array(); |
| 4521 | } |
| 4522 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 4523 | { |
| 4524 | return __left_->fix_forward_references(t_begin, t_end); |
| 4525 | } |
| 4526 | virtual size_t list_len() const |
| 4527 | { |
| 4528 | return __left_->list_len(); |
| 4529 | } |
| 4530 | }; |
| 4531 | |
| 4532 | class __lvalue_reference_to |
| 4533 | : public __node |
| 4534 | { |
| 4535 | public: |
| 4536 | |
| 4537 | explicit __lvalue_reference_to(__node* type) |
| 4538 | { |
| 4539 | __left_ = type; |
| 4540 | } |
| 4541 | virtual size_t first_size() const |
| 4542 | { |
| 4543 | return __left_->first_size() + (__left_->is_array() ? 3 : 1); |
| 4544 | } |
| 4545 | virtual size_t second_size() const |
| 4546 | { |
| 4547 | return __left_->second_size() + (__left_->is_array() ? 1 : 0); |
| 4548 | } |
| 4549 | virtual char* first_demangled_name(char* buf) const |
| 4550 | { |
| 4551 | buf = __left_->first_demangled_name(buf); |
| 4552 | if (__left_->is_array()) |
| 4553 | { |
| 4554 | *buf++ = ' '; |
| 4555 | *buf++ = '('; |
| 4556 | *buf++ = '&'; |
| 4557 | } |
| 4558 | else |
| 4559 | *buf++ = '&'; |
| 4560 | return buf; |
| 4561 | } |
| 4562 | virtual char* second_demangled_name(char* buf) const |
| 4563 | { |
| 4564 | if (__left_->is_array()) |
| 4565 | *buf++ = ')'; |
| 4566 | return __left_->second_demangled_name(buf); |
| 4567 | } |
| 4568 | virtual __node* base_name() const |
| 4569 | { |
| 4570 | return __left_->base_name(); |
| 4571 | } |
| 4572 | virtual bool is_reference_or_pointer_to_function_or_array() const |
| 4573 | { |
| 4574 | return __left_->is_function(); |
| 4575 | } |
| 4576 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 4577 | { |
| 4578 | return __left_->fix_forward_references(t_begin, t_end); |
| 4579 | } |
| 4580 | virtual size_t list_len() const |
| 4581 | { |
| 4582 | return __left_->list_len(); |
| 4583 | } |
| 4584 | }; |
| 4585 | |
| 4586 | class __rvalue_reference_to |
| 4587 | : public __node |
| 4588 | { |
| 4589 | public: |
| 4590 | |
| 4591 | explicit __rvalue_reference_to(__node* type) |
| 4592 | { |
| 4593 | __left_ = type; |
| 4594 | } |
| 4595 | virtual size_t first_size() const |
| 4596 | { |
| 4597 | return __left_->first_size() + (__left_->is_array() ? 4 : 2); |
| 4598 | } |
| 4599 | virtual size_t second_size() const |
| 4600 | { |
| 4601 | return __left_->second_size() + (__left_->is_array() ? 1 : 0); |
| 4602 | } |
| 4603 | virtual char* first_demangled_name(char* buf) const |
| 4604 | { |
| 4605 | buf = __left_->first_demangled_name(buf); |
| 4606 | if (__left_->is_array()) |
| 4607 | { |
| 4608 | strncpy(buf, " (&&", 4); |
| 4609 | buf += 4; |
| 4610 | } |
| 4611 | else |
| 4612 | { |
| 4613 | *buf++ = '&'; |
| 4614 | *buf++ = '&'; |
| 4615 | } |
| 4616 | return buf; |
| 4617 | } |
| 4618 | virtual char* second_demangled_name(char* buf) const |
| 4619 | { |
| 4620 | if (__left_->is_array()) |
| 4621 | *buf++ = ')'; |
| 4622 | return __left_->second_demangled_name(buf); |
| 4623 | } |
| 4624 | virtual __node* base_name() const |
| 4625 | { |
| 4626 | return __left_->base_name(); |
| 4627 | } |
| 4628 | virtual bool is_reference_or_pointer_to_function_or_array() const |
| 4629 | { |
| 4630 | return __left_->is_function(); |
| 4631 | } |
| 4632 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 4633 | { |
| 4634 | return __left_->fix_forward_references(t_begin, t_end); |
| 4635 | } |
| 4636 | virtual size_t list_len() const |
| 4637 | { |
| 4638 | return __left_->list_len(); |
| 4639 | } |
| 4640 | }; |
| 4641 | |
| 4642 | class __d_complex |
| 4643 | : public __node |
| 4644 | { |
| 4645 | static const size_t n = sizeof(" complex") - 1; |
| 4646 | public: |
| 4647 | |
| 4648 | explicit __d_complex(__node* type) |
| 4649 | { |
| 4650 | __left_ = type; |
| 4651 | } |
| 4652 | virtual size_t first_size() const |
| 4653 | { |
| 4654 | if (__cached_size_ == -1) |
| 4655 | const_cast<long&>(__cached_size_) = static_cast<long>(n + __left_->size()); |
| 4656 | return static_cast<size_t>(__cached_size_); |
| 4657 | } |
| 4658 | virtual char* first_demangled_name(char* buf) const |
| 4659 | { |
| 4660 | buf = __left_->get_demangled_name(buf); |
| 4661 | strncpy(buf, " complex", n); |
| 4662 | return buf + n; |
| 4663 | } |
| 4664 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 4665 | { |
| 4666 | return __left_->fix_forward_references(t_begin, t_end); |
| 4667 | } |
| 4668 | }; |
| 4669 | |
| 4670 | class __imaginary |
| 4671 | : public __node |
| 4672 | { |
| 4673 | static const size_t n = sizeof(" imaginary") - 1; |
| 4674 | public: |
| 4675 | |
| 4676 | explicit __imaginary(__node* type) |
| 4677 | { |
| 4678 | __left_ = type; |
| 4679 | } |
| 4680 | virtual size_t first_size() const |
| 4681 | { |
| 4682 | if (__cached_size_ == -1) |
| 4683 | const_cast<long&>(__cached_size_) = static_cast<long>(n + __left_->size()); |
| 4684 | return static_cast<size_t>(__cached_size_); |
| 4685 | } |
| 4686 | virtual char* first_demangled_name(char* buf) const |
| 4687 | { |
| 4688 | buf = __left_->get_demangled_name(buf); |
| 4689 | strncpy(buf, " imaginary", n); |
| 4690 | return buf + n; |
| 4691 | } |
| 4692 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 4693 | { |
| 4694 | return __left_->fix_forward_references(t_begin, t_end); |
| 4695 | } |
| 4696 | }; |
| 4697 | |
| 4698 | class __pack_expansion |
| 4699 | : public __node |
| 4700 | { |
| 4701 | public: |
| 4702 | |
| 4703 | explicit __pack_expansion(__node* type) |
| 4704 | { |
| 4705 | __left_ = type; |
| 4706 | } |
| 4707 | virtual size_t first_size() const |
| 4708 | { |
| 4709 | if (__cached_size_ == -1) |
| 4710 | { |
| 4711 | size_t len = __left_->list_len(); |
| 4712 | size_t off = 0; |
| 4713 | if (len != 0) |
| 4714 | { |
| 4715 | if (__left_->is_sub() || len == 1) |
| 4716 | off = __left_->size(); |
| 4717 | else |
| 4718 | { |
| 4719 | __node* top = __left_; |
| 4720 | __node* bottom = top; |
| 4721 | while (!bottom->__left_->is_sub()) |
| 4722 | bottom = bottom->__left_; |
| 4723 | __node* sub = bottom->__left_; |
| 4724 | __node* i = sub->__left_; |
| 4725 | bool first = true; |
| 4726 | top->reset_cached_size(); |
| 4727 | while (i) |
| 4728 | { |
| 4729 | if (!first) |
| 4730 | off += 2; |
| 4731 | bottom->__left_ = i->__left_; |
| 4732 | off += top->size(); |
| 4733 | top->reset_cached_size(); |
| 4734 | i = i->__right_; |
| 4735 | first = false; |
| 4736 | } |
| 4737 | bottom->__left_ = sub; |
| 4738 | } |
| 4739 | } |
| 4740 | const_cast<long&>(__cached_size_) = static_cast<long>(off); |
| 4741 | } |
| 4742 | return static_cast<size_t>(__cached_size_); |
| 4743 | } |
| 4744 | virtual char* first_demangled_name(char* buf) const |
| 4745 | { |
| 4746 | size_t len = __left_->list_len(); |
| 4747 | if (len != 0) |
| 4748 | { |
| 4749 | if (__left_->is_sub() || len == 1) |
| 4750 | buf = __left_->get_demangled_name(buf); |
| 4751 | else |
| 4752 | { |
| 4753 | __node* top = __left_; |
| 4754 | __node* bottom = top; |
| 4755 | while (!bottom->__left_->is_sub()) |
| 4756 | bottom = bottom->__left_; |
| 4757 | __node* sub = bottom->__left_; |
| 4758 | __node* i = sub->__left_; |
| 4759 | bool first = true; |
| 4760 | top->reset_cached_size(); |
| 4761 | while (i) |
| 4762 | { |
| 4763 | if (!first) |
| 4764 | { |
| 4765 | *buf++ = ','; |
| 4766 | *buf++ = ' '; |
| 4767 | } |
| 4768 | bottom->__left_ = i->__left_; |
| 4769 | buf = top->get_demangled_name(buf); |
| 4770 | top->reset_cached_size(); |
| 4771 | i = i->__right_; |
| 4772 | first = false; |
| 4773 | } |
| 4774 | bottom->__left_ = sub; |
| 4775 | } |
| 4776 | } |
| 4777 | return buf; |
| 4778 | } |
| 4779 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 4780 | { |
| 4781 | return __left_->fix_forward_references(t_begin, t_end); |
| 4782 | } |
| 4783 | }; |
| 4784 | |
| 4785 | class __void |
| 4786 | : public __node |
| 4787 | { |
| 4788 | static const size_t n = sizeof("void") - 1; |
| 4789 | public: |
| 4790 | |
| 4791 | virtual size_t first_size() const {return n;} |
| 4792 | virtual char* first_demangled_name(char* buf) const |
| 4793 | { |
| 4794 | strncpy(buf, "void", n); |
| 4795 | return buf + n; |
| 4796 | } |
| 4797 | }; |
| 4798 | |
| 4799 | class __wchar_t |
| 4800 | : public __node |
| 4801 | { |
| 4802 | static const size_t n = sizeof("wchar_t") - 1; |
| 4803 | public: |
| 4804 | |
| 4805 | virtual size_t first_size() const {return n;} |
| 4806 | virtual char* first_demangled_name(char* buf) const |
| 4807 | { |
| 4808 | strncpy(buf, "wchar_t", n); |
| 4809 | return buf + n; |
| 4810 | } |
| 4811 | }; |
| 4812 | |
| 4813 | class __wchar_t_literal |
| 4814 | : public __node |
| 4815 | { |
| 4816 | public: |
| 4817 | explicit __wchar_t_literal(const char* __first, const char* __last) |
| 4818 | { |
| 4819 | __name_ = __first; |
| 4820 | __size_ = static_cast<size_t>(__last - __first); |
| 4821 | } |
| 4822 | |
| 4823 | virtual size_t first_size() const |
| 4824 | { |
| 4825 | return __size_+9; |
| 4826 | } |
| 4827 | virtual char* first_demangled_name(char* buf) const |
| 4828 | { |
| 4829 | strncpy(buf, "(wchar_t)", 9); |
| 4830 | buf += 9; |
| 4831 | strncpy(buf, __name_, __size_); |
| 4832 | return buf + __size_; |
| 4833 | } |
| 4834 | }; |
| 4835 | |
| 4836 | class __bool |
| 4837 | : public __node |
| 4838 | { |
| 4839 | static const size_t n = sizeof("bool") - 1; |
| 4840 | public: |
| 4841 | |
| 4842 | virtual size_t first_size() const {return n;} |
| 4843 | virtual char* first_demangled_name(char* buf) const |
| 4844 | { |
| 4845 | strncpy(buf, "bool", n); |
| 4846 | return buf + n; |
| 4847 | } |
| 4848 | }; |
| 4849 | |
| 4850 | class __bool_literal |
| 4851 | : public __node |
| 4852 | { |
| 4853 | public: |
| 4854 | explicit __bool_literal(const char* __name, unsigned __size) |
| 4855 | { |
| 4856 | __name_ = __name; |
| 4857 | __size_ = __size; |
| 4858 | } |
| 4859 | |
| 4860 | virtual size_t first_size() const |
| 4861 | { |
| 4862 | return __size_; |
| 4863 | } |
| 4864 | virtual char* first_demangled_name(char* buf) const |
| 4865 | { |
| 4866 | strncpy(buf, __name_, __size_); |
| 4867 | return buf + __size_; |
| 4868 | } |
| 4869 | }; |
| 4870 | |
| 4871 | class __char |
| 4872 | : public __node |
| 4873 | { |
| 4874 | static const size_t n = sizeof("char") - 1; |
| 4875 | public: |
| 4876 | |
| 4877 | virtual size_t first_size() const {return n;} |
| 4878 | virtual char* first_demangled_name(char* buf) const |
| 4879 | { |
| 4880 | strncpy(buf, "char", n); |
| 4881 | return buf + n; |
| 4882 | } |
| 4883 | }; |
| 4884 | |
| 4885 | class __char_literal |
| 4886 | : public __node |
| 4887 | { |
| 4888 | public: |
| 4889 | explicit __char_literal(const char* __first, const char* __last) |
| 4890 | { |
| 4891 | __name_ = __first; |
| 4892 | __size_ = static_cast<size_t>(__last - __first); |
| 4893 | } |
| 4894 | |
| 4895 | virtual size_t first_size() const |
| 4896 | { |
| 4897 | return __size_+6; |
| 4898 | } |
| 4899 | virtual char* first_demangled_name(char* buf) const |
| 4900 | { |
| 4901 | strncpy(buf, "(char)", 6); |
| 4902 | buf += 6; |
| 4903 | if (*__name_ == 'n') |
| 4904 | { |
| 4905 | *buf++ = '-'; // strncpy(buf+6, "-", 1); |
| 4906 | strncpy(buf, __name_+1, __size_-1); |
| 4907 | buf += __size_ - 1; |
| 4908 | } |
| 4909 | else |
| 4910 | { |
| 4911 | strncpy(buf, __name_, __size_); |
| 4912 | buf += __size_; |
| 4913 | } |
| 4914 | return buf; |
| 4915 | } |
| 4916 | }; |
| 4917 | |
| 4918 | class __signed_char |
| 4919 | : public __node |
| 4920 | { |
| 4921 | static const size_t n = sizeof("signed char") - 1; |
| 4922 | public: |
| 4923 | |
| 4924 | virtual size_t first_size() const {return n;} |
| 4925 | virtual char* first_demangled_name(char* buf) const |
| 4926 | { |
| 4927 | strncpy(buf, "signed char", n); |
| 4928 | return buf + n; |
| 4929 | } |
| 4930 | }; |
| 4931 | |
| 4932 | class __signed_char_literal |
| 4933 | : public __node |
| 4934 | { |
| 4935 | public: |
| 4936 | explicit __signed_char_literal(const char* __first, const char* __last) |
| 4937 | { |
| 4938 | __name_ = __first; |
| 4939 | __size_ = static_cast<size_t>(__last - __first); |
| 4940 | } |
| 4941 | |
| 4942 | virtual size_t first_size() const |
| 4943 | { |
| 4944 | return __size_+13; |
| 4945 | } |
| 4946 | virtual char* first_demangled_name(char* buf) const |
| 4947 | { |
| 4948 | strncpy(buf, "(signed char)", 13); |
| 4949 | buf += 13; |
| 4950 | if (*__name_ == 'n') |
| 4951 | { |
| 4952 | *buf++ = '-'; |
| 4953 | strncpy(buf, __name_+1, __size_-1); |
| 4954 | buf += __size_ - 1; |
| 4955 | } |
| 4956 | else |
| 4957 | { |
| 4958 | strncpy(buf, __name_, __size_); |
| 4959 | buf += __size_; |
| 4960 | } |
| 4961 | return buf; |
| 4962 | } |
| 4963 | }; |
| 4964 | |
| 4965 | class __unsigned_char |
| 4966 | : public __node |
| 4967 | { |
| 4968 | static const size_t n = sizeof("unsigned char") - 1; |
| 4969 | public: |
| 4970 | |
| 4971 | virtual size_t first_size() const {return n;} |
| 4972 | virtual char* first_demangled_name(char* buf) const |
| 4973 | { |
| 4974 | strncpy(buf, "unsigned char", n); |
| 4975 | return buf + n; |
| 4976 | } |
| 4977 | }; |
| 4978 | |
| 4979 | class __unsigned_char_literal |
| 4980 | : public __node |
| 4981 | { |
| 4982 | public: |
| 4983 | explicit __unsigned_char_literal(const char* __first, const char* __last) |
| 4984 | { |
| 4985 | __name_ = __first; |
| 4986 | __size_ = static_cast<size_t>(__last - __first); |
| 4987 | } |
| 4988 | |
| 4989 | virtual size_t first_size() const |
| 4990 | { |
| 4991 | return __size_+15; |
| 4992 | } |
| 4993 | virtual char* first_demangled_name(char* buf) const |
| 4994 | { |
| 4995 | strncpy(buf, "(unsigned char)", 15); |
| 4996 | buf += 15; |
| 4997 | strncpy(buf, __name_, __size_); |
| 4998 | return buf + __size_; |
| 4999 | } |
| 5000 | }; |
| 5001 | |
| 5002 | class __short |
| 5003 | : public __node |
| 5004 | { |
| 5005 | static const size_t n = sizeof("short") - 1; |
| 5006 | public: |
| 5007 | |
| 5008 | virtual size_t first_size() const {return n;} |
| 5009 | virtual char* first_demangled_name(char* buf) const |
| 5010 | { |
| 5011 | strncpy(buf, "short", n); |
| 5012 | return buf + n; |
| 5013 | } |
| 5014 | }; |
| 5015 | |
| 5016 | class __short_literal |
| 5017 | : public __node |
| 5018 | { |
| 5019 | public: |
| 5020 | explicit __short_literal(const char* __first, const char* __last) |
| 5021 | { |
| 5022 | __name_ = __first; |
| 5023 | __size_ = static_cast<size_t>(__last - __first); |
| 5024 | } |
| 5025 | |
| 5026 | virtual size_t first_size() const |
| 5027 | { |
| 5028 | return __size_+7; |
| 5029 | } |
| 5030 | virtual char* first_demangled_name(char* buf) const |
| 5031 | { |
| 5032 | strncpy(buf, "(short)", 7); |
| 5033 | buf += 7; |
| 5034 | if (*__name_ == 'n') |
| 5035 | { |
| 5036 | *buf++ = '-'; |
| 5037 | strncpy(buf, __name_+1, __size_-1); |
| 5038 | buf += __size_ - 1; |
| 5039 | } |
| 5040 | else |
| 5041 | { |
| 5042 | strncpy(buf, __name_, __size_); |
| 5043 | buf += __size_; |
| 5044 | } |
| 5045 | return buf; |
| 5046 | } |
| 5047 | }; |
| 5048 | |
| 5049 | class __unsigned_short |
| 5050 | : public __node |
| 5051 | { |
| 5052 | static const size_t n = sizeof("unsigned short") - 1; |
| 5053 | public: |
| 5054 | |
| 5055 | virtual size_t first_size() const {return n;} |
| 5056 | virtual char* first_demangled_name(char* buf) const |
| 5057 | { |
| 5058 | strncpy(buf, "unsigned short", n); |
| 5059 | return buf + n; |
| 5060 | } |
| 5061 | }; |
| 5062 | |
| 5063 | class __unsigned_short_literal |
| 5064 | : public __node |
| 5065 | { |
| 5066 | public: |
| 5067 | explicit __unsigned_short_literal(const char* __first, const char* __last) |
| 5068 | { |
| 5069 | __name_ = __first; |
| 5070 | __size_ = static_cast<size_t>(__last - __first); |
| 5071 | } |
| 5072 | |
| 5073 | virtual size_t first_size() const |
| 5074 | { |
| 5075 | return __size_+16; |
| 5076 | } |
| 5077 | virtual char* first_demangled_name(char* buf) const |
| 5078 | { |
| 5079 | strncpy(buf, "(unsigned short)", 16); |
| 5080 | buf += 16; |
| 5081 | strncpy(buf, __name_, __size_); |
| 5082 | return buf + __size_; |
| 5083 | } |
| 5084 | }; |
| 5085 | |
| 5086 | class __int |
| 5087 | : public __node |
| 5088 | { |
| 5089 | static const size_t n = sizeof("int") - 1; |
| 5090 | public: |
| 5091 | |
| 5092 | virtual size_t first_size() const {return n;} |
| 5093 | virtual char* first_demangled_name(char* buf) const |
| 5094 | { |
| 5095 | *buf++ = 'i'; |
| 5096 | *buf++ = 'n'; |
| 5097 | *buf++ = 't'; |
| 5098 | return buf; |
| 5099 | } |
| 5100 | }; |
| 5101 | |
| 5102 | class __int_literal |
| 5103 | : public __node |
| 5104 | { |
| 5105 | public: |
| 5106 | explicit __int_literal(const char* __first, const char* __last) |
| 5107 | { |
| 5108 | __name_ = __first; |
| 5109 | __size_ = static_cast<size_t>(__last - __first); |
| 5110 | } |
| 5111 | |
| 5112 | virtual size_t first_size() const |
| 5113 | { |
| 5114 | return __size_; |
| 5115 | } |
| 5116 | virtual char* first_demangled_name(char* buf) const |
| 5117 | { |
| 5118 | if (*__name_ == 'n') |
| 5119 | { |
| 5120 | *buf++ = '-'; |
| 5121 | strncpy(buf, __name_+1, __size_-1); |
| 5122 | buf += __size_ - 1; |
| 5123 | } |
| 5124 | else |
| 5125 | { |
| 5126 | strncpy(buf, __name_, __size_); |
| 5127 | buf += __size_; |
| 5128 | } |
| 5129 | return buf; |
| 5130 | } |
| 5131 | }; |
| 5132 | |
| 5133 | class __unsigned_int |
| 5134 | : public __node |
| 5135 | { |
| 5136 | static const size_t n = sizeof("unsigned int") - 1; |
| 5137 | public: |
| 5138 | |
| 5139 | virtual size_t first_size() const {return n;} |
| 5140 | virtual char* first_demangled_name(char* buf) const |
| 5141 | { |
| 5142 | strncpy(buf, "unsigned int", n); |
| 5143 | return buf + n; |
| 5144 | } |
| 5145 | }; |
| 5146 | |
| 5147 | class __unsigned_int_literal |
| 5148 | : public __node |
| 5149 | { |
| 5150 | public: |
| 5151 | explicit __unsigned_int_literal(const char* __first, const char* __last) |
| 5152 | { |
| 5153 | __name_ = __first; |
| 5154 | __size_ = static_cast<size_t>(__last - __first); |
| 5155 | } |
| 5156 | |
| 5157 | virtual size_t first_size() const |
| 5158 | { |
| 5159 | return __size_+1; |
| 5160 | } |
| 5161 | virtual char* first_demangled_name(char* buf) const |
| 5162 | { |
| 5163 | strncpy(buf, __name_, __size_); |
| 5164 | buf += __size_; |
| 5165 | *buf++ = 'u'; |
| 5166 | return buf; |
| 5167 | } |
| 5168 | }; |
| 5169 | |
| 5170 | class __long |
| 5171 | : public __node |
| 5172 | { |
| 5173 | static const size_t n = sizeof("long") - 1; |
| 5174 | public: |
| 5175 | |
| 5176 | virtual size_t first_size() const {return n;} |
| 5177 | virtual char* first_demangled_name(char* buf) const |
| 5178 | { |
| 5179 | strncpy(buf, "long", n); |
| 5180 | return buf + n; |
| 5181 | } |
| 5182 | }; |
| 5183 | |
| 5184 | class __long_literal |
| 5185 | : public __node |
| 5186 | { |
| 5187 | public: |
| 5188 | explicit __long_literal(const char* __first, const char* __last) |
| 5189 | { |
| 5190 | __name_ = __first; |
| 5191 | __size_ = static_cast<size_t>(__last - __first); |
| 5192 | } |
| 5193 | |
| 5194 | virtual size_t first_size() const |
| 5195 | { |
| 5196 | return __size_+1; |
| 5197 | } |
| 5198 | virtual char* first_demangled_name(char* buf) const |
| 5199 | { |
| 5200 | if (*__name_ == 'n') |
| 5201 | { |
| 5202 | *buf++ = '-'; // strncpy(buf, "-", 1); |
| 5203 | strncpy(buf, __name_+1, __size_-1); |
| 5204 | buf += __size_ - 1; |
| 5205 | } |
| 5206 | else |
| 5207 | { |
| 5208 | strncpy(buf, __name_, __size_); |
| 5209 | buf += __size_; |
| 5210 | } |
| 5211 | *buf++ = 'l'; |
| 5212 | return buf; |
| 5213 | } |
| 5214 | }; |
| 5215 | |
| 5216 | class __unsigned_long |
| 5217 | : public __node |
| 5218 | { |
| 5219 | static const size_t n = sizeof("unsigned long") - 1; |
| 5220 | public: |
| 5221 | |
| 5222 | virtual size_t first_size() const {return n;} |
| 5223 | virtual char* first_demangled_name(char* buf) const |
| 5224 | { |
| 5225 | strncpy(buf, "unsigned long", n); |
| 5226 | return buf + n; |
| 5227 | } |
| 5228 | }; |
| 5229 | |
| 5230 | class __unsigned_long_literal |
| 5231 | : public __node |
| 5232 | { |
| 5233 | public: |
| 5234 | explicit __unsigned_long_literal(const char* __first, const char* __last) |
| 5235 | { |
| 5236 | __name_ = __first; |
| 5237 | __size_ = static_cast<size_t>(__last - __first); |
| 5238 | } |
| 5239 | |
| 5240 | virtual size_t first_size() const |
| 5241 | { |
| 5242 | return __size_+2; |
| 5243 | } |
| 5244 | virtual char* first_demangled_name(char* buf) const |
| 5245 | { |
| 5246 | strncpy(buf, __name_, __size_); |
| 5247 | buf += __size_; |
| 5248 | *buf++ = 'u'; |
| 5249 | *buf++ = 'l'; |
| 5250 | return buf; |
| 5251 | } |
| 5252 | }; |
| 5253 | |
| 5254 | class __long_long |
| 5255 | : public __node |
| 5256 | { |
| 5257 | static const size_t n = sizeof("long long") - 1; |
| 5258 | public: |
| 5259 | |
| 5260 | virtual size_t first_size() const {return n;} |
| 5261 | virtual char* first_demangled_name(char* buf) const |
| 5262 | { |
| 5263 | strncpy(buf, "long long", n); |
| 5264 | return buf + n; |
| 5265 | } |
| 5266 | }; |
| 5267 | |
| 5268 | class __long_long_literal |
| 5269 | : public __node |
| 5270 | { |
| 5271 | public: |
| 5272 | explicit __long_long_literal(const char* __first, const char* __last) |
| 5273 | { |
| 5274 | __name_ = __first; |
| 5275 | __size_ = static_cast<size_t>(__last - __first); |
| 5276 | } |
| 5277 | |
| 5278 | virtual size_t first_size() const |
| 5279 | { |
| 5280 | return __size_+2; |
| 5281 | } |
| 5282 | virtual char* first_demangled_name(char* buf) const |
| 5283 | { |
| 5284 | if (*__name_ == 'n') |
| 5285 | { |
| 5286 | *buf++ = '-'; |
| 5287 | strncpy(buf, __name_+1, __size_-1); |
| 5288 | buf += __size_ - 1; |
| 5289 | } |
| 5290 | else |
| 5291 | { |
| 5292 | strncpy(buf, __name_, __size_); |
| 5293 | buf += __size_; |
| 5294 | } |
| 5295 | *buf++ = 'l'; |
| 5296 | *buf++ = 'l'; |
| 5297 | return buf; |
| 5298 | } |
| 5299 | }; |
| 5300 | |
| 5301 | class __unsigned_long_long |
| 5302 | : public __node |
| 5303 | { |
| 5304 | static const size_t n = sizeof("unsigned long long") - 1; |
| 5305 | public: |
| 5306 | |
| 5307 | virtual size_t first_size() const {return n;} |
| 5308 | virtual char* first_demangled_name(char* buf) const |
| 5309 | { |
| 5310 | strncpy(buf, "unsigned long long", n); |
| 5311 | return buf + n; |
| 5312 | } |
| 5313 | }; |
| 5314 | |
| 5315 | class __unsigned_long_long_literal |
| 5316 | : public __node |
| 5317 | { |
| 5318 | public: |
| 5319 | explicit __unsigned_long_long_literal(const char* __first, const char* __last) |
| 5320 | { |
| 5321 | __name_ = __first; |
| 5322 | __size_ = static_cast<size_t>(__last - __first); |
| 5323 | } |
| 5324 | |
| 5325 | virtual size_t first_size() const |
| 5326 | { |
| 5327 | return __size_+3; |
| 5328 | } |
| 5329 | virtual char* first_demangled_name(char* buf) const |
| 5330 | { |
| 5331 | strncpy(buf, __name_, __size_); |
| 5332 | buf += __size_; |
| 5333 | *buf++ = 'u'; |
| 5334 | *buf++ = 'l'; |
| 5335 | *buf++ = 'l'; |
| 5336 | return buf; |
| 5337 | } |
| 5338 | }; |
| 5339 | |
| 5340 | class __signed_int128 |
| 5341 | : public __node |
| 5342 | { |
| 5343 | static const size_t n = sizeof("__int128") - 1; |
| 5344 | public: |
| 5345 | |
| 5346 | virtual size_t first_size() const {return n;} |
| 5347 | virtual char* first_demangled_name(char* buf) const |
| 5348 | { |
| 5349 | strncpy(buf, "__int128", n); |
| 5350 | return buf + n; |
| 5351 | } |
| 5352 | }; |
| 5353 | |
| 5354 | class __int128_literal |
| 5355 | : public __node |
| 5356 | { |
| 5357 | public: |
| 5358 | explicit __int128_literal(const char* __first, const char* __last) |
| 5359 | { |
| 5360 | __name_ = __first; |
| 5361 | __size_ = static_cast<size_t>(__last - __first); |
| 5362 | } |
| 5363 | |
| 5364 | virtual size_t first_size() const |
| 5365 | { |
| 5366 | return __size_+10; |
| 5367 | } |
| 5368 | virtual char* first_demangled_name(char* buf) const |
| 5369 | { |
| 5370 | strncpy(buf, "(__int128)", 10); |
| 5371 | buf += 10; |
| 5372 | if (*__name_ == 'n') |
| 5373 | { |
| 5374 | *buf++ = '-'; |
| 5375 | strncpy(buf, __name_+1, __size_-1); |
| 5376 | buf += __size_ - 1; |
| 5377 | } |
| 5378 | else |
| 5379 | { |
| 5380 | strncpy(buf, __name_, __size_); |
| 5381 | buf += __size_; |
| 5382 | } |
| 5383 | return buf; |
| 5384 | } |
| 5385 | }; |
| 5386 | |
| 5387 | class __unsigned_int128 |
| 5388 | : public __node |
| 5389 | { |
| 5390 | static const size_t n = sizeof("unsigned __int128") - 1; |
| 5391 | public: |
| 5392 | |
| 5393 | virtual size_t first_size() const {return n;} |
| 5394 | virtual char* first_demangled_name(char* buf) const |
| 5395 | { |
| 5396 | strncpy(buf, "unsigned __int128", n); |
| 5397 | return buf + n; |
| 5398 | } |
| 5399 | }; |
| 5400 | |
| 5401 | class __unsigned_int128_literal |
| 5402 | : public __node |
| 5403 | { |
| 5404 | public: |
| 5405 | explicit __unsigned_int128_literal(const char* __first, const char* __last) |
| 5406 | { |
| 5407 | __name_ = __first; |
| 5408 | __size_ = static_cast<size_t>(__last - __first); |
| 5409 | } |
| 5410 | |
| 5411 | virtual size_t first_size() const |
| 5412 | { |
| 5413 | return __size_+19; |
| 5414 | } |
| 5415 | virtual char* first_demangled_name(char* buf) const |
| 5416 | { |
| 5417 | strncpy(buf, "(unsigned __int128)", 19); |
| 5418 | buf += 19; |
| 5419 | strncpy(buf, __name_, __size_); |
| 5420 | return buf + __size_; |
| 5421 | } |
| 5422 | }; |
| 5423 | |
| 5424 | class __float_literal |
| 5425 | : public __node |
| 5426 | { |
| 5427 | public: |
| 5428 | explicit __float_literal(float value) |
| 5429 | { |
| 5430 | __value_ = value; |
| 5431 | } |
| 5432 | |
| 5433 | virtual size_t first_size() const |
| 5434 | { |
| 5435 | if (__cached_size_ == -1) |
| 5436 | { |
| 5437 | char num[20] = {0}; |
| 5438 | float v = static_cast<float>(__value_); |
| 5439 | const_cast<long&>(__cached_size_) = sprintf(num, "%a", v)+1; |
| 5440 | } |
| 5441 | return static_cast<size_t>(__cached_size_); |
| 5442 | } |
| 5443 | virtual char* first_demangled_name(char* buf) const |
| 5444 | { |
| 5445 | char num[20] = {0}; |
| 5446 | float v = static_cast<float>(__value_); |
| 5447 | int n = sprintf(num, "%a", v); |
| 5448 | strncpy(buf, num, static_cast<size_t>(n)); |
| 5449 | buf += n; |
| 5450 | *buf++ = 'f'; |
| 5451 | return buf; |
| 5452 | } |
| 5453 | }; |
| 5454 | |
| 5455 | class __float |
| 5456 | : public __node |
| 5457 | { |
| 5458 | static const size_t n = sizeof("float") - 1; |
| 5459 | public: |
| 5460 | |
| 5461 | virtual size_t first_size() const {return n;} |
| 5462 | virtual char* first_demangled_name(char* buf) const |
| 5463 | { |
| 5464 | strncpy(buf, "float", n); |
| 5465 | return buf + n; |
| 5466 | } |
| 5467 | }; |
| 5468 | |
| 5469 | class __double_literal |
| 5470 | : public __node |
| 5471 | { |
| 5472 | public: |
| 5473 | explicit __double_literal(double value) |
| 5474 | { |
| 5475 | __value_ = value; |
| 5476 | } |
| 5477 | |
| 5478 | virtual size_t first_size() const |
| 5479 | { |
| 5480 | if (__cached_size_ == -1) |
| 5481 | { |
| 5482 | char num[30] = {0}; |
| 5483 | double v = static_cast<double>(__value_); |
| 5484 | const_cast<long&>(__cached_size_) = sprintf(num, "%a", v); |
| 5485 | } |
| 5486 | return static_cast<size_t>(__cached_size_); |
| 5487 | } |
| 5488 | virtual char* first_demangled_name(char* buf) const |
| 5489 | { |
| 5490 | char num[30] = {0}; |
| 5491 | double v = static_cast<double>(__value_); |
| 5492 | int n = sprintf(num, "%a", v); |
| 5493 | strncpy(buf, num, static_cast<size_t>(n)); |
| 5494 | return buf + n; |
| 5495 | } |
| 5496 | }; |
| 5497 | |
| 5498 | class __double |
| 5499 | : public __node |
| 5500 | { |
| 5501 | static const size_t n = sizeof("double") - 1; |
| 5502 | public: |
| 5503 | |
| 5504 | virtual size_t first_size() const {return n;} |
| 5505 | virtual char* first_demangled_name(char* buf) const |
| 5506 | { |
| 5507 | strncpy(buf, "double", n); |
| 5508 | return buf + n; |
| 5509 | } |
| 5510 | }; |
| 5511 | |
| 5512 | class __long_double |
| 5513 | : public __node |
| 5514 | { |
| 5515 | static const size_t n = sizeof("long double") - 1; |
| 5516 | public: |
| 5517 | |
| 5518 | virtual size_t first_size() const {return n;} |
| 5519 | virtual char* first_demangled_name(char* buf) const |
| 5520 | { |
| 5521 | strncpy(buf, "long double", n); |
| 5522 | return buf + n; |
| 5523 | } |
| 5524 | }; |
| 5525 | |
| 5526 | class __float128 |
| 5527 | : public __node |
| 5528 | { |
| 5529 | static const size_t n = sizeof("__float128") - 1; |
| 5530 | public: |
| 5531 | |
| 5532 | virtual size_t first_size() const {return n;} |
| 5533 | virtual char* first_demangled_name(char* buf) const |
| 5534 | { |
| 5535 | strncpy(buf, "__float128", n); |
| 5536 | return buf + n; |
| 5537 | } |
| 5538 | }; |
| 5539 | |
| 5540 | class __ellipsis |
| 5541 | : public __node |
| 5542 | { |
| 5543 | static const size_t n = sizeof("...") - 1; |
| 5544 | public: |
| 5545 | |
| 5546 | virtual size_t first_size() const {return n;} |
| 5547 | virtual char* first_demangled_name(char* buf) const |
| 5548 | { |
| 5549 | *buf++ = '.'; |
| 5550 | *buf++ = '.'; |
| 5551 | *buf++ = '.'; |
| 5552 | return buf; |
| 5553 | } |
| 5554 | }; |
| 5555 | |
| 5556 | class __decimal64 |
| 5557 | : public __node |
| 5558 | { |
| 5559 | static const size_t n = sizeof("decimal64") - 1; |
| 5560 | public: |
| 5561 | |
| 5562 | virtual size_t first_size() const {return n;} |
| 5563 | virtual char* first_demangled_name(char* buf) const |
| 5564 | { |
| 5565 | strncpy(buf, "decimal64", n); |
| 5566 | return buf + n; |
| 5567 | } |
| 5568 | }; |
| 5569 | |
| 5570 | class __decimal128 |
| 5571 | : public __node |
| 5572 | { |
| 5573 | static const size_t n = sizeof("decimal128") - 1; |
| 5574 | public: |
| 5575 | |
| 5576 | virtual size_t first_size() const {return n;} |
| 5577 | virtual char* first_demangled_name(char* buf) const |
| 5578 | { |
| 5579 | strncpy(buf, "decimal128", n); |
| 5580 | return buf + n; |
| 5581 | } |
| 5582 | }; |
| 5583 | |
| 5584 | class __decimal32 |
| 5585 | : public __node |
| 5586 | { |
| 5587 | static const size_t n = sizeof("decimal32") - 1; |
| 5588 | public: |
| 5589 | |
| 5590 | virtual size_t first_size() const {return n;} |
| 5591 | virtual char* first_demangled_name(char* buf) const |
| 5592 | { |
| 5593 | strncpy(buf, "decimal32", n); |
| 5594 | return buf + n; |
| 5595 | } |
| 5596 | }; |
| 5597 | |
| 5598 | class __decimal16 |
| 5599 | : public __node |
| 5600 | { |
| 5601 | static const size_t n = sizeof("decimal16") - 1; |
| 5602 | public: |
| 5603 | |
| 5604 | virtual size_t first_size() const {return n;} |
| 5605 | virtual char* first_demangled_name(char* buf) const |
| 5606 | { |
| 5607 | strncpy(buf, "decimal16", n); |
| 5608 | return buf + n; |
| 5609 | } |
| 5610 | }; |
| 5611 | |
| 5612 | class __d_char32_t |
| 5613 | : public __node |
| 5614 | { |
| 5615 | static const size_t n = sizeof("char32_t") - 1; |
| 5616 | public: |
| 5617 | |
| 5618 | virtual size_t first_size() const {return n;} |
| 5619 | virtual char* first_demangled_name(char* buf) const |
| 5620 | { |
| 5621 | strncpy(buf, "char32_t", n); |
| 5622 | return buf + n; |
| 5623 | } |
| 5624 | }; |
| 5625 | |
| 5626 | class __d_char16_t |
| 5627 | : public __node |
| 5628 | { |
| 5629 | static const size_t n = sizeof("char16_t") - 1; |
| 5630 | public: |
| 5631 | |
| 5632 | virtual size_t first_size() const {return n;} |
| 5633 | virtual char* first_demangled_name(char* buf) const |
| 5634 | { |
| 5635 | strncpy(buf, "char16_t", n); |
| 5636 | return buf + n; |
| 5637 | } |
| 5638 | }; |
| 5639 | |
| 5640 | class __auto |
| 5641 | : public __node |
| 5642 | { |
| 5643 | static const size_t n = sizeof("auto") - 1; |
| 5644 | public: |
| 5645 | |
| 5646 | virtual size_t first_size() const {return n;} |
| 5647 | virtual char* first_demangled_name(char* buf) const |
| 5648 | { |
| 5649 | strncpy(buf, "auto", n); |
| 5650 | return buf + n; |
| 5651 | } |
| 5652 | }; |
| 5653 | |
| 5654 | class __nullptr_t |
| 5655 | : public __node |
| 5656 | { |
| 5657 | static const size_t n = sizeof("std::nullptr_t") - 1; |
| 5658 | public: |
| 5659 | |
| 5660 | virtual size_t first_size() const {return n;} |
| 5661 | virtual char* first_demangled_name(char* buf) const |
| 5662 | { |
| 5663 | strncpy(buf, "std::nullptr_t", n); |
| 5664 | return buf + n; |
| 5665 | } |
| 5666 | }; |
| 5667 | |
| 5668 | class __array |
| 5669 | : public __node |
| 5670 | { |
| 5671 | public: |
| 5672 | |
| 5673 | explicit __array(__node* type) |
| 5674 | { |
| 5675 | __left_ = type; |
| 5676 | } |
| 5677 | |
| 5678 | __array(__node* type, size_t dim) |
| 5679 | { |
| 5680 | __left_ = type; |
| 5681 | __size_ = dim; |
| 5682 | } |
| 5683 | |
| 5684 | __array(__node* type, __node* dim) |
| 5685 | { |
| 5686 | __left_ = type; |
| 5687 | __right_ = dim; |
| 5688 | } |
| 5689 | |
| 5690 | virtual size_t size() const |
| 5691 | { |
| 5692 | if (__cached_size_ == -1) |
| 5693 | { |
| 5694 | size_t r = __left_->size() + 3; |
| 5695 | if (__right_ != 0) |
| 5696 | r += __right_->size(); |
| 5697 | else if (__size_ != 0) |
| 5698 | r += static_cast<size_t>(snprintf(0, 0, "%ld", __size_)); |
| 5699 | const_cast<long&>(__cached_size_) = static_cast<long>(r); |
| 5700 | } |
| 5701 | return static_cast<size_t>(__cached_size_); |
| 5702 | } |
| 5703 | |
| 5704 | virtual char* get_demangled_name(char* buf) const |
| 5705 | { |
| 5706 | buf = __left_->get_demangled_name(buf); |
| 5707 | *buf++ = ' '; |
| 5708 | *buf++ = '['; |
| 5709 | if (__right_ != 0) |
| 5710 | buf = __right_->get_demangled_name(buf); |
| 5711 | else if (__size_ != 0) |
| 5712 | { |
| 5713 | int rs = sprintf(buf, "%ld", __size_); |
| 5714 | buf += rs; |
| 5715 | } |
| 5716 | *buf++ = ']'; |
| 5717 | return buf; |
| 5718 | } |
| 5719 | |
| 5720 | virtual size_t first_size() const |
| 5721 | { |
| 5722 | return __left_->first_size(); |
| 5723 | } |
| 5724 | |
| 5725 | virtual char* first_demangled_name(char* buf) const |
| 5726 | { |
| 5727 | return __left_->first_demangled_name(buf); |
| 5728 | } |
| 5729 | |
| 5730 | virtual size_t second_size() const |
| 5731 | { |
| 5732 | size_t r = 2 + __left_->second_size(); |
| 5733 | if (!__left_->is_array()) |
| 5734 | ++r; |
| 5735 | if (__right_ != 0) |
| 5736 | r += __right_->size(); |
| 5737 | else if (__size_ != 0) |
| 5738 | r += static_cast<size_t>(snprintf(0, 0, "%ld", __size_)); |
| 5739 | return r; |
| 5740 | } |
| 5741 | |
| 5742 | virtual char* second_demangled_name(char* buf) const |
| 5743 | { |
| 5744 | *buf++ = ' '; |
| 5745 | *buf++ = '['; |
| 5746 | if (__right_ != 0) |
| 5747 | buf = __right_->get_demangled_name(buf); |
| 5748 | else if (__size_ != 0) |
| 5749 | { |
| 5750 | int off = sprintf(buf, "%ld", __size_); |
| 5751 | buf += off; |
| 5752 | } |
| 5753 | char* t = buf; |
| 5754 | buf = __left_->second_demangled_name(buf); |
| 5755 | *t = ']'; |
| 5756 | if (buf == t) |
| 5757 | ++buf; |
| 5758 | return buf; |
| 5759 | } |
| 5760 | virtual bool is_array() const |
| 5761 | { |
| 5762 | return true; |
| 5763 | } |
| 5764 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 5765 | { |
| 5766 | bool r = __left_->fix_forward_references(t_begin, t_end); |
| 5767 | if (__right_) |
| 5768 | r = r && __right_->fix_forward_references(t_begin, t_end); |
| 5769 | return r; |
| 5770 | } |
| 5771 | }; |
| 5772 | |
| 5773 | class __pointer_to_member_type |
| 5774 | : public __node |
| 5775 | { |
| 5776 | public: |
| 5777 | |
| 5778 | __pointer_to_member_type(__node* class_type, __node* member_type) |
| 5779 | { |
| 5780 | __left_ = class_type; |
| 5781 | __right_ = member_type; |
| 5782 | } |
| 5783 | |
| 5784 | virtual size_t first_size() const |
| 5785 | { |
| 5786 | if (__cached_size_ == -1) |
| 5787 | const_cast<long&>(__cached_size_) = static_cast<long>(__left_->size() + 3 |
| 5788 | + __right_->first_size() |
| 5789 | + __right_->second_size()); |
| 5790 | return static_cast<size_t>(__cached_size_); |
| 5791 | } |
| 5792 | virtual char* first_demangled_name(char* buf) const |
| 5793 | { |
| 5794 | buf = __right_->first_demangled_name(buf); |
| 5795 | buf = __left_->get_demangled_name(buf); |
| 5796 | *buf++ = ':'; |
| 5797 | *buf++ = ':'; |
| 5798 | *buf++ = '*'; |
| 5799 | return __right_->second_demangled_name(buf); |
| 5800 | } |
| 5801 | virtual __node* base_name() const |
| 5802 | { |
| 5803 | return __left_->base_name(); |
| 5804 | } |
| 5805 | virtual bool is_reference_or_pointer_to_function_or_array() const |
| 5806 | { |
| 5807 | return __right_->is_function(); |
| 5808 | } |
| 5809 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 5810 | { |
| 5811 | return __left_->fix_forward_references(t_begin, t_end) && |
| 5812 | __right_->fix_forward_references(t_begin, t_end); |
| 5813 | } |
| 5814 | }; |
| 5815 | |
| 5816 | class __decltype_node |
| 5817 | : public __node |
| 5818 | { |
| 5819 | public: |
| 5820 | |
| 5821 | explicit __decltype_node(__node* expr) |
| 5822 | { |
| 5823 | __right_ = expr; |
| 5824 | } |
| 5825 | |
| 5826 | virtual size_t first_size() const |
| 5827 | { |
| 5828 | if (__cached_size_ == -1) |
| 5829 | const_cast<long&>(__cached_size_) = static_cast<long>(10 + __right_->size()); |
| 5830 | return static_cast<size_t>(__cached_size_); |
| 5831 | } |
| 5832 | |
| 5833 | virtual char* first_demangled_name(char* buf) const |
| 5834 | { |
| 5835 | strncpy(buf, "decltype(", 9); |
| 5836 | buf += 9; |
| 5837 | buf = __right_->get_demangled_name(buf); |
| 5838 | *buf++ = ')'; |
| 5839 | return buf; |
| 5840 | } |
| 5841 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 5842 | { |
| 5843 | return __right_->fix_forward_references(t_begin, t_end); |
| 5844 | } |
| 5845 | }; |
| 5846 | |
| 5847 | class __nested_delimeter |
| 5848 | : public __node |
| 5849 | { |
| 5850 | public: |
| 5851 | |
| 5852 | explicit __nested_delimeter(__node* prev, __node* arg) |
| 5853 | { |
| 5854 | __left_ = prev; |
| 5855 | __right_ = arg; |
| 5856 | } |
| 5857 | |
| 5858 | virtual size_t first_size() const |
| 5859 | { |
| 5860 | if (__cached_size_ == -1) |
| 5861 | const_cast<long&>(__cached_size_) = static_cast<long>(__left_->size() + |
| 5862 | __right_->size() + 2); |
| 5863 | return static_cast<size_t>(__cached_size_); |
| 5864 | } |
| 5865 | |
| 5866 | virtual char* first_demangled_name(char* buf) const |
| 5867 | { |
| 5868 | buf = __left_->get_demangled_name(buf); |
| 5869 | *buf++ = ':'; |
| 5870 | *buf++ = ':'; |
| 5871 | return __right_->get_demangled_name(buf); |
| 5872 | } |
| 5873 | |
| 5874 | virtual bool ends_with_template(bool parsing = false) const |
| 5875 | { |
| 5876 | return __right_->ends_with_template(parsing); |
| 5877 | } |
| 5878 | virtual __node* base_name() const |
| 5879 | { |
| 5880 | return __right_->base_name(); |
| 5881 | } |
| 5882 | virtual bool is_ctor_dtor_conv() const |
| 5883 | { |
| 5884 | return __right_->is_ctor_dtor_conv(); |
| 5885 | } |
| 5886 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 5887 | { |
| 5888 | return __left_->fix_forward_references(t_begin, t_end) && |
| 5889 | __right_->fix_forward_references(t_begin, t_end); |
| 5890 | } |
| 5891 | virtual __node* extract_cv(__node*&) const |
| 5892 | { |
| 5893 | return __right_->extract_cv(const_cast<__node*&>(__right_)); |
| 5894 | } |
| 5895 | }; |
| 5896 | |
| 5897 | class __unresolved_name |
| 5898 | : public __node |
| 5899 | { |
| 5900 | public: |
| 5901 | |
| 5902 | __unresolved_name(__node* prev, __node* arg) |
| 5903 | { |
| 5904 | __left_ = prev; |
| 5905 | __right_ = arg; |
| 5906 | } |
| 5907 | |
| 5908 | __unresolved_name(bool global, __node* prev, __node* arg) |
| 5909 | { |
| 5910 | __size_ = global; |
| 5911 | __left_ = prev; |
| 5912 | __right_ = arg; |
| 5913 | } |
| 5914 | |
| 5915 | virtual size_t first_size() const |
| 5916 | { |
| 5917 | if (__cached_size_ == -1) |
| 5918 | const_cast<long&>(__cached_size_) = static_cast<long>((__left_ ? |
| 5919 | __left_->size() + 2 : 0) + |
| 5920 | __right_->size() + __size_ * 2); |
| 5921 | return static_cast<size_t>(__cached_size_); |
| 5922 | } |
| 5923 | |
| 5924 | virtual char* first_demangled_name(char* buf) const |
| 5925 | { |
| 5926 | if (__size_) |
| 5927 | { |
| 5928 | *buf++ = ':'; |
| 5929 | *buf++ = ':'; |
| 5930 | } |
| 5931 | if (__left_) |
| 5932 | { |
| 5933 | buf = __left_->get_demangled_name(buf); |
| 5934 | *buf++ = ':'; |
| 5935 | *buf++ = ':'; |
| 5936 | } |
| 5937 | return __right_->get_demangled_name(buf); |
| 5938 | } |
| 5939 | |
| 5940 | virtual bool ends_with_template(bool parsing = false) const |
| 5941 | { |
| 5942 | return __right_->ends_with_template(parsing); |
| 5943 | } |
| 5944 | virtual __node* base_name() const |
| 5945 | { |
| 5946 | return __right_->base_name(); |
| 5947 | } |
| 5948 | virtual bool is_ctor_dtor_conv() const |
| 5949 | { |
| 5950 | return __right_->is_ctor_dtor_conv(); |
| 5951 | } |
| 5952 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 5953 | { |
| 5954 | bool r = true; |
| 5955 | if (__left_) |
| 5956 | r = __left_->fix_forward_references(t_begin, t_end); |
| 5957 | return r && __right_->fix_forward_references(t_begin, t_end); |
| 5958 | } |
| 5959 | virtual __node* extract_cv(__node*&) const |
| 5960 | { |
| 5961 | return __right_->extract_cv(const_cast<__node*&>(__right_)); |
| 5962 | } |
| 5963 | }; |
| 5964 | |
| 5965 | class __string_literal |
| 5966 | : public __node |
| 5967 | { |
| 5968 | public: |
| 5969 | |
| 5970 | virtual size_t first_size() const |
| 5971 | { |
| 5972 | return 14; |
| 5973 | } |
| 5974 | |
| 5975 | virtual char* first_demangled_name(char* buf) const |
| 5976 | { |
| 5977 | strncpy(buf, "string literal", 14); |
| 5978 | return buf + 14; |
| 5979 | } |
| 5980 | }; |
| 5981 | |
| 5982 | class __constructor |
| 5983 | : public __node |
| 5984 | { |
| 5985 | public: |
| 5986 | |
| 5987 | explicit __constructor(__node* name) |
| 5988 | { |
| 5989 | __right_ = name; |
| 5990 | } |
| 5991 | |
| 5992 | virtual size_t first_size() const |
| 5993 | { |
| 5994 | if (__cached_size_ == -1) |
| 5995 | const_cast<long&>(__cached_size_) = static_cast<long>(__right_->base_size()); |
| 5996 | return static_cast<size_t>(__cached_size_); |
| 5997 | } |
| 5998 | |
| 5999 | virtual char* first_demangled_name(char* buf) const |
| 6000 | { |
| 6001 | return __right_->get_base_name(buf); |
| 6002 | } |
| 6003 | virtual __node* base_name() const |
| 6004 | { |
| 6005 | return __right_->base_name(); |
| 6006 | } |
| 6007 | virtual bool ends_with_template(bool parsing = false) const |
| 6008 | { |
| 6009 | return __right_->ends_with_template(parsing); |
| 6010 | } |
| 6011 | virtual bool is_ctor_dtor_conv() const |
| 6012 | { |
| 6013 | return true; |
| 6014 | } |
| 6015 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 6016 | { |
| 6017 | return __right_->fix_forward_references(t_begin, t_end); |
| 6018 | } |
| 6019 | }; |
| 6020 | |
| 6021 | class __destructor |
| 6022 | : public __node |
| 6023 | { |
| 6024 | public: |
| 6025 | |
| 6026 | explicit __destructor(__node* name) |
| 6027 | { |
| 6028 | __right_ = name; |
| 6029 | } |
| 6030 | |
| 6031 | virtual size_t first_size() const |
| 6032 | { |
| 6033 | if (__cached_size_ == -1) |
| 6034 | const_cast<long&>(__cached_size_) = static_cast<long>(__right_->base_size() + 1); |
| 6035 | return static_cast<size_t>(__cached_size_); |
| 6036 | } |
| 6037 | |
| 6038 | virtual char* first_demangled_name(char* buf) const |
| 6039 | { |
| 6040 | *buf++ = '~'; |
| 6041 | return __right_->get_base_name(buf); |
| 6042 | } |
| 6043 | virtual __node* base_name() const |
| 6044 | { |
| 6045 | return __right_->base_name(); |
| 6046 | } |
| 6047 | virtual bool is_ctor_dtor_conv() const |
| 6048 | { |
| 6049 | return true; |
| 6050 | } |
| 6051 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 6052 | { |
| 6053 | return __right_->fix_forward_references(t_begin, t_end); |
| 6054 | } |
| 6055 | }; |
| 6056 | |
| 6057 | class __dot_suffix |
| 6058 | : public __node |
| 6059 | { |
| 6060 | public: |
| 6061 | __dot_suffix(__node* name, const char* suffix, size_t sz) |
| 6062 | { |
| 6063 | __left_ = name; |
| 6064 | __name_ = suffix; |
| 6065 | __size_ = sz; |
| 6066 | } |
| 6067 | |
| 6068 | virtual size_t first_size() const |
| 6069 | { |
| 6070 | if (__cached_size_ == -1) |
| 6071 | { |
| 6072 | size_t off = __left_->size(); |
| 6073 | off += __size_ + 3; |
| 6074 | const_cast<long&>(__cached_size_) = static_cast<long>(off); |
| 6075 | } |
| 6076 | return static_cast<size_t>(__cached_size_); |
| 6077 | } |
| 6078 | virtual char* first_demangled_name(char* buf) const |
| 6079 | { |
| 6080 | buf = __left_->get_demangled_name(buf); |
| 6081 | *buf++ = ' '; |
| 6082 | *buf++ = '('; |
| 6083 | strncpy(buf, __name_, __size_); |
| 6084 | buf += __size_; |
| 6085 | *buf++ = ')'; |
| 6086 | return buf; |
| 6087 | } |
| 6088 | virtual __node* base_name() const |
| 6089 | { |
| 6090 | return __left_->base_name(); |
| 6091 | } |
| 6092 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 6093 | { |
| 6094 | return __left_->fix_forward_references(t_begin, t_end); |
| 6095 | } |
| 6096 | }; |
| 6097 | |
| 6098 | class __vector_type |
| 6099 | : public __node |
| 6100 | { |
| 6101 | public: |
| 6102 | __vector_type(__node* type, const char* num, size_t sz) |
| 6103 | { |
| 6104 | __left_ = type; |
| 6105 | __name_ = num; |
| 6106 | __size_ = sz; |
| 6107 | } |
| 6108 | |
| 6109 | __vector_type(__node* type, __node* num) |
| 6110 | { |
| 6111 | __left_ = type; |
| 6112 | __right_ = num; |
| 6113 | } |
| 6114 | |
| 6115 | virtual size_t first_size() const |
| 6116 | { |
| 6117 | if (__cached_size_ == -1) |
| 6118 | { |
| 6119 | size_t off = 5; |
| 6120 | if (__left_) |
| 6121 | off = __left_->size(); |
| 6122 | off += 9; |
| 6123 | if (__right_) |
| 6124 | off += __right_->size(); |
| 6125 | else if (__size_ > 0) |
| 6126 | off += __size_; |
| 6127 | const_cast<long&>(__cached_size_) = static_cast<long>(off); |
| 6128 | } |
| 6129 | return static_cast<size_t>(__cached_size_); |
| 6130 | } |
| 6131 | virtual char* first_demangled_name(char* buf) const |
| 6132 | { |
| 6133 | if (__left_) |
| 6134 | buf = __left_->get_demangled_name(buf); |
| 6135 | else |
| 6136 | { |
| 6137 | strncpy(buf, "pixel", 5); |
| 6138 | buf += 5; |
| 6139 | } |
| 6140 | strncpy(buf, " vector[", 8); |
| 6141 | buf += 8; |
| 6142 | if (__right_) |
| 6143 | buf = __right_->get_demangled_name(buf); |
| 6144 | else if (__size_ > 0) |
| 6145 | { |
| 6146 | strncpy(buf, __name_, __size_); |
| 6147 | buf += __size_; |
| 6148 | } |
| 6149 | *buf++ = ']'; |
| 6150 | return buf; |
| 6151 | } |
| 6152 | virtual __node* base_name() const |
| 6153 | { |
| 6154 | if (__left_) |
| 6155 | return __left_->base_name(); |
| 6156 | return __left_; |
| 6157 | } |
| 6158 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 6159 | { |
| 6160 | bool r = true; |
| 6161 | if (__left_) |
| 6162 | r = __left_->fix_forward_references(t_begin, t_end); |
| 6163 | if (__right_) |
| 6164 | r = r && __right_->fix_forward_references(t_begin, t_end); |
| 6165 | return r; |
| 6166 | } |
| 6167 | }; |
| 6168 | |
| 6169 | |
| 6170 | enum {invalid_args = -3, invalid_mangled_name, memory_alloc_failure, success, |
| 6171 | not_yet_implemented}; |
| 6172 | |
| 6173 | __demangle_tree::__demangle_tree(const char* mangled_name, char* buf, size_t bs) |
| 6174 | : __mangled_name_begin_(0), __mangled_name_end_(0), |
| 6175 | __status_(invalid_mangled_name), __root_(0), |
| 6176 | __node_begin_(0), __node_end_(0), __node_cap_(0), |
| 6177 | __sub_begin_(0), __sub_end_(0), __sub_cap_(0), |
| 6178 | __t_begin_(0), __t_end_(0), __t_cap_(0), |
| 6179 | __tag_templates_(true), |
| 6180 | __fix_forward_references_(false) |
| 6181 | { |
| 6182 | size_t n = strlen(mangled_name); |
| 6183 | size_t ms = n + 2*n*sizeof(__node) + 2*n*sizeof(__node*); |
| 6184 | char* m; |
| 6185 | if (ms <= bs) |
| 6186 | { |
| 6187 | m = buf; |
| 6188 | __owns_buf_ = false; |
| 6189 | } |
| 6190 | else |
| 6191 | { |
| 6192 | m = static_cast<char*>(malloc(ms)); |
| 6193 | __owns_buf_ = true; |
| 6194 | } |
| 6195 | if (m == NULL) |
| 6196 | { |
| 6197 | __status_ = memory_alloc_failure; |
| 6198 | return; |
| 6199 | } |
| 6200 | __node_begin_ = __node_end_ = (__node*)(m); |
| 6201 | __node_cap_ = __node_begin_ + 2*n; |
| 6202 | __sub_begin_ = __sub_end_ = (__node**)(__node_cap_); |
| 6203 | __sub_cap_ = __sub_begin_ + n; |
| 6204 | __t_begin_ = __t_end_ = (__node**)(__sub_cap_); |
| 6205 | __t_cap_ = __t_begin_ + n; |
| 6206 | __mangled_name_begin_ = (const char*)(__t_cap_); |
| 6207 | __mangled_name_end_ = __mangled_name_begin_ + n; |
| 6208 | strncpy(const_cast<char*>(__mangled_name_begin_), mangled_name, n); |
| 6209 | } |
| 6210 | |
| 6211 | __demangle_tree::~__demangle_tree() |
| 6212 | { |
| 6213 | if (__owns_buf_) |
| 6214 | free(__node_begin_); |
| 6215 | } |
| 6216 | |
| 6217 | __demangle_tree::__demangle_tree(__demangle_tree& t) |
| 6218 | : __mangled_name_begin_(t.__mangled_name_begin_), |
| 6219 | __mangled_name_end_(t.__mangled_name_end_), |
| 6220 | __status_(t.__status_), __root_(t.__root_), |
| 6221 | __node_begin_(t.__node_begin_), __node_end_(t.__node_end_), |
| 6222 | __node_cap_(t.__node_cap_), |
| 6223 | __sub_begin_(t.__sub_begin_), __sub_end_(t.__sub_end_), |
| 6224 | __sub_cap_(t.__sub_cap_), |
| 6225 | __t_begin_(t.__t_begin_), __t_end_(t.__t_end_), |
| 6226 | __t_cap_(t.__t_cap_), |
| 6227 | __tag_templates_(t.__tag_templates_), |
| 6228 | __fix_forward_references_(t.__fix_forward_references_), |
| 6229 | __owns_buf_(t.__owns_buf_) |
| 6230 | { |
| 6231 | t.__mangled_name_begin_ = 0; |
| 6232 | t.__mangled_name_end_ = 0; |
| 6233 | t.__status_ = invalid_mangled_name; |
| 6234 | t.__root_ = 0; |
| 6235 | t.__node_begin_ = t.__node_end_ = t.__node_cap_ = 0; |
| 6236 | t.__sub_begin_ = t.__sub_end_ = t.__sub_cap_ = 0; |
| 6237 | t.__t_begin_ = t.__t_end_ = t.__t_cap_ = 0; |
| 6238 | t.__owns_buf_ = false; |
| 6239 | } |
| 6240 | |
| 6241 | __demangle_tree::__demangle_tree(__demangle_tree_rv rv) |
| 6242 | : __mangled_name_begin_(rv.ptr_->__mangled_name_begin_), |
| 6243 | __mangled_name_end_(rv.ptr_->__mangled_name_end_), |
| 6244 | __status_(rv.ptr_->__status_), __root_(rv.ptr_->__root_), |
| 6245 | __node_begin_(rv.ptr_->__node_begin_), __node_end_(rv.ptr_->__node_end_), |
| 6246 | __node_cap_(rv.ptr_->__node_cap_), |
| 6247 | __sub_begin_(rv.ptr_->__sub_begin_), __sub_end_(rv.ptr_->__sub_end_), |
| 6248 | __sub_cap_(rv.ptr_->__sub_cap_), |
| 6249 | __t_begin_(rv.ptr_->__t_begin_), __t_end_(rv.ptr_->__t_end_), |
| 6250 | __t_cap_(rv.ptr_->__t_cap_), |
| 6251 | __tag_templates_(rv.ptr_->__tag_templates_), |
| 6252 | __fix_forward_references_(rv.ptr_->__fix_forward_references_), |
| 6253 | __owns_buf_(rv.ptr_->__owns_buf_) |
| 6254 | { |
| 6255 | rv.ptr_->__mangled_name_begin_ = 0; |
| 6256 | rv.ptr_->__mangled_name_end_ = 0; |
| 6257 | rv.ptr_->__status_ = invalid_mangled_name; |
| 6258 | rv.ptr_->__root_ = 0; |
| 6259 | rv.ptr_->__node_begin_ = rv.ptr_->__node_end_ = rv.ptr_->__node_cap_ = 0; |
| 6260 | rv.ptr_->__sub_begin_ = rv.ptr_->__sub_end_ = rv.ptr_->__sub_cap_ = 0; |
| 6261 | rv.ptr_->__t_begin_ = rv.ptr_->__t_end_ = rv.ptr_->__t_cap_ = 0; |
| 6262 | rv.ptr_->__owns_buf_ = false; |
| 6263 | } |
| 6264 | |
| 6265 | int |
| 6266 | __demangle_tree::__status() const |
| 6267 | { |
| 6268 | return __status_; |
| 6269 | } |
| 6270 | |
| 6271 | size_t |
| 6272 | __demangle_tree::size() const |
| 6273 | { |
| 6274 | return __status_ == success ? __root_->size() : 0; |
| 6275 | } |
| 6276 | |
| 6277 | char* |
| 6278 | __demangle_tree::__get_demangled_name(char* buf) const |
| 6279 | { |
| 6280 | if (__status_ == success) |
| 6281 | return __root_->get_demangled_name(buf); |
| 6282 | return 0; |
| 6283 | } |
| 6284 | |
| 6285 | template <class _Tp> |
| 6286 | bool |
| 6287 | __demangle_tree::__make() |
| 6288 | { |
| 6289 | if (__node_end_ < __node_cap_) |
| 6290 | { |
| 6291 | ::new (__node_end_) _Tp(); |
| 6292 | __root_ = __node_end_; |
| 6293 | ++__node_end_; |
| 6294 | return true; |
| 6295 | } |
| 6296 | __status_ = memory_alloc_failure; |
| 6297 | return false; |
| 6298 | } |
| 6299 | |
| 6300 | template <class _Tp, class _A0> |
| 6301 | bool |
| 6302 | __demangle_tree::__make(_A0 __a0) |
| 6303 | { |
| 6304 | if (__node_end_ < __node_cap_) |
| 6305 | { |
| 6306 | ::new (__node_end_) _Tp(__a0); |
| 6307 | __root_ = __node_end_; |
| 6308 | ++__node_end_; |
| 6309 | return true; |
| 6310 | } |
| 6311 | __status_ = memory_alloc_failure; |
| 6312 | return false; |
| 6313 | } |
| 6314 | |
| 6315 | template <class _Tp, class _A0, class _A1> |
| 6316 | bool |
| 6317 | __demangle_tree::__make(_A0 __a0, _A1 __a1) |
| 6318 | { |
| 6319 | if (__node_end_ < __node_cap_) |
| 6320 | { |
| 6321 | ::new (__node_end_) _Tp(__a0, __a1); |
| 6322 | __root_ = __node_end_; |
| 6323 | ++__node_end_; |
| 6324 | return true; |
| 6325 | } |
| 6326 | __status_ = memory_alloc_failure; |
| 6327 | return false; |
| 6328 | } |
| 6329 | |
| 6330 | template <class _Tp, class _A0, class _A1, class _A2> |
| 6331 | bool |
| 6332 | __demangle_tree::__make(_A0 __a0, _A1 __a1, _A2 __a2) |
| 6333 | { |
| 6334 | if (__node_end_ < __node_cap_) |
| 6335 | { |
| 6336 | ::new (__node_end_) _Tp(__a0, __a1, __a2); |
| 6337 | __root_ = __node_end_; |
| 6338 | ++__node_end_; |
| 6339 | return true; |
| 6340 | } |
| 6341 | __status_ = memory_alloc_failure; |
| 6342 | return false; |
| 6343 | } |
| 6344 | |
| 6345 | template <class _Tp, class _A0, class _A1, class _A2, class _A3> |
| 6346 | bool |
| 6347 | __demangle_tree::__make(_A0 __a0, _A1 __a1, _A2 __a2, _A3 __a3) |
| 6348 | { |
| 6349 | if (__node_end_ < __node_cap_) |
| 6350 | { |
| 6351 | ::new (__node_end_) _Tp(__a0, __a1, __a2, __a3); |
| 6352 | __root_ = __node_end_; |
| 6353 | ++__node_end_; |
| 6354 | return true; |
| 6355 | } |
| 6356 | __status_ = memory_alloc_failure; |
| 6357 | return false; |
| 6358 | } |
| 6359 | |
| 6360 | template <class _Tp, class _A0, class _A1, class _A2, class _A3, class _A4> |
| 6361 | bool |
| 6362 | __demangle_tree::__make(_A0 __a0, _A1 __a1, _A2 __a2, _A3 __a3, _A4 __a4) |
| 6363 | { |
| 6364 | if (__node_end_ < __node_cap_) |
| 6365 | { |
| 6366 | ::new (__node_end_) _Tp(__a0, __a1, __a2, __a3, __a4); |
| 6367 | __root_ = __node_end_; |
| 6368 | ++__node_end_; |
| 6369 | return true; |
| 6370 | } |
| 6371 | __status_ = memory_alloc_failure; |
| 6372 | return false; |
| 6373 | } |
| 6374 | |
| 6375 | template <class _Tp, class _A0, class _A1, class _A2, class _A3, class _A4, |
| 6376 | class _A5> |
| 6377 | bool |
| 6378 | __demangle_tree::__make(_A0 __a0, _A1 __a1, _A2 __a2, _A3 __a3, _A4 __a4, |
| 6379 | _A5 __a5) |
| 6380 | { |
| 6381 | if (__node_end_ < __node_cap_) |
| 6382 | { |
| 6383 | ::new (__node_end_) _Tp(__a0, __a1, __a2, __a3, __a4, __a5); |
| 6384 | __root_ = __node_end_; |
| 6385 | ++__node_end_; |
| 6386 | return true; |
| 6387 | } |
| 6388 | __status_ = memory_alloc_failure; |
| 6389 | return false; |
| 6390 | } |
| 6391 | |
| 6392 | // <CV-qualifiers> ::= [r] [V] [K] # restrict (C99), volatile, const |
| 6393 | // [R | O] # & or && |
| 6394 | |
| 6395 | const char* |
| 6396 | __demangle_tree::__parse_cv_qualifiers(const char* first, const char* last, |
| 6397 | unsigned& cv, bool look_for_ref_quals) |
| 6398 | { |
| 6399 | if (look_for_ref_quals) |
| 6400 | { |
| 6401 | for (; first != last; ++first) |
| 6402 | { |
| 6403 | switch (*first) |
| 6404 | { |
| 6405 | case 'r': |
| 6406 | cv |= 4; |
| 6407 | break; |
| 6408 | case 'V': |
| 6409 | cv |= 2; |
| 6410 | break; |
| 6411 | case 'K': |
| 6412 | cv |= 1; |
| 6413 | break; |
| 6414 | case 'R': |
| 6415 | cv |= 8; |
| 6416 | break; |
| 6417 | case 'O': |
| 6418 | cv |= 16; |
| 6419 | break; |
| 6420 | default: |
| 6421 | return first; |
| 6422 | } |
| 6423 | } |
| 6424 | } |
| 6425 | else |
| 6426 | { |
| 6427 | for (; first != last; ++first) |
| 6428 | { |
| 6429 | switch (*first) |
| 6430 | { |
| 6431 | case 'r': |
| 6432 | cv |= 4; |
| 6433 | break; |
| 6434 | case 'V': |
| 6435 | cv |= 2; |
| 6436 | break; |
| 6437 | case 'K': |
| 6438 | cv |= 1; |
| 6439 | break; |
| 6440 | default: |
| 6441 | return first; |
| 6442 | } |
| 6443 | } |
| 6444 | } |
| 6445 | return first; |
| 6446 | } |
| 6447 | |
| 6448 | // <builtin-type> ::= v # void |
| 6449 | // ::= w # wchar_t |
| 6450 | // ::= b # bool |
| 6451 | // ::= c # char |
| 6452 | // ::= a # signed char |
| 6453 | // ::= h # unsigned char |
| 6454 | // ::= s # short |
| 6455 | // ::= t # unsigned short |
| 6456 | // ::= i # int |
| 6457 | // ::= j # unsigned int |
| 6458 | // ::= l # long |
| 6459 | // ::= m # unsigned long |
| 6460 | // ::= x # long long, __int64 |
| 6461 | // ::= y # unsigned long long, __int64 |
| 6462 | // ::= n # __int128 |
| 6463 | // ::= o # unsigned __int128 |
| 6464 | // ::= f # float |
| 6465 | // ::= d # double |
| 6466 | // ::= e # long double, __float80 |
| 6467 | // ::= g # __float128 |
| 6468 | // ::= z # ellipsis |
| 6469 | // ::= Dd # IEEE 754r decimal floating point (64 bits) |
| 6470 | // ::= De # IEEE 754r decimal floating point (128 bits) |
| 6471 | // ::= Df # IEEE 754r decimal floating point (32 bits) |
| 6472 | // ::= Dh # IEEE 754r half-precision floating point (16 bits) |
| 6473 | // ::= Di # char32_t |
| 6474 | // ::= Ds # char16_t |
| 6475 | // ::= Da # auto (in dependent new-expressions) |
| 6476 | // ::= Dn # std::nullptr_t (i.e., decltype(nullptr)) |
| 6477 | // ::= u <source-name> # vendor extended type |
| 6478 | |
| 6479 | const char* |
| 6480 | __demangle_tree::__parse_builtin_type(const char* first, const char* last) |
| 6481 | { |
| 6482 | if (first != last) |
| 6483 | { |
| 6484 | switch (*first) |
| 6485 | { |
| 6486 | case 'v': |
| 6487 | if (__make<__void>()) |
| 6488 | ++first; |
| 6489 | break; |
| 6490 | case 'w': |
| 6491 | if (__make<__wchar_t>()) |
| 6492 | ++first; |
| 6493 | break; |
| 6494 | case 'b': |
| 6495 | if (__make<__bool>()) |
| 6496 | ++first; |
| 6497 | break; |
| 6498 | case 'c': |
| 6499 | if (__make<__char>()) |
| 6500 | ++first; |
| 6501 | break; |
| 6502 | case 'a': |
| 6503 | if (__make<__signed_char>()) |
| 6504 | ++first; |
| 6505 | break; |
| 6506 | case 'h': |
| 6507 | if (__make<__unsigned_char>()) |
| 6508 | ++first; |
| 6509 | break; |
| 6510 | case 's': |
| 6511 | if (__make<__short>()) |
| 6512 | ++first; |
| 6513 | break; |
| 6514 | case 't': |
| 6515 | if (__make<__unsigned_short>()) |
| 6516 | ++first; |
| 6517 | break; |
| 6518 | case 'i': |
| 6519 | if (__make<__int>()) |
| 6520 | ++first; |
| 6521 | break; |
| 6522 | case 'j': |
| 6523 | if (__make<__unsigned_int>()) |
| 6524 | ++first; |
| 6525 | break; |
| 6526 | case 'l': |
| 6527 | if (__make<__long>()) |
| 6528 | ++first; |
| 6529 | break; |
| 6530 | case 'm': |
| 6531 | if (__make<__unsigned_long>()) |
| 6532 | ++first; |
| 6533 | break; |
| 6534 | case 'x': |
| 6535 | if (__make<__long_long>()) |
| 6536 | ++first; |
| 6537 | break; |
| 6538 | case 'y': |
| 6539 | if (__make<__unsigned_long_long>()) |
| 6540 | ++first; |
| 6541 | break; |
| 6542 | case 'n': |
| 6543 | if (__make<__signed_int128>()) |
| 6544 | ++first; |
| 6545 | break; |
| 6546 | case 'o': |
| 6547 | if (__make<__unsigned_int128>()) |
| 6548 | ++first; |
| 6549 | break; |
| 6550 | case 'f': |
| 6551 | if (__make<__float>()) |
| 6552 | ++first; |
| 6553 | break; |
| 6554 | case 'd': |
| 6555 | if (__make<__double>()) |
| 6556 | ++first; |
| 6557 | break; |
| 6558 | case 'e': |
| 6559 | if (__make<__long_double>()) |
| 6560 | ++first; |
| 6561 | break; |
| 6562 | case 'g': |
| 6563 | if (__make<__float128>()) |
| 6564 | ++first; |
| 6565 | break; |
| 6566 | case 'z': |
| 6567 | if (__make<__ellipsis>()) |
| 6568 | ++first; |
| 6569 | break; |
| 6570 | case 'D': |
| 6571 | if (first+1 != last) |
| 6572 | { |
| 6573 | switch (first[1]) |
| 6574 | { |
| 6575 | case 'd': |
| 6576 | if (__make<__decimal64>()) |
| 6577 | first += 2; |
| 6578 | break; |
| 6579 | case 'e': |
| 6580 | if (__make<__decimal128>()) |
| 6581 | first += 2; |
| 6582 | break; |
| 6583 | case 'f': |
| 6584 | if (__make<__decimal32>()) |
| 6585 | first += 2; |
| 6586 | break; |
| 6587 | case 'h': |
| 6588 | if (__make<__decimal16>()) |
| 6589 | first += 2; |
| 6590 | break; |
| 6591 | case 'i': |
| 6592 | if (__make<__d_char32_t>()) |
| 6593 | first += 2; |
| 6594 | break; |
| 6595 | case 's': |
| 6596 | if (__make<__d_char16_t>()) |
| 6597 | first += 2; |
| 6598 | break; |
| 6599 | case 'a': |
| 6600 | if (__make<__auto>()) |
| 6601 | first += 2; |
| 6602 | break; |
| 6603 | case 'n': |
| 6604 | if (__make<__nullptr_t>()) |
| 6605 | first += 2; |
| 6606 | break; |
| 6607 | } |
| 6608 | } |
| 6609 | break; |
| 6610 | } |
| 6611 | } |
| 6612 | return first; |
| 6613 | } |
| 6614 | |
| 6615 | // <bare-function-type> ::= <signature type>+ |
| 6616 | // # types are possible return type, then parameter types |
| 6617 | |
| 6618 | const char* |
| 6619 | __demangle_tree::__parse_bare_function_type(const char* first, const char* last) |
| 6620 | { |
| 6621 | if (first != last) |
| 6622 | { |
| 6623 | bool prev_tag_templates = __tag_templates_; |
| 6624 | __tag_templates_ = false; |
| 6625 | const char* t = __parse_type(first, last); |
| 6626 | if (t != first && __make<__list>(__root_)) |
| 6627 | { |
| 6628 | const char* t0 = t; |
| 6629 | __node* head = __root_; |
| 6630 | __node* prev = head; |
| 6631 | while (true) |
| 6632 | { |
| 6633 | t = __parse_type(t0, last); |
| 6634 | if (t != t0) |
| 6635 | { |
| 6636 | if (__make<__list>(__root_)) |
| 6637 | { |
| 6638 | t0 = t; |
| 6639 | prev->__right_ = __root_; |
| 6640 | __root_->__size_ = prev->__size_ + 1; |
| 6641 | prev = __root_; |
| 6642 | } |
| 6643 | else |
| 6644 | break; |
| 6645 | } |
| 6646 | else |
| 6647 | { |
| 6648 | first = t; |
| 6649 | __root_ = head; |
| 6650 | break; |
| 6651 | } |
| 6652 | } |
| 6653 | } |
| 6654 | __tag_templates_ = prev_tag_templates; |
| 6655 | } |
| 6656 | return first; |
| 6657 | } |
| 6658 | |
| 6659 | // <function-type> ::= F [Y] <bare-function-type> E |
| 6660 | |
| 6661 | const char* |
| 6662 | __demangle_tree::__parse_function_type(const char* first, const char* last) |
| 6663 | { |
| 6664 | if (first != last && *first == 'F') |
| 6665 | { |
| 6666 | const char* t = first+1; |
| 6667 | if (t != last) |
| 6668 | { |
| 6669 | bool externC = false; |
| 6670 | if (*t == 'Y') |
| 6671 | { |
| 6672 | externC = true; |
| 6673 | if (++t == last) |
| 6674 | return first; |
| 6675 | } |
| 6676 | const char* t1 = __parse_type(t, last); |
| 6677 | if (t1 != t) |
| 6678 | { |
| 6679 | __node* ret = __root_; |
| 6680 | t = t1; |
| 6681 | t1 = __parse_bare_function_type(t, last); |
| 6682 | if (t1 != t && t1 != last && *t1 == 'E') |
| 6683 | { |
| 6684 | if (dynamic_cast<__void*>(__root_->__left_) != NULL) |
| 6685 | __root_->__left_ = NULL; |
| 6686 | if (__make<__function_signature>(ret, __root_)) |
| 6687 | { |
| 6688 | if (__make<__function>((__node*)0, __root_)) |
| 6689 | first = t1+1; |
| 6690 | } |
| 6691 | } |
| 6692 | } |
| 6693 | } |
| 6694 | } |
| 6695 | return first; |
| 6696 | } |
| 6697 | |
| 6698 | const char* |
| 6699 | __demangle_tree::__parse_hex_number(const char* first, const char* last, unsigned long long& n) |
| 6700 | { |
| 6701 | const char* t = first; |
| 6702 | for (; t != last && isxdigit(*t); ++t) |
| 6703 | { |
| 6704 | if (t == first) |
| 6705 | n = 0; |
| 6706 | if (isdigit(*t)) |
| 6707 | n = n * 16 + static_cast<unsigned long long>(*t - '0'); |
| 6708 | else if (isupper(*t)) |
| 6709 | n = n * 16 + static_cast<unsigned long long>(*t - 'A') + 10; |
| 6710 | else |
| 6711 | n = n * 16 + static_cast<unsigned long long>(*t - 'a') + 10; |
| 6712 | } |
| 6713 | first = t; |
| 6714 | return first; |
| 6715 | } |
| 6716 | |
| 6717 | // <expr-primary> ::= L <type> <value number> E # integer literal |
| 6718 | // ::= L <type> <value float> E # floating literal |
| 6719 | // ::= L <string type> E # string literal |
| 6720 | // ::= L <nullptr type> E # nullptr literal (i.e., "LDnE") |
| 6721 | // ::= L <type> <real-part float> _ <imag-part float> E # complex floating point literal (C 2000) |
| 6722 | // ::= L <mangled-name> E # external name |
| 6723 | |
| 6724 | const char* |
| 6725 | __demangle_tree::__parse_expr_primary(const char* first, const char* last) |
| 6726 | { |
| 6727 | if (last - first >= 4 && *first == 'L') |
| 6728 | { |
| 6729 | switch (first[1]) |
| 6730 | { |
| 6731 | case 'w': |
| 6732 | { |
| 6733 | const char* t = __parse_number(first+2, last); |
| 6734 | if (t != first+2 && t != last && *t == 'E') |
| 6735 | { |
| 6736 | if (__make<__wchar_t_literal>(first+2, t)) |
| 6737 | first = t+1; |
| 6738 | } |
| 6739 | } |
| 6740 | break; |
| 6741 | case 'b': |
| 6742 | if (first[3] == 'E') |
| 6743 | { |
| 6744 | switch (first[2]) |
| 6745 | { |
| 6746 | case '0': |
| 6747 | if (__make<__bool_literal>("false", 5u)) |
| 6748 | first += 4; |
| 6749 | break; |
| 6750 | case '1': |
| 6751 | if (__make<__bool_literal>("true", 4u)) |
| 6752 | first += 4; |
| 6753 | break; |
| 6754 | } |
| 6755 | } |
| 6756 | break; |
| 6757 | case 'c': |
| 6758 | { |
| 6759 | const char* t = __parse_number(first+2, last); |
| 6760 | if (t != first+2 && t != last && *t == 'E') |
| 6761 | { |
| 6762 | if (__make<__char_literal>(first+2, t)) |
| 6763 | first = t+1; |
| 6764 | } |
| 6765 | } |
| 6766 | break; |
| 6767 | case 'a': |
| 6768 | { |
| 6769 | const char* t = __parse_number(first+2, last); |
| 6770 | if (t != first+2 && t != last && *t == 'E') |
| 6771 | { |
| 6772 | if (__make<__signed_char_literal>(first+2, t)) |
| 6773 | first = t+1; |
| 6774 | } |
| 6775 | } |
| 6776 | break; |
| 6777 | case 'h': |
| 6778 | { |
| 6779 | const char* t = __parse_number(first+2, last); |
| 6780 | if (t != first+2 && t != last && *t == 'E') |
| 6781 | { |
| 6782 | if (__make<__unsigned_char_literal>(first+2, t)) |
| 6783 | first = t+1; |
| 6784 | } |
| 6785 | } |
| 6786 | break; |
| 6787 | case 's': |
| 6788 | { |
| 6789 | const char* t = __parse_number(first+2, last); |
| 6790 | if (t != first+2 && t != last && *t == 'E') |
| 6791 | { |
| 6792 | if (__make<__short_literal>(first+2, t)) |
| 6793 | first = t+1; |
| 6794 | } |
| 6795 | } |
| 6796 | break; |
| 6797 | case 't': |
| 6798 | { |
| 6799 | const char* t = __parse_number(first+2, last); |
| 6800 | if (t != first+2 && t != last && *t == 'E') |
| 6801 | { |
| 6802 | if (__make<__unsigned_short_literal>(first+2, t)) |
| 6803 | first = t+1; |
| 6804 | } |
| 6805 | } |
| 6806 | break; |
| 6807 | case 'i': |
| 6808 | { |
| 6809 | const char* t = __parse_number(first+2, last); |
| 6810 | if (t != first+2 && t != last && *t == 'E') |
| 6811 | { |
| 6812 | if (__make<__int_literal>(first+2, t)) |
| 6813 | first = t+1; |
| 6814 | } |
| 6815 | } |
| 6816 | break; |
| 6817 | case 'j': |
| 6818 | { |
| 6819 | const char* t = __parse_number(first+2, last); |
| 6820 | if (t != first+2 && t != last && *t == 'E') |
| 6821 | { |
| 6822 | if (__make<__unsigned_int_literal>(first+2, t)) |
| 6823 | first = t+1; |
| 6824 | } |
| 6825 | } |
| 6826 | break; |
| 6827 | case 'l': |
| 6828 | { |
| 6829 | const char* t = __parse_number(first+2, last); |
| 6830 | if (t != first+2 && t != last && *t == 'E') |
| 6831 | { |
| 6832 | if (__make<__long_literal>(first+2, t)) |
| 6833 | first = t+1; |
| 6834 | } |
| 6835 | } |
| 6836 | break; |
| 6837 | case 'm': |
| 6838 | { |
| 6839 | const char* t = __parse_number(first+2, last); |
| 6840 | if (t != first+2 && t != last && *t == 'E') |
| 6841 | { |
| 6842 | if (__make<__unsigned_long_literal>(first+2, t)) |
| 6843 | first = t+1; |
| 6844 | } |
| 6845 | } |
| 6846 | break; |
| 6847 | case 'x': |
| 6848 | { |
| 6849 | const char* t = __parse_number(first+2, last); |
| 6850 | if (t != first+2 && t != last && *t == 'E') |
| 6851 | { |
| 6852 | if (__make<__long_long_literal>(first+2, t)) |
| 6853 | first = t+1; |
| 6854 | } |
| 6855 | } |
| 6856 | break; |
| 6857 | case 'y': |
| 6858 | { |
| 6859 | const char* t = __parse_number(first+2, last); |
| 6860 | if (t != first+2 && t != last && *t == 'E') |
| 6861 | { |
| 6862 | if (__make<__unsigned_long_long_literal>(first+2, t)) |
| 6863 | first = t+1; |
| 6864 | } |
| 6865 | } |
| 6866 | break; |
| 6867 | case 'n': |
| 6868 | { |
| 6869 | const char* t = __parse_number(first+2, last); |
| 6870 | if (t != first+2 && t != last && *t == 'E') |
| 6871 | { |
| 6872 | if (__make<__int128_literal>(first+2, t)) |
| 6873 | first = t+1; |
| 6874 | } |
| 6875 | } |
| 6876 | break; |
| 6877 | case 'o': |
| 6878 | { |
| 6879 | const char* t = __parse_number(first+2, last); |
| 6880 | if (t != first+2 && t != last && *t == 'E') |
| 6881 | { |
| 6882 | if (__make<__unsigned_int128_literal>(first+2, t)) |
| 6883 | first = t+1; |
| 6884 | } |
| 6885 | } |
| 6886 | break; |
| 6887 | case 'f': |
| 6888 | { |
| 6889 | if (last - (first+2) <= 8) |
| 6890 | return first; |
| 6891 | unsigned long long j; |
| 6892 | const char* t = __parse_hex_number(first+2, first+10, j); |
| 6893 | if (t != first+2 && t != last && *t == 'E') |
| 6894 | { |
| 6895 | unsigned i = static_cast<unsigned>(j); |
| 6896 | float value = *(float*)&i; |
| 6897 | if (__make<__float_literal>(value)) |
| 6898 | first = t+1; |
| 6899 | } |
| 6900 | } |
| 6901 | break; |
| 6902 | case 'd': |
| 6903 | { |
| 6904 | if (last - (first+2) <= 16) |
| 6905 | return first; |
| 6906 | unsigned long long j; |
| 6907 | const char* t = __parse_hex_number(first+2, first+18, j); |
| 6908 | if (t != first+2 && t != last && *t == 'E') |
| 6909 | { |
| 6910 | double value = *(double*)&j; |
| 6911 | if (__make<__double_literal>(value)) |
| 6912 | first = t+1; |
| 6913 | } |
| 6914 | } |
| 6915 | break; |
| 6916 | case 'e': |
| 6917 | break; |
| 6918 | case '_': |
| 6919 | if (first[2] == 'Z') |
| 6920 | { |
| 6921 | const char* t = __parse_encoding(first+3, last); |
| 6922 | if (t != first+3 && t != last && *t == 'E') |
| 6923 | first = t+1; |
| 6924 | } |
| 6925 | break; |
Sean Callanan | 3ba0e14 | 2012-09-14 00:52:49 +0000 | [diff] [blame] | 6926 | case 'T': |
| 6927 | // Invalid mangled name per |
| 6928 | // http://sourcerytools.com/pipermail/cxx-abi-dev/2011-August/002422.html |
| 6929 | break; |
Johnny Chen | 5016669 | 2012-08-04 01:36:57 +0000 | [diff] [blame] | 6930 | default: |
| 6931 | { |
| 6932 | // might be named type |
| 6933 | const char* t = __parse_type(first+1, last); |
| 6934 | if (t != first+1 && t != last) |
| 6935 | { |
| 6936 | if (*t != 'E') |
| 6937 | { |
| 6938 | const char* n = t; |
| 6939 | for (; n != last && isdigit(*n); ++n) |
| 6940 | ; |
| 6941 | if (n != t && n != last && *n == 'E') |
| 6942 | { |
| 6943 | if (__make<__cast_literal>(__root_, t, n)) |
| 6944 | { |
| 6945 | first = n+1; |
| 6946 | break; |
| 6947 | } |
| 6948 | } |
| 6949 | } |
| 6950 | else |
| 6951 | { |
| 6952 | first = t+1; |
| 6953 | break; |
| 6954 | } |
| 6955 | } |
| 6956 | } |
| 6957 | // assert(!"case in __parse_expr_primary not implemented"); |
| 6958 | __status_ = not_yet_implemented; |
| 6959 | } |
| 6960 | } |
| 6961 | return first; |
| 6962 | } |
| 6963 | |
| 6964 | // <unnamed-type-name> ::= Ut [ <nonnegative number> ] _ |
| 6965 | // ::= <closure-type-name> |
| 6966 | // |
| 6967 | // <closure-type-name> ::= Ul <lambda-sig> E [ <nonnegative number> ] _ |
| 6968 | // |
| 6969 | // <lambda-sig> ::= <parameter type>+ # Parameter types or "v" if the lambda has no parameters |
| 6970 | |
| 6971 | const char* |
| 6972 | __demangle_tree::__parse_unnamed_type_name(const char* first, const char* last) |
| 6973 | { |
| 6974 | if (last - first > 2 && first[0] == 'U') |
| 6975 | { |
| 6976 | char type = first[1]; |
| 6977 | switch (type) |
| 6978 | { |
| 6979 | case 't': |
| 6980 | case 'l': |
Greg Clayton | 5292b44 | 2012-12-03 17:50:07 +0000 | [diff] [blame] | 6981 | { |
| 6982 | const char* t = first + 2; |
| 6983 | __node* params = 0; |
Johnny Chen | 5016669 | 2012-08-04 01:36:57 +0000 | [diff] [blame] | 6984 | if (type == 'l') |
| 6985 | { |
Greg Clayton | 5292b44 | 2012-12-03 17:50:07 +0000 | [diff] [blame] | 6986 | if (*t == 'v') |
Johnny Chen | 5016669 | 2012-08-04 01:36:57 +0000 | [diff] [blame] | 6987 | { |
| 6988 | // void lambda |
Greg Clayton | 5292b44 | 2012-12-03 17:50:07 +0000 | [diff] [blame] | 6989 | ++t; |
| 6990 | if (t != last && *t == 'E') |
| 6991 | ++t; |
Johnny Chen | 5016669 | 2012-08-04 01:36:57 +0000 | [diff] [blame] | 6992 | else |
| 6993 | return first; |
| 6994 | } |
| 6995 | else |
| 6996 | { |
Greg Clayton | 5292b44 | 2012-12-03 17:50:07 +0000 | [diff] [blame] | 6997 | const char* t1 = __parse_type(t, last); |
| 6998 | if (t1 == t || !__make<__list>(__root_)) |
Johnny Chen | 5016669 | 2012-08-04 01:36:57 +0000 | [diff] [blame] | 6999 | return first; |
Greg Clayton | 5292b44 | 2012-12-03 17:50:07 +0000 | [diff] [blame] | 7000 | params = __root_; |
| 7001 | __node* prev = params; |
| 7002 | t = t1; |
| 7003 | while (true) |
| 7004 | { |
| 7005 | t1 = __parse_type(t, last); |
| 7006 | if (t1 == t) |
| 7007 | break; |
| 7008 | if (!__make<__list>(__root_)) |
| 7009 | return first; |
| 7010 | t = t1; |
| 7011 | prev->__right_ = __root_; |
| 7012 | __root_->__size_ = prev->__size_ + 1; |
| 7013 | prev = __root_; |
| 7014 | } |
| 7015 | if (t == last || *t != 'E') |
| 7016 | return first; |
| 7017 | ++t; |
Johnny Chen | 5016669 | 2012-08-04 01:36:57 +0000 | [diff] [blame] | 7018 | } |
| 7019 | } |
Greg Clayton | 5292b44 | 2012-12-03 17:50:07 +0000 | [diff] [blame] | 7020 | const char* number_start = t; |
| 7021 | const char* number_end = __parse_number(t, last); |
| 7022 | if (number_end == last || *number_end != '_') |
| 7023 | return first; |
| 7024 | t = number_end + 1; |
| 7025 | if (type == 'l') |
Johnny Chen | 5016669 | 2012-08-04 01:36:57 +0000 | [diff] [blame] | 7026 | { |
Daniel Malea | 81b78ca | 2012-12-06 16:52:09 +0000 | [diff] [blame] | 7027 | if (!__make<___lambda_node>(params, number_start, static_cast<size_t>(number_end - number_start))) |
Greg Clayton | 5292b44 | 2012-12-03 17:50:07 +0000 | [diff] [blame] | 7028 | return first; |
Johnny Chen | 5016669 | 2012-08-04 01:36:57 +0000 | [diff] [blame] | 7029 | } |
| 7030 | else |
Greg Clayton | 5292b44 | 2012-12-03 17:50:07 +0000 | [diff] [blame] | 7031 | { |
| 7032 | if (!__make<__unnamed>(number_start, static_cast<size_t>(number_end - number_start))) |
| 7033 | return first; |
| 7034 | } |
| 7035 | first = t; |
| 7036 | } |
Johnny Chen | 5016669 | 2012-08-04 01:36:57 +0000 | [diff] [blame] | 7037 | break; |
| 7038 | } |
| 7039 | } |
| 7040 | return first; |
| 7041 | } |
| 7042 | |
| 7043 | // <ctor-dtor-name> ::= C1 # complete object constructor |
| 7044 | // ::= C2 # base object constructor |
| 7045 | // ::= C3 # complete object allocating constructor |
| 7046 | // ::= D0 # deleting destructor |
| 7047 | // ::= D1 # complete object destructor |
| 7048 | // ::= D2 # base object destructor |
| 7049 | |
| 7050 | const char* |
| 7051 | __demangle_tree::__parse_ctor_dtor_name(const char* first, const char* last) |
| 7052 | { |
| 7053 | if (last-first >= 2 && __root_) |
| 7054 | { |
| 7055 | switch (first[0]) |
| 7056 | { |
| 7057 | case 'C': |
| 7058 | switch (first[1]) |
| 7059 | { |
| 7060 | case '1': |
| 7061 | case '2': |
| 7062 | case '3': |
| 7063 | if (__make<__constructor>(__root_->base_name())) |
| 7064 | first += 2; |
| 7065 | break; |
| 7066 | } |
| 7067 | break; |
| 7068 | case 'D': |
| 7069 | switch (first[1]) |
| 7070 | { |
| 7071 | case '0': |
| 7072 | case '1': |
| 7073 | case '2': |
| 7074 | if (__make<__destructor>(__root_->base_name())) |
| 7075 | first += 2; |
| 7076 | break; |
| 7077 | } |
| 7078 | break; |
| 7079 | } |
| 7080 | } |
| 7081 | return first; |
| 7082 | } |
| 7083 | |
| 7084 | const char* |
| 7085 | __demangle_tree::__parse_unscoped_template_name(const char* first, const char*) |
| 7086 | { |
| 7087 | // assert(!"__parse_unscoped_template_name not implemented"); |
| 7088 | __status_ = not_yet_implemented; |
| 7089 | return first; |
| 7090 | } |
| 7091 | |
| 7092 | // <discriminator> := _ <non-negative number> # when number < 10 |
| 7093 | // := __ <non-negative number> _ # when number >= 10 |
| 7094 | // extension := decimal-digit+ |
| 7095 | |
| 7096 | const char* |
| 7097 | __demangle_tree::__parse_discriminator(const char* first, const char* last) |
| 7098 | { |
| 7099 | // parse but ignore discriminator |
| 7100 | if (first != last) |
| 7101 | { |
| 7102 | if (*first == '_') |
| 7103 | { |
| 7104 | const char* t1 = first+1; |
| 7105 | if (t1 != last) |
| 7106 | { |
| 7107 | if (isdigit(*t1)) |
| 7108 | first = t1+1; |
| 7109 | else if (*t1 == '_') |
| 7110 | { |
| 7111 | for (++t1; t1 != last && isdigit(*t1); ++t1) |
| 7112 | ; |
| 7113 | if (t1 != last && *t1 == '_') |
| 7114 | first = t1 + 1; |
| 7115 | } |
| 7116 | } |
| 7117 | } |
| 7118 | else if (isdigit(*first)) |
| 7119 | { |
| 7120 | const char* t1 = first+1; |
| 7121 | for (; t1 != last && isdigit(*t1); ++t1) |
| 7122 | ; |
| 7123 | first = t1; |
| 7124 | } |
| 7125 | } |
| 7126 | return first; |
| 7127 | } |
| 7128 | |
| 7129 | // <local-name> := Z <function encoding> E <entity name> [<discriminator>] |
| 7130 | // := Z <function encoding> E s [<discriminator>] |
| 7131 | // := Z <function encoding> Ed [ <parameter number> ] _ <entity name> |
| 7132 | |
| 7133 | const char* |
| 7134 | __demangle_tree::__parse_local_name(const char* first, const char* last) |
| 7135 | { |
| 7136 | if (first != last && *first == 'Z') |
| 7137 | { |
| 7138 | const char* t = __parse_encoding(first+1, last); |
| 7139 | if (t != first+1 && t != last && *t == 'E' && ++t != last) |
| 7140 | { |
| 7141 | __node* encoding = __root_; |
| 7142 | switch (*t) |
| 7143 | { |
| 7144 | case 's': |
| 7145 | { |
| 7146 | const char*t1 = __parse_discriminator(t+1, last); |
| 7147 | if (__make<__string_literal>()) |
| 7148 | { |
| 7149 | if (__make<__nested_delimeter>(encoding, __root_)) |
| 7150 | first = t1; |
| 7151 | } |
| 7152 | } |
| 7153 | break; |
| 7154 | case 'd': |
| 7155 | // assert(!"__parse_local_name d not implemented"); |
| 7156 | __status_ = not_yet_implemented; |
| 7157 | break; |
| 7158 | default: |
| 7159 | { |
| 7160 | const char*t1 = __parse_name(t, last); |
| 7161 | if (t1 != t) |
| 7162 | { |
| 7163 | // parse but ignore discriminator |
| 7164 | t1 = __parse_discriminator(t1, last); |
| 7165 | if (__make<__nested_delimeter>(encoding, __root_)) |
| 7166 | first = t1; |
| 7167 | } |
| 7168 | } |
| 7169 | break; |
| 7170 | } |
| 7171 | } |
| 7172 | } |
| 7173 | return first; |
| 7174 | } |
| 7175 | |
| 7176 | // <destructor-name> ::= <unresolved-type> # e.g., ~T or ~decltype(f()) |
| 7177 | // ::= <simple-id> # e.g., ~A<2*N> |
| 7178 | |
| 7179 | const char* |
| 7180 | __demangle_tree::__parse_destructor_name(const char* first, const char* last) |
| 7181 | { |
| 7182 | if (first != last) |
| 7183 | { |
| 7184 | const char* t = __parse_unresolved_type(first, last); |
| 7185 | if (t == first) |
| 7186 | t = __parse_simple_id(first, last); |
| 7187 | if (t != first && __make<__destructor>(__root_)) |
| 7188 | first = t; |
| 7189 | } |
| 7190 | return first; |
| 7191 | } |
| 7192 | |
| 7193 | // <simple-id> ::= <source-name> [ <template-args> ] |
| 7194 | |
| 7195 | const char* |
| 7196 | __demangle_tree::__parse_simple_id(const char* first, const char* last) |
| 7197 | { |
| 7198 | if (first != last) |
| 7199 | { |
| 7200 | const char* t = __parse_source_name(first, last); |
| 7201 | if (t != first) |
| 7202 | first = __parse_template_args(t, last); |
| 7203 | else |
| 7204 | first = t; |
| 7205 | } |
| 7206 | return first; |
| 7207 | } |
| 7208 | |
| 7209 | // <base-unresolved-name> ::= <simple-id> # unresolved name |
| 7210 | // extension ::= <operator-name> # unresolved operator-function-id |
| 7211 | // extension ::= <operator-name> <template-args> # unresolved operator template-id |
| 7212 | // ::= on <operator-name> # unresolved operator-function-id |
| 7213 | // ::= on <operator-name> <template-args> # unresolved operator template-id |
| 7214 | // ::= dn <destructor-name> # destructor or pseudo-destructor; |
| 7215 | // # e.g. ~X or ~X<N-1> |
| 7216 | |
| 7217 | const char* |
| 7218 | __demangle_tree::__parse_base_unresolved_name(const char* first, const char* last) |
| 7219 | { |
| 7220 | if (last - first >= 2) |
| 7221 | { |
| 7222 | if ((first[0] == 'o' || first[0] == 'd') && first[1] == 'n') |
| 7223 | { |
| 7224 | if (first[0] == 'o') |
| 7225 | { |
| 7226 | const char* t = __parse_operator_name(first+2, last); |
| 7227 | if (t != first+2) |
| 7228 | first = __parse_template_args(t, last); |
| 7229 | else |
| 7230 | first = t; |
| 7231 | } |
| 7232 | else |
| 7233 | { |
| 7234 | const char* t = __parse_destructor_name(first+2, last); |
| 7235 | if (t != first+2) |
| 7236 | first = t; |
| 7237 | } |
| 7238 | } |
| 7239 | else |
| 7240 | { |
| 7241 | const char* t = __parse_simple_id(first, last); |
| 7242 | if (t == first) |
| 7243 | { |
| 7244 | t = __parse_operator_name(first, last); |
| 7245 | if (t != first) |
| 7246 | t = __parse_template_args(t, last); |
| 7247 | } |
| 7248 | if (t != first) |
| 7249 | first = t; |
| 7250 | } |
| 7251 | } |
| 7252 | return first; |
| 7253 | } |
| 7254 | |
| 7255 | // <unresolved-type> ::= <template-param> |
| 7256 | // ::= <decltype> |
| 7257 | // ::= <substitution> |
| 7258 | |
| 7259 | const char* |
| 7260 | __demangle_tree::__parse_unresolved_type(const char* first, const char* last) |
| 7261 | { |
| 7262 | if (first != last) |
| 7263 | { |
| 7264 | const char* t; |
| 7265 | switch (*first) |
| 7266 | { |
| 7267 | case 'T': |
| 7268 | t = __parse_template_param(first, last); |
| 7269 | if (t != first) |
| 7270 | { |
| 7271 | if (__sub_end_ == __sub_cap_) |
| 7272 | __status_ = memory_alloc_failure; |
| 7273 | else |
| 7274 | { |
| 7275 | *__sub_end_++ = __root_; |
| 7276 | first = t; |
| 7277 | } |
| 7278 | } |
| 7279 | break; |
| 7280 | case 'D': |
| 7281 | t = __parse_decltype(first, last); |
| 7282 | if (t != first) |
| 7283 | { |
| 7284 | if (__sub_end_ == __sub_cap_) |
| 7285 | __status_ = memory_alloc_failure; |
| 7286 | else |
| 7287 | { |
| 7288 | *__sub_end_++ = __root_; |
| 7289 | first = t; |
| 7290 | } |
| 7291 | } |
| 7292 | break; |
| 7293 | case 'S': |
| 7294 | t = __parse_substitution(first, last); |
| 7295 | if (t != first) |
| 7296 | first = t; |
| 7297 | break; |
| 7298 | } |
| 7299 | } |
| 7300 | return first; |
| 7301 | } |
| 7302 | |
| 7303 | // <unresolved-qualifier-level> ::= <source-name> [ <template-args> ] |
| 7304 | |
| 7305 | const char* |
| 7306 | __demangle_tree::__parse_unresolved_qualifier_level(const char* first, const char* last) |
| 7307 | { |
| 7308 | if (first != last) |
| 7309 | { |
| 7310 | const char* t = __parse_source_name(first, last); |
| 7311 | if (t != first) |
| 7312 | first = __parse_template_args(t, last); |
| 7313 | } |
| 7314 | return first; |
| 7315 | } |
| 7316 | |
| 7317 | // <unresolved-name> |
| 7318 | // extension ::= srN <unresolved-type> [<template-args>] <unresolved-qualifier-level>* E <base-unresolved-name> |
| 7319 | // ::= [gs] <base-unresolved-name> # x or (with "gs") ::x |
| 7320 | // ::= [gs] sr <unresolved-qualifier-level>+ E <base-unresolved-name> |
| 7321 | // # A::x, N::y, A<T>::z; "gs" means leading "::" |
| 7322 | // ::= sr <unresolved-type> <base-unresolved-name> # T::x / decltype(p)::x |
| 7323 | // # T::N::x /decltype(p)::N::x |
| 7324 | // (ignored) ::= srN <unresolved-type> <unresolved-qualifier-level>+ E <base-unresolved-name> |
| 7325 | |
| 7326 | const char* |
| 7327 | __demangle_tree::__parse_unresolved_name(const char* first, const char* last) |
| 7328 | { |
| 7329 | if (last - first > 2) |
| 7330 | { |
| 7331 | const char* t = first; |
| 7332 | bool global = false; |
| 7333 | if (t[0] == 'g' && t[1] == 's') |
| 7334 | { |
| 7335 | global = true; |
| 7336 | t += 2; |
| 7337 | } |
| 7338 | const char* t2 = __parse_base_unresolved_name(t, last); |
| 7339 | if (t2 != t) |
| 7340 | { |
| 7341 | if (__make<__unresolved_name>(global, (__node*)0, __root_)) |
| 7342 | first = t2; |
| 7343 | } |
| 7344 | else if (last - t > 2 && t[0] == 's' && t[1] == 'r') |
| 7345 | { |
| 7346 | if (!global && t[2] == 'N') |
| 7347 | { |
| 7348 | t2 = __parse_unresolved_type(t+3, last); |
| 7349 | if (t2 != t+3 && t2 != last) |
| 7350 | { |
| 7351 | t = __parse_template_args(t2, last); |
| 7352 | if (t == last) |
| 7353 | return first; |
| 7354 | __node* name = __root_; |
| 7355 | while (*t != 'E') |
| 7356 | { |
| 7357 | t2 = __parse_unresolved_qualifier_level(t, last); |
| 7358 | if (t2 == t || t2 == last) |
| 7359 | return first; |
| 7360 | if (!__make<__nested_delimeter>(name, __root_)) |
| 7361 | return first; |
| 7362 | name = __root_; |
| 7363 | t = t2; |
| 7364 | } |
| 7365 | t2 = __parse_base_unresolved_name(++t, last); |
| 7366 | if (t2 != t && __make<__unresolved_name>(false, name, __root_)) |
| 7367 | first = t2; |
| 7368 | } |
| 7369 | } |
| 7370 | else |
| 7371 | { |
| 7372 | if (!global) |
| 7373 | { |
| 7374 | t2 = __parse_unresolved_type(t+2, last); |
| 7375 | if (t2 != t+2) |
| 7376 | { |
| 7377 | t = t2; |
| 7378 | __node* name = __root_; |
| 7379 | t2 = __parse_base_unresolved_name(t, last); |
| 7380 | if (t2 != t && __make<__unresolved_name>(false, name, __root_)) |
| 7381 | return t2; |
| 7382 | return first; |
| 7383 | } |
| 7384 | } |
| 7385 | t2 = __parse_unresolved_qualifier_level(t+2, last); |
| 7386 | if (t2 != t+2 && t2 != last) |
| 7387 | { |
| 7388 | __node* name = __root_; |
| 7389 | t = t2; |
| 7390 | while (*t != 'E') |
| 7391 | { |
| 7392 | t2 = __parse_unresolved_qualifier_level(t, last); |
| 7393 | if (t2 == t || t2 == last) |
| 7394 | return first; |
| 7395 | if (!__make<__nested_delimeter>(name, __root_)) |
| 7396 | return first; |
| 7397 | name = __root_; |
| 7398 | t = t2; |
| 7399 | } |
| 7400 | t2 = __parse_base_unresolved_name(++t, last); |
| 7401 | if (t2 != t && __make<__unresolved_name>(global, name, __root_)) |
| 7402 | first = t2; |
| 7403 | } |
| 7404 | } |
| 7405 | } |
| 7406 | } |
| 7407 | return first; |
| 7408 | } |
| 7409 | |
| 7410 | // <function-param> ::= fp <top-level CV-qualifiers> _ # L == 0, first parameter |
| 7411 | // ::= fp <top-level CV-qualifiers> <parameter-2 non-negative number> _ # L == 0, second and later parameters |
| 7412 | // ::= fL <L-1 non-negative number> p <top-level CV-qualifiers> _ # L > 0, first parameter |
| 7413 | // ::= fL <L-1 non-negative number> p <top-level CV-qualifiers> |
| 7414 | |
| 7415 | const char* |
| 7416 | __demangle_tree::__parse_function_param(const char* first, const char* last) |
| 7417 | { |
| 7418 | if (last - first >= 3 && *first == 'f') |
| 7419 | { |
| 7420 | if (first[1] == 'p') |
| 7421 | { |
| 7422 | // assert(!"__parse_function_param not implemented"); |
| 7423 | __status_ = not_yet_implemented; |
| 7424 | } |
| 7425 | else if (first[1] == 'L') |
| 7426 | { |
| 7427 | // assert(!"__parse_function_param not implemented"); |
| 7428 | __status_ = not_yet_implemented; |
| 7429 | } |
| 7430 | } |
| 7431 | return first; |
| 7432 | } |
| 7433 | |
| 7434 | // at <type> # alignof (a type) |
| 7435 | |
| 7436 | const char* |
| 7437 | __demangle_tree::__parse_alignof_expr(const char* first, const char* last) |
| 7438 | { |
| 7439 | if (last - first >= 3 && first[0] == 'a' && first[1] == 't') |
| 7440 | { |
| 7441 | const char* t = __parse_type(first+2, last); |
| 7442 | if (t != first+2) |
| 7443 | { |
| 7444 | if (__make<__operator_alignof_expression>(__root_)) |
| 7445 | first = t; |
| 7446 | } |
| 7447 | } |
| 7448 | return first; |
| 7449 | } |
| 7450 | |
| 7451 | // cc <type> <expression> # const_cast<type> (expression) |
| 7452 | |
| 7453 | const char* |
| 7454 | __demangle_tree::__parse_const_cast_expr(const char* first, const char* last) |
| 7455 | { |
| 7456 | if (last - first >= 3 && first[0] == 'c' && first[1] == 'c') |
| 7457 | { |
| 7458 | const char* t = __parse_type(first+2, last); |
| 7459 | if (t != first+2) |
| 7460 | { |
| 7461 | __node* type = __root_; |
| 7462 | const char* t1 = __parse_expression(t, last); |
| 7463 | if (t1 != t) |
| 7464 | { |
| 7465 | if (__make<__const_cast>(type, __root_)) |
| 7466 | first = t1; |
| 7467 | } |
| 7468 | } |
| 7469 | } |
| 7470 | return first; |
| 7471 | } |
| 7472 | |
| 7473 | // cl <expression>+ E # call |
| 7474 | |
| 7475 | const char* |
| 7476 | __demangle_tree::__parse_call_expr(const char* first, const char* last) |
| 7477 | { |
| 7478 | if (last - first >= 4 && first[0] == 'c' && first[1] == 'l') |
| 7479 | { |
| 7480 | const char* t = __parse_expression(first+2, last); |
| 7481 | if (t != first+2) |
| 7482 | { |
| 7483 | if (t == last) |
| 7484 | return first; |
| 7485 | __node* name = __root_; |
| 7486 | __node* args = 0; |
| 7487 | __node* prev = 0; |
| 7488 | while (*t != 'E') |
| 7489 | { |
| 7490 | const char* t1 = __parse_expression(t, last); |
| 7491 | if (t1 == t || t1 == last) |
| 7492 | return first; |
| 7493 | if (!__make<__list>(__root_)) |
| 7494 | return first; |
| 7495 | if (args == 0) |
| 7496 | args = __root_; |
| 7497 | if (prev) |
| 7498 | { |
| 7499 | prev->__right_ = __root_; |
| 7500 | __root_->__size_ = prev->__size_ + 1; |
| 7501 | } |
| 7502 | prev = __root_; |
| 7503 | t = t1; |
| 7504 | } |
| 7505 | ++t; |
| 7506 | if (__make<__call_expr>(name, args)) |
| 7507 | first = t; |
| 7508 | } |
| 7509 | } |
| 7510 | return first; |
| 7511 | } |
| 7512 | |
| 7513 | // cv <type> <expression> # conversion with one argument |
| 7514 | // cv <type> _ <expression>* E # conversion with a different number of arguments |
| 7515 | |
| 7516 | const char* |
| 7517 | __demangle_tree::__parse_conversion_expr(const char* first, const char* last) |
| 7518 | { |
| 7519 | if (last - first >= 3 && first[0] == 'c' && first[1] == 'v') |
| 7520 | { |
| 7521 | const char* t = __parse_type(first+2, last); |
| 7522 | if (t != first+2 && t != last) |
| 7523 | { |
| 7524 | __node* type = __root_; |
| 7525 | __node* args = 0; |
| 7526 | if (*t != '_') |
| 7527 | { |
| 7528 | const char* t1 = __parse_expression(t, last); |
| 7529 | if (t1 == t) |
| 7530 | return first; |
| 7531 | args = __root_; |
| 7532 | t = t1; |
| 7533 | } |
| 7534 | else |
| 7535 | { |
| 7536 | ++t; |
| 7537 | if (t == last) |
| 7538 | return first; |
| 7539 | __node* prev = 0; |
| 7540 | while (*t != 'E') |
| 7541 | { |
| 7542 | const char* t1 = __parse_expression(t, last); |
| 7543 | if (t1 == t || t1 == last) |
| 7544 | return first; |
| 7545 | if (!__make<__list>(__root_)) |
| 7546 | return first; |
| 7547 | if (args == 0) |
| 7548 | args = __root_; |
| 7549 | if (prev) |
| 7550 | { |
| 7551 | prev->__right_ = __root_; |
| 7552 | __root_->__size_ = prev->__size_ + 1; |
| 7553 | } |
| 7554 | prev = __root_; |
| 7555 | t = t1; |
| 7556 | } |
| 7557 | ++t; |
| 7558 | } |
| 7559 | if (__make<__operator_cast>(type, args)) |
| 7560 | first = t; |
| 7561 | } |
| 7562 | } |
| 7563 | return first; |
| 7564 | } |
| 7565 | |
| 7566 | // [gs] da <expression> # delete[] expression |
| 7567 | |
| 7568 | const char* |
| 7569 | __demangle_tree::__parse_delete_array_expr(const char* first, const char* last) |
| 7570 | { |
| 7571 | if (last - first >= 4) |
| 7572 | { |
| 7573 | const char* t = first; |
| 7574 | bool parsed_gs = false; |
| 7575 | if (t[0] == 'g' && t[1] == 's') |
| 7576 | { |
| 7577 | t += 2; |
| 7578 | parsed_gs = true; |
| 7579 | } |
| 7580 | if (t[0] == 'd' && t[1] == 'a') |
| 7581 | { |
| 7582 | t += 2; |
| 7583 | const char* t1 = __parse_expression(t, last); |
| 7584 | if (t1 != t) |
| 7585 | { |
| 7586 | if (__make<__delete_array_expr>(parsed_gs, __root_)) |
| 7587 | first = t1; |
| 7588 | } |
| 7589 | } |
| 7590 | } |
| 7591 | return first; |
| 7592 | } |
| 7593 | |
| 7594 | // dc <type> <expression> # dynamic_cast<type> (expression) |
| 7595 | |
| 7596 | const char* |
| 7597 | __demangle_tree::__parse_dynamic_cast_expr(const char* first, const char* last) |
| 7598 | { |
| 7599 | if (last - first >= 3 && first[0] == 'd' && first[1] == 'c') |
| 7600 | { |
| 7601 | const char* t = __parse_type(first+2, last); |
| 7602 | if (t != first+2) |
| 7603 | { |
| 7604 | __node* type = __root_; |
| 7605 | const char* t1 = __parse_expression(t, last); |
| 7606 | if (t1 != t) |
| 7607 | { |
| 7608 | if (__make<__dynamic_cast>(type, __root_)) |
| 7609 | first = t1; |
| 7610 | } |
| 7611 | } |
| 7612 | } |
| 7613 | return first; |
| 7614 | } |
| 7615 | |
| 7616 | // [gs] dl <expression> # delete expression |
| 7617 | |
| 7618 | const char* |
| 7619 | __demangle_tree::__parse_delete_expr(const char* first, const char* last) |
| 7620 | { |
| 7621 | if (last - first >= 4) |
| 7622 | { |
| 7623 | const char* t = first; |
| 7624 | bool parsed_gs = false; |
| 7625 | if (t[0] == 'g' && t[1] == 's') |
| 7626 | { |
| 7627 | t += 2; |
| 7628 | parsed_gs = true; |
| 7629 | } |
| 7630 | if (t[0] == 'd' && t[1] == 'l') |
| 7631 | { |
| 7632 | t += 2; |
| 7633 | const char* t1 = __parse_expression(t, last); |
| 7634 | if (t1 != t) |
| 7635 | { |
| 7636 | if (__make<__delete_expr>(parsed_gs, __root_)) |
| 7637 | first = t1; |
| 7638 | } |
| 7639 | } |
| 7640 | } |
| 7641 | return first; |
| 7642 | } |
| 7643 | |
| 7644 | // ds <expression> <expression> # expr.*expr |
| 7645 | |
| 7646 | const char* |
| 7647 | __demangle_tree::__parse_dot_star_expr(const char* first, const char* last) |
| 7648 | { |
| 7649 | if (last - first >= 3 && first[0] == 'd' && first[1] == 's') |
| 7650 | { |
| 7651 | const char* t = __parse_expression(first+2, last); |
| 7652 | if (t != first+2) |
| 7653 | { |
| 7654 | __node* expr = __root_; |
| 7655 | const char* t1 = __parse_expression(t, last); |
| 7656 | if (t1 != t) |
| 7657 | { |
| 7658 | if (__make<__dot_star_expr>(expr, __root_)) |
| 7659 | first = t1; |
| 7660 | } |
| 7661 | } |
| 7662 | } |
| 7663 | return first; |
| 7664 | } |
| 7665 | |
| 7666 | // dt <expression> <unresolved-name> # expr.name |
| 7667 | |
| 7668 | const char* |
| 7669 | __demangle_tree::__parse_dot_expr(const char* first, const char* last) |
| 7670 | { |
| 7671 | if (last - first >= 3 && first[0] == 'd' && first[1] == 't') |
| 7672 | { |
| 7673 | const char* t = __parse_expression(first+2, last); |
| 7674 | if (t != first+2) |
| 7675 | { |
| 7676 | __node* expr = __root_; |
| 7677 | const char* t1 = __parse_unresolved_name(t, last); |
| 7678 | if (t1 != t) |
| 7679 | { |
| 7680 | if (__make<__dot_expr>(expr, __root_)) |
| 7681 | first = t1; |
| 7682 | } |
| 7683 | } |
| 7684 | } |
| 7685 | return first; |
| 7686 | } |
| 7687 | |
| 7688 | // mm_ <expression> # prefix -- |
| 7689 | |
| 7690 | const char* |
| 7691 | __demangle_tree::__parse_decrement_expr(const char* first, const char* last) |
| 7692 | { |
| 7693 | if (last - first > 3 && first[0] == 'm' && first[1] == 'm' && first[2] == '_') |
| 7694 | { |
| 7695 | const char* t = __parse_expression(first+3, last); |
| 7696 | if (t != first+3) |
| 7697 | { |
| 7698 | if (__make<__operator_decrement>(true, __root_)) |
| 7699 | first = t; |
| 7700 | } |
| 7701 | } |
| 7702 | return first; |
| 7703 | } |
| 7704 | |
| 7705 | // pp_ <expression> # prefix ++ |
| 7706 | |
| 7707 | const char* |
| 7708 | __demangle_tree::__parse_increment_expr(const char* first, const char* last) |
| 7709 | { |
| 7710 | if (last - first > 3 && first[0] == 'p' && first[1] == 'p' && first[2] == '_') |
| 7711 | { |
| 7712 | const char* t = __parse_expression(first+3, last); |
| 7713 | if (t != first+3) |
| 7714 | { |
| 7715 | if (__make<__operator_increment>(true, __root_)) |
| 7716 | first = t; |
| 7717 | } |
| 7718 | } |
| 7719 | return first; |
| 7720 | } |
| 7721 | |
| 7722 | // [gs] nw <expression>* _ <type> E # new (expr-list) type |
| 7723 | // [gs] nw <expression>* _ <type> <initializer> # new (expr-list) type (init) |
| 7724 | // [gs] na <expression>* _ <type> E # new[] (expr-list) type |
| 7725 | // [gs] na <expression>* _ <type> <initializer> # new[] (expr-list) type (init) |
| 7726 | // <initializer> ::= pi <expression>* E # parenthesized initialization |
| 7727 | |
| 7728 | const char* |
| 7729 | __demangle_tree::__parse_new_expr(const char* first, const char* last) |
| 7730 | { |
| 7731 | if (last - first >= 4) |
| 7732 | { |
| 7733 | const char* t = first; |
| 7734 | bool parsed_gs = false; |
| 7735 | if (t[0] == 'g' && t[1] == 's') |
| 7736 | { |
| 7737 | t += 2; |
| 7738 | parsed_gs = true; |
| 7739 | } |
| 7740 | if (t[0] == 'n' && (t[1] == 'w' || t[1] == 'a')) |
| 7741 | { |
| 7742 | bool is_array = t[1] == 'a'; |
| 7743 | t += 2; |
| 7744 | if (t == last) |
| 7745 | return first; |
| 7746 | __node* expr = 0; |
| 7747 | __node* prev = 0; |
| 7748 | while (*t != '_') |
| 7749 | { |
| 7750 | const char* t1 = __parse_expression(t, last); |
| 7751 | if (t1 == t || t1 == last) |
| 7752 | return first; |
| 7753 | if (!__make<__list>(__root_)) |
| 7754 | return first; |
| 7755 | if (expr == 0) |
| 7756 | expr = __root_; |
| 7757 | if (prev) |
| 7758 | { |
| 7759 | prev->__right_ = __root_; |
| 7760 | __root_->__size_ = prev->__size_ + 1; |
| 7761 | } |
| 7762 | prev = __root_; |
| 7763 | t = t1; |
| 7764 | } |
| 7765 | ++t; |
| 7766 | const char* t1 = __parse_type(t, last); |
| 7767 | if (t1 == t || t1 == last) |
| 7768 | return first; |
| 7769 | t = t1; |
| 7770 | __node* type = __root_; |
| 7771 | __node* init = 0; |
| 7772 | prev = 0; |
| 7773 | bool has_init = false; |
| 7774 | if (last - t >= 3 && t[0] == 'p' && t[1] == 'i') |
| 7775 | { |
| 7776 | t += 2; |
| 7777 | has_init = true; |
| 7778 | while (*t != 'E') |
| 7779 | { |
| 7780 | t1 = __parse_expression(t, last); |
| 7781 | if (t1 == t || t1 == last) |
| 7782 | return first; |
| 7783 | if (!__make<__list>(__root_)) |
| 7784 | return first; |
| 7785 | if (init == 0) |
| 7786 | init = __root_; |
| 7787 | if (prev) |
| 7788 | { |
| 7789 | prev->__right_ = __root_; |
| 7790 | __root_->__size_ = prev->__size_ + 1; |
| 7791 | } |
| 7792 | prev = __root_; |
| 7793 | t = t1; |
| 7794 | } |
| 7795 | } |
| 7796 | if (*t != 'E') |
| 7797 | return first; |
| 7798 | if (__make<__new_expr>(parsed_gs, is_array, has_init, |
| 7799 | expr, type, init)) |
| 7800 | first = t; |
| 7801 | } |
| 7802 | } |
| 7803 | return first; |
| 7804 | } |
| 7805 | |
| 7806 | // pt <expression> <unresolved-name> # expr->name |
| 7807 | |
| 7808 | const char* |
| 7809 | __demangle_tree::__parse_arrow_expr(const char* first, const char* last) |
| 7810 | { |
| 7811 | if (last - first >= 3 && first[0] == 'p' && first[1] == 't') |
| 7812 | { |
| 7813 | const char* t = __parse_expression(first+2, last); |
| 7814 | if (t != first+2) |
| 7815 | { |
| 7816 | __node* expr = __root_; |
| 7817 | const char* t1 = __parse_unresolved_name(t, last); |
| 7818 | if (t1 != t) |
| 7819 | { |
| 7820 | if (__make<__arrow_expr>(expr, __root_)) |
| 7821 | first = t1; |
| 7822 | } |
| 7823 | } |
| 7824 | } |
| 7825 | return first; |
| 7826 | } |
| 7827 | |
| 7828 | // rc <type> <expression> # reinterpret_cast<type> (expression) |
| 7829 | |
| 7830 | const char* |
| 7831 | __demangle_tree::__parse_reinterpret_cast_expr(const char* first, const char* last) |
| 7832 | { |
| 7833 | if (last - first >= 3 && first[0] == 'r' && first[1] == 'c') |
| 7834 | { |
| 7835 | const char* t = __parse_type(first+2, last); |
| 7836 | if (t != first+2) |
| 7837 | { |
| 7838 | __node* type = __root_; |
| 7839 | const char* t1 = __parse_expression(t, last); |
| 7840 | if (t1 != t) |
| 7841 | { |
| 7842 | if (__make<__reinterpret_cast>(type, __root_)) |
| 7843 | first = t1; |
| 7844 | } |
| 7845 | } |
| 7846 | } |
| 7847 | return first; |
| 7848 | } |
| 7849 | |
| 7850 | // sc <type> <expression> # static_cast<type> (expression) |
| 7851 | |
| 7852 | const char* |
| 7853 | __demangle_tree::__parse_static_cast_expr(const char* first, const char* last) |
| 7854 | { |
| 7855 | if (last - first >= 3 && first[0] == 's' && first[1] == 'c') |
| 7856 | { |
| 7857 | const char* t = __parse_type(first+2, last); |
| 7858 | if (t != first+2) |
| 7859 | { |
| 7860 | __node* type = __root_; |
| 7861 | const char* t1 = __parse_expression(t, last); |
| 7862 | if (t1 != t) |
| 7863 | { |
| 7864 | if (__make<__static_cast>(type, __root_)) |
| 7865 | first = t1; |
| 7866 | } |
| 7867 | } |
| 7868 | } |
| 7869 | return first; |
| 7870 | } |
| 7871 | |
| 7872 | // st <type> # sizeof (a type) |
| 7873 | |
| 7874 | const char* |
| 7875 | __demangle_tree::__parse_sizeof_type_expr(const char* first, const char* last) |
| 7876 | { |
| 7877 | if (last - first >= 3 && first[0] == 's' && first[1] == 't') |
| 7878 | { |
| 7879 | const char* t = __parse_type(first+2, last); |
| 7880 | if (t != first+2) |
| 7881 | { |
| 7882 | if (__make<__operator_sizeof_expression>(__root_)) |
| 7883 | first = t; |
| 7884 | } |
| 7885 | } |
| 7886 | return first; |
| 7887 | } |
| 7888 | |
| 7889 | // sZ <template-param> # size of a parameter pack |
| 7890 | |
| 7891 | const char* |
| 7892 | __demangle_tree::__parse_sizeof_param_pack_expr(const char* first, const char* last) |
| 7893 | { |
| 7894 | if (last - first >= 3 && first[0] == 's' && first[1] == 'Z' && first[2] == 'T') |
| 7895 | { |
| 7896 | const char* t = __parse_template_param(first+2, last); |
| 7897 | if (t != first+2) |
| 7898 | { |
| 7899 | if (__make<__operator_sizeof_param_pack>(__root_)) |
| 7900 | first = t; |
| 7901 | } |
| 7902 | } |
| 7903 | return first; |
| 7904 | } |
| 7905 | |
| 7906 | // sZ <function-param> # size of a function parameter pack |
| 7907 | |
| 7908 | const char* |
| 7909 | __demangle_tree::__parse_sizeof_function_param_pack_expr(const char* first, const char* last) |
| 7910 | { |
| 7911 | if (last - first >= 3 && first[0] == 's' && first[1] == 'Z' && first[2] == 'f') |
| 7912 | { |
| 7913 | const char* t = __parse_function_param(first+2, last); |
| 7914 | if (t != first+2) |
| 7915 | { |
| 7916 | if (__make<__operator_sizeof_param_pack>(__root_)) |
| 7917 | first = t; |
| 7918 | } |
| 7919 | } |
| 7920 | return first; |
| 7921 | } |
| 7922 | |
| 7923 | // sp <expression> # pack expansion |
| 7924 | |
| 7925 | const char* |
| 7926 | __demangle_tree::__parse_pack_expansion(const char* first, const char* last) |
| 7927 | { |
| 7928 | if (last - first >= 3 && first[0] == 's' && first[1] == 'p') |
| 7929 | { |
| 7930 | const char* t = __parse_expression(first+2, last); |
| 7931 | if (t != first+2) |
| 7932 | { |
| 7933 | if (__make<__pack_expansion>(__root_)) |
| 7934 | first = t; |
| 7935 | } |
| 7936 | } |
| 7937 | return first; |
| 7938 | } |
| 7939 | |
| 7940 | // te <expression> # typeid (expression) |
| 7941 | // ti <type> # typeid (type) |
| 7942 | |
| 7943 | const char* |
| 7944 | __demangle_tree::__parse_typeid_expr(const char* first, const char* last) |
| 7945 | { |
| 7946 | if (last - first >= 3 && first[0] == 't' && (first[1] == 'e' || first[1] == 'i')) |
| 7947 | { |
| 7948 | const char* t; |
| 7949 | if (first[1] == 'e') |
| 7950 | t = __parse_expression(first+2, last); |
| 7951 | else |
| 7952 | t = __parse_type(first+2, last); |
| 7953 | if (t != first+2) |
| 7954 | { |
| 7955 | if (__make<__typeid>(__root_)) |
| 7956 | first = t; |
| 7957 | } |
| 7958 | } |
| 7959 | return first; |
| 7960 | } |
| 7961 | |
| 7962 | // tw <expression> # throw expression |
| 7963 | |
| 7964 | const char* |
| 7965 | __demangle_tree::__parse_throw_expr(const char* first, const char* last) |
| 7966 | { |
| 7967 | if (last - first >= 3 && first[0] == 't' && first[1] == 'w') |
| 7968 | { |
| 7969 | const char* t = __parse_expression(first+2, last); |
| 7970 | if (t != first+2) |
| 7971 | { |
| 7972 | if (__make<__throw>(__root_)) |
| 7973 | first = t; |
| 7974 | } |
| 7975 | } |
| 7976 | return first; |
| 7977 | } |
| 7978 | |
| 7979 | // <expression> ::= <unary operator-name> <expression> |
| 7980 | // ::= <binary operator-name> <expression> <expression> |
| 7981 | // ::= <ternary operator-name> <expression> <expression> <expression> |
| 7982 | // ::= cl <expression>+ E # call |
| 7983 | // ::= cv <type> <expression> # conversion with one argument |
| 7984 | // ::= cv <type> _ <expression>* E # conversion with a different number of arguments |
| 7985 | // ::= [gs] nw <expression>* _ <type> E # new (expr-list) type |
| 7986 | // ::= [gs] nw <expression>* _ <type> <initializer> # new (expr-list) type (init) |
| 7987 | // ::= [gs] na <expression>* _ <type> E # new[] (expr-list) type |
| 7988 | // ::= [gs] na <expression>* _ <type> <initializer> # new[] (expr-list) type (init) |
| 7989 | // ::= [gs] dl <expression> # delete expression |
| 7990 | // ::= [gs] da <expression> # delete[] expression |
| 7991 | // ::= pp_ <expression> # prefix ++ |
| 7992 | // ::= mm_ <expression> # prefix -- |
| 7993 | // ::= ti <type> # typeid (type) |
| 7994 | // ::= te <expression> # typeid (expression) |
| 7995 | // ::= dc <type> <expression> # dynamic_cast<type> (expression) |
| 7996 | // ::= sc <type> <expression> # static_cast<type> (expression) |
| 7997 | // ::= cc <type> <expression> # const_cast<type> (expression) |
| 7998 | // ::= rc <type> <expression> # reinterpret_cast<type> (expression) |
| 7999 | // ::= st <type> # sizeof (a type) |
| 8000 | // ::= at <type> # alignof (a type) |
| 8001 | // ::= <template-param> |
| 8002 | // ::= <function-param> |
| 8003 | // ::= dt <expression> <unresolved-name> # expr.name |
| 8004 | // ::= pt <expression> <unresolved-name> # expr->name |
| 8005 | // ::= ds <expression> <expression> # expr.*expr |
| 8006 | // ::= sZ <template-param> # size of a parameter pack |
| 8007 | // ::= sZ <function-param> # size of a function parameter pack |
| 8008 | // ::= sp <expression> # pack expansion |
| 8009 | // ::= tw <expression> # throw expression |
| 8010 | // ::= tr # throw with no operand (rethrow) |
| 8011 | // ::= <unresolved-name> # f(p), N::f(p), ::f(p), |
| 8012 | // # freestanding dependent name (e.g., T::x), |
| 8013 | // # objectless nonstatic member reference |
| 8014 | // ::= <expr-primary> |
| 8015 | |
| 8016 | const char* |
| 8017 | __demangle_tree::__parse_expression(const char* first, const char* last) |
| 8018 | { |
| 8019 | if (last - first >= 2) |
| 8020 | { |
| 8021 | const char* t = first; |
| 8022 | bool parsed_gs = false; |
| 8023 | if (last - first >= 4 && t[0] == 'g' && t[1] == 's') |
| 8024 | { |
| 8025 | t += 2; |
| 8026 | parsed_gs = true; |
| 8027 | } |
| 8028 | switch (*t) |
| 8029 | { |
| 8030 | case 'L': |
| 8031 | t = __parse_expr_primary(first, last); |
| 8032 | break; |
| 8033 | case 'T': |
| 8034 | t = __parse_template_param(first, last); |
| 8035 | break; |
| 8036 | case 'f': |
| 8037 | t = __parse_function_param(first, last); |
| 8038 | break; |
| 8039 | case 'a': |
| 8040 | if (t[1] == 't') |
| 8041 | t = __parse_alignof_expr(first, last); |
| 8042 | break; |
| 8043 | case 'c': |
| 8044 | switch (t[1]) |
| 8045 | { |
| 8046 | case 'c': |
| 8047 | t = __parse_const_cast_expr(first, last); |
| 8048 | break; |
| 8049 | case 'l': |
| 8050 | t = __parse_call_expr(first, last); |
| 8051 | break; |
| 8052 | case 'v': |
| 8053 | t = __parse_conversion_expr(first, last); |
| 8054 | break; |
| 8055 | } |
| 8056 | break; |
| 8057 | case 'd': |
| 8058 | switch (t[1]) |
| 8059 | { |
| 8060 | case 'a': |
| 8061 | t = __parse_delete_array_expr(first, last); |
| 8062 | break; |
| 8063 | case 'c': |
| 8064 | t = __parse_dynamic_cast_expr(first, last); |
| 8065 | break; |
| 8066 | case 'l': |
| 8067 | t = __parse_delete_expr(first, last); |
| 8068 | break; |
| 8069 | case 's': |
| 8070 | t = __parse_dot_star_expr(first, last); |
| 8071 | break; |
| 8072 | case 't': |
| 8073 | t = __parse_dot_expr(first, last); |
| 8074 | break; |
| 8075 | } |
| 8076 | break; |
| 8077 | case 'm': |
| 8078 | t = __parse_decrement_expr(first, last); |
| 8079 | break; |
| 8080 | case 'n': |
| 8081 | switch (t[1]) |
| 8082 | { |
| 8083 | case 'a': |
| 8084 | case 'w': |
| 8085 | t = __parse_new_expr(first, last); |
| 8086 | break; |
| 8087 | } |
| 8088 | break; |
| 8089 | case 'p': |
| 8090 | switch (t[1]) |
| 8091 | { |
| 8092 | case 'p': |
| 8093 | t = __parse_increment_expr(first, last); |
| 8094 | break; |
| 8095 | case 't': |
| 8096 | t = __parse_arrow_expr(first, last); |
| 8097 | break; |
| 8098 | } |
| 8099 | break; |
| 8100 | case 'r': |
| 8101 | t = __parse_reinterpret_cast_expr(first, last); |
| 8102 | break; |
| 8103 | case 's': |
| 8104 | switch (t[1]) |
| 8105 | { |
| 8106 | case 'c': |
| 8107 | t = __parse_static_cast_expr(first, last); |
| 8108 | break; |
| 8109 | case 'p': |
| 8110 | t = __parse_pack_expansion(first, last); |
| 8111 | break; |
| 8112 | case 't': |
| 8113 | t = __parse_sizeof_type_expr(first, last); |
| 8114 | break; |
| 8115 | case 'Z': |
| 8116 | if (last - t >= 3) |
| 8117 | { |
| 8118 | switch (t[2]) |
| 8119 | { |
| 8120 | case 'T': |
| 8121 | t = __parse_sizeof_param_pack_expr(first, last); |
| 8122 | break; |
| 8123 | case 'f': |
| 8124 | t = __parse_sizeof_function_param_pack_expr(first, last); |
| 8125 | break; |
| 8126 | } |
| 8127 | } |
| 8128 | break; |
| 8129 | } |
| 8130 | break; |
| 8131 | case 't': |
| 8132 | switch (t[1]) |
| 8133 | { |
| 8134 | case 'e': |
| 8135 | case 'i': |
| 8136 | t = __parse_typeid_expr(first, last); |
| 8137 | break; |
| 8138 | case 'r': |
| 8139 | if (__make<__rethrow>()) |
| 8140 | t = first +2; |
| 8141 | break; |
| 8142 | case 'w': |
| 8143 | t = __parse_throw_expr(first, last); |
| 8144 | break; |
| 8145 | } |
| 8146 | break; |
| 8147 | } |
| 8148 | if ((!parsed_gs && t == first) || (parsed_gs && t == first+2)) |
| 8149 | { |
| 8150 | int op; |
| 8151 | t = __parse_operator_name(first, last, &op); |
| 8152 | if (t == first) |
| 8153 | first = __parse_unresolved_name(first, last); |
| 8154 | else |
| 8155 | first = t; |
| 8156 | } |
| 8157 | else |
| 8158 | first = t; |
| 8159 | } |
| 8160 | return first; |
| 8161 | } |
| 8162 | |
| 8163 | // <array-type> ::= A <positive dimension number> _ <element type> |
| 8164 | // ::= A [<dimension expression>] _ <element type> |
| 8165 | |
| 8166 | const char* |
| 8167 | __demangle_tree::__parse_array_type(const char* first, const char* last) |
| 8168 | { |
| 8169 | if (first != last && *first == 'A' && first+1 != last) |
| 8170 | { |
| 8171 | if (first[1] == '_') |
| 8172 | { |
| 8173 | const char* t = __parse_type(first+2, last); |
| 8174 | if (t != first+2) |
| 8175 | { |
| 8176 | if (__make<__array>(__root_)) |
| 8177 | first = t; |
| 8178 | } |
| 8179 | } |
| 8180 | else if ('1' <= first[1] && first[1] <= '9') |
| 8181 | { |
| 8182 | size_t dim = static_cast<size_t>(first[1] - '0'); |
| 8183 | const char* t = first+2; |
| 8184 | for (; t != last && isdigit(*t); ++t) |
| 8185 | dim = dim * 10 + static_cast<size_t>(*t - '0'); |
| 8186 | if (t != last && *t == '_') |
| 8187 | { |
| 8188 | const char* t2 = __parse_type(t+1, last); |
| 8189 | if (t2 != t+1) |
| 8190 | { |
| 8191 | if (__make<__array>(__root_, dim)) |
| 8192 | first = t2; |
| 8193 | } |
| 8194 | } |
| 8195 | } |
| 8196 | else |
| 8197 | { |
| 8198 | const char* t = __parse_expression(first+1, last); |
| 8199 | if (t != first+1 && t != last && *t == '_') |
| 8200 | { |
| 8201 | __node* dim = __root_; |
| 8202 | const char* t2 = __parse_type(++t, last); |
| 8203 | if (t2 != t) |
| 8204 | { |
| 8205 | if (__make<__array>(__root_, dim)) |
| 8206 | first = t2; |
| 8207 | } |
| 8208 | } |
| 8209 | } |
| 8210 | } |
| 8211 | return first; |
| 8212 | } |
| 8213 | |
| 8214 | // <class-enum-type> ::= <name> |
| 8215 | |
| 8216 | const char* |
| 8217 | __demangle_tree::__parse_class_enum_type(const char* first, const char* last) |
| 8218 | { |
| 8219 | return __parse_name(first, last); |
| 8220 | } |
| 8221 | |
| 8222 | // <pointer-to-member-type> ::= M <class type> <member type> |
| 8223 | |
| 8224 | const char* |
| 8225 | __demangle_tree::__parse_pointer_to_member_type(const char* first, const char* last) |
| 8226 | { |
| 8227 | if (first != last && *first == 'M') |
| 8228 | { |
| 8229 | const char* t = __parse_type(first+1, last); |
| 8230 | if (t != first+1) |
| 8231 | { |
| 8232 | __node* class_type = __root_; |
| 8233 | const char* t2 = __parse_type(t, last, true, true); |
| 8234 | if (t2 != t) |
| 8235 | { |
| 8236 | if (__make<__pointer_to_member_type>(class_type, __root_)) |
| 8237 | first = t2; |
| 8238 | } |
| 8239 | } |
| 8240 | } |
| 8241 | return first; |
| 8242 | } |
| 8243 | |
| 8244 | // <decltype> ::= Dt <expression> E # decltype of an id-expression or class member access (C++0x) |
| 8245 | // ::= DT <expression> E # decltype of an expression (C++0x) |
| 8246 | |
| 8247 | const char* |
| 8248 | __demangle_tree::__parse_decltype(const char* first, const char* last) |
| 8249 | { |
| 8250 | if (last - first >= 4 && first[0] == 'D') |
| 8251 | { |
| 8252 | switch (first[1]) |
| 8253 | { |
| 8254 | case 't': |
| 8255 | case 'T': |
| 8256 | { |
| 8257 | const char* t = __parse_expression(first+2, last); |
| 8258 | if (t != first+2 && t != last && *t == 'E') |
| 8259 | { |
| 8260 | if (__make<__decltype_node>(__root_)) |
| 8261 | first = t+1; |
| 8262 | } |
| 8263 | } |
| 8264 | break; |
| 8265 | } |
| 8266 | } |
| 8267 | return first; |
| 8268 | } |
| 8269 | |
| 8270 | // <template-param> ::= T_ # first template parameter |
| 8271 | // ::= T <parameter-2 non-negative number> _ |
| 8272 | |
| 8273 | const char* |
| 8274 | __demangle_tree::__parse_template_param(const char* first, const char* last) |
| 8275 | { |
| 8276 | if (last - first >= 2) |
| 8277 | { |
| 8278 | if (*first == 'T') |
| 8279 | { |
| 8280 | if (first[1] == '_') |
| 8281 | { |
| 8282 | if (__t_begin_ != __t_end_) |
| 8283 | { |
| 8284 | if (__make<__sub>(*__t_begin_)) |
| 8285 | first += 2; |
| 8286 | } |
| 8287 | else |
| 8288 | { |
| 8289 | if (__make<__sub>(size_t(0))) |
| 8290 | { |
| 8291 | first += 2; |
| 8292 | __fix_forward_references_ = true; |
| 8293 | } |
| 8294 | } |
| 8295 | } |
| 8296 | else if (isdigit(first[1])) |
| 8297 | { |
| 8298 | const char* t = first+1; |
| 8299 | size_t sub = static_cast<size_t>(*t - '0'); |
| 8300 | for (++t; t != last && isdigit(*t); ++t) |
| 8301 | { |
| 8302 | sub *= 10; |
| 8303 | sub += static_cast<size_t>(*t - '0'); |
| 8304 | } |
| 8305 | if (t == last || *t != '_') |
| 8306 | return first; |
| 8307 | ++sub; |
| 8308 | if (sub < static_cast<size_t>(__t_end_ - __t_begin_)) |
| 8309 | { |
| 8310 | if (__make<__sub>(__t_begin_[sub])) |
| 8311 | first = t+1; |
| 8312 | } |
| 8313 | else |
| 8314 | { |
| 8315 | if (__make<__sub>(sub)) |
| 8316 | { |
| 8317 | first = t+1; |
| 8318 | __fix_forward_references_ = true; |
| 8319 | } |
| 8320 | } |
| 8321 | } |
| 8322 | } |
| 8323 | } |
| 8324 | return first; |
| 8325 | } |
| 8326 | |
| 8327 | // extension: |
| 8328 | // <vector-type> ::= Dv <positive dimension number> _ |
| 8329 | // <extended element type> |
| 8330 | // ::= Dv [<dimension expression>] _ <element type> |
| 8331 | // <extended element type> ::= <element type> |
| 8332 | // ::= p # AltiVec vector pixel |
| 8333 | |
| 8334 | const char* |
| 8335 | __demangle_tree::__parse_vector_type(const char* first, const char* last) |
| 8336 | { |
| 8337 | if (last - first > 3 && first[0] == 'D' && first[1] == 'v') |
| 8338 | { |
| 8339 | if ('1' <= first[2] && first[2] <= '9') |
| 8340 | { |
| 8341 | const char* t = first+3; |
| 8342 | while (*t != '_') |
| 8343 | { |
| 8344 | if (!isdigit(*t) || ++t == last) |
| 8345 | return first; |
| 8346 | } |
| 8347 | const char* num = first + 2; |
| 8348 | size_t sz = static_cast<size_t>(t - num); |
| 8349 | if (++t != last) |
| 8350 | { |
| 8351 | if (*t != 'p') |
| 8352 | { |
| 8353 | const char* t1 = __parse_type(t, last); |
| 8354 | if (t1 != t) |
| 8355 | { |
| 8356 | if (__make<__vector_type>(__root_, num, sz)) |
| 8357 | first = t1; |
| 8358 | } |
| 8359 | } |
| 8360 | else |
| 8361 | { |
| 8362 | ++t; |
| 8363 | if (__make<__vector_type>((__node*)0, num, sz)) |
| 8364 | first = t; |
| 8365 | } |
| 8366 | } |
| 8367 | } |
| 8368 | else |
| 8369 | { |
| 8370 | __node* num = 0; |
| 8371 | const char* t1 = first+2; |
| 8372 | if (*t1 != '_') |
| 8373 | { |
| 8374 | const char* t = __parse_expression(t1, last); |
| 8375 | if (t != t1) |
| 8376 | num = __root_; |
| 8377 | t1 = t; |
| 8378 | } |
| 8379 | if (t1 != last && *t1 == '_' && ++t1 != last) |
| 8380 | { |
| 8381 | const char* t = __parse_type(t1, last); |
| 8382 | if (t != t1) |
| 8383 | { |
| 8384 | if (__make<__vector_type>(__root_, num)) |
| 8385 | first = t; |
| 8386 | } |
| 8387 | } |
| 8388 | } |
| 8389 | } |
| 8390 | return first; |
| 8391 | } |
| 8392 | |
| 8393 | // <type> ::= <builtin-type> |
| 8394 | // ::= <function-type> |
| 8395 | // ::= <class-enum-type> |
| 8396 | // ::= <array-type> |
| 8397 | // ::= <pointer-to-member-type> |
| 8398 | // ::= <template-param> |
| 8399 | // ::= <template-template-param> <template-args> |
| 8400 | // ::= <decltype> |
| 8401 | // ::= <substitution> |
| 8402 | // ::= <CV-qualifiers> <type> |
| 8403 | // ::= P <type> # pointer-to |
| 8404 | // ::= R <type> # reference-to |
| 8405 | // ::= O <type> # rvalue reference-to (C++0x) |
| 8406 | // ::= C <type> # complex pair (C 2000) |
| 8407 | // ::= G <type> # imaginary (C 2000) |
| 8408 | // ::= Dp <type> # pack expansion (C++0x) |
| 8409 | // ::= U <source-name> <type> # vendor extended type qualifier |
| 8410 | // extension := <vector-type> # <vector-type> starts with Dv |
| 8411 | |
| 8412 | const char* |
| 8413 | __demangle_tree::__parse_type(const char* first, const char* last, |
| 8414 | bool try_to_parse_template_args, |
| 8415 | bool look_for_ref_quals) |
| 8416 | { |
| 8417 | unsigned cv = 0; |
| 8418 | const char* t = __parse_cv_qualifiers(first, last, cv, look_for_ref_quals); |
| 8419 | if (t != first) |
| 8420 | { |
| 8421 | const char* t2 = __parse_type(t, last, try_to_parse_template_args); |
| 8422 | if (t2 != t) |
| 8423 | { |
| 8424 | if (__make<__cv_qualifiers>(cv, __root_)) |
| 8425 | { |
| 8426 | if (__sub_end_ == __sub_cap_) |
| 8427 | __status_ = memory_alloc_failure; |
| 8428 | else |
| 8429 | { |
| 8430 | *__sub_end_++ = __root_; |
| 8431 | first = t2; |
| 8432 | } |
| 8433 | } |
| 8434 | } |
| 8435 | return first; |
| 8436 | } |
| 8437 | if (first != last) |
| 8438 | { |
| 8439 | switch (*first) |
| 8440 | { |
| 8441 | case 'A': |
| 8442 | t = __parse_array_type(first, last); |
| 8443 | if (t != first) |
| 8444 | { |
| 8445 | if (__sub_end_ == __sub_cap_) |
| 8446 | __status_ = memory_alloc_failure; |
| 8447 | else |
| 8448 | { |
| 8449 | *__sub_end_++ = __root_; |
| 8450 | first = t; |
| 8451 | } |
| 8452 | } |
| 8453 | break; |
| 8454 | case 'C': |
| 8455 | t = __parse_type(first+1, last, try_to_parse_template_args); |
| 8456 | if (t != first+1) |
| 8457 | { |
| 8458 | if (__make<__d_complex>(__root_)) |
| 8459 | { |
| 8460 | if (__sub_end_ == __sub_cap_) |
| 8461 | __status_ = memory_alloc_failure; |
| 8462 | else |
| 8463 | { |
| 8464 | *__sub_end_++ = __root_; |
| 8465 | first = t; |
| 8466 | } |
| 8467 | } |
| 8468 | return first; |
| 8469 | } |
| 8470 | break; |
| 8471 | case 'F': |
| 8472 | t = __parse_function_type(first, last); |
| 8473 | if (t != first) |
| 8474 | { |
| 8475 | if (__sub_end_ == __sub_cap_) |
| 8476 | __status_ = memory_alloc_failure; |
| 8477 | else |
| 8478 | { |
| 8479 | *__sub_end_++ = __root_; |
| 8480 | first = t; |
| 8481 | } |
| 8482 | } |
| 8483 | break; |
| 8484 | case 'G': |
| 8485 | t = __parse_type(first+1, last, try_to_parse_template_args); |
| 8486 | if (t != first+1) |
| 8487 | { |
| 8488 | if (__make<__imaginary>(__root_)) |
| 8489 | { |
| 8490 | if (__sub_end_ == __sub_cap_) |
| 8491 | __status_ = memory_alloc_failure; |
| 8492 | else |
| 8493 | { |
| 8494 | *__sub_end_++ = __root_; |
| 8495 | first = t; |
| 8496 | } |
| 8497 | } |
| 8498 | return first; |
| 8499 | } |
| 8500 | break; |
| 8501 | case 'M': |
| 8502 | t = __parse_pointer_to_member_type(first, last); |
| 8503 | if (t != first) |
| 8504 | { |
| 8505 | if (__sub_end_ == __sub_cap_) |
| 8506 | __status_ = memory_alloc_failure; |
| 8507 | else |
| 8508 | { |
| 8509 | *__sub_end_++ = __root_; |
| 8510 | first = t; |
| 8511 | } |
| 8512 | } |
| 8513 | break; |
| 8514 | case 'O': |
| 8515 | t = __parse_type(first+1, last, try_to_parse_template_args); |
| 8516 | if (t != first+1) |
| 8517 | { |
| 8518 | if (__make<__rvalue_reference_to>(__root_)) |
| 8519 | { |
| 8520 | if (__sub_end_ == __sub_cap_) |
| 8521 | __status_ = memory_alloc_failure; |
| 8522 | else |
| 8523 | { |
| 8524 | *__sub_end_++ = __root_; |
| 8525 | first = t; |
| 8526 | } |
| 8527 | } |
| 8528 | return first; |
| 8529 | } |
| 8530 | break; |
| 8531 | case 'P': |
| 8532 | t = __parse_type(first+1, last, try_to_parse_template_args); |
| 8533 | if (t != first+1) |
| 8534 | { |
| 8535 | if (__make<__pointer_to>(__root_)) |
| 8536 | { |
| 8537 | if (__sub_end_ == __sub_cap_) |
| 8538 | __status_ = memory_alloc_failure; |
| 8539 | else |
| 8540 | { |
| 8541 | *__sub_end_++ = __root_; |
| 8542 | first = t; |
| 8543 | } |
| 8544 | } |
| 8545 | return first; |
| 8546 | } |
| 8547 | break; |
| 8548 | case 'R': |
| 8549 | t = __parse_type(first+1, last, try_to_parse_template_args); |
| 8550 | if (t != first+1) |
| 8551 | { |
| 8552 | if (__make<__lvalue_reference_to>(__root_)) |
| 8553 | { |
| 8554 | if (__sub_end_ == __sub_cap_) |
| 8555 | __status_ = memory_alloc_failure; |
| 8556 | else |
| 8557 | { |
| 8558 | *__sub_end_++ = __root_; |
| 8559 | first = t; |
| 8560 | } |
| 8561 | } |
| 8562 | return first; |
| 8563 | } |
| 8564 | break; |
| 8565 | case 'T': |
| 8566 | t = __parse_template_param(first, last); |
| 8567 | if (t != first) |
| 8568 | { |
| 8569 | if (__sub_end_ == __sub_cap_) |
| 8570 | __status_ = memory_alloc_failure; |
| 8571 | else |
| 8572 | { |
| 8573 | *__sub_end_++ = __root_; |
| 8574 | if (try_to_parse_template_args) |
| 8575 | { |
| 8576 | const char* t2 = __parse_template_args(t, last); |
| 8577 | if (t2 != t) |
| 8578 | { |
| 8579 | if (__sub_end_ < __sub_cap_) |
| 8580 | { |
| 8581 | *__sub_end_++ = __root_; |
| 8582 | first = t2; |
| 8583 | } |
| 8584 | else |
| 8585 | __status_ = memory_alloc_failure; |
| 8586 | } |
| 8587 | else |
| 8588 | { |
| 8589 | first = t; |
| 8590 | } |
| 8591 | } |
| 8592 | else |
| 8593 | { |
| 8594 | first = t; |
| 8595 | } |
| 8596 | } |
| 8597 | } |
| 8598 | break; |
| 8599 | case 'U': |
| 8600 | if (first+1 != last) |
| 8601 | { |
| 8602 | t = __parse_source_name(first+1, last); |
| 8603 | if (t != first+1) |
| 8604 | { |
| 8605 | __node* name = __root_; |
| 8606 | const char* t2 = __parse_type(t, last, try_to_parse_template_args); |
| 8607 | if (t2 != t) |
| 8608 | { |
| 8609 | if (__make<__extended_qualifier>(name, __root_)) |
| 8610 | { |
| 8611 | if (__sub_end_ == __sub_cap_) |
| 8612 | __status_ = memory_alloc_failure; |
| 8613 | else |
| 8614 | { |
| 8615 | *__sub_end_++ = __root_; |
| 8616 | first = t2; |
| 8617 | } |
| 8618 | } |
| 8619 | return first; |
| 8620 | } |
| 8621 | } |
| 8622 | } |
| 8623 | break; |
| 8624 | case 'S': |
| 8625 | if (first+1 != last && first[1] == 't') |
| 8626 | { |
| 8627 | t = __parse_class_enum_type(first, last); |
| 8628 | if (t != first) |
| 8629 | { |
| 8630 | if (__sub_end_ == __sub_cap_) |
| 8631 | __status_ = memory_alloc_failure; |
| 8632 | else |
| 8633 | { |
| 8634 | *__sub_end_++ = __root_; |
| 8635 | first = t; |
| 8636 | } |
| 8637 | } |
| 8638 | } |
| 8639 | else |
| 8640 | { |
| 8641 | t = __parse_substitution(first, last); |
| 8642 | if (t != first) |
| 8643 | { |
| 8644 | first = t; |
| 8645 | // Parsed a substitution. If the substitution is a |
| 8646 | // <template-param> it might be followed by <template-args>. |
| 8647 | t = __parse_template_args(first, last); |
| 8648 | if (t != first) |
| 8649 | { |
| 8650 | // Need to create substitution for <template-template-param> <template-args> |
| 8651 | if (__sub_end_ == __sub_cap_) |
| 8652 | __status_ = memory_alloc_failure; |
| 8653 | else |
| 8654 | { |
| 8655 | *__sub_end_++ = __root_; |
| 8656 | first = t; |
| 8657 | } |
| 8658 | } |
| 8659 | } |
| 8660 | } |
| 8661 | break; |
| 8662 | case 'D': |
| 8663 | if (first+1 != last) |
| 8664 | { |
| 8665 | switch (first[1]) |
| 8666 | { |
| 8667 | case 'p': |
| 8668 | t = __parse_type(first+2, last, try_to_parse_template_args); |
| 8669 | if (t != first+1) |
| 8670 | { |
| 8671 | if (__make<__pack_expansion>(__root_)) |
| 8672 | { |
| 8673 | if (__sub_end_ == __sub_cap_) |
| 8674 | __status_ = memory_alloc_failure; |
| 8675 | else |
| 8676 | { |
| 8677 | *__sub_end_++ = __root_; |
| 8678 | first = t; |
| 8679 | } |
| 8680 | } |
| 8681 | return first; |
| 8682 | } |
| 8683 | break; |
| 8684 | case 't': |
| 8685 | case 'T': |
| 8686 | t = __parse_decltype(first, last); |
| 8687 | if (t != first) |
| 8688 | { |
| 8689 | if (__sub_end_ == __sub_cap_) |
| 8690 | __status_ = memory_alloc_failure; |
| 8691 | else |
| 8692 | { |
| 8693 | *__sub_end_++ = __root_; |
| 8694 | first = t; |
| 8695 | } |
| 8696 | return first; |
| 8697 | } |
| 8698 | break; |
| 8699 | case 'v': |
| 8700 | t = __parse_vector_type(first, last); |
| 8701 | if (t != first) |
| 8702 | { |
| 8703 | if (__sub_end_ == __sub_cap_) |
| 8704 | __status_ = memory_alloc_failure; |
| 8705 | else |
| 8706 | { |
| 8707 | *__sub_end_++ = __root_; |
| 8708 | first = t; |
| 8709 | } |
| 8710 | return first; |
| 8711 | } |
| 8712 | break; |
| 8713 | } |
| 8714 | } |
| 8715 | // drop through |
| 8716 | default: |
| 8717 | // must check for builtin-types before class-enum-types to avoid |
| 8718 | // ambiguities with operator-names |
| 8719 | t = __parse_builtin_type(first, last); |
| 8720 | if (t != first) |
| 8721 | { |
| 8722 | first = t; |
| 8723 | } |
| 8724 | else |
| 8725 | { |
| 8726 | t = __parse_class_enum_type(first, last); |
| 8727 | if (t != first) |
| 8728 | { |
| 8729 | if (__sub_end_ == __sub_cap_) |
| 8730 | __status_ = memory_alloc_failure; |
| 8731 | else |
| 8732 | { |
| 8733 | *__sub_end_++ = __root_; |
| 8734 | first = t; |
| 8735 | } |
| 8736 | } |
| 8737 | } |
| 8738 | break; |
| 8739 | } |
| 8740 | } |
| 8741 | return first; |
| 8742 | } |
| 8743 | |
| 8744 | // <number> ::= [n] <non-negative decimal integer> |
| 8745 | |
| 8746 | const char* |
| 8747 | __demangle_tree::__parse_number(const char* first, const char* last) |
| 8748 | { |
| 8749 | if (first != last) |
| 8750 | { |
| 8751 | const char* t = first; |
| 8752 | if (*t == 'n') |
| 8753 | ++t; |
| 8754 | if (t != last) |
| 8755 | { |
| 8756 | if (*t == '0') |
| 8757 | { |
| 8758 | first = t+1; |
| 8759 | } |
| 8760 | else if ('1' <= *t && *t <= '9') |
| 8761 | { |
| 8762 | first = t+1; |
| 8763 | while (first != last && isdigit(*first)) |
| 8764 | ++first; |
| 8765 | } |
| 8766 | } |
| 8767 | } |
| 8768 | return first; |
| 8769 | } |
| 8770 | |
| 8771 | // <call-offset> ::= h <nv-offset> _ |
| 8772 | // ::= v <v-offset> _ |
| 8773 | // |
| 8774 | // <nv-offset> ::= <offset number> |
| 8775 | // # non-virtual base override |
| 8776 | // |
| 8777 | // <v-offset> ::= <offset number> _ <virtual offset number> |
| 8778 | // # virtual base override, with vcall offset |
| 8779 | |
| 8780 | const char* |
| 8781 | __demangle_tree::__parse_call_offset(const char* first, const char* last) |
| 8782 | { |
| 8783 | if (first != last) |
| 8784 | { |
| 8785 | switch (*first) |
| 8786 | { |
| 8787 | case 'h': |
| 8788 | { |
| 8789 | const char* t = __parse_number(first + 1, last); |
| 8790 | if (t != first + 1 && t != last && *t == '_') |
| 8791 | first = t + 1; |
| 8792 | } |
| 8793 | break; |
| 8794 | case 'v': |
| 8795 | { |
| 8796 | const char* t = __parse_number(first + 1, last); |
| 8797 | if (t != first + 1 && t != last && *t == '_') |
| 8798 | { |
| 8799 | const char* t2 = __parse_number(++t, last); |
| 8800 | if (t2 != t && t2 != last && *t2 == '_') |
| 8801 | first = t2 + 1; |
| 8802 | } |
| 8803 | } |
| 8804 | break; |
| 8805 | } |
| 8806 | } |
| 8807 | return first; |
| 8808 | } |
| 8809 | |
| 8810 | // <special-name> ::= TV <type> # virtual table |
| 8811 | // ::= TT <type> # VTT structure (construction vtable index) |
| 8812 | // ::= TI <type> # typeinfo structure |
| 8813 | // ::= TS <type> # typeinfo name (null-terminated byte string) |
| 8814 | // ::= Tc <call-offset> <call-offset> <base encoding> |
| 8815 | // # base is the nominal target function of thunk |
| 8816 | // # first call-offset is 'this' adjustment |
| 8817 | // # second call-offset is result adjustment |
| 8818 | // ::= T <call-offset> <base encoding> |
| 8819 | // # base is the nominal target function of thunk |
| 8820 | // ::= GV <object name> # Guard variable for one-time initialization |
| 8821 | // # No <type> |
| 8822 | // extension ::= TC <first type> <number> _ <second type> # construction vtable for second-in-first |
| 8823 | // extension ::= GR <object name> # reference temporary for object |
| 8824 | |
| 8825 | const char* |
| 8826 | __demangle_tree::__parse_special_name(const char* first, const char* last) |
| 8827 | { |
| 8828 | if (last - first > 2) |
| 8829 | { |
| 8830 | const char* t; |
| 8831 | switch (*first) |
| 8832 | { |
| 8833 | case 'T': |
| 8834 | switch (first[1]) |
| 8835 | { |
| 8836 | case 'V': |
| 8837 | // TV <type> # virtual table |
| 8838 | t = __parse_type(first+2, last); |
| 8839 | if (t != first+2 && __make<__vtable>(__root_)) |
| 8840 | first = t; |
| 8841 | break; |
| 8842 | case 'T': |
| 8843 | // TT <type> # VTT structure (construction vtable index) |
| 8844 | t = __parse_type(first+2, last); |
| 8845 | if (t != first+2 && __make<__VTT>(__root_)) |
| 8846 | first = t; |
| 8847 | break; |
| 8848 | case 'I': |
| 8849 | // TI <type> # typeinfo structure |
| 8850 | t = __parse_type(first+2, last); |
| 8851 | if (t != first+2 && __make<__typeinfo>(__root_)) |
| 8852 | first = t; |
| 8853 | break; |
| 8854 | case 'S': |
| 8855 | // TS <type> # typeinfo name (null-terminated byte string) |
| 8856 | t = __parse_type(first+2, last); |
| 8857 | if (t != first+2 && __make<__typeinfo_name>(__root_)) |
| 8858 | first = t; |
| 8859 | break; |
| 8860 | case 'c': |
| 8861 | // Tc <call-offset> <call-offset> <base encoding> |
| 8862 | { |
| 8863 | const char* t0 = __parse_call_offset(first+2, last); |
| 8864 | if (t0 == first+2) |
| 8865 | break; |
| 8866 | const char* t1 = __parse_call_offset(t0, last); |
| 8867 | if (t1 == t0) |
| 8868 | break; |
| 8869 | t = __parse_encoding(t1, last); |
| 8870 | if (t != t1 && __make<__covariant_return_thunk>(__root_)) |
| 8871 | first = t; |
| 8872 | } |
| 8873 | break; |
| 8874 | case 'C': |
| 8875 | // extension ::= TC <first type> <number> _ <second type> # construction vtable for second-in-first |
| 8876 | t = __parse_type(first+2, last); |
| 8877 | if (t != first+2) |
| 8878 | { |
| 8879 | __node* op1 = __root_; |
| 8880 | const char* t0 = __parse_number(t, last); |
| 8881 | if (t0 != t && t0 != last && *t0 == '_') |
| 8882 | { |
| 8883 | const char* t1 = __parse_type(++t0, last); |
| 8884 | if (t1 != t0) |
| 8885 | { |
| 8886 | if (__make<__construction_vtable>(__root_, op1)) |
| 8887 | first = t1; |
| 8888 | } |
| 8889 | } |
| 8890 | } |
| 8891 | break; |
| 8892 | default: |
| 8893 | // T <call-offset> <base encoding> |
| 8894 | { |
| 8895 | const char* t0 = __parse_call_offset(first+1, last); |
| 8896 | if (t0 == first+1) |
| 8897 | break; |
| 8898 | t = __parse_encoding(t0, last); |
| 8899 | if (t != t0) |
| 8900 | { |
| 8901 | if (first[2] == 'v') |
| 8902 | { |
| 8903 | if (__make<__virtual_thunk>(__root_)) |
| 8904 | first = t; |
| 8905 | } |
| 8906 | else |
| 8907 | { |
| 8908 | if (__make<__non_virtual_thunk>(__root_)) |
| 8909 | first = t; |
| 8910 | } |
| 8911 | } |
| 8912 | } |
| 8913 | break; |
| 8914 | } |
| 8915 | break; |
| 8916 | case 'G': |
| 8917 | switch (first[1]) |
| 8918 | { |
| 8919 | case 'V': |
| 8920 | // GV <object name> # Guard variable for one-time initialization |
| 8921 | t = __parse_name(first+2, last); |
| 8922 | if (t != first+2 && __make<__guard_variable>(__root_)) |
| 8923 | first = t; |
| 8924 | break; |
| 8925 | case 'R': |
| 8926 | // extension ::= GR <object name> # reference temporary for object |
| 8927 | t = __parse_name(first+2, last); |
| 8928 | if (t != first+2 && __make<__reference_temporary>(__root_)) |
| 8929 | first = t; |
| 8930 | break; |
| 8931 | } |
| 8932 | break; |
| 8933 | } |
| 8934 | } |
| 8935 | return first; |
| 8936 | } |
| 8937 | |
| 8938 | // <operator-name> |
| 8939 | // ::= aa # && |
| 8940 | // ::= ad # & (unary) |
| 8941 | // ::= an # & |
| 8942 | // ::= aN # &= |
| 8943 | // ::= aS # = |
| 8944 | // ::= at # alignof (a type) |
| 8945 | // ::= az # alignof (an expression) |
| 8946 | // ::= cl # () |
| 8947 | // ::= cm # , |
| 8948 | // ::= co # ~ |
| 8949 | // ::= cv <type> # (cast) |
| 8950 | // ::= da # delete[] |
| 8951 | // ::= de # * (unary) |
| 8952 | // ::= dl # delete |
| 8953 | // ::= dv # / |
| 8954 | // ::= dV # /= |
| 8955 | // ::= eo # ^ |
| 8956 | // ::= eO # ^= |
| 8957 | // ::= eq # == |
| 8958 | // ::= ge # >= |
| 8959 | // ::= gt # > |
| 8960 | // ::= ix # [] |
| 8961 | // ::= le # <= |
| 8962 | // ::= ls # << |
| 8963 | // ::= lS # <<= |
| 8964 | // ::= lt # < |
| 8965 | // ::= mi # - |
| 8966 | // ::= mI # -= |
| 8967 | // ::= ml # * |
| 8968 | // ::= mL # *= |
| 8969 | // ::= mm # -- (postfix in <expression> context) |
| 8970 | // ::= na # new[] |
| 8971 | // ::= ne # != |
| 8972 | // ::= ng # - (unary) |
| 8973 | // ::= nt # ! |
| 8974 | // ::= nw # new |
| 8975 | // ::= oo # || |
| 8976 | // ::= or # | |
| 8977 | // ::= oR # |= |
| 8978 | // ::= pm # ->* |
| 8979 | // ::= pl # + |
| 8980 | // ::= pL # += |
| 8981 | // ::= pp # ++ (postfix in <expression> context) |
| 8982 | // ::= ps # + (unary) |
| 8983 | // ::= pt # -> |
| 8984 | // ::= qu # ? |
| 8985 | // ::= rm # % |
| 8986 | // ::= rM # %= |
| 8987 | // ::= rs # >> |
| 8988 | // ::= rS # >>= |
| 8989 | // ::= st # sizeof (a type) |
| 8990 | // ::= sz # sizeof (an expression) |
| 8991 | // ::= v <digit> <source-name> # vendor extended operator |
| 8992 | |
| 8993 | const char* |
| 8994 | __demangle_tree::__parse_operator_name(const char* first, const char* last, int* type) |
| 8995 | { |
| 8996 | if (last - first >= 2) |
| 8997 | { |
| 8998 | switch (*first) |
| 8999 | { |
| 9000 | case 'a': |
| 9001 | switch (first[1]) |
| 9002 | { |
| 9003 | case 'a': |
| 9004 | // && |
| 9005 | if (type) |
| 9006 | { |
| 9007 | const char* t = __parse_expression(first+2, last); |
| 9008 | if (t != first+2) |
| 9009 | { |
| 9010 | __node* op1 = __root_; |
| 9011 | const char* t2 = __parse_expression(t, last); |
| 9012 | if (t != t2) |
| 9013 | { |
| 9014 | if (__make<__operator_logical_and>(op1, __root_)) |
| 9015 | { |
| 9016 | *type = 2; |
| 9017 | first = t2; |
| 9018 | } |
| 9019 | } |
| 9020 | } |
| 9021 | } |
| 9022 | else |
| 9023 | { |
| 9024 | if (__make<__operator_logical_and>()) |
| 9025 | first += 2; |
| 9026 | } |
| 9027 | break; |
| 9028 | case 'd': |
| 9029 | // & (unary) |
| 9030 | if (type) |
| 9031 | { |
| 9032 | const char* t = __parse_expression(first+2, last); |
| 9033 | if (t != first+2) |
| 9034 | { |
| 9035 | if (__make<__operator_addressof>(__root_)) |
| 9036 | { |
| 9037 | *type = 1; |
| 9038 | first = t; |
| 9039 | } |
| 9040 | } |
| 9041 | } |
| 9042 | else |
| 9043 | { |
| 9044 | if (__make<__operator_addressof>()) |
| 9045 | first += 2; |
| 9046 | } |
| 9047 | break; |
| 9048 | case 'n': |
| 9049 | // & |
| 9050 | if (type) |
| 9051 | { |
| 9052 | const char* t = __parse_expression(first+2, last); |
| 9053 | if (t != first+2) |
| 9054 | { |
| 9055 | __node* op1 = __root_; |
| 9056 | const char* t2 = __parse_expression(t, last); |
| 9057 | if (t != t2) |
| 9058 | { |
| 9059 | if (__make<__operator_bit_and>(op1, __root_)) |
| 9060 | { |
| 9061 | *type = 2; |
| 9062 | first = t2; |
| 9063 | } |
| 9064 | } |
| 9065 | } |
| 9066 | } |
| 9067 | else |
| 9068 | { |
| 9069 | if (__make<__operator_bit_and>()) |
| 9070 | first += 2; |
| 9071 | } |
| 9072 | break; |
| 9073 | case 'N': |
| 9074 | // &= |
| 9075 | if (type) |
| 9076 | { |
| 9077 | const char* t = __parse_expression(first+2, last); |
| 9078 | if (t != first+2) |
| 9079 | { |
| 9080 | __node* op1 = __root_; |
| 9081 | const char* t2 = __parse_expression(t, last); |
| 9082 | if (t != t2) |
| 9083 | { |
| 9084 | if (__make<__operator_and_equal>(op1, __root_)) |
| 9085 | { |
| 9086 | *type = 2; |
| 9087 | first = t2; |
| 9088 | } |
| 9089 | } |
| 9090 | } |
| 9091 | } |
| 9092 | else |
| 9093 | { |
| 9094 | if (__make<__operator_and_equal>()) |
| 9095 | first += 2; |
| 9096 | } |
| 9097 | break; |
| 9098 | case 'S': |
| 9099 | // = |
| 9100 | if (type) |
| 9101 | { |
| 9102 | const char* t = __parse_expression(first+2, last); |
| 9103 | if (t != first+2) |
| 9104 | { |
| 9105 | __node* op1 = __root_; |
| 9106 | const char* t2 = __parse_expression(t, last); |
| 9107 | if (t != t2) |
| 9108 | { |
| 9109 | if (__make<__operator_equal>(op1, __root_)) |
| 9110 | { |
| 9111 | *type = 2; |
| 9112 | first = t2; |
| 9113 | } |
| 9114 | } |
| 9115 | } |
| 9116 | } |
| 9117 | else |
| 9118 | { |
| 9119 | if (__make<__operator_equal>()) |
| 9120 | first += 2; |
| 9121 | } |
| 9122 | break; |
| 9123 | case 't': |
| 9124 | // alignof (a type) |
| 9125 | if (type) |
| 9126 | { |
| 9127 | const char* t = __parse_expression(first+2, last); |
| 9128 | if (t != first+2) |
| 9129 | { |
| 9130 | if (__make<__operator_alignof_type>(__root_)) |
| 9131 | { |
| 9132 | *type = -1; |
| 9133 | first = t; |
| 9134 | } |
| 9135 | } |
| 9136 | } |
| 9137 | else |
| 9138 | { |
| 9139 | if (__make<__operator_alignof_type>()) |
| 9140 | first += 2; |
| 9141 | } |
| 9142 | break; |
| 9143 | case 'z': |
| 9144 | // alignof (an expression) |
| 9145 | if (type) |
| 9146 | { |
| 9147 | const char* t = __parse_expression(first+2, last); |
| 9148 | if (t != first+2) |
| 9149 | { |
| 9150 | if (__make<__operator_alignof_expression>(__root_)) |
| 9151 | { |
| 9152 | *type = -1; |
| 9153 | first = t; |
| 9154 | } |
| 9155 | } |
| 9156 | } |
| 9157 | else |
| 9158 | { |
| 9159 | if (__make<__operator_alignof_expression>()) |
| 9160 | first += 2; |
| 9161 | } |
| 9162 | break; |
| 9163 | } |
| 9164 | break; |
| 9165 | case 'c': |
| 9166 | switch (first[1]) |
| 9167 | { |
| 9168 | case 'l': |
| 9169 | // () |
| 9170 | if (__make<__operator_paren>()) |
| 9171 | { |
| 9172 | first += 2; |
| 9173 | if (type) |
| 9174 | *type = -1; |
| 9175 | } |
| 9176 | break; |
| 9177 | case 'm': |
| 9178 | // , |
| 9179 | if (type) |
| 9180 | { |
| 9181 | const char* t = __parse_expression(first+2, last); |
| 9182 | if (t != first+2) |
| 9183 | { |
| 9184 | __node* op1 = __root_; |
| 9185 | const char* t2 = __parse_expression(t, last); |
| 9186 | if (t != t2) |
| 9187 | { |
| 9188 | if (__make<__operator_comma>(op1, __root_)) |
| 9189 | { |
| 9190 | *type = 2; |
| 9191 | first = t2; |
| 9192 | } |
| 9193 | } |
| 9194 | } |
| 9195 | } |
| 9196 | else |
| 9197 | { |
| 9198 | if (__make<__operator_comma>()) |
| 9199 | first += 2; |
| 9200 | } |
| 9201 | break; |
| 9202 | case 'o': |
| 9203 | // ~ |
| 9204 | if (type) |
| 9205 | { |
| 9206 | const char* t = __parse_expression(first+2, last); |
| 9207 | if (t != first+2) |
| 9208 | { |
| 9209 | if (__make<__operator_tilda>(__root_)) |
| 9210 | { |
| 9211 | *type = 1; |
| 9212 | first = t; |
| 9213 | } |
| 9214 | } |
| 9215 | } |
| 9216 | else |
| 9217 | { |
| 9218 | if (__make<__operator_tilda>()) |
| 9219 | first += 2; |
| 9220 | } |
| 9221 | break; |
| 9222 | case 'v': |
| 9223 | // cast <type> |
| 9224 | { |
| 9225 | const char* t = __parse_type(first+2, last, false, true); |
| 9226 | if (t != first+2) |
| 9227 | { |
| 9228 | __node* cast_type = __root_; |
| 9229 | if (type) |
| 9230 | { |
| 9231 | const char* t2 = __parse_expression(t, last); |
| 9232 | if (t2 != t) |
| 9233 | { |
| 9234 | if (__make<__operator_cast>(cast_type, __root_)) |
| 9235 | { |
| 9236 | *type = -1; |
| 9237 | first = t2; |
| 9238 | } |
| 9239 | } |
| 9240 | } |
| 9241 | else |
| 9242 | { |
| 9243 | if (__make<__operator_cast>(cast_type)) |
| 9244 | first = t; |
| 9245 | } |
| 9246 | } |
| 9247 | } |
| 9248 | break; |
| 9249 | } |
| 9250 | break; |
| 9251 | case 'd': |
| 9252 | switch (first[1]) |
| 9253 | { |
| 9254 | case 'a': |
| 9255 | // delete[] |
| 9256 | if (__make<__operator_delete_array>()) |
| 9257 | { |
| 9258 | first += 2; |
| 9259 | if (type) |
| 9260 | *type = -1; |
| 9261 | } |
| 9262 | break; |
| 9263 | case 'e': |
| 9264 | // * (unary) |
| 9265 | if (type) |
| 9266 | { |
| 9267 | const char* t = __parse_expression(first+2, last); |
| 9268 | if (t != first+2) |
| 9269 | { |
| 9270 | if (__make<__operator_dereference>(__root_)) |
| 9271 | { |
| 9272 | *type = 1; |
| 9273 | first = t; |
| 9274 | } |
| 9275 | } |
| 9276 | } |
| 9277 | else |
| 9278 | { |
| 9279 | if (__make<__operator_dereference>()) |
| 9280 | first += 2; |
| 9281 | } |
| 9282 | break; |
| 9283 | case 'l': |
| 9284 | // delete |
| 9285 | if (__make<__operator_delete>()) |
| 9286 | { |
| 9287 | first += 2; |
| 9288 | if (type) |
| 9289 | *type = -1; |
| 9290 | } |
| 9291 | break; |
| 9292 | case 'v': |
| 9293 | // / |
| 9294 | if (type) |
| 9295 | { |
| 9296 | const char* t = __parse_expression(first+2, last); |
| 9297 | if (t != first+2) |
| 9298 | { |
| 9299 | __node* op1 = __root_; |
| 9300 | const char* t2 = __parse_expression(t, last); |
| 9301 | if (t != t2) |
| 9302 | { |
| 9303 | if (__make<__operator_divide>(op1, __root_)) |
| 9304 | { |
| 9305 | *type = 2; |
| 9306 | first = t2; |
| 9307 | } |
| 9308 | } |
| 9309 | } |
| 9310 | } |
| 9311 | else |
| 9312 | { |
| 9313 | if (__make<__operator_divide>()) |
| 9314 | first += 2; |
| 9315 | } |
| 9316 | break; |
| 9317 | case 'V': |
| 9318 | // /= |
| 9319 | if (type) |
| 9320 | { |
| 9321 | const char* t = __parse_expression(first+2, last); |
| 9322 | if (t != first+2) |
| 9323 | { |
| 9324 | __node* op1 = __root_; |
| 9325 | const char* t2 = __parse_expression(t, last); |
| 9326 | if (t != t2) |
| 9327 | { |
| 9328 | if (__make<__operator_divide_equal>(op1, __root_)) |
| 9329 | { |
| 9330 | *type = 2; |
| 9331 | first = t2; |
| 9332 | } |
| 9333 | } |
| 9334 | } |
| 9335 | } |
| 9336 | else |
| 9337 | { |
| 9338 | if (__make<__operator_divide_equal>()) |
| 9339 | first += 2; |
| 9340 | } |
| 9341 | break; |
| 9342 | } |
| 9343 | break; |
| 9344 | case 'e': |
| 9345 | switch (first[1]) |
| 9346 | { |
| 9347 | case 'o': |
| 9348 | // ^ |
| 9349 | if (type) |
| 9350 | { |
| 9351 | const char* t = __parse_expression(first+2, last); |
| 9352 | if (t != first+2) |
| 9353 | { |
| 9354 | __node* op1 = __root_; |
| 9355 | const char* t2 = __parse_expression(t, last); |
| 9356 | if (t != t2) |
| 9357 | { |
| 9358 | if (__make<__operator_xor>(op1, __root_)) |
| 9359 | { |
| 9360 | *type = 2; |
| 9361 | first = t2; |
| 9362 | } |
| 9363 | } |
| 9364 | } |
| 9365 | } |
| 9366 | else |
| 9367 | { |
| 9368 | if (__make<__operator_xor>()) |
| 9369 | first += 2; |
| 9370 | } |
| 9371 | break; |
| 9372 | case 'O': |
| 9373 | // ^= |
| 9374 | if (type) |
| 9375 | { |
| 9376 | const char* t = __parse_expression(first+2, last); |
| 9377 | if (t != first+2) |
| 9378 | { |
| 9379 | __node* op1 = __root_; |
| 9380 | const char* t2 = __parse_expression(t, last); |
| 9381 | if (t != t2) |
| 9382 | { |
| 9383 | if (__make<__operator_xor_equal>(op1, __root_)) |
| 9384 | { |
| 9385 | *type = 2; |
| 9386 | first = t2; |
| 9387 | } |
| 9388 | } |
| 9389 | } |
| 9390 | } |
| 9391 | else |
| 9392 | { |
| 9393 | if (__make<__operator_xor_equal>()) |
| 9394 | first += 2; |
| 9395 | } |
| 9396 | break; |
| 9397 | case 'q': |
| 9398 | // == |
| 9399 | if (type) |
| 9400 | { |
| 9401 | const char* t = __parse_expression(first+2, last); |
| 9402 | if (t != first+2) |
| 9403 | { |
| 9404 | __node* op1 = __root_; |
| 9405 | const char* t2 = __parse_expression(t, last); |
| 9406 | if (t != t2) |
| 9407 | { |
| 9408 | if (__make<__operator_equality>(op1, __root_)) |
| 9409 | { |
| 9410 | *type = 2; |
| 9411 | first = t2; |
| 9412 | } |
| 9413 | } |
| 9414 | } |
| 9415 | } |
| 9416 | else |
| 9417 | { |
| 9418 | if (__make<__operator_equality>()) |
| 9419 | first += 2; |
| 9420 | } |
| 9421 | break; |
| 9422 | } |
| 9423 | break; |
| 9424 | case 'g': |
| 9425 | switch (first[1]) |
| 9426 | { |
| 9427 | case 'e': |
| 9428 | // >= |
| 9429 | if (type) |
| 9430 | { |
| 9431 | const char* t = __parse_expression(first+2, last); |
| 9432 | if (t != first+2) |
| 9433 | { |
| 9434 | __node* op1 = __root_; |
| 9435 | const char* t2 = __parse_expression(t, last); |
| 9436 | if (t != t2) |
| 9437 | { |
| 9438 | if (__make<__operator_greater_equal>(op1, __root_)) |
| 9439 | { |
| 9440 | *type = 2; |
| 9441 | first = t2; |
| 9442 | } |
| 9443 | } |
| 9444 | } |
| 9445 | } |
| 9446 | else |
| 9447 | { |
| 9448 | if (__make<__operator_greater_equal>()) |
| 9449 | first += 2; |
| 9450 | } |
| 9451 | break; |
| 9452 | case 't': |
| 9453 | // > |
| 9454 | if (type) |
| 9455 | { |
| 9456 | const char* t = __parse_expression(first+2, last); |
| 9457 | if (t != first+2) |
| 9458 | { |
| 9459 | __node* op1 = __root_; |
| 9460 | const char* t2 = __parse_expression(t, last); |
| 9461 | if (t != t2) |
| 9462 | { |
| 9463 | if (__make<__operator_greater>(op1, __root_)) |
| 9464 | { |
| 9465 | *type = 2; |
| 9466 | first = t2; |
| 9467 | } |
| 9468 | } |
| 9469 | } |
| 9470 | } |
| 9471 | else |
| 9472 | { |
| 9473 | if (__make<__operator_greater>()) |
| 9474 | first += 2; |
| 9475 | } |
| 9476 | break; |
| 9477 | } |
| 9478 | break; |
| 9479 | case 'i': |
| 9480 | // [] |
| 9481 | if (first[1] == 'x' && __make<__operator_brackets>()) |
| 9482 | { |
| 9483 | first += 2; |
| 9484 | if (type) |
| 9485 | *type = -1; |
| 9486 | } |
| 9487 | break; |
| 9488 | case 'l': |
| 9489 | switch (first[1]) |
| 9490 | { |
| 9491 | case 'e': |
| 9492 | // <= |
| 9493 | if (type) |
| 9494 | { |
| 9495 | const char* t = __parse_expression(first+2, last); |
| 9496 | if (t != first+2) |
| 9497 | { |
| 9498 | __node* op1 = __root_; |
| 9499 | const char* t2 = __parse_expression(t, last); |
| 9500 | if (t != t2) |
| 9501 | { |
| 9502 | if (__make<__operator_less_equal>(op1, __root_)) |
| 9503 | { |
| 9504 | *type = 2; |
| 9505 | first = t2; |
| 9506 | } |
| 9507 | } |
| 9508 | } |
| 9509 | } |
| 9510 | else |
| 9511 | { |
| 9512 | if (__make<__operator_less_equal>()) |
| 9513 | first += 2; |
| 9514 | } |
| 9515 | break; |
| 9516 | case 's': |
| 9517 | // << |
| 9518 | if (type) |
| 9519 | { |
| 9520 | const char* t = __parse_expression(first+2, last); |
| 9521 | if (t != first+2) |
| 9522 | { |
| 9523 | __node* op1 = __root_; |
| 9524 | const char* t2 = __parse_expression(t, last); |
| 9525 | if (t != t2) |
| 9526 | { |
| 9527 | if (__make<__operator_left_shift>(op1, __root_)) |
| 9528 | { |
| 9529 | *type = 2; |
| 9530 | first = t2; |
| 9531 | } |
| 9532 | } |
| 9533 | } |
| 9534 | } |
| 9535 | else |
| 9536 | { |
| 9537 | if (__make<__operator_left_shift>()) |
| 9538 | first += 2; |
| 9539 | } |
| 9540 | break; |
| 9541 | case 'S': |
| 9542 | // <<= |
| 9543 | if (type) |
| 9544 | { |
| 9545 | const char* t = __parse_expression(first+2, last); |
| 9546 | if (t != first+2) |
| 9547 | { |
| 9548 | __node* op1 = __root_; |
| 9549 | const char* t2 = __parse_expression(t, last); |
| 9550 | if (t != t2) |
| 9551 | { |
| 9552 | if (__make<__operator_left_shift_equal>(op1, __root_)) |
| 9553 | { |
| 9554 | *type = 2; |
| 9555 | first = t2; |
| 9556 | } |
| 9557 | } |
| 9558 | } |
| 9559 | } |
| 9560 | else |
| 9561 | { |
| 9562 | if (__make<__operator_left_shift_equal>()) |
| 9563 | first += 2; |
| 9564 | } |
| 9565 | break; |
| 9566 | case 't': |
| 9567 | // < |
| 9568 | if (type) |
| 9569 | { |
| 9570 | const char* t = __parse_expression(first+2, last); |
| 9571 | if (t != first+2) |
| 9572 | { |
| 9573 | __node* op1 = __root_; |
| 9574 | const char* t2 = __parse_expression(t, last); |
| 9575 | if (t != t2) |
| 9576 | { |
| 9577 | if (__make<__operator_less>(op1, __root_)) |
| 9578 | { |
| 9579 | *type = 2; |
| 9580 | first = t2; |
| 9581 | } |
| 9582 | } |
| 9583 | } |
| 9584 | } |
| 9585 | else |
| 9586 | { |
| 9587 | if (__make<__operator_less>()) |
| 9588 | first += 2; |
| 9589 | } |
| 9590 | break; |
| 9591 | } |
| 9592 | break; |
| 9593 | case 'm': |
| 9594 | switch (first[1]) |
| 9595 | { |
| 9596 | case 'i': |
| 9597 | // - |
| 9598 | if (type) |
| 9599 | { |
| 9600 | const char* t = __parse_expression(first+2, last); |
| 9601 | if (t != first+2) |
| 9602 | { |
| 9603 | __node* op1 = __root_; |
| 9604 | const char* t2 = __parse_expression(t, last); |
| 9605 | if (t != t2) |
| 9606 | { |
| 9607 | if (__make<__operator_minus>(op1, __root_)) |
| 9608 | { |
| 9609 | *type = 2; |
| 9610 | first = t2; |
| 9611 | } |
| 9612 | } |
| 9613 | } |
| 9614 | } |
| 9615 | else |
| 9616 | { |
| 9617 | if (__make<__operator_minus>()) |
| 9618 | first += 2; |
| 9619 | } |
| 9620 | break; |
| 9621 | case 'I': |
| 9622 | // -= |
| 9623 | if (type) |
| 9624 | { |
| 9625 | const char* t = __parse_expression(first+2, last); |
| 9626 | if (t != first+2) |
| 9627 | { |
| 9628 | __node* op1 = __root_; |
| 9629 | const char* t2 = __parse_expression(t, last); |
| 9630 | if (t != t2) |
| 9631 | { |
| 9632 | if (__make<__operator_minus_equal>(op1, __root_)) |
| 9633 | { |
| 9634 | *type = 2; |
| 9635 | first = t2; |
| 9636 | } |
| 9637 | } |
| 9638 | } |
| 9639 | } |
| 9640 | else |
| 9641 | { |
| 9642 | if (__make<__operator_minus_equal>()) |
| 9643 | first += 2; |
| 9644 | } |
| 9645 | break; |
| 9646 | case 'l': |
| 9647 | // * |
| 9648 | if (type) |
| 9649 | { |
| 9650 | const char* t = __parse_expression(first+2, last); |
| 9651 | if (t != first+2) |
| 9652 | { |
| 9653 | __node* op1 = __root_; |
| 9654 | const char* t2 = __parse_expression(t, last); |
| 9655 | if (t != t2) |
| 9656 | { |
| 9657 | if (__make<__operator_times>(op1, __root_)) |
| 9658 | { |
| 9659 | *type = 2; |
| 9660 | first = t2; |
| 9661 | } |
| 9662 | } |
| 9663 | } |
| 9664 | } |
| 9665 | else |
| 9666 | { |
| 9667 | if (__make<__operator_times>()) |
| 9668 | first += 2; |
| 9669 | } |
| 9670 | break; |
| 9671 | case 'L': |
| 9672 | // *= |
| 9673 | if (type) |
| 9674 | { |
| 9675 | const char* t = __parse_expression(first+2, last); |
| 9676 | if (t != first+2) |
| 9677 | { |
| 9678 | __node* op1 = __root_; |
| 9679 | const char* t2 = __parse_expression(t, last); |
| 9680 | if (t != t2) |
| 9681 | { |
| 9682 | if (__make<__operator_times_equal>(op1, __root_)) |
| 9683 | { |
| 9684 | *type = 2; |
| 9685 | first = t2; |
| 9686 | } |
| 9687 | } |
| 9688 | } |
| 9689 | } |
| 9690 | else |
| 9691 | { |
| 9692 | if (__make<__operator_times_equal>()) |
| 9693 | first += 2; |
| 9694 | } |
| 9695 | break; |
| 9696 | case 'm': |
| 9697 | // -- (postfix in <expression> context) |
| 9698 | if (type) |
| 9699 | { |
| 9700 | const char* t = __parse_expression(first+2, last); |
| 9701 | if (t != first+2) |
| 9702 | { |
| 9703 | if (__make<__operator_decrement>(false, __root_)) |
| 9704 | { |
| 9705 | *type = 1; |
| 9706 | first = t; |
| 9707 | } |
| 9708 | } |
| 9709 | } |
| 9710 | else |
| 9711 | { |
| 9712 | if (__make<__operator_decrement>()) |
| 9713 | first += 2; |
| 9714 | } |
| 9715 | break; |
| 9716 | } |
| 9717 | break; |
| 9718 | case 'n': |
| 9719 | switch (first[1]) |
| 9720 | { |
| 9721 | case 'a': |
| 9722 | // new[] |
| 9723 | if (__make<__operator_new_array>()) |
| 9724 | { |
| 9725 | first += 2; |
| 9726 | if (type) |
| 9727 | *type = -1; |
| 9728 | } |
| 9729 | break; |
| 9730 | case 'e': |
| 9731 | // != |
| 9732 | if (type) |
| 9733 | { |
| 9734 | const char* t = __parse_expression(first+2, last); |
| 9735 | if (t != first+2) |
| 9736 | { |
| 9737 | __node* op1 = __root_; |
| 9738 | const char* t2 = __parse_expression(t, last); |
| 9739 | if (t != t2) |
| 9740 | { |
| 9741 | if (__make<__operator_not_equal>(op1, __root_)) |
| 9742 | { |
| 9743 | *type = 2; |
| 9744 | first = t2; |
| 9745 | } |
| 9746 | } |
| 9747 | } |
| 9748 | } |
| 9749 | else |
| 9750 | { |
| 9751 | if (__make<__operator_not_equal>()) |
| 9752 | first += 2; |
| 9753 | } |
| 9754 | break; |
| 9755 | case 'g': |
| 9756 | // - (unary) |
| 9757 | if (type) |
| 9758 | { |
| 9759 | const char* t = __parse_expression(first+2, last); |
| 9760 | if (t != first+2) |
| 9761 | { |
| 9762 | if (__make<__operator_negate>(__root_)) |
| 9763 | { |
| 9764 | *type = 1; |
| 9765 | first = t; |
| 9766 | } |
| 9767 | } |
| 9768 | } |
| 9769 | else |
| 9770 | { |
| 9771 | if (__make<__operator_negate>()) |
| 9772 | first += 2; |
| 9773 | } |
| 9774 | break; |
| 9775 | case 't': |
| 9776 | // ! |
| 9777 | if (type) |
| 9778 | { |
| 9779 | const char* t = __parse_expression(first+2, last); |
| 9780 | if (t != first+2) |
| 9781 | { |
| 9782 | if (__make<__operator_logical_not>(__root_)) |
| 9783 | { |
| 9784 | *type = 1; |
| 9785 | first = t; |
| 9786 | } |
| 9787 | } |
| 9788 | } |
| 9789 | else |
| 9790 | { |
| 9791 | if (__make<__operator_logical_not>()) |
| 9792 | first += 2; |
| 9793 | } |
| 9794 | break; |
| 9795 | case 'w': |
| 9796 | // new |
| 9797 | if (__make<__operator_new>()) |
| 9798 | { |
| 9799 | first += 2; |
| 9800 | if (type) |
| 9801 | *type = -1; |
| 9802 | } |
| 9803 | break; |
| 9804 | } |
| 9805 | break; |
| 9806 | case 'o': |
| 9807 | switch (first[1]) |
| 9808 | { |
| 9809 | case 'o': |
| 9810 | // || |
| 9811 | if (type) |
| 9812 | { |
| 9813 | const char* t = __parse_expression(first+2, last); |
| 9814 | if (t != first+2) |
| 9815 | { |
| 9816 | __node* op1 = __root_; |
| 9817 | const char* t2 = __parse_expression(t, last); |
| 9818 | if (t != t2) |
| 9819 | { |
| 9820 | if (__make<__operator_logical_or>(op1, __root_)) |
| 9821 | { |
| 9822 | *type = 2; |
| 9823 | first = t2; |
| 9824 | } |
| 9825 | } |
| 9826 | } |
| 9827 | } |
| 9828 | else |
| 9829 | { |
| 9830 | if (__make<__operator_logical_or>()) |
| 9831 | first += 2; |
| 9832 | } |
| 9833 | break; |
| 9834 | case 'r': |
| 9835 | // | |
| 9836 | if (type) |
| 9837 | { |
| 9838 | const char* t = __parse_expression(first+2, last); |
| 9839 | if (t != first+2) |
| 9840 | { |
| 9841 | __node* op1 = __root_; |
| 9842 | const char* t2 = __parse_expression(t, last); |
| 9843 | if (t != t2) |
| 9844 | { |
| 9845 | if (__make<__operator_bit_or>(op1, __root_)) |
| 9846 | { |
| 9847 | *type = 2; |
| 9848 | first = t2; |
| 9849 | } |
| 9850 | } |
| 9851 | } |
| 9852 | } |
| 9853 | else |
| 9854 | { |
| 9855 | if (__make<__operator_bit_or>()) |
| 9856 | first += 2; |
| 9857 | } |
| 9858 | break; |
| 9859 | case 'R': |
| 9860 | // |= |
| 9861 | if (type) |
| 9862 | { |
| 9863 | const char* t = __parse_expression(first+2, last); |
| 9864 | if (t != first+2) |
| 9865 | { |
| 9866 | __node* op1 = __root_; |
| 9867 | const char* t2 = __parse_expression(t, last); |
| 9868 | if (t != t2) |
| 9869 | { |
| 9870 | if (__make<__operator_or_equal>(op1, __root_)) |
| 9871 | { |
| 9872 | *type = 2; |
| 9873 | first = t2; |
| 9874 | } |
| 9875 | } |
| 9876 | } |
| 9877 | } |
| 9878 | else |
| 9879 | { |
| 9880 | if (__make<__operator_or_equal>()) |
| 9881 | first += 2; |
| 9882 | } |
| 9883 | break; |
| 9884 | } |
| 9885 | break; |
| 9886 | case 'p': |
| 9887 | switch (first[1]) |
| 9888 | { |
| 9889 | case 'm': |
| 9890 | // ->* |
| 9891 | if (type) |
| 9892 | { |
| 9893 | const char* t = __parse_expression(first+2, last); |
| 9894 | if (t != first+2) |
| 9895 | { |
| 9896 | __node* op1 = __root_; |
| 9897 | const char* t2 = __parse_expression(t, last); |
| 9898 | if (t != t2) |
| 9899 | { |
| 9900 | if (__make<__operator_pointer_to_member>(op1, __root_)) |
| 9901 | { |
| 9902 | *type = 2; |
| 9903 | first = t2; |
| 9904 | } |
| 9905 | } |
| 9906 | } |
| 9907 | } |
| 9908 | else |
| 9909 | { |
| 9910 | if (__make<__operator_pointer_to_member>()) |
| 9911 | first += 2; |
| 9912 | } |
| 9913 | break; |
| 9914 | case 'l': |
| 9915 | // + |
| 9916 | if (type) |
| 9917 | { |
| 9918 | const char* t = __parse_expression(first+2, last); |
| 9919 | if (t != first+2) |
| 9920 | { |
| 9921 | __node* op1 = __root_; |
| 9922 | const char* t2 = __parse_expression(t, last); |
| 9923 | if (t != t2) |
| 9924 | { |
| 9925 | if (__make<__operator_plus>(op1, __root_)) |
| 9926 | { |
| 9927 | *type = 2; |
| 9928 | first = t2; |
| 9929 | } |
| 9930 | } |
| 9931 | } |
| 9932 | } |
| 9933 | else |
| 9934 | { |
| 9935 | if (__make<__operator_plus>()) |
| 9936 | first += 2; |
| 9937 | } |
| 9938 | break; |
| 9939 | case 'L': |
| 9940 | // += |
| 9941 | if (type) |
| 9942 | { |
| 9943 | const char* t = __parse_expression(first+2, last); |
| 9944 | if (t != first+2) |
| 9945 | { |
| 9946 | __node* op1 = __root_; |
| 9947 | const char* t2 = __parse_expression(t, last); |
| 9948 | if (t != t2) |
| 9949 | { |
| 9950 | if (__make<__operator_plus_equal>(op1, __root_)) |
| 9951 | { |
| 9952 | *type = 2; |
| 9953 | first = t2; |
| 9954 | } |
| 9955 | } |
| 9956 | } |
| 9957 | } |
| 9958 | else |
| 9959 | { |
| 9960 | if (__make<__operator_plus_equal>()) |
| 9961 | first += 2; |
| 9962 | } |
| 9963 | break; |
| 9964 | case 'p': |
| 9965 | // ++ (postfix in <expression> context) |
| 9966 | if (type) |
| 9967 | { |
| 9968 | const char* t = __parse_expression(first+2, last); |
| 9969 | if (t != first+2) |
| 9970 | { |
| 9971 | if (__make<__operator_increment>(false, __root_)) |
| 9972 | { |
| 9973 | *type = 1; |
| 9974 | first = t; |
| 9975 | } |
| 9976 | } |
| 9977 | } |
| 9978 | else |
| 9979 | { |
| 9980 | if (__make<__operator_increment>()) |
| 9981 | first += 2; |
| 9982 | } |
| 9983 | break; |
| 9984 | case 's': |
| 9985 | // + (unary) |
| 9986 | if (type) |
| 9987 | { |
| 9988 | const char* t = __parse_expression(first+2, last); |
| 9989 | if (t != first+2) |
| 9990 | { |
| 9991 | if (__make<__operator_unary_plus>(__root_)) |
| 9992 | { |
| 9993 | *type = 1; |
| 9994 | first = t; |
| 9995 | } |
| 9996 | } |
| 9997 | } |
| 9998 | else |
| 9999 | { |
| 10000 | if (__make<__operator_unary_plus>()) |
| 10001 | first += 2; |
| 10002 | } |
| 10003 | break; |
| 10004 | case 't': |
| 10005 | // -> |
| 10006 | if (type) |
| 10007 | { |
| 10008 | const char* t = __parse_expression(first+2, last); |
| 10009 | if (t != first+2) |
| 10010 | { |
| 10011 | __node* op1 = __root_; |
| 10012 | const char* t2 = __parse_expression(t, last); |
| 10013 | if (t != t2) |
| 10014 | { |
| 10015 | if (__make<__operator_arrow>(op1, __root_)) |
| 10016 | { |
| 10017 | *type = 2; |
| 10018 | first = t2; |
| 10019 | } |
| 10020 | } |
| 10021 | } |
| 10022 | } |
| 10023 | else |
| 10024 | { |
| 10025 | if (__make<__operator_arrow>()) |
| 10026 | first += 2; |
| 10027 | } |
| 10028 | break; |
| 10029 | } |
| 10030 | break; |
| 10031 | case 'q': |
| 10032 | // ? |
| 10033 | if (first[1] == 'u') |
| 10034 | { |
| 10035 | if (type) |
| 10036 | { |
| 10037 | const char* t = __parse_expression(first+2, last); |
| 10038 | if (t != first+2) |
| 10039 | { |
| 10040 | __node* op1 = __root_; |
| 10041 | const char* t2 = __parse_expression(t, last); |
| 10042 | if (t != t2) |
| 10043 | { |
| 10044 | __node* op2 = __root_; |
| 10045 | const char* t3 = __parse_expression(t2, last); |
| 10046 | if (t3 != t2) |
| 10047 | { |
| 10048 | if (__make<__operator_conditional>(op1, op2, __root_)) |
| 10049 | { |
| 10050 | *type = 3; |
| 10051 | first = t3; |
| 10052 | } |
| 10053 | } |
| 10054 | } |
| 10055 | } |
| 10056 | } |
| 10057 | else |
| 10058 | { |
| 10059 | if (__make<__operator_conditional>()) |
| 10060 | first += 2; |
| 10061 | } |
| 10062 | } |
| 10063 | break; |
| 10064 | case 'r': |
| 10065 | switch (first[1]) |
| 10066 | { |
| 10067 | case 'm': |
| 10068 | // % |
| 10069 | if (type) |
| 10070 | { |
| 10071 | const char* t = __parse_expression(first+2, last); |
| 10072 | if (t != first+2) |
| 10073 | { |
| 10074 | __node* op1 = __root_; |
| 10075 | const char* t2 = __parse_expression(t, last); |
| 10076 | if (t != t2) |
| 10077 | { |
| 10078 | if (__make<__operator_mod>(op1, __root_)) |
| 10079 | { |
| 10080 | *type = 2; |
| 10081 | first = t2; |
| 10082 | } |
| 10083 | } |
| 10084 | } |
| 10085 | } |
| 10086 | else |
| 10087 | { |
| 10088 | if (__make<__operator_mod>()) |
| 10089 | first += 2; |
| 10090 | } |
| 10091 | break; |
| 10092 | case 'M': |
| 10093 | // %= |
| 10094 | if (type) |
| 10095 | { |
| 10096 | const char* t = __parse_expression(first+2, last); |
| 10097 | if (t != first+2) |
| 10098 | { |
| 10099 | __node* op1 = __root_; |
| 10100 | const char* t2 = __parse_expression(t, last); |
| 10101 | if (t != t2) |
| 10102 | { |
| 10103 | if (__make<__operator_mod_equal>(op1, __root_)) |
| 10104 | { |
| 10105 | *type = 2; |
| 10106 | first = t2; |
| 10107 | } |
| 10108 | } |
| 10109 | } |
| 10110 | } |
| 10111 | else |
| 10112 | { |
| 10113 | if (__make<__operator_mod_equal>()) |
| 10114 | first += 2; |
| 10115 | } |
| 10116 | break; |
| 10117 | case 's': |
| 10118 | // >> |
| 10119 | if (type) |
| 10120 | { |
| 10121 | const char* t = __parse_expression(first+2, last); |
| 10122 | if (t != first+2) |
| 10123 | { |
| 10124 | __node* op1 = __root_; |
| 10125 | const char* t2 = __parse_expression(t, last); |
| 10126 | if (t != t2) |
| 10127 | { |
| 10128 | if (__make<__operator_right_shift>(op1, __root_)) |
| 10129 | { |
| 10130 | *type = 2; |
| 10131 | first = t2; |
| 10132 | } |
| 10133 | } |
| 10134 | } |
| 10135 | } |
| 10136 | else |
| 10137 | { |
| 10138 | if (__make<__operator_right_shift>()) |
| 10139 | first += 2; |
| 10140 | } |
| 10141 | break; |
| 10142 | case 'S': |
| 10143 | // >>= |
| 10144 | if (type) |
| 10145 | { |
| 10146 | const char* t = __parse_expression(first+2, last); |
| 10147 | if (t != first+2) |
| 10148 | { |
| 10149 | __node* op1 = __root_; |
| 10150 | const char* t2 = __parse_expression(t, last); |
| 10151 | if (t != t2) |
| 10152 | { |
| 10153 | if (__make<__operator_right_shift_equal>(op1, __root_)) |
| 10154 | { |
| 10155 | *type = 2; |
| 10156 | first = t2; |
| 10157 | } |
| 10158 | } |
| 10159 | } |
| 10160 | } |
| 10161 | else |
| 10162 | { |
| 10163 | if (__make<__operator_right_shift_equal>()) |
| 10164 | first += 2; |
| 10165 | } |
| 10166 | break; |
| 10167 | } |
| 10168 | break; |
| 10169 | case 's': |
| 10170 | switch (first[1]) |
| 10171 | { |
| 10172 | case 't': |
| 10173 | // sizeof (a type) |
| 10174 | if (type) |
| 10175 | { |
| 10176 | const char* t = __parse_expression(first+2, last); |
| 10177 | if (t != first+2) |
| 10178 | { |
| 10179 | if (__make<__operator_sizeof_type>(__root_)) |
| 10180 | { |
| 10181 | *type = -1; |
| 10182 | first = t; |
| 10183 | } |
| 10184 | } |
| 10185 | } |
| 10186 | else |
| 10187 | { |
| 10188 | if (__make<__operator_sizeof_type>()) |
| 10189 | first += 2; |
| 10190 | } |
| 10191 | break; |
| 10192 | case 'z': |
| 10193 | // sizeof (an expression) |
| 10194 | if (type) |
| 10195 | { |
| 10196 | const char* t = __parse_expression(first+2, last); |
| 10197 | if (t != first+2) |
| 10198 | { |
| 10199 | if (__make<__operator_sizeof_expression>(__root_)) |
| 10200 | { |
| 10201 | *type = -1; |
| 10202 | first = t; |
| 10203 | } |
| 10204 | } |
| 10205 | } |
| 10206 | else |
| 10207 | { |
| 10208 | if (__make<__operator_sizeof_expression>()) |
| 10209 | first += 2; |
| 10210 | } |
| 10211 | break; |
| 10212 | } |
| 10213 | break; |
| 10214 | } |
| 10215 | } |
| 10216 | return first; |
| 10217 | } |
| 10218 | |
| 10219 | // <source-name> ::= <positive length number> <identifier> |
| 10220 | |
| 10221 | const char* |
| 10222 | __demangle_tree::__parse_source_name(const char* first, const char* last) |
| 10223 | { |
| 10224 | if (first != last) |
| 10225 | { |
| 10226 | char c = *first; |
| 10227 | if ('1' <= c && c <= '9' && first+1 != last) |
| 10228 | { |
| 10229 | const char* t = first+1; |
| 10230 | size_t n = static_cast<size_t>(c - '0'); |
| 10231 | for (c = *t; '0' <= c && c <= '9'; c = *t) |
| 10232 | { |
| 10233 | n = n * 10 + static_cast<size_t>(c - '0'); |
| 10234 | if (++t == last) |
| 10235 | return first; |
| 10236 | } |
| 10237 | if (static_cast<size_t>(last - t) >= n && __make<__source_name>(t, n)) |
| 10238 | first = t + n; |
| 10239 | } |
| 10240 | } |
| 10241 | return first; |
| 10242 | } |
| 10243 | |
| 10244 | // <unqualified-name> ::= <operator-name> |
| 10245 | // ::= <ctor-dtor-name> |
| 10246 | // ::= <source-name> |
| 10247 | // ::= <unnamed-type-name> |
| 10248 | |
| 10249 | const char* |
| 10250 | __demangle_tree::__parse_unqualified_name(const char* first, const char* last) |
| 10251 | { |
| 10252 | const char* t = __parse_source_name(first, last); |
| 10253 | if (t == first) |
| 10254 | { |
| 10255 | t = __parse_ctor_dtor_name(first, last); |
| 10256 | if (t == first) |
| 10257 | { |
| 10258 | t = __parse_operator_name(first, last); |
| 10259 | if (t == first) |
| 10260 | first = __parse_unnamed_type_name(first, last); |
| 10261 | else |
| 10262 | first = t; |
| 10263 | } |
| 10264 | else |
| 10265 | first = t; |
| 10266 | } |
| 10267 | else |
| 10268 | first = t; |
| 10269 | return first; |
| 10270 | } |
| 10271 | |
| 10272 | // <unscoped-name> ::= <unqualified-name> |
| 10273 | // ::= St <unqualified-name> # ::std:: |
| 10274 | // extension ::= StL<unqualified-name> |
| 10275 | |
| 10276 | const char* |
| 10277 | __demangle_tree::__parse_unscoped_name(const char* first, const char* last) |
| 10278 | { |
| 10279 | if (last - first >= 2) |
| 10280 | { |
| 10281 | const char* t0 = first; |
| 10282 | if (first[0] == 'S' && first[1] == 't') |
| 10283 | { |
| 10284 | t0 += 2; |
| 10285 | if (t0 != last && *t0 == 'L') |
| 10286 | ++t0; |
| 10287 | } |
| 10288 | const char* t1 = __parse_unqualified_name(t0, last); |
| 10289 | if (t1 != t0) |
| 10290 | { |
| 10291 | if (t0 != first) |
| 10292 | { |
| 10293 | __node* name = __root_; |
| 10294 | if (__make<__std_qualified_name>()) |
| 10295 | { |
| 10296 | if (__make<__nested_delimeter>(__root_, name)) |
| 10297 | first = t1; |
| 10298 | } |
| 10299 | } |
| 10300 | else |
| 10301 | first = t1; |
| 10302 | } |
| 10303 | } |
| 10304 | return first; |
| 10305 | } |
| 10306 | |
| 10307 | // <nested-name> ::= N [<CV-qualifiers>] <prefix> <unqualified-name> E |
| 10308 | // ::= N [<CV-qualifiers>] <template-prefix> <template-args> E |
| 10309 | // |
| 10310 | // <prefix> ::= <prefix> <unqualified-name> |
| 10311 | // ::= <template-prefix> <template-args> |
| 10312 | // ::= <template-param> |
| 10313 | // ::= <decltype> |
| 10314 | // ::= # empty |
| 10315 | // ::= <substitution> |
| 10316 | // ::= <prefix> <data-member-prefix> |
| 10317 | // extension ::= L |
| 10318 | // |
| 10319 | // <template-prefix> ::= <prefix> <template unqualified-name> |
| 10320 | // ::= <template-param> |
| 10321 | // ::= <substitution> |
| 10322 | |
| 10323 | const char* |
| 10324 | __demangle_tree::__parse_nested_name(const char* first, const char* last) |
| 10325 | { |
| 10326 | if (first != last && *first == 'N') |
| 10327 | { |
| 10328 | unsigned cv = 0; |
| 10329 | const char* t0 = __parse_cv_qualifiers(first+1, last, cv, true); |
| 10330 | __node* prev = NULL; |
| 10331 | if (last - t0 >= 2 && t0[0] == 'S' && t0[1] == 't') |
| 10332 | { |
| 10333 | t0 += 2; |
| 10334 | if (!__make<__std_qualified_name>()) |
| 10335 | return first; |
| 10336 | prev = __root_; |
| 10337 | } |
| 10338 | while (t0 != last) |
| 10339 | { |
| 10340 | bool can_sub = true; |
| 10341 | bool make_nested = true; |
| 10342 | const char* t1 = NULL; |
| 10343 | switch (*t0) |
| 10344 | { |
| 10345 | case '1': |
| 10346 | case '2': |
| 10347 | case '3': |
| 10348 | case '4': |
| 10349 | case '5': |
| 10350 | case '6': |
| 10351 | case '7': |
| 10352 | case '8': |
| 10353 | case '9': |
| 10354 | t1 = __parse_source_name(t0, last); |
| 10355 | if (t1 == t0 || t1 == last) |
| 10356 | return first; |
| 10357 | if (*t1 == 'M') |
| 10358 | { |
| 10359 | // This is a data-member-prefix |
| 10360 | ++t1; |
| 10361 | } |
| 10362 | else if (*t1 == 'I') |
| 10363 | { |
| 10364 | // has following <template-args> |
| 10365 | if (prev) |
| 10366 | { |
| 10367 | if (!__make<__nested_delimeter>(prev, __root_)) |
| 10368 | return first; |
| 10369 | make_nested = false; |
| 10370 | } |
| 10371 | if (__sub_end_ == __sub_cap_) |
| 10372 | { |
| 10373 | __status_ = memory_alloc_failure; |
| 10374 | return first; |
| 10375 | } |
| 10376 | else |
| 10377 | *__sub_end_++ = __root_; |
| 10378 | const char* t2 = __parse_template_args(t1, last); |
| 10379 | if (t2 == t1) |
| 10380 | return first; |
| 10381 | t1 = t2; |
| 10382 | } |
| 10383 | break; |
| 10384 | case 'D': |
| 10385 | if (t0+1 != last && (t0[1] == 't' || t0[1] == 'T')) |
| 10386 | { |
| 10387 | t1 = __parse_decltype(t0, last); |
| 10388 | break; |
| 10389 | } |
| 10390 | // check for Dt, DT here, else drop through |
| 10391 | case 'C': |
| 10392 | t1 = __parse_ctor_dtor_name(t0, last); |
| 10393 | if (t1 == t0 || t1 == last) |
| 10394 | return first; |
| 10395 | if (*t1 == 'I') |
| 10396 | { |
| 10397 | // has following <template-args> |
| 10398 | if (prev) |
| 10399 | { |
| 10400 | if (!__make<__nested_delimeter>(prev, __root_)) |
| 10401 | return first; |
| 10402 | make_nested = false; |
| 10403 | } |
| 10404 | if (__sub_end_ == __sub_cap_) |
| 10405 | { |
| 10406 | __status_ = memory_alloc_failure; |
| 10407 | return first; |
| 10408 | } |
| 10409 | else |
| 10410 | *__sub_end_++ = __root_; |
| 10411 | const char* t2 = __parse_template_args(t1, last); |
| 10412 | if (t2 == t1) |
| 10413 | return first; |
| 10414 | t1 = t2; |
| 10415 | } |
| 10416 | break; |
| 10417 | case 'U': |
| 10418 | t1 = __parse_unnamed_type_name(t0, last); |
| 10419 | if (t1 == t0 || t1 == last) |
| 10420 | return first; |
| 10421 | break; |
| 10422 | case 'T': |
| 10423 | t1 = __parse_template_param(t0, last); |
| 10424 | if (t1 == t0 || t1 == last) |
| 10425 | return first; |
| 10426 | if (*t1 == 'I') |
| 10427 | { |
| 10428 | // has following <template-args> |
| 10429 | if (prev) |
| 10430 | { |
| 10431 | if (!__make<__nested_delimeter>(prev, __root_)) |
| 10432 | return first; |
| 10433 | make_nested = false; |
| 10434 | } |
| 10435 | if (__sub_end_ == __sub_cap_) |
| 10436 | { |
| 10437 | __status_ = memory_alloc_failure; |
| 10438 | return first; |
| 10439 | } |
| 10440 | else |
| 10441 | *__sub_end_++ = __root_; |
| 10442 | const char* t2 = __parse_template_args(t1, last); |
| 10443 | if (t2 == t1) |
| 10444 | return first; |
| 10445 | t1 = t2; |
| 10446 | } |
| 10447 | break; |
| 10448 | case 'S': |
| 10449 | t1 = __parse_substitution(t0, last); |
| 10450 | if (t1 == t0 || t1 == last) |
| 10451 | return first; |
| 10452 | if (*t1 == 'I') |
| 10453 | { |
| 10454 | const char* t2 = __parse_template_args(t1, last); |
| 10455 | if (t2 == t1) |
| 10456 | return first; |
| 10457 | t1 = t2; |
| 10458 | } |
| 10459 | else |
| 10460 | can_sub = false; |
| 10461 | break; |
| 10462 | case 'L': |
| 10463 | // extension: ignore L here |
| 10464 | ++t0; |
| 10465 | continue; |
| 10466 | default: |
| 10467 | t1 = __parse_operator_name(t0, last); |
| 10468 | if (t1 == t0 || t1 == last) |
| 10469 | return first; |
| 10470 | if (*t1 == 'I') |
| 10471 | { |
| 10472 | // has following <template-args> |
| 10473 | if (prev) |
| 10474 | { |
| 10475 | if (!__make<__nested_delimeter>(prev, __root_)) |
| 10476 | return first; |
| 10477 | make_nested = false; |
| 10478 | } |
| 10479 | if (__sub_end_ == __sub_cap_) |
| 10480 | { |
| 10481 | __status_ = memory_alloc_failure; |
| 10482 | return first; |
| 10483 | } |
| 10484 | else |
| 10485 | *__sub_end_++ = __root_; |
| 10486 | const char* t2 = __parse_template_args(t1, last); |
| 10487 | if (t2 == t1) |
| 10488 | return first; |
| 10489 | t1 = t2; |
| 10490 | } |
| 10491 | break; |
| 10492 | } |
| 10493 | if (t1 == t0 || t1 == last) |
| 10494 | return first; |
| 10495 | if (prev && make_nested) |
| 10496 | { |
| 10497 | if (!__make<__nested_delimeter>(prev, __root_)) |
| 10498 | return first; |
| 10499 | can_sub = true; |
| 10500 | } |
| 10501 | if (can_sub && *t1 != 'E') |
| 10502 | { |
| 10503 | if (__sub_end_ == __sub_cap_) |
| 10504 | { |
| 10505 | __status_ = memory_alloc_failure; |
| 10506 | return first; |
| 10507 | } |
| 10508 | else |
| 10509 | *__sub_end_++ = __root_; |
| 10510 | } |
| 10511 | if (*t1 == 'E') |
| 10512 | { |
| 10513 | if (cv != 0) |
| 10514 | { |
| 10515 | if (!__make<__cv_qualifiers>(cv, __root_)) |
| 10516 | return first; |
| 10517 | } |
| 10518 | first = t1+1; |
| 10519 | break; |
| 10520 | } |
| 10521 | prev = __root_; |
| 10522 | t0 = t1; |
| 10523 | } |
| 10524 | } |
| 10525 | return first; |
| 10526 | } |
| 10527 | |
| 10528 | // <template-arg> ::= <type> # type or template |
| 10529 | // ::= X <expression> E # expression |
| 10530 | // ::= <expr-primary> # simple expressions |
| 10531 | // ::= J <template-arg>* E # argument pack |
| 10532 | // ::= LZ <encoding> E # extension |
| 10533 | |
| 10534 | const char* |
| 10535 | __demangle_tree::__parse_template_arg(const char* first, const char* last) |
| 10536 | { |
| 10537 | if (first != last) |
| 10538 | { |
| 10539 | const char* t; |
| 10540 | switch (*first) |
| 10541 | { |
| 10542 | case 'X': |
| 10543 | t = __parse_expression(first+1, last); |
| 10544 | if (t != first+1) |
| 10545 | { |
| 10546 | if (t != last && *t == 'E') |
| 10547 | first = t+1; |
| 10548 | } |
| 10549 | break; |
| 10550 | case 'J': |
| 10551 | t = first+1; |
| 10552 | if (t == last) |
| 10553 | return first; |
| 10554 | if (*t == 'E') |
| 10555 | { |
| 10556 | if (__make<__list>((__node*)0)) |
| 10557 | first = t+1; |
| 10558 | } |
| 10559 | else |
| 10560 | { |
| 10561 | __node* list = NULL; |
| 10562 | __node* prev = NULL; |
| 10563 | do |
| 10564 | { |
| 10565 | const char* t2 = __parse_template_arg(t, last); |
| 10566 | if (t2 == t || !__make<__list>(__root_)) |
| 10567 | return first; |
| 10568 | if (list == 0) |
| 10569 | list = __root_; |
| 10570 | if (prev) |
| 10571 | { |
| 10572 | prev->__right_ = __root_; |
| 10573 | __root_->__size_ = prev->__size_ + 1; |
| 10574 | } |
| 10575 | prev = __root_; |
| 10576 | t = t2; |
| 10577 | } while (t != last && *t != 'E'); |
| 10578 | first = t+1; |
| 10579 | __root_ = list; |
| 10580 | } |
| 10581 | break; |
| 10582 | case 'L': |
| 10583 | // <expr-primary> or LZ <encoding> E |
| 10584 | if (first+1 != last && first[1] == 'Z') |
| 10585 | { |
| 10586 | t = __parse_encoding(first+2, last); |
| 10587 | if (t != first+2 && t != last && *t == 'E') |
| 10588 | first = t+1; |
| 10589 | } |
| 10590 | else |
| 10591 | first = __parse_expr_primary(first, last); |
| 10592 | break; |
| 10593 | default: |
| 10594 | // <type> |
| 10595 | first = __parse_type(first, last); |
| 10596 | break; |
| 10597 | } |
| 10598 | } |
| 10599 | return first; |
| 10600 | } |
| 10601 | |
| 10602 | // <template-args> ::= I <template-arg>* E |
| 10603 | // extension, the abi says <template-arg>+ |
| 10604 | |
| 10605 | const char* |
| 10606 | __demangle_tree::__parse_template_args(const char* first, const char* last) |
| 10607 | { |
| 10608 | if (last - first >= 2 && *first == 'I') |
| 10609 | { |
| 10610 | __node* args = NULL; |
| 10611 | __node* prev = NULL; |
| 10612 | __node* name = __root_; |
| 10613 | if (__tag_templates_) |
| 10614 | __t_end_ = __t_begin_; |
| 10615 | const char* t = first+1; |
| 10616 | while (*t != 'E') |
| 10617 | { |
| 10618 | bool prev_tag_templates = __tag_templates_; |
| 10619 | __node** prev_t_begin = __t_begin_; |
| 10620 | __node** prev_t_end = __t_end_; |
| 10621 | if (__tag_templates_) |
| 10622 | __t_begin_ = __t_end_; |
| 10623 | const char* t2 = __parse_template_arg(t, last); |
| 10624 | if (prev_tag_templates) |
| 10625 | { |
| 10626 | __tag_templates_ = prev_tag_templates; |
| 10627 | __t_begin_ = prev_t_begin; |
| 10628 | __t_end_ = prev_t_end; |
| 10629 | } |
| 10630 | if (t2 == t || t2 == last) |
| 10631 | break; |
| 10632 | if (!__make<__list>(__root_)) |
| 10633 | return first; |
| 10634 | if (args == 0) |
| 10635 | args = __root_; |
| 10636 | if (prev) |
| 10637 | { |
| 10638 | prev->__right_ = __root_; |
| 10639 | __root_->__size_ = prev->__size_ + 1; |
| 10640 | } |
| 10641 | prev = __root_; |
| 10642 | if (__tag_templates_) |
| 10643 | { |
| 10644 | if (__t_end_ == __t_cap_) |
| 10645 | { |
| 10646 | __status_ = memory_alloc_failure; |
| 10647 | return first; |
| 10648 | } |
| 10649 | if (__root_->__left_) |
| 10650 | *__t_end_++ = __root_->__left_; |
| 10651 | else |
| 10652 | *__t_end_++ = __root_; |
| 10653 | } |
| 10654 | t = t2; |
| 10655 | } |
| 10656 | if (t != last && *t == 'E') |
| 10657 | { |
| 10658 | if (__make<__template_args>(name, args)) |
| 10659 | first = t+1; |
| 10660 | } |
| 10661 | } |
| 10662 | return first; |
| 10663 | } |
| 10664 | |
| 10665 | // <substitution> ::= S <seq-id> _ |
| 10666 | // ::= S_ |
| 10667 | // <substitution> ::= Sa # ::std::allocator |
| 10668 | // <substitution> ::= Sb # ::std::basic_string |
| 10669 | // <substitution> ::= Ss # ::std::basic_string < char, |
| 10670 | // ::std::char_traits<char>, |
| 10671 | // ::std::allocator<char> > |
| 10672 | // <substitution> ::= Si # ::std::basic_istream<char, std::char_traits<char> > |
| 10673 | // <substitution> ::= So # ::std::basic_ostream<char, std::char_traits<char> > |
| 10674 | // <substitution> ::= Sd # ::std::basic_iostream<char, std::char_traits<char> > |
| 10675 | |
| 10676 | const char* |
| 10677 | __demangle_tree::__parse_substitution(const char* first, const char* last) |
| 10678 | { |
| 10679 | if (last - first >= 2) |
| 10680 | { |
| 10681 | if (*first == 'S') |
| 10682 | { |
| 10683 | switch (first[1]) |
| 10684 | { |
| 10685 | case 'a': |
| 10686 | if (__make<__sub_allocator>()) |
| 10687 | first += 2; |
| 10688 | break; |
| 10689 | case 'b': |
| 10690 | if (__make<__sub_basic_string>()) |
| 10691 | first += 2; |
| 10692 | break; |
| 10693 | case 's': |
| 10694 | if (__make<__sub_string>()) |
| 10695 | first += 2; |
| 10696 | break; |
| 10697 | case 'i': |
| 10698 | if (__make<__sub_istream>()) |
| 10699 | first += 2; |
| 10700 | break; |
| 10701 | case 'o': |
| 10702 | if (__make<__sub_ostream>()) |
| 10703 | first += 2; |
| 10704 | break; |
| 10705 | case 'd': |
| 10706 | if (__make<__sub_iostream>()) |
| 10707 | first += 2; |
| 10708 | break; |
| 10709 | case '_': |
| 10710 | if (__sub_begin_ != __sub_end_) |
| 10711 | { |
| 10712 | if (__make<__sub>(*__sub_begin_)) |
| 10713 | first += 2; |
| 10714 | } |
| 10715 | break; |
| 10716 | default: |
| 10717 | if (isdigit(first[1]) || isupper(first[1])) |
| 10718 | { |
| 10719 | size_t sub = 0; |
| 10720 | const char* t = first+1; |
| 10721 | if (isdigit(*t)) |
| 10722 | sub = static_cast<size_t>(*t - '0'); |
| 10723 | else |
| 10724 | sub = static_cast<size_t>(*t - 'A') + 10; |
| 10725 | for (++t; t != last && (isdigit(*t) || isupper(*t)); ++t) |
| 10726 | { |
| 10727 | sub *= 36; |
| 10728 | if (isdigit(*t)) |
| 10729 | sub += static_cast<size_t>(*t - '0'); |
| 10730 | else |
| 10731 | sub += static_cast<size_t>(*t - 'A') + 10; |
| 10732 | } |
| 10733 | if (t == last || *t != '_') |
| 10734 | return first; |
| 10735 | ++sub; |
| 10736 | if (sub < static_cast<size_t>(__sub_end_ - __sub_begin_)) |
| 10737 | { |
| 10738 | if (__make<__sub>(__sub_begin_[sub])) |
| 10739 | first = t+1; |
| 10740 | } |
| 10741 | } |
| 10742 | break; |
| 10743 | } |
| 10744 | } |
| 10745 | } |
| 10746 | return first; |
| 10747 | } |
| 10748 | |
| 10749 | // <name> ::= <nested-name> |
| 10750 | // ::= <local-name> # See Scope Encoding below |
| 10751 | // ::= <unscoped-template-name> <template-args> |
| 10752 | // ::= <unscoped-name> |
| 10753 | |
| 10754 | const char* |
| 10755 | __demangle_tree::__parse_name(const char* first, const char* last) |
| 10756 | { |
| 10757 | if (first != last) |
| 10758 | { |
| 10759 | const char* t0 = first; |
| 10760 | // extension: ignore L here |
| 10761 | if (*t0 == 'L') |
| 10762 | ++t0; |
| 10763 | const char* t = __parse_nested_name(t0, last); |
| 10764 | if (t == t0) |
| 10765 | { |
| 10766 | t = __parse_local_name(t0, last); |
| 10767 | if (t == t0) |
| 10768 | { |
| 10769 | // not <nested-name> nor <local-name> |
| 10770 | // Try to parse <unscoped-template-name> <template-args> or |
| 10771 | // <unscoped-name> which are nearly ambiguous. |
| 10772 | // This logic occurs nowhere else. |
| 10773 | if (last - t0 >= 2) |
| 10774 | { |
| 10775 | if (t0[0] == 'S' && (t0[1] == '_' || |
| 10776 | isdigit(t0[1]) || |
| 10777 | isupper(t0[1]) || |
| 10778 | t0[1] == 'a' || |
| 10779 | t0[1] == 'b')) |
| 10780 | { |
| 10781 | t = __parse_substitution(t0, last); |
| 10782 | if (t != t0) |
| 10783 | { |
| 10784 | const char* t2 = __parse_template_args(t, last); |
| 10785 | if (t2 != t) |
| 10786 | first = t2; |
| 10787 | } |
| 10788 | } |
| 10789 | else // Not a substitution, except maybe St |
| 10790 | { |
| 10791 | t = __parse_unscoped_name(t0, last); |
| 10792 | if (t != t0) |
| 10793 | { |
| 10794 | // unscoped-name might be <unscoped-template-name> |
| 10795 | if (t != last && *t == 'I') |
| 10796 | { |
| 10797 | if (__sub_end_ == __sub_cap_) |
| 10798 | { |
| 10799 | __status_ = memory_alloc_failure; |
| 10800 | return first; |
| 10801 | } |
| 10802 | *__sub_end_++ = __root_; |
| 10803 | const char* t2 = __parse_template_args(t, last); |
| 10804 | if (t2 != t) |
| 10805 | first = t2; |
| 10806 | } |
| 10807 | else |
| 10808 | { |
| 10809 | // <unscoped-name> |
| 10810 | first = t; |
| 10811 | } |
| 10812 | } |
| 10813 | } |
| 10814 | } |
| 10815 | } |
| 10816 | else |
| 10817 | first = t; |
| 10818 | } |
| 10819 | else |
| 10820 | first = t; |
| 10821 | } |
| 10822 | return first; |
| 10823 | } |
| 10824 | |
| 10825 | // extension |
| 10826 | // <dot-suffix> := .<anything and everything> |
| 10827 | |
| 10828 | const char* |
| 10829 | __demangle_tree::__parse_dot_suffix(const char* first, const char* last) |
| 10830 | { |
| 10831 | if (first != last && *first == '.') |
| 10832 | { |
| 10833 | if (__make<__dot_suffix>(__root_, first, static_cast<size_t>(last-first))) |
| 10834 | first = last; |
| 10835 | } |
| 10836 | return first; |
| 10837 | } |
| 10838 | |
| 10839 | // <encoding> ::= <function name> <bare-function-type> |
| 10840 | // ::= <data name> |
| 10841 | // ::= <special-name> |
| 10842 | |
| 10843 | const char* |
| 10844 | __demangle_tree::__parse_encoding(const char* first, const char* last) |
| 10845 | { |
| 10846 | const char* t = __parse_name(first, last); |
| 10847 | if (t != first) |
| 10848 | { |
| 10849 | if (t != last && *t != 'E' && *t != '.') |
| 10850 | { |
| 10851 | __node* name = __root_; |
| 10852 | bool has_return = name->ends_with_template(true) && |
| 10853 | !name->is_ctor_dtor_conv(); |
| 10854 | __node* ret = NULL; |
| 10855 | const char* t2; |
| 10856 | bool prev_tag_templates = __tag_templates_; |
| 10857 | __tag_templates_ = false; |
| 10858 | if (has_return) |
| 10859 | { |
| 10860 | t2 = __parse_type(t, last); |
| 10861 | if (t2 != t) |
| 10862 | { |
| 10863 | ret = __root_; |
| 10864 | t = t2; |
| 10865 | } |
| 10866 | else |
| 10867 | return first; |
| 10868 | } |
| 10869 | t2 = __parse_bare_function_type(t, last); |
| 10870 | if (t2 != t) |
| 10871 | { |
| 10872 | if (dynamic_cast<__void*>(__root_->__left_) != NULL) |
| 10873 | __root_->__left_ = NULL; |
| 10874 | if (__make<__function_signature>(ret, __root_)) |
| 10875 | { |
| 10876 | __node* cv = name->extract_cv(name); |
| 10877 | if (__make<__function>(name, __root_)) |
| 10878 | { |
| 10879 | if (cv) |
| 10880 | { |
| 10881 | cv->__left_ = __root_; |
| 10882 | cv->__size_ <<= 5; |
| 10883 | __root_ = cv; |
| 10884 | } |
| 10885 | first = t2; |
| 10886 | } |
| 10887 | } |
| 10888 | } |
| 10889 | __tag_templates_ = prev_tag_templates; |
| 10890 | } |
| 10891 | else |
| 10892 | first = t; |
| 10893 | } |
| 10894 | else |
| 10895 | first = __parse_special_name(first, last); |
| 10896 | return first; |
| 10897 | } |
| 10898 | |
| 10899 | // <mangled-name> ::= _Z<encoding> |
| 10900 | // ::= <type> |
| 10901 | |
| 10902 | void |
| 10903 | __demangle_tree::__parse() |
| 10904 | { |
| 10905 | if (__mangled_name_begin_ == __mangled_name_end_) |
| 10906 | { |
| 10907 | __status_ = invalid_mangled_name; |
| 10908 | return; |
| 10909 | } |
| 10910 | const char* t = NULL; |
| 10911 | if (__mangled_name_end_ - __mangled_name_begin_ >= 2 && |
| 10912 | __mangled_name_begin_[0] == '_' && |
| 10913 | __mangled_name_begin_[1] == 'Z') |
| 10914 | { |
| 10915 | t = __parse_encoding(__mangled_name_begin_+2, __mangled_name_end_); |
| 10916 | if (t != __mangled_name_begin_+2 && t != __mangled_name_end_ && *t == '.') |
| 10917 | t = __parse_dot_suffix(t, __mangled_name_end_); |
| 10918 | } |
| 10919 | else |
| 10920 | t = __parse_type(__mangled_name_begin_, __mangled_name_end_); |
| 10921 | if (t == __mangled_name_end_ && __root_) |
| 10922 | { |
| 10923 | if (__fix_forward_references_) |
| 10924 | { |
| 10925 | if (__root_->fix_forward_references(__t_begin_, __t_end_)) |
| 10926 | __status_ = success; |
| 10927 | } |
| 10928 | else |
| 10929 | __status_ = success; |
| 10930 | } |
| 10931 | } |
| 10932 | |
| 10933 | __demangle_tree |
| 10934 | __demangle(const char* mangled_name, char* buf, size_t bs) |
| 10935 | { |
| 10936 | __demangle_tree t(mangled_name, buf, bs); |
| 10937 | if (t.__status() == invalid_mangled_name) |
| 10938 | t.__parse(); |
| 10939 | return t; |
| 10940 | } |
| 10941 | |
| 10942 | __demangle_tree |
| 10943 | __demangle(const char* mangled_name) |
| 10944 | { |
| 10945 | return __demangle(mangled_name, 0, 0); |
| 10946 | } |
| 10947 | |
| 10948 | char* |
| 10949 | __demangle(__demangle_tree dmg_tree, char* buf, size_t* n, int* status) |
| 10950 | { |
| 10951 | if (dmg_tree.__status() != success) |
| 10952 | { |
| 10953 | if (status) |
| 10954 | *status = dmg_tree.__status(); |
| 10955 | return NULL; |
| 10956 | } |
| 10957 | #ifdef DEBUGGING |
| 10958 | display(dmg_tree.__root_); |
| 10959 | printf("\n"); |
| 10960 | #endif |
| 10961 | const size_t bs = buf == NULL ? 0 : *n; |
| 10962 | ptrdiff_t sm = dmg_tree.__mangled_name_end_ - dmg_tree.__mangled_name_begin_; |
| 10963 | ptrdiff_t est = sm + 60 * ( |
| 10964 | (dmg_tree.__node_end_ - dmg_tree.__node_begin_) + |
| 10965 | (dmg_tree.__sub_end_ - dmg_tree.__sub_begin_) + |
| 10966 | (dmg_tree.__t_end_ - dmg_tree.__t_begin_)); |
| 10967 | const unsigned N = 4096; |
| 10968 | char tmp[N]; |
| 10969 | ptrdiff_t s; |
| 10970 | if (static_cast<size_t>(est) <= bs) |
| 10971 | { |
| 10972 | char* e = dmg_tree.__get_demangled_name(buf); |
| 10973 | *e++ = '\0'; |
| 10974 | s = e - buf; |
| 10975 | } |
| 10976 | else if (static_cast<size_t>(est) <= N) |
| 10977 | { |
| 10978 | char* e = dmg_tree.__get_demangled_name(tmp); |
| 10979 | *e++ = '\0'; |
| 10980 | s = e - tmp; |
| 10981 | } |
| 10982 | else |
| 10983 | s = static_cast<ptrdiff_t>(dmg_tree.size() + 1); |
| 10984 | if (static_cast<size_t>(s) > bs) |
| 10985 | { |
| 10986 | buf = static_cast<char*>(realloc(buf, static_cast<size_t>(s))); |
| 10987 | if (buf == NULL) |
| 10988 | { |
| 10989 | if (status) |
| 10990 | *status = memory_alloc_failure; |
| 10991 | return NULL; |
| 10992 | } |
| 10993 | if (n) |
| 10994 | *n = static_cast<size_t>(s); |
| 10995 | } |
| 10996 | if (static_cast<size_t>(est) > bs) |
| 10997 | { |
| 10998 | if (static_cast<size_t>(est) <= N) |
| 10999 | strncpy(buf, tmp, static_cast<size_t>(s)); |
| 11000 | else |
| 11001 | *dmg_tree.__get_demangled_name(buf) = '\0'; |
| 11002 | } |
| 11003 | if (status) |
| 11004 | *status = success; |
| 11005 | return buf; |
| 11006 | } |
| 11007 | |
| 11008 | } // __libcxxabi |
| 11009 | |
| 11010 | #pragma GCC visibility pop |
| 11011 | #pragma GCC visibility push(default) |
| 11012 | |
| 11013 | //extern "C" |
| 11014 | //{ |
| 11015 | |
| 11016 | char* |
| 11017 | __cxa_demangle(const char* mangled_name, char* buf, size_t* n, int* status) |
| 11018 | { |
| 11019 | if (mangled_name == NULL || (buf != NULL && n == NULL)) |
| 11020 | { |
| 11021 | if (status) |
| 11022 | *status = __libcxxabi::invalid_args; |
| 11023 | return NULL; |
| 11024 | } |
| 11025 | const size_t bs = 4 * 1024; |
| 11026 | __attribute((aligned(16))) char static_buf[bs]; |
| 11027 | |
| 11028 | buf = __libcxxabi::__demangle(__libcxxabi::__demangle(mangled_name, |
| 11029 | static_buf, bs), |
| 11030 | buf, n, status); |
| 11031 | return buf; |
| 11032 | } |
| 11033 | |
| 11034 | //} // extern "C" |
| 11035 | |
| 11036 | } // lldb_cxxabiv1 |