Howard Hinnant | 4fbf16a | 2011-05-05 15:27:28 +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 | |
| 10 | #include "cxa_demangle.h" |
| 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 | |
| 21 | #ifdef DEBUGGING |
| 22 | |
| 23 | #include <string> |
| 24 | #include <typeinfo> |
| 25 | |
| 26 | #endif |
| 27 | |
| 28 | namespace __cxxabiv1 |
| 29 | { |
| 30 | |
| 31 | namespace __libcxxabi |
| 32 | { |
| 33 | |
| 34 | #pragma GCC visibility push(hidden) |
| 35 | |
| 36 | class __node |
| 37 | { |
| 38 | __node(const __node&); |
| 39 | __node& operator=(const __node&); |
| 40 | public: |
| 41 | const char* __name_; |
| 42 | size_t __size_; |
| 43 | __node* __left_; |
| 44 | __node* __right_; |
| 45 | long double __value_; |
| 46 | long __cached_size_; |
| 47 | public: |
| 48 | __node() |
| 49 | : __name_(0), __size_(0), __left_(0), __right_(0), __cached_size_(-1) |
| 50 | {} |
| 51 | virtual ~__node() {}; |
| 52 | |
| 53 | void reset_cached_size() |
| 54 | { |
| 55 | __cached_size_ = -1; |
| 56 | if (__left_) |
| 57 | __left_->reset_cached_size(); |
| 58 | if (__right_) |
| 59 | __right_->reset_cached_size(); |
| 60 | } |
| 61 | |
| 62 | virtual size_t first_size() const {return 0;} |
| 63 | virtual size_t second_size() const {return 0;} |
| 64 | virtual size_t size() const |
| 65 | { |
| 66 | if (__cached_size_ == -1) |
| 67 | const_cast<long&>(__cached_size_) = first_size() + second_size(); |
| 68 | return __cached_size_; |
| 69 | } |
| 70 | virtual char* first_demangled_name(char* buf) const {return buf;} |
| 71 | virtual char* second_demangled_name(char* buf) const {return buf;} |
| 72 | virtual char* get_demangled_name(char* buf) const |
| 73 | { |
| 74 | return second_demangled_name(first_demangled_name(buf)); |
| 75 | } |
| 76 | virtual size_t base_size() const {return size();} |
| 77 | virtual char* get_base_name(char* buf) const |
| 78 | { |
| 79 | return get_demangled_name(buf); |
| 80 | } |
| 81 | virtual ptrdiff_t print_base_name(char* f, char* l) const |
| 82 | { |
| 83 | return print(f, l); |
| 84 | } |
| 85 | virtual bool ends_with_template() const |
| 86 | { |
| 87 | return false; |
| 88 | } |
| 89 | virtual bool is_ctor_dtor_conv() const |
| 90 | { |
| 91 | return false; |
| 92 | } |
| 93 | virtual __node* base_name() const |
| 94 | { |
| 95 | return const_cast<__node*>(this); |
| 96 | } |
| 97 | virtual bool is_reference_or_pointer_to_function_or_array() const |
| 98 | { |
| 99 | return false; |
| 100 | } |
| 101 | virtual bool is_function() const |
| 102 | { |
| 103 | return false; |
| 104 | } |
| 105 | virtual bool is_cv_qualifer() const |
| 106 | { |
| 107 | return false; |
| 108 | } |
| 109 | virtual bool is_array() const |
| 110 | { |
| 111 | return false; |
| 112 | } |
| 113 | |
| 114 | virtual bool fix_forward_references(__node**, __node**) |
| 115 | { |
| 116 | return true; |
| 117 | } |
| 118 | virtual __node* extract_cv(__node*&) const |
| 119 | { |
| 120 | return 0; |
| 121 | } |
| 122 | virtual size_t list_len() const |
| 123 | { |
| 124 | return 0; |
| 125 | } |
| 126 | virtual bool is_sub() const |
| 127 | { |
| 128 | return false; |
| 129 | } |
| 130 | |
| 131 | virtual ptrdiff_t print(char* f, char* l) const |
| 132 | { |
| 133 | const ptrdiff_t sz1 = print_first(f, l); |
| 134 | return sz1 + print_second(f+std::min(sz1, l-f), l); |
| 135 | } |
| 136 | virtual ptrdiff_t print_first(char*, char*) const |
| 137 | { |
| 138 | return 0; |
| 139 | } |
| 140 | virtual ptrdiff_t print_second(char*, char*) const |
| 141 | { |
| 142 | return 0; |
| 143 | } |
| 144 | }; |
| 145 | |
| 146 | #ifdef DEBUGGING |
| 147 | |
| 148 | void display(__node* x, int indent = 0) |
| 149 | { |
| 150 | if (x) |
| 151 | { |
| 152 | for (int i = 0; i < 2*indent; ++i) |
| 153 | printf(" "); |
| 154 | std::string buf(x->size(), '\0'); |
| 155 | x->print(&buf.front(), &buf.back()+1); |
| 156 | printf("%s %s, %p\n", typeid(*x).name(), buf.c_str(), x); |
| 157 | display(x->__left_, indent+1); |
| 158 | display(x->__right_, indent+1); |
| 159 | } |
| 160 | } |
| 161 | |
| 162 | #endif |
| 163 | |
| 164 | class __vtable |
| 165 | : public __node |
| 166 | { |
| 167 | static const ptrdiff_t n = sizeof("vtable for ") - 1; |
| 168 | public: |
| 169 | __vtable(__node* type) |
| 170 | { |
| 171 | __right_ = type; |
| 172 | } |
| 173 | |
| 174 | virtual size_t first_size() const |
| 175 | { |
| 176 | if (__cached_size_ == -1) |
| 177 | const_cast<long&>(__cached_size_) = n + __right_->size(); |
| 178 | return __cached_size_; |
| 179 | } |
| 180 | virtual char* first_demangled_name(char* buf) const |
| 181 | { |
| 182 | strncpy(buf, "vtable for ", n); |
| 183 | return __right_->get_demangled_name(buf+n); |
| 184 | } |
| 185 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 186 | { |
| 187 | const ptrdiff_t r = l - f; |
| 188 | if (r < n) |
| 189 | return n + __right_->print(l, l); |
| 190 | ptrdiff_t sz = __right_->print(f+n, l) + n; |
| 191 | if (r >= sz) |
| 192 | { |
| 193 | *f++ = 'v'; |
| 194 | *f++ = 't'; |
| 195 | *f++ = 'a'; |
| 196 | *f++ = 'b'; |
| 197 | *f++ = 'l'; |
| 198 | *f++ = 'e'; |
| 199 | *f++ = ' '; |
| 200 | *f++ = 'f'; |
| 201 | *f++ = 'o'; |
| 202 | *f++ = 'r'; |
| 203 | *f = ' '; |
| 204 | } |
| 205 | return sz; |
| 206 | } |
| 207 | virtual __node* base_name() const |
| 208 | { |
| 209 | return __right_->base_name(); |
| 210 | } |
| 211 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 212 | { |
| 213 | return __right_->fix_forward_references(t_begin, t_end); |
| 214 | } |
| 215 | }; |
| 216 | |
| 217 | class __VTT |
| 218 | : public __node |
| 219 | { |
| 220 | static const ptrdiff_t n = sizeof("VTT for ") - 1; |
| 221 | public: |
| 222 | __VTT(__node* type) |
| 223 | { |
| 224 | __right_ = type; |
| 225 | } |
| 226 | |
| 227 | virtual size_t first_size() const |
| 228 | { |
| 229 | if (__cached_size_ == -1) |
| 230 | const_cast<long&>(__cached_size_) = n + __right_->size(); |
| 231 | return __cached_size_; |
| 232 | } |
| 233 | virtual char* first_demangled_name(char* buf) const |
| 234 | { |
| 235 | strncpy(buf, "VTT for ", n); |
| 236 | return __right_->get_demangled_name(buf+n); |
| 237 | } |
| 238 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 239 | { |
| 240 | const ptrdiff_t r = l - f; |
| 241 | if (r < n) |
| 242 | return n + __right_->print(l, l); |
| 243 | ptrdiff_t sz = __right_->print(f+n, l) + n; |
| 244 | if (r >= sz) |
| 245 | { |
| 246 | *f++ = 'V'; |
| 247 | *f++ = 'T'; |
| 248 | *f++ = 'T'; |
| 249 | *f++ = ' '; |
| 250 | *f++ = 'f'; |
| 251 | *f++ = 'o'; |
| 252 | *f++ = 'r'; |
| 253 | *f = ' '; |
| 254 | } |
| 255 | return sz; |
| 256 | } |
| 257 | virtual __node* base_name() const |
| 258 | { |
| 259 | return __right_->base_name(); |
| 260 | } |
| 261 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 262 | { |
| 263 | return __right_->fix_forward_references(t_begin, t_end); |
| 264 | } |
| 265 | }; |
| 266 | |
| 267 | class __typeinfo |
| 268 | : public __node |
| 269 | { |
| 270 | static const ptrdiff_t n = sizeof("typeinfo for ") - 1; |
| 271 | public: |
| 272 | __typeinfo(__node* type) |
| 273 | { |
| 274 | __right_ = type; |
| 275 | } |
| 276 | |
| 277 | virtual size_t first_size() const |
| 278 | { |
| 279 | if (__cached_size_ == -1) |
| 280 | const_cast<long&>(__cached_size_) = n + __right_->size(); |
| 281 | return __cached_size_; |
| 282 | } |
| 283 | virtual char* first_demangled_name(char* buf) const |
| 284 | { |
| 285 | strncpy(buf, "typeinfo for ", n); |
| 286 | return __right_->get_demangled_name(buf+n); |
| 287 | } |
| 288 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 289 | { |
| 290 | const ptrdiff_t r = l - f; |
| 291 | if (r < n) |
| 292 | return n + __right_->print(l, l); |
| 293 | ptrdiff_t sz = __right_->print(f+n, l) + n; |
| 294 | if (r >= sz) |
| 295 | { |
| 296 | *f++ = 't'; |
| 297 | *f++ = 'y'; |
| 298 | *f++ = 'p'; |
| 299 | *f++ = 'e'; |
| 300 | *f++ = 'i'; |
| 301 | *f++ = 'n'; |
| 302 | *f++ = 'f'; |
| 303 | *f++ = 'o'; |
| 304 | *f++ = ' '; |
| 305 | *f++ = 'f'; |
| 306 | *f++ = 'o'; |
| 307 | *f++ = 'r'; |
| 308 | *f = ' '; |
| 309 | } |
| 310 | return sz; |
| 311 | } |
| 312 | virtual __node* base_name() const |
| 313 | { |
| 314 | return __right_->base_name(); |
| 315 | } |
| 316 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 317 | { |
| 318 | return __right_->fix_forward_references(t_begin, t_end); |
| 319 | } |
| 320 | }; |
| 321 | |
| 322 | class __typeinfo_name |
| 323 | : public __node |
| 324 | { |
| 325 | static const ptrdiff_t n = sizeof("typeinfo name for ") - 1; |
| 326 | public: |
| 327 | __typeinfo_name(__node* type) |
| 328 | { |
| 329 | __right_ = type; |
| 330 | } |
| 331 | |
| 332 | virtual size_t first_size() const |
| 333 | { |
| 334 | if (__cached_size_ == -1) |
| 335 | const_cast<long&>(__cached_size_) = n + __right_->size(); |
| 336 | return __cached_size_; |
| 337 | } |
| 338 | virtual char* first_demangled_name(char* buf) const |
| 339 | { |
| 340 | strncpy(buf, "typeinfo name for ", n); |
| 341 | return __right_->get_demangled_name(buf+n); |
| 342 | } |
| 343 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 344 | { |
| 345 | const ptrdiff_t r = l - f; |
| 346 | if (r < n) |
| 347 | return n + __right_->print(l, l); |
| 348 | ptrdiff_t sz = __right_->print(f+n, l) + n; |
| 349 | if (r >= sz) |
| 350 | { |
| 351 | *f++ = 't'; |
| 352 | *f++ = 'y'; |
| 353 | *f++ = 'p'; |
| 354 | *f++ = 'e'; |
| 355 | *f++ = 'i'; |
| 356 | *f++ = 'n'; |
| 357 | *f++ = 'f'; |
| 358 | *f++ = 'o'; |
| 359 | *f++ = ' '; |
| 360 | *f++ = 'n'; |
| 361 | *f++ = 'a'; |
| 362 | *f++ = 'm'; |
| 363 | *f++ = 'e'; |
| 364 | *f++ = ' '; |
| 365 | *f++ = 'f'; |
| 366 | *f++ = 'o'; |
| 367 | *f++ = 'r'; |
| 368 | *f = ' '; |
| 369 | } |
| 370 | return sz; |
| 371 | } |
| 372 | virtual __node* base_name() const |
| 373 | { |
| 374 | return __right_->base_name(); |
| 375 | } |
| 376 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 377 | { |
| 378 | return __right_->fix_forward_references(t_begin, t_end); |
| 379 | } |
| 380 | }; |
| 381 | |
| 382 | class __covariant_return_thunk |
| 383 | : public __node |
| 384 | { |
| 385 | static const ptrdiff_t n = sizeof("covariant return thunk to ") - 1; |
| 386 | public: |
| 387 | __covariant_return_thunk(__node* type) |
| 388 | { |
| 389 | __right_ = type; |
| 390 | } |
| 391 | |
| 392 | virtual size_t first_size() const |
| 393 | { |
| 394 | if (__cached_size_ == -1) |
| 395 | const_cast<long&>(__cached_size_) = n + __right_->size(); |
| 396 | return __cached_size_; |
| 397 | } |
| 398 | virtual char* first_demangled_name(char* buf) const |
| 399 | { |
| 400 | strncpy(buf, "covariant return thunk to ", n); |
| 401 | return __right_->get_demangled_name(buf+n); |
| 402 | } |
| 403 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 404 | { |
| 405 | const ptrdiff_t r = l - f; |
| 406 | if (r < n) |
| 407 | return n + __right_->print(l, l); |
| 408 | ptrdiff_t sz = __right_->print(f+n, l) + n; |
| 409 | if (r >= sz) |
| 410 | { |
| 411 | *f++ = 'c'; |
| 412 | *f++ = 'o'; |
| 413 | *f++ = 'v'; |
| 414 | *f++ = 'a'; |
| 415 | *f++ = 'r'; |
| 416 | *f++ = 'i'; |
| 417 | *f++ = 'a'; |
| 418 | *f++ = 'n'; |
| 419 | *f++ = 't'; |
| 420 | *f++ = ' '; |
| 421 | *f++ = 'r'; |
| 422 | *f++ = 'e'; |
| 423 | *f++ = 't'; |
| 424 | *f++ = 'u'; |
| 425 | *f++ = 'r'; |
| 426 | *f++ = 'n'; |
| 427 | *f++ = ' '; |
| 428 | *f++ = 't'; |
| 429 | *f++ = 'h'; |
| 430 | *f++ = 'u'; |
| 431 | *f++ = 'n'; |
| 432 | *f++ = 'k'; |
| 433 | *f++ = ' '; |
| 434 | *f++ = 't'; |
| 435 | *f++ = 'o'; |
| 436 | *f = ' '; |
| 437 | } |
| 438 | return sz; |
| 439 | } |
| 440 | virtual __node* base_name() const |
| 441 | { |
| 442 | return __right_->base_name(); |
| 443 | } |
| 444 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 445 | { |
| 446 | return __right_->fix_forward_references(t_begin, t_end); |
| 447 | } |
| 448 | }; |
| 449 | |
| 450 | class __virtual_thunk |
| 451 | : public __node |
| 452 | { |
| 453 | static const size_t n = sizeof("virtual thunk to ") - 1; |
| 454 | public: |
| 455 | __virtual_thunk(__node* type) |
| 456 | { |
| 457 | __right_ = type; |
| 458 | } |
| 459 | |
| 460 | virtual size_t first_size() const |
| 461 | { |
| 462 | if (__cached_size_ == -1) |
| 463 | const_cast<long&>(__cached_size_) = n + __right_->size(); |
| 464 | return __cached_size_; |
| 465 | } |
| 466 | virtual char* first_demangled_name(char* buf) const |
| 467 | { |
| 468 | strncpy(buf, "virtual thunk to ", n); |
| 469 | return __right_->get_demangled_name(buf+n); |
| 470 | } |
| 471 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 472 | { |
| 473 | const ptrdiff_t r = l - f; |
| 474 | if (r < n) |
| 475 | return n + __right_->print(l, l); |
| 476 | ptrdiff_t sz = __right_->print(f+n, l) + n; |
| 477 | if (r >= sz) |
| 478 | { |
| 479 | *f++ = 'v'; |
| 480 | *f++ = 'i'; |
| 481 | *f++ = 'r'; |
| 482 | *f++ = 't'; |
| 483 | *f++ = 'u'; |
| 484 | *f++ = 'a'; |
| 485 | *f++ = 'l'; |
| 486 | *f++ = ' '; |
| 487 | *f++ = 't'; |
| 488 | *f++ = 'h'; |
| 489 | *f++ = 'u'; |
| 490 | *f++ = 'n'; |
| 491 | *f++ = 'k'; |
| 492 | *f++ = ' '; |
| 493 | *f++ = 't'; |
| 494 | *f++ = 'o'; |
| 495 | *f = ' '; |
| 496 | } |
| 497 | return sz; |
| 498 | } |
| 499 | virtual __node* base_name() const |
| 500 | { |
| 501 | return __right_->base_name(); |
| 502 | } |
| 503 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 504 | { |
| 505 | return __right_->fix_forward_references(t_begin, t_end); |
| 506 | } |
| 507 | }; |
| 508 | |
| 509 | class __non_virtual_thunk |
| 510 | : public __node |
| 511 | { |
| 512 | static const size_t n = sizeof("non-virtual thunk to ") - 1; |
| 513 | public: |
| 514 | __non_virtual_thunk(__node* type) |
| 515 | { |
| 516 | __right_ = type; |
| 517 | } |
| 518 | |
| 519 | virtual size_t first_size() const |
| 520 | { |
| 521 | if (__cached_size_ == -1) |
| 522 | const_cast<long&>(__cached_size_) = n + __right_->size(); |
| 523 | return __cached_size_; |
| 524 | } |
| 525 | virtual char* first_demangled_name(char* buf) const |
| 526 | { |
| 527 | strncpy(buf, "non-virtual thunk to ", n); |
| 528 | return __right_->get_demangled_name(buf+n); |
| 529 | } |
| 530 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 531 | { |
| 532 | const ptrdiff_t r = l - f; |
| 533 | if (r < n) |
| 534 | return n + __right_->print(l, l); |
| 535 | ptrdiff_t sz = __right_->print(f+n, l) + n; |
| 536 | if (r >= sz) |
| 537 | { |
| 538 | *f++ = 'n'; |
| 539 | *f++ = 'o'; |
| 540 | *f++ = 'n'; |
| 541 | *f++ = '-'; |
| 542 | *f++ = 'v'; |
| 543 | *f++ = 'i'; |
| 544 | *f++ = 'r'; |
| 545 | *f++ = 't'; |
| 546 | *f++ = 'u'; |
| 547 | *f++ = 'a'; |
| 548 | *f++ = 'l'; |
| 549 | *f++ = ' '; |
| 550 | *f++ = 't'; |
| 551 | *f++ = 'h'; |
| 552 | *f++ = 'u'; |
| 553 | *f++ = 'n'; |
| 554 | *f++ = 'k'; |
| 555 | *f++ = ' '; |
| 556 | *f++ = 't'; |
| 557 | *f++ = 'o'; |
| 558 | *f = ' '; |
| 559 | } |
| 560 | return sz; |
| 561 | } |
| 562 | virtual __node* base_name() const |
| 563 | { |
| 564 | return __right_->base_name(); |
| 565 | } |
| 566 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 567 | { |
| 568 | return __right_->fix_forward_references(t_begin, t_end); |
| 569 | } |
| 570 | }; |
| 571 | |
| 572 | class __guard_variable |
| 573 | : public __node |
| 574 | { |
| 575 | static const size_t n = sizeof("guard variable for ") - 1; |
| 576 | public: |
| 577 | __guard_variable(__node* type) |
| 578 | { |
| 579 | __right_ = type; |
| 580 | } |
| 581 | |
| 582 | virtual size_t first_size() const |
| 583 | { |
| 584 | if (__cached_size_ == -1) |
| 585 | const_cast<long&>(__cached_size_) = n + __right_->size(); |
| 586 | return __cached_size_; |
| 587 | } |
| 588 | virtual char* first_demangled_name(char* buf) const |
| 589 | { |
| 590 | strncpy(buf, "guard variable for ", n); |
| 591 | return __right_->get_demangled_name(buf+n); |
| 592 | } |
| 593 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 594 | { |
| 595 | const ptrdiff_t r = l - f; |
| 596 | if (r < n) |
| 597 | return n + __right_->print(l, l); |
| 598 | ptrdiff_t sz = __right_->print(f+n, l) + n; |
| 599 | if (r >= sz) |
| 600 | { |
| 601 | *f++ = 'g'; |
| 602 | *f++ = 'u'; |
| 603 | *f++ = 'a'; |
| 604 | *f++ = 'r'; |
| 605 | *f++ = 'd'; |
| 606 | *f++ = ' '; |
| 607 | *f++ = 'v'; |
| 608 | *f++ = 'a'; |
| 609 | *f++ = 'r'; |
| 610 | *f++ = 'i'; |
| 611 | *f++ = 'a'; |
| 612 | *f++ = 'b'; |
| 613 | *f++ = 'l'; |
| 614 | *f++ = 'e'; |
| 615 | *f++ = ' '; |
| 616 | *f++ = 'f'; |
| 617 | *f++ = 'o'; |
| 618 | *f++ = 'r'; |
| 619 | *f = ' '; |
| 620 | } |
| 621 | return sz; |
| 622 | } |
| 623 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 624 | { |
| 625 | return __right_->fix_forward_references(t_begin, t_end); |
| 626 | } |
| 627 | }; |
| 628 | |
| 629 | class __source_name |
| 630 | : public __node |
| 631 | { |
| 632 | public: |
| 633 | __source_name(const char* __name, unsigned __size) |
| 634 | { |
| 635 | __name_ = __name; |
| 636 | __size_ = __size; |
| 637 | } |
| 638 | |
| 639 | virtual size_t first_size() const |
| 640 | { |
| 641 | if (__cached_size_ == -1) |
| 642 | { |
| 643 | if (__size_ >= 10 && strncmp(__name_, "_GLOBAL__N", 10) == 0) |
| 644 | const_cast<long&>(__cached_size_) = 21; |
| 645 | else |
| 646 | const_cast<long&>(__cached_size_) = __size_; |
| 647 | } |
| 648 | return __cached_size_; |
| 649 | } |
| 650 | virtual char* first_demangled_name(char* buf) const |
| 651 | { |
| 652 | if (__size_ >= 10 && strncmp(__name_, "_GLOBAL__N", 10) == 0) |
| 653 | return strncpy(buf, "(anonymous namespace)", 21) + 21; |
| 654 | return strncpy(buf, __name_, __size_) + __size_; |
| 655 | } |
| 656 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 657 | { |
| 658 | const ptrdiff_t r = l - f; |
| 659 | if (__size_ >= 10 && strncmp(__name_, "_GLOBAL__N", 10) == 0) |
| 660 | { |
| 661 | const ptrdiff_t n = sizeof("(anonymous namespace)") - 1; |
| 662 | if (r >= n) |
| 663 | { |
| 664 | *f++ = '('; |
| 665 | *f++ = 'a'; |
| 666 | *f++ = 'n'; |
| 667 | *f++ = 'o'; |
| 668 | *f++ = 'n'; |
| 669 | *f++ = 'y'; |
| 670 | *f++ = 'm'; |
| 671 | *f++ = 'o'; |
| 672 | *f++ = 'u'; |
| 673 | *f++ = 's'; |
| 674 | *f++ = ' '; |
| 675 | *f++ = 'n'; |
| 676 | *f++ = 'a'; |
| 677 | *f++ = 'm'; |
| 678 | *f++ = 'e'; |
| 679 | *f++ = 's'; |
| 680 | *f++ = 'p'; |
| 681 | *f++ = 'a'; |
| 682 | *f++ = 'c'; |
| 683 | *f++ = 'e'; |
| 684 | *f = ')'; |
| 685 | } |
| 686 | return n; |
| 687 | } |
| 688 | if (r >= __size_) |
| 689 | strncpy(f, __name_, __size_); |
| 690 | return __size_; |
| 691 | } |
| 692 | }; |
| 693 | |
| 694 | class __operator_new |
| 695 | : public __node |
| 696 | { |
| 697 | public: |
| 698 | |
| 699 | virtual size_t first_size() const {return sizeof("operator new") - 1;} |
| 700 | virtual char* first_demangled_name(char* buf) const |
| 701 | { |
| 702 | return strncpy(buf, "operator new", sizeof("operator new") - 1) + |
| 703 | sizeof("operator new") - 1; |
| 704 | } |
| 705 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 706 | { |
| 707 | const ptrdiff_t r = l - f; |
| 708 | const ptrdiff_t n = sizeof("operator new") - 1; |
| 709 | if (r >= n) |
| 710 | { |
| 711 | *f++ = 'o'; |
| 712 | *f++ = 'p'; |
| 713 | *f++ = 'e'; |
| 714 | *f++ = 'r'; |
| 715 | *f++ = 'a'; |
| 716 | *f++ = 't'; |
| 717 | *f++ = 'o'; |
| 718 | *f++ = 'r'; |
| 719 | *f++ = ' '; |
| 720 | *f++ = 'n'; |
| 721 | *f++ = 'e'; |
| 722 | *f = 'w'; |
| 723 | } |
| 724 | return n; |
| 725 | } |
| 726 | }; |
| 727 | |
| 728 | class __operator_new_array |
| 729 | : public __node |
| 730 | { |
| 731 | public: |
| 732 | |
| 733 | virtual size_t first_size() const {return sizeof("operator new[]") - 1;} |
| 734 | virtual char* first_demangled_name(char* buf) const |
| 735 | { |
| 736 | return strncpy(buf, "operator new[]", sizeof("operator new[]") - 1) + |
| 737 | sizeof("operator new[]") - 1; |
| 738 | } |
| 739 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 740 | { |
| 741 | const ptrdiff_t r = l - f; |
| 742 | const ptrdiff_t n = sizeof("operator new[]") - 1; |
| 743 | if (r >= n) |
| 744 | { |
| 745 | *f++ = 'o'; |
| 746 | *f++ = 'p'; |
| 747 | *f++ = 'e'; |
| 748 | *f++ = 'r'; |
| 749 | *f++ = 'a'; |
| 750 | *f++ = 't'; |
| 751 | *f++ = 'o'; |
| 752 | *f++ = 'r'; |
| 753 | *f++ = ' '; |
| 754 | *f++ = 'n'; |
| 755 | *f++ = 'e'; |
| 756 | *f++ = 'w'; |
| 757 | *f++ = '['; |
| 758 | *f = ']'; |
| 759 | } |
| 760 | return n; |
| 761 | } |
| 762 | }; |
| 763 | |
| 764 | class __operator_delete |
| 765 | : public __node |
| 766 | { |
| 767 | public: |
| 768 | |
| 769 | virtual size_t first_size() const {return sizeof("operator delete") - 1;} |
| 770 | virtual char* first_demangled_name(char* buf) const |
| 771 | { |
| 772 | return strncpy(buf, "operator delete", sizeof("operator delete") - 1) + |
| 773 | sizeof("operator delete") - 1; |
| 774 | } |
| 775 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 776 | { |
| 777 | const ptrdiff_t r = l - f; |
| 778 | const ptrdiff_t n = sizeof("operator delete") - 1; |
| 779 | if (r >= n) |
| 780 | { |
| 781 | *f++ = 'o'; |
| 782 | *f++ = 'p'; |
| 783 | *f++ = 'e'; |
| 784 | *f++ = 'r'; |
| 785 | *f++ = 'a'; |
| 786 | *f++ = 't'; |
| 787 | *f++ = 'o'; |
| 788 | *f++ = 'r'; |
| 789 | *f++ = ' '; |
| 790 | *f++ = 'd'; |
| 791 | *f++ = 'e'; |
| 792 | *f++ = 'l'; |
| 793 | *f++ = 'e'; |
| 794 | *f++ = 't'; |
| 795 | *f = 'e'; |
| 796 | } |
| 797 | return n; |
| 798 | } |
| 799 | }; |
| 800 | |
| 801 | class __operator_delete_array |
| 802 | : public __node |
| 803 | { |
| 804 | public: |
| 805 | |
| 806 | virtual size_t first_size() const {return sizeof("operator delete[]") - 1;} |
| 807 | virtual char* first_demangled_name(char* buf) const |
| 808 | { |
| 809 | return strncpy(buf, "operator delete[]", sizeof("operator delete[]") - 1) + |
| 810 | sizeof("operator delete[]") - 1; |
| 811 | } |
| 812 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 813 | { |
| 814 | const ptrdiff_t r = l - f; |
| 815 | const ptrdiff_t n = sizeof("operator delete[]") - 1; |
| 816 | if (r >= n) |
| 817 | { |
| 818 | *f++ = 'o'; |
| 819 | *f++ = 'p'; |
| 820 | *f++ = 'e'; |
| 821 | *f++ = 'r'; |
| 822 | *f++ = 'a'; |
| 823 | *f++ = 't'; |
| 824 | *f++ = 'o'; |
| 825 | *f++ = 'r'; |
| 826 | *f++ = ' '; |
| 827 | *f++ = 'd'; |
| 828 | *f++ = 'e'; |
| 829 | *f++ = 'l'; |
| 830 | *f++ = 'e'; |
| 831 | *f++ = 't'; |
| 832 | *f++ = 'e'; |
| 833 | *f++ = '['; |
| 834 | *f = ']'; |
| 835 | } |
| 836 | return n; |
| 837 | } |
| 838 | }; |
| 839 | |
| 840 | class __operator_logical_and |
| 841 | : public __node |
| 842 | { |
| 843 | public: |
| 844 | |
| 845 | __operator_logical_and() {} |
| 846 | __operator_logical_and(__node* op1, __node* op2) |
| 847 | { |
| 848 | __left_ = op1; |
| 849 | __right_ = op2; |
| 850 | } |
| 851 | virtual size_t first_size() const |
| 852 | { |
| 853 | if (__cached_size_ == -1) |
| 854 | { |
| 855 | if (__left_) |
| 856 | const_cast<long&>(__cached_size_) = __left_->size() + 8 + __right_->size(); |
| 857 | else |
| 858 | const_cast<long&>(__cached_size_) = sizeof("operator&&") - 1; |
| 859 | } |
| 860 | return __cached_size_; |
| 861 | } |
| 862 | virtual char* first_demangled_name(char* buf) const |
| 863 | { |
| 864 | if (__left_) |
| 865 | { |
| 866 | *buf++ = '('; |
| 867 | buf = __left_->get_demangled_name(buf); |
| 868 | strncpy(buf, ") && (", 6); |
| 869 | buf += 6; |
| 870 | buf = __right_->get_demangled_name(buf); |
| 871 | *buf++ = ')'; |
| 872 | } |
| 873 | else |
| 874 | { |
| 875 | strncpy(buf, "operator&&", sizeof("operator&&") - 1); |
| 876 | buf += sizeof("operator&&") - 1; |
| 877 | } |
| 878 | return buf; |
| 879 | } |
| 880 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 881 | { |
| 882 | const ptrdiff_t r = l - f; |
| 883 | if (__left_) |
| 884 | { |
| 885 | const ptrdiff_t n1 = 8; |
| 886 | if (r < n1) |
| 887 | return n1 + __left_->print(l, l) + __right_->print(l, l); |
| 888 | ptrdiff_t sz1 = __left_->print(f+1, l); |
| 889 | if (r < n1 + sz1) |
| 890 | return n1 + sz1 + __right_->print(l, l); |
| 891 | ptrdiff_t sz2 = __right_->print(f+(n1-1)+sz1, l); |
| 892 | if (r >= n1 + sz1 + sz2) |
| 893 | { |
| 894 | *f = '('; |
| 895 | f += 1 + sz1; |
| 896 | *f++ = ')'; |
| 897 | *f++ = ' '; |
| 898 | *f++ = '&'; |
| 899 | *f++ = '&'; |
| 900 | *f++ = ' '; |
| 901 | *f = '('; |
| 902 | f += 1 + sz2; |
| 903 | *f = ')'; |
| 904 | } |
| 905 | return n1 + sz1 + sz2; |
| 906 | } |
| 907 | const ptrdiff_t n2 = sizeof("operator&&") - 1; |
| 908 | if (r >= n2) |
| 909 | { |
| 910 | *f++ = 'o'; |
| 911 | *f++ = 'p'; |
| 912 | *f++ = 'e'; |
| 913 | *f++ = 'r'; |
| 914 | *f++ = 'a'; |
| 915 | *f++ = 't'; |
| 916 | *f++ = 'o'; |
| 917 | *f++ = 'r'; |
| 918 | *f++ = '&'; |
| 919 | *f = '&'; |
| 920 | } |
| 921 | return n2; |
| 922 | } |
| 923 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 924 | { |
| 925 | bool r = true; |
| 926 | if (__left_) |
| 927 | r = r && __left_->fix_forward_references(t_begin, t_end); |
| 928 | if (__right_) |
| 929 | r = r && __right_->fix_forward_references(t_begin, t_end); |
| 930 | return r; |
| 931 | } |
| 932 | }; |
| 933 | |
| 934 | class __operator_addressof |
| 935 | : public __node |
| 936 | { |
| 937 | public: |
| 938 | |
| 939 | __operator_addressof() {} |
| 940 | explicit __operator_addressof(__node* op) |
| 941 | { |
| 942 | __left_ = op; |
| 943 | } |
| 944 | virtual size_t first_size() const |
| 945 | { |
| 946 | if (__cached_size_ == -1) |
| 947 | { |
| 948 | if (__left_) |
| 949 | const_cast<long&>(__cached_size_) = 3+__left_->size(); |
| 950 | else |
| 951 | const_cast<long&>(__cached_size_) = sizeof("operator&") - 1; |
| 952 | } |
| 953 | return __cached_size_; |
| 954 | } |
| 955 | virtual char* first_demangled_name(char* buf) const |
| 956 | { |
| 957 | if (__left_) |
| 958 | { |
| 959 | *buf++ = '&'; |
| 960 | *buf++ = '('; |
| 961 | buf = __left_->get_demangled_name(buf); |
| 962 | *buf++ = ')'; |
| 963 | } |
| 964 | else |
| 965 | { |
| 966 | strncpy(buf, "operator&", sizeof("operator&") - 1); |
| 967 | buf += sizeof("operator&") - 1; |
| 968 | } |
| 969 | return buf; |
| 970 | } |
| 971 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 972 | { |
| 973 | const ptrdiff_t r = l - f; |
| 974 | if (__left_) |
| 975 | { |
| 976 | const ptrdiff_t n1 = 3; |
| 977 | if (r < n1) |
| 978 | return n1 + __left_->print(l, l); |
| 979 | ptrdiff_t sz1 = __left_->print(f+2, l); |
| 980 | if (r >= n1 + sz1) |
| 981 | { |
| 982 | *f++ = '&'; |
| 983 | *f = '('; |
| 984 | f += 1 + sz1; |
| 985 | *f = ')'; |
| 986 | } |
| 987 | return n1 + sz1; |
| 988 | } |
| 989 | const ptrdiff_t n2 = sizeof("operator&") - 1; |
| 990 | if (r >= n2) |
| 991 | { |
| 992 | *f++ = 'o'; |
| 993 | *f++ = 'p'; |
| 994 | *f++ = 'e'; |
| 995 | *f++ = 'r'; |
| 996 | *f++ = 'a'; |
| 997 | *f++ = 't'; |
| 998 | *f++ = 'o'; |
| 999 | *f++ = 'r'; |
| 1000 | *f = '&'; |
| 1001 | } |
| 1002 | return n2; |
| 1003 | } |
| 1004 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 1005 | { |
| 1006 | if (__left_) |
| 1007 | return __left_->fix_forward_references(t_begin, t_end); |
| 1008 | return true; |
| 1009 | } |
| 1010 | }; |
| 1011 | |
| 1012 | class __operator_bit_and |
| 1013 | : public __node |
| 1014 | { |
| 1015 | public: |
| 1016 | |
| 1017 | __operator_bit_and() {} |
| 1018 | __operator_bit_and(__node* op1, __node* op2) |
| 1019 | { |
| 1020 | __left_ = op1; |
| 1021 | __right_ = op2; |
| 1022 | } |
| 1023 | virtual size_t first_size() const |
| 1024 | { |
| 1025 | if (__cached_size_ == -1) |
| 1026 | { |
| 1027 | if (__left_) |
| 1028 | const_cast<long&>(__cached_size_) = __left_->size() + 7 + __right_->size(); |
| 1029 | else |
| 1030 | const_cast<long&>(__cached_size_) = sizeof("operator&") - 1; |
| 1031 | } |
| 1032 | return __cached_size_; |
| 1033 | } |
| 1034 | virtual char* first_demangled_name(char* buf) const |
| 1035 | { |
| 1036 | if (__left_) |
| 1037 | { |
| 1038 | *buf++ = '('; |
| 1039 | buf = __left_->get_demangled_name(buf); |
| 1040 | strncpy(buf, ") & (", 5); |
| 1041 | buf += 5; |
| 1042 | buf = __right_->get_demangled_name(buf); |
| 1043 | *buf++ = ')'; |
| 1044 | } |
| 1045 | else |
| 1046 | { |
| 1047 | strncpy(buf, "operator&", sizeof("operator&") - 1); |
| 1048 | buf += sizeof("operator&") - 1; |
| 1049 | } |
| 1050 | return buf; |
| 1051 | } |
| 1052 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 1053 | { |
| 1054 | const ptrdiff_t r = l - f; |
| 1055 | if (__left_) |
| 1056 | { |
| 1057 | const ptrdiff_t n1 = 7; |
| 1058 | if (r < n1) |
| 1059 | return n1 + __left_->print(l, l) + __right_->print(l, l); |
| 1060 | ptrdiff_t sz1 = __left_->print(f+1, l); |
| 1061 | if (r < n1 + sz1) |
| 1062 | return n1 + sz1 + __right_->print(l, l); |
| 1063 | ptrdiff_t sz2 = __right_->print(f+(n1-1)+sz1, l); |
| 1064 | if (r >= n1 + sz1 + sz2) |
| 1065 | { |
| 1066 | *f = '('; |
| 1067 | f += 1 + sz1; |
| 1068 | *f++ = ')'; |
| 1069 | *f++ = ' '; |
| 1070 | *f++ = '&'; |
| 1071 | *f++ = ' '; |
| 1072 | *f = '('; |
| 1073 | f += 1 + sz2; |
| 1074 | *f = ')'; |
| 1075 | } |
| 1076 | return n1 + sz1 + sz2; |
| 1077 | } |
| 1078 | const ptrdiff_t n2 = sizeof("operator&") - 1; |
| 1079 | if (r >= n2) |
| 1080 | { |
| 1081 | *f++ = 'o'; |
| 1082 | *f++ = 'p'; |
| 1083 | *f++ = 'e'; |
| 1084 | *f++ = 'r'; |
| 1085 | *f++ = 'a'; |
| 1086 | *f++ = 't'; |
| 1087 | *f++ = 'o'; |
| 1088 | *f++ = 'r'; |
| 1089 | *f = '&'; |
| 1090 | } |
| 1091 | return n2; |
| 1092 | } |
| 1093 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 1094 | { |
| 1095 | bool r = true; |
| 1096 | if (__left_) |
| 1097 | r = r && __left_->fix_forward_references(t_begin, t_end); |
| 1098 | if (__right_) |
| 1099 | r = r && __right_->fix_forward_references(t_begin, t_end); |
| 1100 | return r; |
| 1101 | } |
| 1102 | }; |
| 1103 | |
| 1104 | class __operator_and_equal |
| 1105 | : public __node |
| 1106 | { |
| 1107 | public: |
| 1108 | |
| 1109 | __operator_and_equal() {} |
| 1110 | __operator_and_equal(__node* op1, __node* op2) |
| 1111 | { |
| 1112 | __left_ = op1; |
| 1113 | __right_ = op2; |
| 1114 | } |
| 1115 | virtual size_t first_size() const |
| 1116 | { |
| 1117 | if (__cached_size_ == -1) |
| 1118 | { |
| 1119 | if (__left_) |
| 1120 | const_cast<long&>(__cached_size_) = __left_->size() + 8 + __right_->size(); |
| 1121 | else |
| 1122 | const_cast<long&>(__cached_size_) = sizeof("operator&=") - 1; |
| 1123 | } |
| 1124 | return __cached_size_; |
| 1125 | } |
| 1126 | virtual char* first_demangled_name(char* buf) const |
| 1127 | { |
| 1128 | if (__left_) |
| 1129 | { |
| 1130 | *buf++ = '('; |
| 1131 | buf = __left_->get_demangled_name(buf); |
| 1132 | strncpy(buf, ") &= (", 6); |
| 1133 | buf += 6; |
| 1134 | buf = __right_->get_demangled_name(buf); |
| 1135 | *buf++ = ')'; |
| 1136 | } |
| 1137 | else |
| 1138 | { |
| 1139 | strncpy(buf, "operator&=", sizeof("operator&=") - 1); |
| 1140 | buf += sizeof("operator&=") - 1; |
| 1141 | } |
| 1142 | return buf; |
| 1143 | } |
| 1144 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 1145 | { |
| 1146 | const ptrdiff_t r = l - f; |
| 1147 | if (__left_) |
| 1148 | { |
| 1149 | const ptrdiff_t n1 = 8; |
| 1150 | if (r < n1) |
| 1151 | return n1 + __left_->print(l, l) + __right_->print(l, l); |
| 1152 | ptrdiff_t sz1 = __left_->print(f+1, l); |
| 1153 | if (r < n1 + sz1) |
| 1154 | return n1 + sz1 + __right_->print(l, l); |
| 1155 | ptrdiff_t sz2 = __right_->print(f+(n1-1)+sz1, l); |
| 1156 | if (r >= n1 + sz1 + sz2) |
| 1157 | { |
| 1158 | *f = '('; |
| 1159 | f += 1 + sz1; |
| 1160 | *f++ = ')'; |
| 1161 | *f++ = ' '; |
| 1162 | *f++ = '&'; |
| 1163 | *f++ = '='; |
| 1164 | *f++ = ' '; |
| 1165 | *f = '('; |
| 1166 | f += 1 + sz2; |
| 1167 | *f = ')'; |
| 1168 | } |
| 1169 | return n1 + sz1 + sz2; |
| 1170 | } |
| 1171 | const ptrdiff_t n2 = sizeof("operator&=") - 1; |
| 1172 | if (r >= n2) |
| 1173 | { |
| 1174 | *f++ = 'o'; |
| 1175 | *f++ = 'p'; |
| 1176 | *f++ = 'e'; |
| 1177 | *f++ = 'r'; |
| 1178 | *f++ = 'a'; |
| 1179 | *f++ = 't'; |
| 1180 | *f++ = 'o'; |
| 1181 | *f++ = 'r'; |
| 1182 | *f++ = '&'; |
| 1183 | *f = '='; |
| 1184 | } |
| 1185 | return n2; |
| 1186 | } |
| 1187 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 1188 | { |
| 1189 | bool r = true; |
| 1190 | if (__left_) |
| 1191 | r = r && __left_->fix_forward_references(t_begin, t_end); |
| 1192 | if (__right_) |
| 1193 | r = r && __right_->fix_forward_references(t_begin, t_end); |
| 1194 | return r; |
| 1195 | } |
| 1196 | }; |
| 1197 | |
| 1198 | class __operator_equal |
| 1199 | : public __node |
| 1200 | { |
| 1201 | public: |
| 1202 | |
| 1203 | __operator_equal() {} |
| 1204 | __operator_equal(__node* op1, __node* op2) |
| 1205 | { |
| 1206 | __left_ = op1; |
| 1207 | __right_ = op2; |
| 1208 | } |
| 1209 | virtual size_t first_size() const |
| 1210 | { |
| 1211 | if (__cached_size_ == -1) |
| 1212 | { |
| 1213 | if (__left_) |
| 1214 | const_cast<long&>(__cached_size_) = __left_->size() + 7 + __right_->size(); |
| 1215 | else |
| 1216 | const_cast<long&>(__cached_size_) = sizeof("operator=") - 1; |
| 1217 | } |
| 1218 | return __cached_size_; |
| 1219 | } |
| 1220 | virtual char* first_demangled_name(char* buf) const |
| 1221 | { |
| 1222 | if (__left_) |
| 1223 | { |
| 1224 | *buf++ = '('; |
| 1225 | buf = __left_->get_demangled_name(buf); |
| 1226 | strncpy(buf, ") = (", 5); |
| 1227 | buf += 5; |
| 1228 | buf = __right_->get_demangled_name(buf); |
| 1229 | *buf++ = ')'; |
| 1230 | } |
| 1231 | else |
| 1232 | { |
| 1233 | strncpy(buf, "operator=", sizeof("operator=") - 1); |
| 1234 | buf += sizeof("operator=") - 1; |
| 1235 | } |
| 1236 | return buf; |
| 1237 | } |
| 1238 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 1239 | { |
| 1240 | const ptrdiff_t r = l - f; |
| 1241 | if (__left_) |
| 1242 | { |
| 1243 | const ptrdiff_t n1 = 7; |
| 1244 | if (r < n1) |
| 1245 | return n1 + __left_->print(l, l) + __right_->print(l, l); |
| 1246 | ptrdiff_t sz1 = __left_->print(f+1, l); |
| 1247 | if (r < n1 + sz1) |
| 1248 | return n1 + sz1 + __right_->print(l, l); |
| 1249 | ptrdiff_t sz2 = __right_->print(f+(n1-1)+sz1, l); |
| 1250 | if (r >= n1 + sz1 + sz2) |
| 1251 | { |
| 1252 | *f = '('; |
| 1253 | f += 1 + sz1; |
| 1254 | *f++ = ')'; |
| 1255 | *f++ = ' '; |
| 1256 | *f++ = '='; |
| 1257 | *f++ = ' '; |
| 1258 | *f = '('; |
| 1259 | f += 1 + sz2; |
| 1260 | *f = ')'; |
| 1261 | } |
| 1262 | return n1 + sz1 + sz2; |
| 1263 | } |
| 1264 | const ptrdiff_t n2 = sizeof("operator=") - 1; |
| 1265 | if (r >= n2) |
| 1266 | { |
| 1267 | *f++ = 'o'; |
| 1268 | *f++ = 'p'; |
| 1269 | *f++ = 'e'; |
| 1270 | *f++ = 'r'; |
| 1271 | *f++ = 'a'; |
| 1272 | *f++ = 't'; |
| 1273 | *f++ = 'o'; |
| 1274 | *f++ = 'r'; |
| 1275 | *f = '='; |
| 1276 | } |
| 1277 | return n2; |
| 1278 | } |
| 1279 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 1280 | { |
| 1281 | bool r = true; |
| 1282 | if (__left_) |
| 1283 | r = r && __left_->fix_forward_references(t_begin, t_end); |
| 1284 | if (__right_) |
| 1285 | r = r && __right_->fix_forward_references(t_begin, t_end); |
| 1286 | return r; |
| 1287 | } |
| 1288 | }; |
| 1289 | |
| 1290 | class __operator_alignof_type |
| 1291 | : public __node |
| 1292 | { |
| 1293 | public: |
| 1294 | |
| 1295 | __operator_alignof_type() {} |
| 1296 | __operator_alignof_type(__node* op) |
| 1297 | { |
| 1298 | __right_ = op; |
| 1299 | } |
| 1300 | virtual size_t first_size() const |
| 1301 | { |
| 1302 | if (__cached_size_ == -1) |
| 1303 | { |
| 1304 | if (__right_) |
| 1305 | const_cast<long&>(__cached_size_) = __right_->size() + 10; |
| 1306 | else |
| 1307 | const_cast<long&>(__cached_size_) = sizeof("operator alignof") - 1; |
| 1308 | } |
| 1309 | return __cached_size_; |
| 1310 | } |
| 1311 | virtual char* first_demangled_name(char* buf) const |
| 1312 | { |
| 1313 | if (__right_) |
| 1314 | { |
| 1315 | strncpy(buf, "alignof (", 9); |
| 1316 | buf += 9; |
| 1317 | buf = __right_->get_demangled_name(buf); |
| 1318 | *buf++ = ')'; |
| 1319 | } |
| 1320 | else |
| 1321 | { |
| 1322 | strncpy(buf, "operator alignof", sizeof("operator alignof") - 1); |
| 1323 | buf += sizeof("operator alignof") - 1; |
| 1324 | } |
| 1325 | return buf; |
| 1326 | } |
| 1327 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 1328 | { |
| 1329 | const ptrdiff_t r = l - f; |
| 1330 | if (__right_) |
| 1331 | { |
| 1332 | const ptrdiff_t n1 = sizeof("alignof ()") - 1; |
| 1333 | if (r < n1) |
| 1334 | return n1 + __right_->print(l, l); |
| 1335 | ptrdiff_t sz1 = __right_->print(f+(n1-1), l); |
| 1336 | if (r >= n1 + sz1) |
| 1337 | { |
| 1338 | *f++ = 'a'; |
| 1339 | *f++ = 'l'; |
| 1340 | *f++ = 'i'; |
| 1341 | *f++ = 'g'; |
| 1342 | *f++ = 'n'; |
| 1343 | *f++ = 'o'; |
| 1344 | *f++ = 'f'; |
| 1345 | *f++ = ' '; |
| 1346 | *f = '('; |
| 1347 | f += 1 + sz1; |
| 1348 | *f = ')'; |
| 1349 | } |
| 1350 | return n1 + sz1; |
| 1351 | } |
| 1352 | const ptrdiff_t n2 = sizeof("operator alignof") - 1; |
| 1353 | if (r >= n2) |
| 1354 | { |
| 1355 | *f++ = 'o'; |
| 1356 | *f++ = 'p'; |
| 1357 | *f++ = 'e'; |
| 1358 | *f++ = 'r'; |
| 1359 | *f++ = 'a'; |
| 1360 | *f++ = 't'; |
| 1361 | *f++ = 'o'; |
| 1362 | *f++ = 'r'; |
| 1363 | *f++ = ' '; |
| 1364 | *f++ = 'a'; |
| 1365 | *f++ = 'l'; |
| 1366 | *f++ = 'i'; |
| 1367 | *f++ = 'g'; |
| 1368 | *f++ = 'n'; |
| 1369 | *f++ = 'o'; |
| 1370 | *f = 'f'; |
| 1371 | } |
| 1372 | return n2; |
| 1373 | } |
| 1374 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 1375 | { |
| 1376 | if (__right_) |
| 1377 | return __right_->fix_forward_references(t_begin, t_end); |
| 1378 | return true; |
| 1379 | } |
| 1380 | }; |
| 1381 | |
| 1382 | class __operator_alignof_expression |
| 1383 | : public __node |
| 1384 | { |
| 1385 | public: |
| 1386 | |
| 1387 | __operator_alignof_expression() {} |
| 1388 | __operator_alignof_expression(__node* op) |
| 1389 | { |
| 1390 | __right_ = op; |
| 1391 | } |
| 1392 | virtual size_t first_size() const |
| 1393 | { |
| 1394 | if (__cached_size_ == -1) |
| 1395 | { |
| 1396 | if (__right_) |
| 1397 | const_cast<long&>(__cached_size_) = __right_->size() + 10; |
| 1398 | else |
| 1399 | const_cast<long&>(__cached_size_) = sizeof("operator alignof") - 1; |
| 1400 | } |
| 1401 | return __cached_size_; |
| 1402 | } |
| 1403 | virtual char* first_demangled_name(char* buf) const |
| 1404 | { |
| 1405 | if (__right_) |
| 1406 | { |
| 1407 | strncpy(buf, "alignof (", 9); |
| 1408 | buf += 9; |
| 1409 | buf = __right_->get_demangled_name(buf); |
| 1410 | *buf++ = ')'; |
| 1411 | } |
| 1412 | else |
| 1413 | { |
| 1414 | strncpy(buf, "operator alignof", sizeof("operator alignof") - 1); |
| 1415 | buf += sizeof("operator alignof") - 1; |
| 1416 | } |
| 1417 | return buf; |
| 1418 | } |
| 1419 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 1420 | { |
| 1421 | const ptrdiff_t r = l - f; |
| 1422 | if (__right_) |
| 1423 | { |
| 1424 | const ptrdiff_t n1 = sizeof("alignof ()") - 1; |
| 1425 | if (r < n1) |
| 1426 | return n1 + __right_->print(l, l); |
| 1427 | ptrdiff_t sz1 = __right_->print(f+(n1-1), l); |
| 1428 | if (r >= n1 + sz1) |
| 1429 | { |
| 1430 | *f++ = 'a'; |
| 1431 | *f++ = 'l'; |
| 1432 | *f++ = 'i'; |
| 1433 | *f++ = 'g'; |
| 1434 | *f++ = 'n'; |
| 1435 | *f++ = 'o'; |
| 1436 | *f++ = 'f'; |
| 1437 | *f++ = ' '; |
| 1438 | *f = '('; |
| 1439 | f += 1 + sz1; |
| 1440 | *f = ')'; |
| 1441 | } |
| 1442 | return n1 + sz1; |
| 1443 | } |
| 1444 | const ptrdiff_t n2 = sizeof("operator alignof") - 1; |
| 1445 | if (r >= n2) |
| 1446 | { |
| 1447 | *f++ = 'o'; |
| 1448 | *f++ = 'p'; |
| 1449 | *f++ = 'e'; |
| 1450 | *f++ = 'r'; |
| 1451 | *f++ = 'a'; |
| 1452 | *f++ = 't'; |
| 1453 | *f++ = 'o'; |
| 1454 | *f++ = 'r'; |
| 1455 | *f++ = ' '; |
| 1456 | *f++ = 'a'; |
| 1457 | *f++ = 'l'; |
| 1458 | *f++ = 'i'; |
| 1459 | *f++ = 'g'; |
| 1460 | *f++ = 'n'; |
| 1461 | *f++ = 'o'; |
| 1462 | *f = 'f'; |
| 1463 | } |
| 1464 | return n2; |
| 1465 | } |
| 1466 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 1467 | { |
| 1468 | if (__right_) |
| 1469 | return __right_->fix_forward_references(t_begin, t_end); |
| 1470 | return true; |
| 1471 | } |
| 1472 | }; |
| 1473 | |
| 1474 | class __operator_paren |
| 1475 | : public __node |
| 1476 | { |
| 1477 | public: |
| 1478 | |
| 1479 | virtual size_t first_size() const {return sizeof("operator()") - 1;} |
| 1480 | virtual char* first_demangled_name(char* buf) const |
| 1481 | { |
| 1482 | strncpy(buf, "operator()", sizeof("operator()") - 1); |
| 1483 | return buf + sizeof("operator()") - 1; |
| 1484 | } |
| 1485 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 1486 | { |
| 1487 | const ptrdiff_t r = l - f; |
| 1488 | const ptrdiff_t n = sizeof("operator()") - 1; |
| 1489 | if (r >= n) |
| 1490 | { |
| 1491 | *f++ = 'o'; |
| 1492 | *f++ = 'p'; |
| 1493 | *f++ = 'e'; |
| 1494 | *f++ = 'r'; |
| 1495 | *f++ = 'a'; |
| 1496 | *f++ = 't'; |
| 1497 | *f++ = 'o'; |
| 1498 | *f++ = 'r'; |
| 1499 | *f++ = '('; |
| 1500 | *f = ')'; |
| 1501 | } |
| 1502 | return n; |
| 1503 | } |
| 1504 | }; |
| 1505 | |
| 1506 | class __operator_comma |
| 1507 | : public __node |
| 1508 | { |
| 1509 | public: |
| 1510 | |
| 1511 | __operator_comma() {} |
| 1512 | __operator_comma(__node* op1, __node* op2) |
| 1513 | { |
| 1514 | __left_ = op1; |
| 1515 | __right_ = op2; |
| 1516 | } |
| 1517 | virtual size_t first_size() const |
| 1518 | { |
| 1519 | if (__cached_size_ == -1) |
| 1520 | { |
| 1521 | if (__left_) |
| 1522 | const_cast<long&>(__cached_size_) = __left_->size() + 7 + __right_->size(); |
| 1523 | else |
| 1524 | const_cast<long&>(__cached_size_) = sizeof("operator,") - 1; |
| 1525 | } |
| 1526 | return __cached_size_; |
| 1527 | } |
| 1528 | virtual char* first_demangled_name(char* buf) const |
| 1529 | { |
| 1530 | if (__left_) |
| 1531 | { |
| 1532 | *buf++ = '('; |
| 1533 | buf = __left_->get_demangled_name(buf); |
| 1534 | strncpy(buf, ") , (", 5); |
| 1535 | buf += 5; |
| 1536 | buf = __right_->get_demangled_name(buf); |
| 1537 | *buf++ = ')'; |
| 1538 | } |
| 1539 | else |
| 1540 | { |
| 1541 | strncpy(buf, "operator,", sizeof("operator,") - 1); |
| 1542 | buf += sizeof("operator,") - 1; |
| 1543 | } |
| 1544 | return buf; |
| 1545 | } |
| 1546 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 1547 | { |
| 1548 | const ptrdiff_t r = l - f; |
| 1549 | if (__left_) |
| 1550 | { |
| 1551 | const ptrdiff_t n1 = 7; |
| 1552 | if (r < n1) |
| 1553 | return n1 + __left_->print(l, l) + __right_->print(l, l); |
| 1554 | ptrdiff_t sz1 = __left_->print(f+1, l); |
| 1555 | if (r < n1 + sz1) |
| 1556 | return n1 + sz1 + __right_->print(l, l); |
| 1557 | ptrdiff_t sz2 = __right_->print(f+(n1-1)+sz1, l); |
| 1558 | if (r >= n1 + sz1 + sz2) |
| 1559 | { |
| 1560 | *f = '('; |
| 1561 | f += 1 + sz1; |
| 1562 | *f++ = ')'; |
| 1563 | *f++ = ' '; |
| 1564 | *f++ = ','; |
| 1565 | *f++ = ' '; |
| 1566 | *f = '('; |
| 1567 | f += 1 + sz2; |
| 1568 | *f = ')'; |
| 1569 | } |
| 1570 | return n1 + sz1 + sz2; |
| 1571 | } |
| 1572 | const ptrdiff_t n2 = sizeof("operator,") - 1; |
| 1573 | if (r >= n2) |
| 1574 | { |
| 1575 | *f++ = 'o'; |
| 1576 | *f++ = 'p'; |
| 1577 | *f++ = 'e'; |
| 1578 | *f++ = 'r'; |
| 1579 | *f++ = 'a'; |
| 1580 | *f++ = 't'; |
| 1581 | *f++ = 'o'; |
| 1582 | *f++ = 'r'; |
| 1583 | *f = ','; |
| 1584 | } |
| 1585 | return n2; |
| 1586 | } |
| 1587 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 1588 | { |
| 1589 | bool r = true; |
| 1590 | if (__left_) |
| 1591 | r = r && __left_->fix_forward_references(t_begin, t_end); |
| 1592 | if (__right_) |
| 1593 | r = r && __right_->fix_forward_references(t_begin, t_end); |
| 1594 | return r; |
| 1595 | } |
| 1596 | }; |
| 1597 | |
| 1598 | class __operator_tilda |
| 1599 | : public __node |
| 1600 | { |
| 1601 | public: |
| 1602 | |
| 1603 | __operator_tilda() {} |
| 1604 | explicit __operator_tilda(__node* op) |
| 1605 | { |
| 1606 | __left_ = op; |
| 1607 | } |
| 1608 | virtual size_t first_size() const |
| 1609 | { |
| 1610 | if (__cached_size_ == -1) |
| 1611 | { |
| 1612 | if (__left_) |
| 1613 | const_cast<long&>(__cached_size_) = 3+__left_->size(); |
| 1614 | else |
| 1615 | const_cast<long&>(__cached_size_) = sizeof("operator~") - 1; |
| 1616 | } |
| 1617 | return __cached_size_; |
| 1618 | } |
| 1619 | virtual char* first_demangled_name(char* buf) const |
| 1620 | { |
| 1621 | if (__left_) |
| 1622 | { |
| 1623 | *buf++ = '~'; |
| 1624 | *buf++ = '('; |
| 1625 | buf = __left_->get_demangled_name(buf); |
| 1626 | *buf++ = ')'; |
| 1627 | } |
| 1628 | else |
| 1629 | { |
| 1630 | strncpy(buf, "operator~", sizeof("operator~") - 1); |
| 1631 | buf += sizeof("operator~") - 1; |
| 1632 | } |
| 1633 | return buf; |
| 1634 | } |
| 1635 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 1636 | { |
| 1637 | const ptrdiff_t r = l - f; |
| 1638 | if (__left_) |
| 1639 | { |
| 1640 | const ptrdiff_t n1 = 3; |
| 1641 | if (r < n1) |
| 1642 | return n1 + __left_->print(l, l); |
| 1643 | ptrdiff_t sz1 = __left_->print(f+2, l); |
| 1644 | if (r >= n1 + sz1) |
| 1645 | { |
| 1646 | *f++ = '~'; |
| 1647 | *f = '('; |
| 1648 | f += 1 + sz1; |
| 1649 | *f = ')'; |
| 1650 | } |
| 1651 | return n1 + sz1; |
| 1652 | } |
| 1653 | const ptrdiff_t n2 = sizeof("operator~") - 1; |
| 1654 | if (r >= n2) |
| 1655 | { |
| 1656 | *f++ = 'o'; |
| 1657 | *f++ = 'p'; |
| 1658 | *f++ = 'e'; |
| 1659 | *f++ = 'r'; |
| 1660 | *f++ = 'a'; |
| 1661 | *f++ = 't'; |
| 1662 | *f++ = 'o'; |
| 1663 | *f++ = 'r'; |
| 1664 | *f = '~'; |
| 1665 | } |
| 1666 | return n2; |
| 1667 | } |
| 1668 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 1669 | { |
| 1670 | if (__left_) |
| 1671 | return __left_->fix_forward_references(t_begin, t_end); |
| 1672 | return true; |
| 1673 | } |
| 1674 | }; |
| 1675 | |
| 1676 | class __operator_cast |
| 1677 | : public __node |
| 1678 | { |
| 1679 | static const size_t n = sizeof("operator ") - 1; |
| 1680 | public: |
| 1681 | |
| 1682 | explicit __operator_cast(__node* type) |
| 1683 | { |
| 1684 | __right_ = type; |
| 1685 | } |
| 1686 | __operator_cast(__node* type, __node* arg) |
| 1687 | { |
| 1688 | __size_ = 1; |
| 1689 | __right_ = type; |
| 1690 | __left_ = arg; |
| 1691 | } |
| 1692 | virtual size_t first_size() const |
| 1693 | { |
| 1694 | if (__cached_size_ == -1) |
| 1695 | { |
| 1696 | size_t off; |
| 1697 | if (__size_) |
| 1698 | { |
| 1699 | off = 4; |
| 1700 | off += __right_->size(); |
| 1701 | if (__left_) |
| 1702 | off += __left_->size(); |
| 1703 | } |
| 1704 | else |
| 1705 | off = n + __right_->size();; |
| 1706 | const_cast<long&>(__cached_size_) = off; |
| 1707 | } |
| 1708 | return __cached_size_; |
| 1709 | } |
| 1710 | virtual char* first_demangled_name(char* buf) const |
| 1711 | { |
| 1712 | if (__size_) |
| 1713 | { |
| 1714 | *buf++ = '('; |
| 1715 | buf = __right_->get_demangled_name(buf); |
| 1716 | *buf++ = ')'; |
| 1717 | *buf++ = '('; |
| 1718 | if (__left_) |
| 1719 | buf = __left_->get_demangled_name(buf); |
| 1720 | *buf++ = ')'; |
| 1721 | } |
| 1722 | else |
| 1723 | { |
| 1724 | strncpy(buf, "operator ", n); |
| 1725 | buf = __right_->get_demangled_name(buf+n); |
| 1726 | } |
| 1727 | return buf; |
| 1728 | } |
| 1729 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 1730 | { |
| 1731 | const ptrdiff_t r = l - f; |
| 1732 | if (__size_) |
| 1733 | { |
| 1734 | const ptrdiff_t n1 = 4; |
| 1735 | if (r < n1) |
| 1736 | return n1 + __right_->print(l, l) + |
| 1737 | (__left_ ? __left_->print(l, l) : 0); |
| 1738 | ptrdiff_t sz1 = __right_->print(f+1, l); |
| 1739 | if (r < n1 + sz1) |
| 1740 | return n1 + sz1 + (__left_ ? __left_->print(l, l) : 0); |
| 1741 | ptrdiff_t sz2 = __left_ ? __left_->print(f+3+sz1, l) : 0; |
| 1742 | if (r >= n1 + sz1 + sz2) |
| 1743 | { |
| 1744 | *f = '('; |
| 1745 | f += 1 + sz1; |
| 1746 | *f++ = ')'; |
| 1747 | *f = '('; |
| 1748 | f += 1 + sz2; |
| 1749 | *f = ')'; |
| 1750 | } |
| 1751 | return n1 + sz1 + sz2; |
| 1752 | } |
| 1753 | const ptrdiff_t n2 = sizeof("operator ") - 1; |
| 1754 | if (r < n2) |
| 1755 | return n2 + __right_->print(l, l); |
| 1756 | ptrdiff_t sz1 = __right_->print(f+n2, l); |
| 1757 | if (r >= n2 + sz1) |
| 1758 | { |
| 1759 | *f++ = 'o'; |
| 1760 | *f++ = 'p'; |
| 1761 | *f++ = 'e'; |
| 1762 | *f++ = 'r'; |
| 1763 | *f++ = 'a'; |
| 1764 | *f++ = 't'; |
| 1765 | *f++ = 'o'; |
| 1766 | *f++ = 'r'; |
| 1767 | *f = ' '; |
| 1768 | } |
| 1769 | return n2 + sz1; |
| 1770 | } |
| 1771 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 1772 | { |
| 1773 | bool r = true; |
| 1774 | if (__left_) |
| 1775 | r = r && __left_->fix_forward_references(t_begin, t_end); |
| 1776 | r = r && __right_->fix_forward_references(t_begin, t_end); |
| 1777 | return r; |
| 1778 | } |
| 1779 | virtual bool is_ctor_dtor_conv() const |
| 1780 | { |
| 1781 | return true; |
| 1782 | } |
| 1783 | }; |
| 1784 | |
| 1785 | class __cast_literal |
| 1786 | : public __node |
| 1787 | { |
| 1788 | public: |
| 1789 | |
| 1790 | __cast_literal(__node* type, const char* f, const char* l) |
| 1791 | { |
| 1792 | __left_ = type; |
| 1793 | __name_ = f; |
| 1794 | __size_ = l - f; |
| 1795 | } |
| 1796 | virtual size_t first_size() const |
| 1797 | { |
| 1798 | if (__cached_size_ == -1) |
| 1799 | const_cast<long&>(__cached_size_) = 2 + __left_->size() + __size_; |
| 1800 | return __cached_size_; |
| 1801 | } |
| 1802 | virtual char* first_demangled_name(char* buf) const |
| 1803 | { |
| 1804 | *buf++ = '('; |
| 1805 | buf = __left_->get_demangled_name(buf); |
| 1806 | *buf++ = ')'; |
| 1807 | strncpy(buf, __name_, __size_); |
| 1808 | return buf + __size_; |
| 1809 | } |
| 1810 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 1811 | { |
| 1812 | const ptrdiff_t r = l - f; |
| 1813 | const ptrdiff_t n = 2; |
| 1814 | if (r < __size_ + n) |
| 1815 | return __size_ + n + __left_->print(l, l); |
| 1816 | ptrdiff_t sz = __left_->print(f+1, l); |
| 1817 | if (r >= __size_ + n + sz) |
| 1818 | { |
| 1819 | *f = '('; |
| 1820 | f += 1 + sz; |
| 1821 | *f++ = ')'; |
| 1822 | strncpy(f, __name_, __size_); |
| 1823 | } |
| 1824 | return __size_ + n + sz; |
| 1825 | } |
| 1826 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 1827 | { |
| 1828 | return __left_->fix_forward_references(t_begin, t_end); |
| 1829 | } |
| 1830 | }; |
| 1831 | |
| 1832 | class __operator_dereference |
| 1833 | : public __node |
| 1834 | { |
| 1835 | public: |
| 1836 | |
| 1837 | __operator_dereference() {} |
| 1838 | explicit __operator_dereference(__node* op) |
| 1839 | { |
| 1840 | __left_ = op; |
| 1841 | } |
| 1842 | virtual size_t first_size() const |
| 1843 | { |
| 1844 | if (__cached_size_ == -1) |
| 1845 | { |
| 1846 | if (__left_) |
| 1847 | const_cast<long&>(__cached_size_) = 3+__left_->size(); |
| 1848 | else |
| 1849 | const_cast<long&>(__cached_size_) = sizeof("operator*") - 1; |
| 1850 | } |
| 1851 | return __cached_size_; |
| 1852 | } |
| 1853 | virtual char* first_demangled_name(char* buf) const |
| 1854 | { |
| 1855 | if (__left_) |
| 1856 | { |
| 1857 | *buf++ = '*'; |
| 1858 | *buf++ = '('; |
| 1859 | buf = __left_->get_demangled_name(buf); |
| 1860 | *buf++ = ')'; |
| 1861 | } |
| 1862 | else |
| 1863 | { |
| 1864 | strncpy(buf, "operator*", sizeof("operator*") - 1); |
| 1865 | buf += sizeof("operator*") - 1; |
| 1866 | } |
| 1867 | return buf; |
| 1868 | } |
| 1869 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 1870 | { |
| 1871 | const ptrdiff_t r = l - f; |
| 1872 | if (__left_) |
| 1873 | { |
| 1874 | const ptrdiff_t n1 = 3; |
| 1875 | if (r < n1) |
| 1876 | return n1 + __left_->print(l, l); |
| 1877 | ptrdiff_t sz1 = __left_->print(f+2, l); |
| 1878 | if (r >= n1 + sz1) |
| 1879 | { |
| 1880 | *f++ = '*'; |
| 1881 | *f = '('; |
| 1882 | f += 1 + sz1; |
| 1883 | *f = ')'; |
| 1884 | } |
| 1885 | return n1 + sz1; |
| 1886 | } |
| 1887 | const ptrdiff_t n2 = sizeof("operator*") - 1; |
| 1888 | if (r >= n2) |
| 1889 | { |
| 1890 | *f++ = 'o'; |
| 1891 | *f++ = 'p'; |
| 1892 | *f++ = 'e'; |
| 1893 | *f++ = 'r'; |
| 1894 | *f++ = 'a'; |
| 1895 | *f++ = 't'; |
| 1896 | *f++ = 'o'; |
| 1897 | *f++ = 'r'; |
| 1898 | *f = '*'; |
| 1899 | } |
| 1900 | return n2; |
| 1901 | } |
| 1902 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 1903 | { |
| 1904 | if (__left_) |
| 1905 | return __left_->fix_forward_references(t_begin, t_end); |
| 1906 | return true; |
| 1907 | } |
| 1908 | }; |
| 1909 | |
| 1910 | class __operator_divide |
| 1911 | : public __node |
| 1912 | { |
| 1913 | public: |
| 1914 | |
| 1915 | __operator_divide() {} |
| 1916 | __operator_divide(__node* op1, __node* op2) |
| 1917 | { |
| 1918 | __left_ = op1; |
| 1919 | __right_ = op2; |
| 1920 | } |
| 1921 | virtual size_t first_size() const |
| 1922 | { |
| 1923 | if (__cached_size_ == -1) |
| 1924 | { |
| 1925 | if (__left_) |
| 1926 | const_cast<long&>(__cached_size_) = __left_->size() + 7 + __right_->size(); |
| 1927 | else |
| 1928 | const_cast<long&>(__cached_size_) = sizeof("operator/") - 1; |
| 1929 | } |
| 1930 | return __cached_size_; |
| 1931 | } |
| 1932 | virtual char* first_demangled_name(char* buf) const |
| 1933 | { |
| 1934 | if (__left_) |
| 1935 | { |
| 1936 | *buf++ = '('; |
| 1937 | buf = __left_->get_demangled_name(buf); |
| 1938 | strncpy(buf, ") / (", 5); |
| 1939 | buf += 5; |
| 1940 | buf = __right_->get_demangled_name(buf); |
| 1941 | *buf++ = ')'; |
| 1942 | } |
| 1943 | else |
| 1944 | { |
| 1945 | strncpy(buf, "operator/", sizeof("operator/") - 1); |
| 1946 | buf += sizeof("operator/") - 1; |
| 1947 | } |
| 1948 | return buf; |
| 1949 | } |
| 1950 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 1951 | { |
| 1952 | const ptrdiff_t r = l - f; |
| 1953 | if (__left_) |
| 1954 | { |
| 1955 | const ptrdiff_t n1 = 7; |
| 1956 | if (r < n1) |
| 1957 | return n1 + __left_->print(l, l) + __right_->print(l, l); |
| 1958 | ptrdiff_t sz1 = __left_->print(f+1, l); |
| 1959 | if (r < n1 + sz1) |
| 1960 | return n1 + sz1 + __right_->print(l, l); |
| 1961 | ptrdiff_t sz2 = __right_->print(f+(n1-1)+sz1, l); |
| 1962 | if (r >= n1 + sz1 + sz2) |
| 1963 | { |
| 1964 | *f = '('; |
| 1965 | f += 1 + sz1; |
| 1966 | *f++ = ')'; |
| 1967 | *f++ = ' '; |
| 1968 | *f++ = '/'; |
| 1969 | *f++ = ' '; |
| 1970 | *f = '('; |
| 1971 | f += 1 + sz2; |
| 1972 | *f = ')'; |
| 1973 | } |
| 1974 | return n1 + sz1 + sz2; |
| 1975 | } |
| 1976 | const ptrdiff_t n2 = sizeof("operator/") - 1; |
| 1977 | if (r >= n2) |
| 1978 | { |
| 1979 | *f++ = 'o'; |
| 1980 | *f++ = 'p'; |
| 1981 | *f++ = 'e'; |
| 1982 | *f++ = 'r'; |
| 1983 | *f++ = 'a'; |
| 1984 | *f++ = 't'; |
| 1985 | *f++ = 'o'; |
| 1986 | *f++ = 'r'; |
| 1987 | *f = '/'; |
| 1988 | } |
| 1989 | return n2; |
| 1990 | } |
| 1991 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 1992 | { |
| 1993 | bool r = true; |
| 1994 | if (__left_) |
| 1995 | r = r && __left_->fix_forward_references(t_begin, t_end); |
| 1996 | if (__right_) |
| 1997 | r = r && __right_->fix_forward_references(t_begin, t_end); |
| 1998 | return r; |
| 1999 | } |
| 2000 | }; |
| 2001 | |
| 2002 | class __operator_divide_equal |
| 2003 | : public __node |
| 2004 | { |
| 2005 | public: |
| 2006 | |
| 2007 | __operator_divide_equal() {} |
| 2008 | __operator_divide_equal(__node* op1, __node* op2) |
| 2009 | { |
| 2010 | __left_ = op1; |
| 2011 | __right_ = op2; |
| 2012 | } |
| 2013 | virtual size_t first_size() const |
| 2014 | { |
| 2015 | if (__cached_size_ == -1) |
| 2016 | { |
| 2017 | if (__left_) |
| 2018 | const_cast<long&>(__cached_size_) = __left_->size() + 8 + __right_->size(); |
| 2019 | else |
| 2020 | const_cast<long&>(__cached_size_) = sizeof("operator/=") - 1; |
| 2021 | } |
| 2022 | return __cached_size_; |
| 2023 | } |
| 2024 | virtual char* first_demangled_name(char* buf) const |
| 2025 | { |
| 2026 | if (__left_) |
| 2027 | { |
| 2028 | *buf++ = '('; |
| 2029 | buf = __left_->get_demangled_name(buf); |
| 2030 | strncpy(buf, ") /= (", 6); |
| 2031 | buf += 6; |
| 2032 | buf = __right_->get_demangled_name(buf); |
| 2033 | *buf++ = ')'; |
| 2034 | } |
| 2035 | else |
| 2036 | { |
| 2037 | strncpy(buf, "operator/=", sizeof("operator/=") - 1); |
| 2038 | buf += sizeof("operator/=") - 1; |
| 2039 | } |
| 2040 | return buf; |
| 2041 | } |
| 2042 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 2043 | { |
| 2044 | const ptrdiff_t r = l - f; |
| 2045 | if (__left_) |
| 2046 | { |
| 2047 | const ptrdiff_t n1 = 8; |
| 2048 | if (r < n1) |
| 2049 | return n1 + __left_->print(l, l) + __right_->print(l, l); |
| 2050 | ptrdiff_t sz1 = __left_->print(f+1, l); |
| 2051 | if (r < n1 + sz1) |
| 2052 | return n1 + sz1 + __right_->print(l, l); |
| 2053 | ptrdiff_t sz2 = __right_->print(f+(n1-1)+sz1, l); |
| 2054 | if (r >= n1 + sz1 + sz2) |
| 2055 | { |
| 2056 | *f = '('; |
| 2057 | f += 1 + sz1; |
| 2058 | *f++ = ')'; |
| 2059 | *f++ = ' '; |
| 2060 | *f++ = '/'; |
| 2061 | *f++ = '='; |
| 2062 | *f++ = ' '; |
| 2063 | *f = '('; |
| 2064 | f += 1 + sz2; |
| 2065 | *f = ')'; |
| 2066 | } |
| 2067 | return n1 + sz1 + sz2; |
| 2068 | } |
| 2069 | const ptrdiff_t n2 = sizeof("operator/=") - 1; |
| 2070 | if (r >= n2) |
| 2071 | { |
| 2072 | *f++ = 'o'; |
| 2073 | *f++ = 'p'; |
| 2074 | *f++ = 'e'; |
| 2075 | *f++ = 'r'; |
| 2076 | *f++ = 'a'; |
| 2077 | *f++ = 't'; |
| 2078 | *f++ = 'o'; |
| 2079 | *f++ = 'r'; |
| 2080 | *f++ = '/'; |
| 2081 | *f = '='; |
| 2082 | } |
| 2083 | return n2; |
| 2084 | } |
| 2085 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 2086 | { |
| 2087 | bool r = true; |
| 2088 | if (__left_) |
| 2089 | r = r && __left_->fix_forward_references(t_begin, t_end); |
| 2090 | if (__right_) |
| 2091 | r = r && __right_->fix_forward_references(t_begin, t_end); |
| 2092 | return r; |
| 2093 | } |
| 2094 | }; |
| 2095 | |
| 2096 | class __operator_xor |
| 2097 | : public __node |
| 2098 | { |
| 2099 | public: |
| 2100 | |
| 2101 | __operator_xor() {} |
| 2102 | __operator_xor(__node* op1, __node* op2) |
| 2103 | { |
| 2104 | __left_ = op1; |
| 2105 | __right_ = op2; |
| 2106 | } |
| 2107 | virtual size_t first_size() const |
| 2108 | { |
| 2109 | if (__cached_size_ == -1) |
| 2110 | { |
| 2111 | if (__left_) |
| 2112 | const_cast<long&>(__cached_size_) = __left_->size() + 7 + __right_->size(); |
| 2113 | else |
| 2114 | const_cast<long&>(__cached_size_) = sizeof("operator^") - 1; |
| 2115 | } |
| 2116 | return __cached_size_; |
| 2117 | } |
| 2118 | virtual char* first_demangled_name(char* buf) const |
| 2119 | { |
| 2120 | if (__left_) |
| 2121 | { |
| 2122 | *buf++ = '('; |
| 2123 | buf = __left_->get_demangled_name(buf); |
| 2124 | strncpy(buf, ") ^ (", 5); |
| 2125 | buf += 5; |
| 2126 | buf = __right_->get_demangled_name(buf); |
| 2127 | *buf++ = ')'; |
| 2128 | } |
| 2129 | else |
| 2130 | { |
| 2131 | strncpy(buf, "operator^", sizeof("operator^") - 1); |
| 2132 | buf += sizeof("operator^") - 1; |
| 2133 | } |
| 2134 | return buf; |
| 2135 | } |
| 2136 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 2137 | { |
| 2138 | const ptrdiff_t r = l - f; |
| 2139 | if (__left_) |
| 2140 | { |
| 2141 | const ptrdiff_t n1 = 7; |
| 2142 | if (r < n1) |
| 2143 | return n1 + __left_->print(l, l) + __right_->print(l, l); |
| 2144 | ptrdiff_t sz1 = __left_->print(f+1, l); |
| 2145 | if (r < n1 + sz1) |
| 2146 | return n1 + sz1 + __right_->print(l, l); |
| 2147 | ptrdiff_t sz2 = __right_->print(f+(n1-1)+sz1, l); |
| 2148 | if (r >= n1 + sz1 + sz2) |
| 2149 | { |
| 2150 | *f = '('; |
| 2151 | f += 1 + sz1; |
| 2152 | *f++ = ')'; |
| 2153 | *f++ = ' '; |
| 2154 | *f++ = '^'; |
| 2155 | *f++ = ' '; |
| 2156 | *f = '('; |
| 2157 | f += 1 + sz2; |
| 2158 | *f = ')'; |
| 2159 | } |
| 2160 | return n1 + sz1 + sz2; |
| 2161 | } |
| 2162 | const ptrdiff_t n2 = sizeof("operator^") - 1; |
| 2163 | if (r >= n2) |
| 2164 | { |
| 2165 | *f++ = 'o'; |
| 2166 | *f++ = 'p'; |
| 2167 | *f++ = 'e'; |
| 2168 | *f++ = 'r'; |
| 2169 | *f++ = 'a'; |
| 2170 | *f++ = 't'; |
| 2171 | *f++ = 'o'; |
| 2172 | *f++ = 'r'; |
| 2173 | *f = '^'; |
| 2174 | } |
| 2175 | return n2; |
| 2176 | } |
| 2177 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 2178 | { |
| 2179 | bool r = true; |
| 2180 | if (__left_) |
| 2181 | r = r && __left_->fix_forward_references(t_begin, t_end); |
| 2182 | if (__right_) |
| 2183 | r = r && __right_->fix_forward_references(t_begin, t_end); |
| 2184 | return r; |
| 2185 | } |
| 2186 | }; |
| 2187 | |
| 2188 | class __operator_xor_equal |
| 2189 | : public __node |
| 2190 | { |
| 2191 | public: |
| 2192 | |
| 2193 | __operator_xor_equal() {} |
| 2194 | __operator_xor_equal(__node* op1, __node* op2) |
| 2195 | { |
| 2196 | __left_ = op1; |
| 2197 | __right_ = op2; |
| 2198 | } |
| 2199 | virtual size_t first_size() const |
| 2200 | { |
| 2201 | if (__cached_size_ == -1) |
| 2202 | { |
| 2203 | if (__left_) |
| 2204 | const_cast<long&>(__cached_size_) = __left_->size() + 8 + __right_->size(); |
| 2205 | else |
| 2206 | const_cast<long&>(__cached_size_) = sizeof("operator^=") - 1; |
| 2207 | } |
| 2208 | return __cached_size_; |
| 2209 | } |
| 2210 | virtual char* first_demangled_name(char* buf) const |
| 2211 | { |
| 2212 | if (__left_) |
| 2213 | { |
| 2214 | *buf++ = '('; // strncpy(buf, "(", 1); |
| 2215 | buf = __left_->get_demangled_name(buf); |
| 2216 | strncpy(buf, ") ^= (", 6); |
| 2217 | buf += 6; |
| 2218 | buf = __right_->get_demangled_name(buf); |
| 2219 | *buf++ = ')'; |
| 2220 | } |
| 2221 | else |
| 2222 | { |
| 2223 | strncpy(buf, "operator^=", sizeof("operator^=") - 1); |
| 2224 | buf += sizeof("operator^=") - 1; |
| 2225 | } |
| 2226 | return buf; |
| 2227 | } |
| 2228 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 2229 | { |
| 2230 | const ptrdiff_t r = l - f; |
| 2231 | if (__left_) |
| 2232 | { |
| 2233 | const ptrdiff_t n1 = 8; |
| 2234 | if (r < n1) |
| 2235 | return n1 + __left_->print(l, l) + __right_->print(l, l); |
| 2236 | ptrdiff_t sz1 = __left_->print(f+1, l); |
| 2237 | if (r < n1 + sz1) |
| 2238 | return n1 + sz1 + __right_->print(l, l); |
| 2239 | ptrdiff_t sz2 = __right_->print(f+(n1-1)+sz1, l); |
| 2240 | if (r >= n1 + sz1 + sz2) |
| 2241 | { |
| 2242 | *f = '('; |
| 2243 | f += 1 + sz1; |
| 2244 | *f++ = ')'; |
| 2245 | *f++ = ' '; |
| 2246 | *f++ = '^'; |
| 2247 | *f++ = '='; |
| 2248 | *f++ = ' '; |
| 2249 | *f = '('; |
| 2250 | f += 1 + sz2; |
| 2251 | *f = ')'; |
| 2252 | } |
| 2253 | return n1 + sz1 + sz2; |
| 2254 | } |
| 2255 | const ptrdiff_t n2 = sizeof("operator^=") - 1; |
| 2256 | if (r >= n2) |
| 2257 | { |
| 2258 | *f++ = 'o'; |
| 2259 | *f++ = 'p'; |
| 2260 | *f++ = 'e'; |
| 2261 | *f++ = 'r'; |
| 2262 | *f++ = 'a'; |
| 2263 | *f++ = 't'; |
| 2264 | *f++ = 'o'; |
| 2265 | *f++ = 'r'; |
| 2266 | *f++ = '^'; |
| 2267 | *f = '='; |
| 2268 | } |
| 2269 | return n2; |
| 2270 | } |
| 2271 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 2272 | { |
| 2273 | bool r = true; |
| 2274 | if (__left_) |
| 2275 | r = r && __left_->fix_forward_references(t_begin, t_end); |
| 2276 | if (__right_) |
| 2277 | r = r && __right_->fix_forward_references(t_begin, t_end); |
| 2278 | return r; |
| 2279 | } |
| 2280 | }; |
| 2281 | |
| 2282 | class __operator_equality |
| 2283 | : public __node |
| 2284 | { |
| 2285 | public: |
| 2286 | |
| 2287 | __operator_equality() {} |
| 2288 | __operator_equality(__node* op1, __node* op2) |
| 2289 | { |
| 2290 | __left_ = op1; |
| 2291 | __right_ = op2; |
| 2292 | } |
| 2293 | virtual size_t first_size() const |
| 2294 | { |
| 2295 | if (__cached_size_ == -1) |
| 2296 | { |
| 2297 | if (__left_) |
| 2298 | const_cast<long&>(__cached_size_) = __left_->size() + 8 + __right_->size(); |
| 2299 | else |
| 2300 | const_cast<long&>(__cached_size_) = sizeof("operator==") - 1; |
| 2301 | } |
| 2302 | return __cached_size_; |
| 2303 | } |
| 2304 | virtual char* first_demangled_name(char* buf) const |
| 2305 | { |
| 2306 | if (__left_) |
| 2307 | { |
| 2308 | *buf++ = '('; |
| 2309 | buf = __left_->get_demangled_name(buf); |
| 2310 | strncpy(buf, ") == (", 6); |
| 2311 | buf += 6; |
| 2312 | buf = __right_->get_demangled_name(buf); |
| 2313 | *buf++ = ')'; |
| 2314 | } |
| 2315 | else |
| 2316 | { |
| 2317 | strncpy(buf, "operator==", sizeof("operator==") - 1); |
| 2318 | buf += sizeof("operator==") - 1; |
| 2319 | } |
| 2320 | return buf; |
| 2321 | } |
| 2322 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 2323 | { |
| 2324 | const ptrdiff_t r = l - f; |
| 2325 | if (__left_) |
| 2326 | { |
| 2327 | const ptrdiff_t n1 = 8; |
| 2328 | if (r < n1) |
| 2329 | return n1 + __left_->print(l, l) + __right_->print(l, l); |
| 2330 | ptrdiff_t sz1 = __left_->print(f+1, l); |
| 2331 | if (r < n1 + sz1) |
| 2332 | return n1 + sz1 + __right_->print(l, l); |
| 2333 | ptrdiff_t sz2 = __right_->print(f+(n1-1)+sz1, l); |
| 2334 | if (r >= n1 + sz1 + sz2) |
| 2335 | { |
| 2336 | *f = '('; |
| 2337 | f += 1 + sz1; |
| 2338 | *f++ = ')'; |
| 2339 | *f++ = ' '; |
| 2340 | *f++ = '='; |
| 2341 | *f++ = '='; |
| 2342 | *f++ = ' '; |
| 2343 | *f = '('; |
| 2344 | f += 1 + sz2; |
| 2345 | *f = ')'; |
| 2346 | } |
| 2347 | return n1 + sz1 + sz2; |
| 2348 | } |
| 2349 | const ptrdiff_t n2 = sizeof("operator==") - 1; |
| 2350 | if (r >= n2) |
| 2351 | { |
| 2352 | *f++ = 'o'; |
| 2353 | *f++ = 'p'; |
| 2354 | *f++ = 'e'; |
| 2355 | *f++ = 'r'; |
| 2356 | *f++ = 'a'; |
| 2357 | *f++ = 't'; |
| 2358 | *f++ = 'o'; |
| 2359 | *f++ = 'r'; |
| 2360 | *f++ = '='; |
| 2361 | *f = '='; |
| 2362 | } |
| 2363 | return n2; |
| 2364 | } |
| 2365 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 2366 | { |
| 2367 | bool r = true; |
| 2368 | if (__left_) |
| 2369 | r = r && __left_->fix_forward_references(t_begin, t_end); |
| 2370 | if (__right_) |
| 2371 | r = r && __right_->fix_forward_references(t_begin, t_end); |
| 2372 | return r; |
| 2373 | } |
| 2374 | }; |
| 2375 | |
| 2376 | class __operator_greater_equal |
| 2377 | : public __node |
| 2378 | { |
| 2379 | public: |
| 2380 | |
| 2381 | __operator_greater_equal() {} |
| 2382 | __operator_greater_equal(__node* op1, __node* op2) |
| 2383 | { |
| 2384 | __left_ = op1; |
| 2385 | __right_ = op2; |
| 2386 | } |
| 2387 | virtual size_t first_size() const |
| 2388 | { |
| 2389 | if (__cached_size_ == -1) |
| 2390 | { |
| 2391 | if (__left_) |
| 2392 | const_cast<long&>(__cached_size_) = __left_->size() + 8 + __right_->size(); |
| 2393 | else |
| 2394 | const_cast<long&>(__cached_size_) = sizeof("operator>=") - 1; |
| 2395 | } |
| 2396 | return __cached_size_; |
| 2397 | } |
| 2398 | virtual char* first_demangled_name(char* buf) const |
| 2399 | { |
| 2400 | if (__left_) |
| 2401 | { |
| 2402 | *buf++ = '('; |
| 2403 | buf = __left_->get_demangled_name(buf); |
| 2404 | strncpy(buf, ") >= (", 6); |
| 2405 | buf += 6; |
| 2406 | buf = __right_->get_demangled_name(buf); |
| 2407 | *buf++ = ')'; |
| 2408 | } |
| 2409 | else |
| 2410 | { |
| 2411 | strncpy(buf, "operator>=", sizeof("operator>=") - 1); |
| 2412 | buf += sizeof("operator>=") - 1; |
| 2413 | } |
| 2414 | return buf; |
| 2415 | } |
| 2416 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 2417 | { |
| 2418 | const ptrdiff_t r = l - f; |
| 2419 | if (__left_) |
| 2420 | { |
| 2421 | const ptrdiff_t n1 = 8; |
| 2422 | if (r < n1) |
| 2423 | return n1 + __left_->print(l, l) + __right_->print(l, l); |
| 2424 | ptrdiff_t sz1 = __left_->print(f+1, l); |
| 2425 | if (r < n1 + sz1) |
| 2426 | return n1 + sz1 + __right_->print(l, l); |
| 2427 | ptrdiff_t sz2 = __right_->print(f+(n1-1)+sz1, l); |
| 2428 | if (r >= n1 + sz1 + sz2) |
| 2429 | { |
| 2430 | *f = '('; |
| 2431 | f += 1 + sz1; |
| 2432 | *f++ = ')'; |
| 2433 | *f++ = ' '; |
| 2434 | *f++ = '>'; |
| 2435 | *f++ = '='; |
| 2436 | *f++ = ' '; |
| 2437 | *f = '('; |
| 2438 | f += 1 + sz2; |
| 2439 | *f = ')'; |
| 2440 | } |
| 2441 | return n1 + sz1 + sz2; |
| 2442 | } |
| 2443 | const ptrdiff_t n2 = sizeof("operator>=") - 1; |
| 2444 | if (r >= n2) |
| 2445 | { |
| 2446 | *f++ = 'o'; |
| 2447 | *f++ = 'p'; |
| 2448 | *f++ = 'e'; |
| 2449 | *f++ = 'r'; |
| 2450 | *f++ = 'a'; |
| 2451 | *f++ = 't'; |
| 2452 | *f++ = 'o'; |
| 2453 | *f++ = 'r'; |
| 2454 | *f++ = '>'; |
| 2455 | *f = '='; |
| 2456 | } |
| 2457 | return n2; |
| 2458 | } |
| 2459 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 2460 | { |
| 2461 | bool r = true; |
| 2462 | if (__left_) |
| 2463 | r = r && __left_->fix_forward_references(t_begin, t_end); |
| 2464 | if (__right_) |
| 2465 | r = r && __right_->fix_forward_references(t_begin, t_end); |
| 2466 | return r; |
| 2467 | } |
| 2468 | }; |
| 2469 | |
| 2470 | class __operator_greater |
| 2471 | : public __node |
| 2472 | { |
| 2473 | public: |
| 2474 | |
| 2475 | __operator_greater() {} |
| 2476 | __operator_greater(__node* op1, __node* op2) |
| 2477 | { |
| 2478 | __left_ = op1; |
| 2479 | __right_ = op2; |
| 2480 | } |
| 2481 | virtual size_t first_size() const |
| 2482 | { |
| 2483 | if (__cached_size_ == -1) |
| 2484 | { |
| 2485 | if (__left_) |
| 2486 | const_cast<long&>(__cached_size_) = __left_->size() + 9 + __right_->size(); |
| 2487 | else |
| 2488 | const_cast<long&>(__cached_size_) = sizeof("operator>") - 1; |
| 2489 | } |
| 2490 | return __cached_size_; |
| 2491 | } |
| 2492 | virtual char* first_demangled_name(char* buf) const |
| 2493 | { |
| 2494 | if (__left_) |
| 2495 | { |
| 2496 | *buf++ = '('; |
| 2497 | *buf++ = '('; |
| 2498 | buf = __left_->get_demangled_name(buf); |
| 2499 | strncpy(buf, ") > (", 5); |
| 2500 | buf += 5; |
| 2501 | buf = __right_->get_demangled_name(buf); |
| 2502 | *buf++ = ')'; |
| 2503 | *buf++ = ')'; |
| 2504 | } |
| 2505 | else |
| 2506 | { |
| 2507 | strncpy(buf, "operator>", sizeof("operator>") - 1); |
| 2508 | buf += sizeof("operator>") - 1; |
| 2509 | } |
| 2510 | return buf; |
| 2511 | } |
| 2512 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 2513 | { |
| 2514 | const ptrdiff_t r = l - f; |
| 2515 | if (__left_) |
| 2516 | { |
| 2517 | const ptrdiff_t n1 = 9; |
| 2518 | if (r < n1) |
| 2519 | return n1 + __left_->print(l, l) + __right_->print(l, l); |
| 2520 | ptrdiff_t sz1 = __left_->print(f+2, l); |
| 2521 | if (r < n1 + sz1) |
| 2522 | return n1 + sz1 + __right_->print(l, l); |
| 2523 | ptrdiff_t sz2 = __right_->print(f+(n1-2)+sz1, l); |
| 2524 | if (r >= n1 + sz1 + sz2) |
| 2525 | { |
| 2526 | *f++ = '('; |
| 2527 | *f = '('; |
| 2528 | f += 1 + sz1; |
| 2529 | *f++ = ')'; |
| 2530 | *f++ = ' '; |
| 2531 | *f++ = '>'; |
| 2532 | *f++ = ' '; |
| 2533 | *f = '('; |
| 2534 | f += 1 + sz2; |
| 2535 | *f++ = ')'; |
| 2536 | *f = ')'; |
| 2537 | } |
| 2538 | return n1 + sz1 + sz2; |
| 2539 | } |
| 2540 | const ptrdiff_t n2 = sizeof("operator>") - 1; |
| 2541 | if (r >= n2) |
| 2542 | { |
| 2543 | *f++ = 'o'; |
| 2544 | *f++ = 'p'; |
| 2545 | *f++ = 'e'; |
| 2546 | *f++ = 'r'; |
| 2547 | *f++ = 'a'; |
| 2548 | *f++ = 't'; |
| 2549 | *f++ = 'o'; |
| 2550 | *f++ = 'r'; |
| 2551 | *f = '>'; |
| 2552 | } |
| 2553 | return n2; |
| 2554 | } |
| 2555 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 2556 | { |
| 2557 | bool r = true; |
| 2558 | if (__left_) |
| 2559 | r = r && __left_->fix_forward_references(t_begin, t_end); |
| 2560 | if (__right_) |
| 2561 | r = r && __right_->fix_forward_references(t_begin, t_end); |
| 2562 | return r; |
| 2563 | } |
| 2564 | }; |
| 2565 | |
| 2566 | class __operator_brackets |
| 2567 | : public __node |
| 2568 | { |
| 2569 | public: |
| 2570 | |
| 2571 | virtual size_t first_size() const {return sizeof("operator[]") - 1;} |
| 2572 | virtual char* first_demangled_name(char* buf) const |
| 2573 | { |
| 2574 | strncpy(buf, "operator[]", sizeof("operator[]") - 1); |
| 2575 | return buf + sizeof("operator[]") - 1; |
| 2576 | } |
| 2577 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 2578 | { |
| 2579 | const ptrdiff_t r = l - f; |
| 2580 | const ptrdiff_t n = sizeof("operator[]") - 1; |
| 2581 | if (r >= n) |
| 2582 | { |
| 2583 | *f++ = 'o'; |
| 2584 | *f++ = 'p'; |
| 2585 | *f++ = 'e'; |
| 2586 | *f++ = 'r'; |
| 2587 | *f++ = 'a'; |
| 2588 | *f++ = 't'; |
| 2589 | *f++ = 'o'; |
| 2590 | *f++ = 'r'; |
| 2591 | *f++ = '['; |
| 2592 | *f = ']'; |
| 2593 | } |
| 2594 | return n; |
| 2595 | } |
| 2596 | }; |
| 2597 | |
| 2598 | class __operator_less_equal |
| 2599 | : public __node |
| 2600 | { |
| 2601 | public: |
| 2602 | |
| 2603 | __operator_less_equal() {} |
| 2604 | __operator_less_equal(__node* op1, __node* op2) |
| 2605 | { |
| 2606 | __left_ = op1; |
| 2607 | __right_ = op2; |
| 2608 | } |
| 2609 | virtual size_t first_size() const |
| 2610 | { |
| 2611 | if (__cached_size_ == -1) |
| 2612 | { |
| 2613 | if (__left_) |
| 2614 | const_cast<long&>(__cached_size_) = __left_->size() + 8 + __right_->size(); |
| 2615 | else |
| 2616 | const_cast<long&>(__cached_size_) = sizeof("operator<=") - 1; |
| 2617 | } |
| 2618 | return __cached_size_; |
| 2619 | } |
| 2620 | virtual char* first_demangled_name(char* buf) const |
| 2621 | { |
| 2622 | if (__left_) |
| 2623 | { |
| 2624 | *buf++ = '('; |
| 2625 | buf = __left_->get_demangled_name(buf); |
| 2626 | strncpy(buf, ") <= (", 6); |
| 2627 | buf += 6; |
| 2628 | buf = __right_->get_demangled_name(buf); |
| 2629 | *buf++ = ')'; |
| 2630 | } |
| 2631 | else |
| 2632 | { |
| 2633 | strncpy(buf, "operator<=", sizeof("operator<=") - 1); |
| 2634 | buf += sizeof("operator<=") - 1; |
| 2635 | } |
| 2636 | return buf; |
| 2637 | } |
| 2638 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 2639 | { |
| 2640 | const ptrdiff_t r = l - f; |
| 2641 | if (__left_) |
| 2642 | { |
| 2643 | const ptrdiff_t n1 = 8; |
| 2644 | if (r < n1) |
| 2645 | return n1 + __left_->print(l, l) + __right_->print(l, l); |
| 2646 | ptrdiff_t sz1 = __left_->print(f+1, l); |
| 2647 | if (r < n1 + sz1) |
| 2648 | return n1 + sz1 + __right_->print(l, l); |
| 2649 | ptrdiff_t sz2 = __right_->print(f+(n1-1)+sz1, l); |
| 2650 | if (r >= n1 + sz1 + sz2) |
| 2651 | { |
| 2652 | *f = '('; |
| 2653 | f += 1 + sz1; |
| 2654 | *f++ = ')'; |
| 2655 | *f++ = ' '; |
| 2656 | *f++ = '<'; |
| 2657 | *f++ = '='; |
| 2658 | *f++ = ' '; |
| 2659 | *f = '('; |
| 2660 | f += 1 + sz2; |
| 2661 | *f = ')'; |
| 2662 | } |
| 2663 | return n1 + sz1 + sz2; |
| 2664 | } |
| 2665 | const ptrdiff_t n2 = sizeof("operator<=") - 1; |
| 2666 | if (r >= n2) |
| 2667 | { |
| 2668 | *f++ = 'o'; |
| 2669 | *f++ = 'p'; |
| 2670 | *f++ = 'e'; |
| 2671 | *f++ = 'r'; |
| 2672 | *f++ = 'a'; |
| 2673 | *f++ = 't'; |
| 2674 | *f++ = 'o'; |
| 2675 | *f++ = 'r'; |
| 2676 | *f++ = '<'; |
| 2677 | *f = '='; |
| 2678 | } |
| 2679 | return n2; |
| 2680 | } |
| 2681 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 2682 | { |
| 2683 | bool r = true; |
| 2684 | if (__left_) |
| 2685 | r = r && __left_->fix_forward_references(t_begin, t_end); |
| 2686 | if (__right_) |
| 2687 | r = r && __right_->fix_forward_references(t_begin, t_end); |
| 2688 | return r; |
| 2689 | } |
| 2690 | }; |
| 2691 | |
| 2692 | class __operator_less |
| 2693 | : public __node |
| 2694 | { |
| 2695 | public: |
| 2696 | |
| 2697 | __operator_less() {} |
| 2698 | __operator_less(__node* op1, __node* op2) |
| 2699 | { |
| 2700 | __left_ = op1; |
| 2701 | __right_ = op2; |
| 2702 | } |
| 2703 | virtual size_t first_size() const |
| 2704 | { |
| 2705 | if (__cached_size_ == -1) |
| 2706 | { |
| 2707 | if (__left_) |
| 2708 | const_cast<long&>(__cached_size_) = __left_->size() + 7 + __right_->size(); |
| 2709 | else |
| 2710 | const_cast<long&>(__cached_size_) = sizeof("operator<") - 1; |
| 2711 | } |
| 2712 | return __cached_size_; |
| 2713 | } |
| 2714 | virtual char* first_demangled_name(char* buf) const |
| 2715 | { |
| 2716 | if (__left_) |
| 2717 | { |
| 2718 | *buf++ = '('; |
| 2719 | buf = __left_->get_demangled_name(buf); |
| 2720 | strncpy(buf, ") < (", 5); |
| 2721 | buf += 5; |
| 2722 | buf = __right_->get_demangled_name(buf); |
| 2723 | *buf++ = ')'; |
| 2724 | } |
| 2725 | else |
| 2726 | { |
| 2727 | strncpy(buf, "operator<", sizeof("operator<") - 1); |
| 2728 | buf += sizeof("operator<") - 1; |
| 2729 | } |
| 2730 | return buf; |
| 2731 | } |
| 2732 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 2733 | { |
| 2734 | const ptrdiff_t r = l - f; |
| 2735 | if (__left_) |
| 2736 | { |
| 2737 | const ptrdiff_t n1 = 7; |
| 2738 | if (r < n1) |
| 2739 | return n1 + __left_->print(l, l) + __right_->print(l, l); |
| 2740 | ptrdiff_t sz1 = __left_->print(f+1, l); |
| 2741 | if (r < n1 + sz1) |
| 2742 | return n1 + sz1 + __right_->print(l, l); |
| 2743 | ptrdiff_t sz2 = __right_->print(f+(n1-1)+sz1, l); |
| 2744 | if (r >= n1 + sz1 + sz2) |
| 2745 | { |
| 2746 | *f = '('; |
| 2747 | f += 1 + sz1; |
| 2748 | *f++ = ')'; |
| 2749 | *f++ = ' '; |
| 2750 | *f++ = '<'; |
| 2751 | *f++ = ' '; |
| 2752 | *f = '('; |
| 2753 | f += 1 + sz2; |
| 2754 | *f = ')'; |
| 2755 | } |
| 2756 | return n1 + sz1 + sz2; |
| 2757 | } |
| 2758 | const ptrdiff_t n2 = sizeof("operator<") - 1; |
| 2759 | if (r >= n2) |
| 2760 | { |
| 2761 | *f++ = 'o'; |
| 2762 | *f++ = 'p'; |
| 2763 | *f++ = 'e'; |
| 2764 | *f++ = 'r'; |
| 2765 | *f++ = 'a'; |
| 2766 | *f++ = 't'; |
| 2767 | *f++ = 'o'; |
| 2768 | *f++ = 'r'; |
| 2769 | *f = '<'; |
| 2770 | } |
| 2771 | return n2; |
| 2772 | } |
| 2773 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 2774 | { |
| 2775 | bool r = true; |
| 2776 | if (__left_) |
| 2777 | r = r && __left_->fix_forward_references(t_begin, t_end); |
| 2778 | if (__right_) |
| 2779 | r = r && __right_->fix_forward_references(t_begin, t_end); |
| 2780 | return r; |
| 2781 | } |
| 2782 | }; |
| 2783 | |
| 2784 | class __operator_left_shift |
| 2785 | : public __node |
| 2786 | { |
| 2787 | public: |
| 2788 | |
| 2789 | __operator_left_shift() {} |
| 2790 | __operator_left_shift(__node* op1, __node* op2) |
| 2791 | { |
| 2792 | __left_ = op1; |
| 2793 | __right_ = op2; |
| 2794 | } |
| 2795 | virtual size_t first_size() const |
| 2796 | { |
| 2797 | if (__cached_size_ == -1) |
| 2798 | { |
| 2799 | if (__left_) |
| 2800 | const_cast<long&>(__cached_size_) = __left_->size() + 8 + __right_->size(); |
| 2801 | else |
| 2802 | const_cast<long&>(__cached_size_) = sizeof("operator<<") - 1; |
| 2803 | } |
| 2804 | return __cached_size_; |
| 2805 | } |
| 2806 | virtual char* first_demangled_name(char* buf) const |
| 2807 | { |
| 2808 | if (__left_) |
| 2809 | { |
| 2810 | *buf++ = '('; |
| 2811 | buf = __left_->get_demangled_name(buf); |
| 2812 | strncpy(buf, ") << (", 6); |
| 2813 | buf += 6; |
| 2814 | buf = __right_->get_demangled_name(buf); |
| 2815 | *buf++ = ')'; |
| 2816 | } |
| 2817 | else |
| 2818 | { |
| 2819 | strncpy(buf, "operator<<", sizeof("operator<<") - 1); |
| 2820 | buf += sizeof("operator<<") - 1; |
| 2821 | } |
| 2822 | return buf; |
| 2823 | } |
| 2824 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 2825 | { |
| 2826 | const ptrdiff_t r = l - f; |
| 2827 | if (__left_) |
| 2828 | { |
| 2829 | const ptrdiff_t n1 = 8; |
| 2830 | if (r < n1) |
| 2831 | return n1 + __left_->print(l, l) + __right_->print(l, l); |
| 2832 | ptrdiff_t sz1 = __left_->print(f+1, l); |
| 2833 | if (r < n1 + sz1) |
| 2834 | return n1 + sz1 + __right_->print(l, l); |
| 2835 | ptrdiff_t sz2 = __right_->print(f+(n1-1)+sz1, l); |
| 2836 | if (r >= n1 + sz1 + sz2) |
| 2837 | { |
| 2838 | *f = '('; |
| 2839 | f += 1 + sz1; |
| 2840 | *f++ = ')'; |
| 2841 | *f++ = ' '; |
| 2842 | *f++ = '<'; |
| 2843 | *f++ = '<'; |
| 2844 | *f++ = ' '; |
| 2845 | *f = '('; |
| 2846 | f += 1 + sz2; |
| 2847 | *f = ')'; |
| 2848 | } |
| 2849 | return n1 + sz1 + sz2; |
| 2850 | } |
| 2851 | const ptrdiff_t n2 = sizeof("operator<<") - 1; |
| 2852 | if (r >= n2) |
| 2853 | { |
| 2854 | *f++ = 'o'; |
| 2855 | *f++ = 'p'; |
| 2856 | *f++ = 'e'; |
| 2857 | *f++ = 'r'; |
| 2858 | *f++ = 'a'; |
| 2859 | *f++ = 't'; |
| 2860 | *f++ = 'o'; |
| 2861 | *f++ = 'r'; |
| 2862 | *f++ = '<'; |
| 2863 | *f = '<'; |
| 2864 | } |
| 2865 | return n2; |
| 2866 | } |
| 2867 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 2868 | { |
| 2869 | bool r = true; |
| 2870 | if (__left_) |
| 2871 | r = r && __left_->fix_forward_references(t_begin, t_end); |
| 2872 | if (__right_) |
| 2873 | r = r && __right_->fix_forward_references(t_begin, t_end); |
| 2874 | return r; |
| 2875 | } |
| 2876 | }; |
| 2877 | |
| 2878 | class __operator_left_shift_equal |
| 2879 | : public __node |
| 2880 | { |
| 2881 | public: |
| 2882 | |
| 2883 | __operator_left_shift_equal() {} |
| 2884 | __operator_left_shift_equal(__node* op1, __node* op2) |
| 2885 | { |
| 2886 | __left_ = op1; |
| 2887 | __right_ = op2; |
| 2888 | } |
| 2889 | virtual size_t first_size() const |
| 2890 | { |
| 2891 | if (__cached_size_ == -1) |
| 2892 | { |
| 2893 | if (__left_) |
| 2894 | const_cast<long&>(__cached_size_) = __left_->size() + 9 + __right_->size(); |
| 2895 | else |
| 2896 | const_cast<long&>(__cached_size_) = sizeof("operator<<=") - 1; |
| 2897 | } |
| 2898 | return __cached_size_; |
| 2899 | } |
| 2900 | virtual char* first_demangled_name(char* buf) const |
| 2901 | { |
| 2902 | if (__left_) |
| 2903 | { |
| 2904 | *buf++ = '('; |
| 2905 | buf = __left_->get_demangled_name(buf); |
| 2906 | strncpy(buf, ") <<= (", 7); |
| 2907 | buf += 7; |
| 2908 | buf = __right_->get_demangled_name(buf); |
| 2909 | *buf++ = ')'; |
| 2910 | } |
| 2911 | else |
| 2912 | { |
| 2913 | strncpy(buf, "operator<<=", sizeof("operator<<=") - 1); |
| 2914 | buf += sizeof("operator<<=") - 1; |
| 2915 | } |
| 2916 | return buf; |
| 2917 | } |
| 2918 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 2919 | { |
| 2920 | const ptrdiff_t r = l - f; |
| 2921 | if (__left_) |
| 2922 | { |
| 2923 | const ptrdiff_t n1 = 9; |
| 2924 | if (r < n1) |
| 2925 | return n1 + __left_->print(l, l) + __right_->print(l, l); |
| 2926 | ptrdiff_t sz1 = __left_->print(f+1, l); |
| 2927 | if (r < n1 + sz1) |
| 2928 | return n1 + sz1 + __right_->print(l, l); |
| 2929 | ptrdiff_t sz2 = __right_->print(f+(n1-1)+sz1, l); |
| 2930 | if (r >= n1 + sz1 + sz2) |
| 2931 | { |
| 2932 | *f = '('; |
| 2933 | f += 1 + sz1; |
| 2934 | *f++ = ')'; |
| 2935 | *f++ = ' '; |
| 2936 | *f++ = '<'; |
| 2937 | *f++ = '<'; |
| 2938 | *f++ = '='; |
| 2939 | *f++ = ' '; |
| 2940 | *f = '('; |
| 2941 | f += 1 + sz2; |
| 2942 | *f = ')'; |
| 2943 | } |
| 2944 | return n1 + sz1 + sz2; |
| 2945 | } |
| 2946 | const ptrdiff_t n2 = sizeof("operator<<=") - 1; |
| 2947 | if (r >= n2) |
| 2948 | { |
| 2949 | *f++ = 'o'; |
| 2950 | *f++ = 'p'; |
| 2951 | *f++ = 'e'; |
| 2952 | *f++ = 'r'; |
| 2953 | *f++ = 'a'; |
| 2954 | *f++ = 't'; |
| 2955 | *f++ = 'o'; |
| 2956 | *f++ = 'r'; |
| 2957 | *f++ = '<'; |
| 2958 | *f++ = '<'; |
| 2959 | *f = '='; |
| 2960 | } |
| 2961 | return n2; |
| 2962 | } |
| 2963 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 2964 | { |
| 2965 | bool r = true; |
| 2966 | if (__left_) |
| 2967 | r = r && __left_->fix_forward_references(t_begin, t_end); |
| 2968 | if (__right_) |
| 2969 | r = r && __right_->fix_forward_references(t_begin, t_end); |
| 2970 | return r; |
| 2971 | } |
| 2972 | }; |
| 2973 | |
| 2974 | class __operator_minus |
| 2975 | : public __node |
| 2976 | { |
| 2977 | public: |
| 2978 | |
| 2979 | __operator_minus() {} |
| 2980 | __operator_minus(__node* op1, __node* op2) |
| 2981 | { |
| 2982 | __left_ = op1; |
| 2983 | __right_ = op2; |
| 2984 | } |
| 2985 | virtual size_t first_size() const |
| 2986 | { |
| 2987 | if (__cached_size_ == -1) |
| 2988 | { |
| 2989 | if (__left_) |
| 2990 | const_cast<long&>(__cached_size_) = __left_->size() + 7 + __right_->size(); |
| 2991 | else |
| 2992 | const_cast<long&>(__cached_size_) = sizeof("operator-") - 1; |
| 2993 | } |
| 2994 | return __cached_size_; |
| 2995 | } |
| 2996 | virtual char* first_demangled_name(char* buf) const |
| 2997 | { |
| 2998 | if (__left_) |
| 2999 | { |
| 3000 | *buf++ = '('; |
| 3001 | buf = __left_->get_demangled_name(buf); |
| 3002 | strncpy(buf, ") - (", 5); |
| 3003 | buf += 5; |
| 3004 | buf = __right_->get_demangled_name(buf); |
| 3005 | *buf++ = ')'; |
| 3006 | } |
| 3007 | else |
| 3008 | { |
| 3009 | strncpy(buf, "operator-", sizeof("operator-") - 1); |
| 3010 | buf += sizeof("operator-") - 1; |
| 3011 | } |
| 3012 | return buf; |
| 3013 | } |
| 3014 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 3015 | { |
| 3016 | const ptrdiff_t r = l - f; |
| 3017 | if (__left_) |
| 3018 | { |
| 3019 | const ptrdiff_t n1 = 7; |
| 3020 | if (r < n1) |
| 3021 | return n1 + __left_->print(l, l) + __right_->print(l, l); |
| 3022 | ptrdiff_t sz1 = __left_->print(f+1, l); |
| 3023 | if (r < n1 + sz1) |
| 3024 | return n1 + sz1 + __right_->print(l, l); |
| 3025 | ptrdiff_t sz2 = __right_->print(f+(n1-1)+sz1, l); |
| 3026 | if (r >= n1 + sz1 + sz2) |
| 3027 | { |
| 3028 | *f = '('; |
| 3029 | f += 1 + sz1; |
| 3030 | *f++ = ')'; |
| 3031 | *f++ = ' '; |
| 3032 | *f++ = '-'; |
| 3033 | *f++ = ' '; |
| 3034 | *f = '('; |
| 3035 | f += 1 + sz2; |
| 3036 | *f = ')'; |
| 3037 | } |
| 3038 | return n1 + sz1 + sz2; |
| 3039 | } |
| 3040 | const ptrdiff_t n2 = sizeof("operator-") - 1; |
| 3041 | if (r >= n2) |
| 3042 | { |
| 3043 | *f++ = 'o'; |
| 3044 | *f++ = 'p'; |
| 3045 | *f++ = 'e'; |
| 3046 | *f++ = 'r'; |
| 3047 | *f++ = 'a'; |
| 3048 | *f++ = 't'; |
| 3049 | *f++ = 'o'; |
| 3050 | *f++ = 'r'; |
| 3051 | *f = '-'; |
| 3052 | } |
| 3053 | return n2; |
| 3054 | } |
| 3055 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 3056 | { |
| 3057 | bool r = true; |
| 3058 | if (__left_) |
| 3059 | r = r && __left_->fix_forward_references(t_begin, t_end); |
| 3060 | if (__right_) |
| 3061 | r = r && __right_->fix_forward_references(t_begin, t_end); |
| 3062 | return r; |
| 3063 | } |
| 3064 | }; |
| 3065 | |
| 3066 | class __operator_minus_equal |
| 3067 | : public __node |
| 3068 | { |
| 3069 | public: |
| 3070 | |
| 3071 | __operator_minus_equal() {} |
| 3072 | __operator_minus_equal(__node* op1, __node* op2) |
| 3073 | { |
| 3074 | __left_ = op1; |
| 3075 | __right_ = op2; |
| 3076 | } |
| 3077 | virtual size_t first_size() const |
| 3078 | { |
| 3079 | if (__cached_size_ == -1) |
| 3080 | { |
| 3081 | if (__left_) |
| 3082 | const_cast<long&>(__cached_size_) = __left_->size() + 8 + __right_->size(); |
| 3083 | else |
| 3084 | const_cast<long&>(__cached_size_) = sizeof("operator-=") - 1; |
| 3085 | } |
| 3086 | return __cached_size_; |
| 3087 | } |
| 3088 | virtual char* first_demangled_name(char* buf) const |
| 3089 | { |
| 3090 | if (__left_) |
| 3091 | { |
| 3092 | *buf++ = '('; |
| 3093 | buf = __left_->get_demangled_name(buf); |
| 3094 | strncpy(buf, ") -= (", 6); |
| 3095 | buf += 6; |
| 3096 | buf = __right_->get_demangled_name(buf); |
| 3097 | *buf++ = ')'; |
| 3098 | } |
| 3099 | else |
| 3100 | { |
| 3101 | strncpy(buf, "operator-=", sizeof("operator-=") - 1); |
| 3102 | buf += sizeof("operator-=") - 1; |
| 3103 | } |
| 3104 | return buf; |
| 3105 | } |
| 3106 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 3107 | { |
| 3108 | const ptrdiff_t r = l - f; |
| 3109 | if (__left_) |
| 3110 | { |
| 3111 | const ptrdiff_t n1 = 8; |
| 3112 | if (r < n1) |
| 3113 | return n1 + __left_->print(l, l) + __right_->print(l, l); |
| 3114 | ptrdiff_t sz1 = __left_->print(f+1, l); |
| 3115 | if (r < n1 + sz1) |
| 3116 | return n1 + sz1 + __right_->print(l, l); |
| 3117 | ptrdiff_t sz2 = __right_->print(f+(n1-1)+sz1, l); |
| 3118 | if (r >= n1 + sz1 + sz2) |
| 3119 | { |
| 3120 | *f = '('; |
| 3121 | f += 1 + sz1; |
| 3122 | *f++ = ')'; |
| 3123 | *f++ = ' '; |
| 3124 | *f++ = '-'; |
| 3125 | *f++ = '='; |
| 3126 | *f++ = ' '; |
| 3127 | *f = '('; |
| 3128 | f += 1 + sz2; |
| 3129 | *f = ')'; |
| 3130 | } |
| 3131 | return n1 + sz1 + sz2; |
| 3132 | } |
| 3133 | const ptrdiff_t n2 = sizeof("operator-=") - 1; |
| 3134 | if (r >= n2) |
| 3135 | { |
| 3136 | *f++ = 'o'; |
| 3137 | *f++ = 'p'; |
| 3138 | *f++ = 'e'; |
| 3139 | *f++ = 'r'; |
| 3140 | *f++ = 'a'; |
| 3141 | *f++ = 't'; |
| 3142 | *f++ = 'o'; |
| 3143 | *f++ = 'r'; |
| 3144 | *f++ = '-'; |
| 3145 | *f = '='; |
| 3146 | } |
| 3147 | return n2; |
| 3148 | } |
| 3149 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 3150 | { |
| 3151 | bool r = true; |
| 3152 | if (__left_) |
| 3153 | r = r && __left_->fix_forward_references(t_begin, t_end); |
| 3154 | if (__right_) |
| 3155 | r = r && __right_->fix_forward_references(t_begin, t_end); |
| 3156 | return r; |
| 3157 | } |
| 3158 | }; |
| 3159 | |
| 3160 | class __operator_times |
| 3161 | : public __node |
| 3162 | { |
| 3163 | public: |
| 3164 | |
| 3165 | __operator_times() {} |
| 3166 | __operator_times(__node* op1, __node* op2) |
| 3167 | { |
| 3168 | __left_ = op1; |
| 3169 | __right_ = op2; |
| 3170 | } |
| 3171 | virtual size_t first_size() const |
| 3172 | { |
| 3173 | if (__cached_size_ == -1) |
| 3174 | { |
| 3175 | if (__left_) |
| 3176 | const_cast<long&>(__cached_size_) = __left_->size() + 7 + __right_->size(); |
| 3177 | else |
| 3178 | const_cast<long&>(__cached_size_) = sizeof("operator*") - 1; |
| 3179 | } |
| 3180 | return __cached_size_; |
| 3181 | } |
| 3182 | virtual char* first_demangled_name(char* buf) const |
| 3183 | { |
| 3184 | if (__left_) |
| 3185 | { |
| 3186 | *buf++ = '('; |
| 3187 | buf = __left_->get_demangled_name(buf); |
| 3188 | strncpy(buf, ") * (", 5); |
| 3189 | buf += 5; |
| 3190 | buf = __right_->get_demangled_name(buf); |
| 3191 | *buf++ = ')'; |
| 3192 | } |
| 3193 | else |
| 3194 | { |
| 3195 | strncpy(buf, "operator*", sizeof("operator*") - 1); |
| 3196 | buf += sizeof("operator*") - 1; |
| 3197 | } |
| 3198 | return buf; |
| 3199 | } |
| 3200 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 3201 | { |
| 3202 | const ptrdiff_t r = l - f; |
| 3203 | if (__left_) |
| 3204 | { |
| 3205 | const ptrdiff_t n1 = 7; |
| 3206 | if (r < n1) |
| 3207 | return n1 + __left_->print(l, l) + __right_->print(l, l); |
| 3208 | ptrdiff_t sz1 = __left_->print(f+1, l); |
| 3209 | if (r < n1 + sz1) |
| 3210 | return n1 + sz1 + __right_->print(l, l); |
| 3211 | ptrdiff_t sz2 = __right_->print(f+(n1-1)+sz1, l); |
| 3212 | if (r >= n1 + sz1 + sz2) |
| 3213 | { |
| 3214 | *f = '('; |
| 3215 | f += 1 + sz1; |
| 3216 | *f++ = ')'; |
| 3217 | *f++ = ' '; |
| 3218 | *f++ = '*'; |
| 3219 | *f++ = ' '; |
| 3220 | *f = '('; |
| 3221 | f += 1 + sz2; |
| 3222 | *f = ')'; |
| 3223 | } |
| 3224 | return n1 + sz1 + sz2; |
| 3225 | } |
| 3226 | const ptrdiff_t n2 = sizeof("operator*") - 1; |
| 3227 | if (r >= n2) |
| 3228 | { |
| 3229 | *f++ = 'o'; |
| 3230 | *f++ = 'p'; |
| 3231 | *f++ = 'e'; |
| 3232 | *f++ = 'r'; |
| 3233 | *f++ = 'a'; |
| 3234 | *f++ = 't'; |
| 3235 | *f++ = 'o'; |
| 3236 | *f++ = 'r'; |
| 3237 | *f = '*'; |
| 3238 | } |
| 3239 | return n2; |
| 3240 | } |
| 3241 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 3242 | { |
| 3243 | bool r = true; |
| 3244 | if (__left_) |
| 3245 | r = r && __left_->fix_forward_references(t_begin, t_end); |
| 3246 | if (__right_) |
| 3247 | r = r && __right_->fix_forward_references(t_begin, t_end); |
| 3248 | return r; |
| 3249 | } |
| 3250 | }; |
| 3251 | |
| 3252 | class __operator_times_equal |
| 3253 | : public __node |
| 3254 | { |
| 3255 | public: |
| 3256 | |
| 3257 | __operator_times_equal() {} |
| 3258 | __operator_times_equal(__node* op1, __node* op2) |
| 3259 | { |
| 3260 | __left_ = op1; |
| 3261 | __right_ = op2; |
| 3262 | } |
| 3263 | virtual size_t first_size() const |
| 3264 | { |
| 3265 | if (__cached_size_ == -1) |
| 3266 | { |
| 3267 | if (__left_) |
| 3268 | const_cast<long&>(__cached_size_) = __left_->size() + 8 + __right_->size(); |
| 3269 | else |
| 3270 | const_cast<long&>(__cached_size_) = sizeof("operator*=") - 1; |
| 3271 | } |
| 3272 | return __cached_size_; |
| 3273 | } |
| 3274 | virtual char* first_demangled_name(char* buf) const |
| 3275 | { |
| 3276 | if (__left_) |
| 3277 | { |
| 3278 | *buf++ = '('; |
| 3279 | buf = __left_->get_demangled_name(buf); |
| 3280 | strncpy(buf, ") *= (", 6); |
| 3281 | buf += 6; |
| 3282 | buf = __right_->get_demangled_name(buf); |
| 3283 | *buf++ = ')'; |
| 3284 | } |
| 3285 | else |
| 3286 | { |
| 3287 | strncpy(buf, "operator*=", sizeof("operator*=") - 1); |
| 3288 | buf += sizeof("operator*=") - 1; |
| 3289 | } |
| 3290 | return buf; |
| 3291 | } |
| 3292 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 3293 | { |
| 3294 | const ptrdiff_t r = l - f; |
| 3295 | if (__left_) |
| 3296 | { |
| 3297 | const ptrdiff_t n1 = 8; |
| 3298 | if (r < n1) |
| 3299 | return n1 + __left_->print(l, l) + __right_->print(l, l); |
| 3300 | ptrdiff_t sz1 = __left_->print(f+1, l); |
| 3301 | if (r < n1 + sz1) |
| 3302 | return n1 + sz1 + __right_->print(l, l); |
| 3303 | ptrdiff_t sz2 = __right_->print(f+(n1-1)+sz1, l); |
| 3304 | if (r >= n1 + sz1 + sz2) |
| 3305 | { |
| 3306 | *f = '('; |
| 3307 | f += 1 + sz1; |
| 3308 | *f++ = ')'; |
| 3309 | *f++ = ' '; |
| 3310 | *f++ = '*'; |
| 3311 | *f++ = '='; |
| 3312 | *f++ = ' '; |
| 3313 | *f = '('; |
| 3314 | f += 1 + sz2; |
| 3315 | *f = ')'; |
| 3316 | } |
| 3317 | return n1 + sz1 + sz2; |
| 3318 | } |
| 3319 | const ptrdiff_t n2 = sizeof("operator*=") - 1; |
| 3320 | if (r >= n2) |
| 3321 | { |
| 3322 | *f++ = 'o'; |
| 3323 | *f++ = 'p'; |
| 3324 | *f++ = 'e'; |
| 3325 | *f++ = 'r'; |
| 3326 | *f++ = 'a'; |
| 3327 | *f++ = 't'; |
| 3328 | *f++ = 'o'; |
| 3329 | *f++ = 'r'; |
| 3330 | *f++ = '*'; |
| 3331 | *f = '='; |
| 3332 | } |
| 3333 | return n2; |
| 3334 | } |
| 3335 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 3336 | { |
| 3337 | bool r = true; |
| 3338 | if (__left_) |
| 3339 | r = r && __left_->fix_forward_references(t_begin, t_end); |
| 3340 | if (__right_) |
| 3341 | r = r && __right_->fix_forward_references(t_begin, t_end); |
| 3342 | return r; |
| 3343 | } |
| 3344 | }; |
| 3345 | |
| 3346 | class __operator_decrement |
| 3347 | : public __node |
| 3348 | { |
| 3349 | public: |
| 3350 | |
| 3351 | __operator_decrement() {} |
| 3352 | explicit __operator_decrement(bool prefix, __node* op) |
| 3353 | { |
| 3354 | __size_ = prefix; |
| 3355 | __left_ = op; |
| 3356 | } |
| 3357 | virtual size_t first_size() const |
| 3358 | { |
| 3359 | if (__cached_size_ == -1) |
| 3360 | { |
| 3361 | if (__left_) |
| 3362 | const_cast<long&>(__cached_size_) = 4+__left_->size(); |
| 3363 | else |
| 3364 | const_cast<long&>(__cached_size_) = sizeof("operator--") - 1; |
| 3365 | } |
| 3366 | return __cached_size_; |
| 3367 | } |
| 3368 | virtual char* first_demangled_name(char* buf) const |
| 3369 | { |
| 3370 | if (__left_) |
| 3371 | { |
| 3372 | if (__size_) |
| 3373 | { |
| 3374 | *buf++ = '-'; |
| 3375 | *buf++ = '-'; |
| 3376 | *buf++ = '('; |
| 3377 | } |
| 3378 | else |
| 3379 | *buf++ = '('; |
| 3380 | buf = __left_->get_demangled_name(buf); |
| 3381 | if (__size_) |
| 3382 | *buf++ = ')'; |
| 3383 | else |
| 3384 | { |
| 3385 | *buf++ = ')'; |
| 3386 | *buf++ = '-'; |
| 3387 | *buf++ = '-'; |
| 3388 | } |
| 3389 | } |
| 3390 | else |
| 3391 | { |
| 3392 | strncpy(buf, "operator--", sizeof("operator--") - 1); |
| 3393 | buf += sizeof("operator--") - 1; |
| 3394 | } |
| 3395 | return buf; |
| 3396 | } |
| 3397 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 3398 | { |
| 3399 | const ptrdiff_t r = l - f; |
| 3400 | if (__left_) |
| 3401 | { |
| 3402 | const ptrdiff_t n1 = 4; |
| 3403 | if (r < n1) |
| 3404 | return n1 + __left_->print(l, l); |
| 3405 | ptrdiff_t sz1 = __left_->print(f + (__size_ ? 3 : 1), l); |
| 3406 | if (r >= n1 + sz1) |
| 3407 | { |
| 3408 | if (__size_) |
| 3409 | { |
| 3410 | *f++ = '-'; |
| 3411 | *f++ = '-'; |
| 3412 | *f = '('; |
| 3413 | f += 1+sz1; |
| 3414 | *f = ')'; |
| 3415 | } |
| 3416 | else |
| 3417 | { |
| 3418 | *f = '('; |
| 3419 | f += 1+sz1; |
| 3420 | *f++ = ')'; |
| 3421 | *f++ = '-'; |
| 3422 | *f = '-'; |
| 3423 | } |
| 3424 | } |
| 3425 | return n1 + sz1; |
| 3426 | } |
| 3427 | const ptrdiff_t n2 = sizeof("operator--") - 1; |
| 3428 | if (r >= n2) |
| 3429 | { |
| 3430 | *f++ = 'o'; |
| 3431 | *f++ = 'p'; |
| 3432 | *f++ = 'e'; |
| 3433 | *f++ = 'r'; |
| 3434 | *f++ = 'a'; |
| 3435 | *f++ = 't'; |
| 3436 | *f++ = 'o'; |
| 3437 | *f++ = 'r'; |
| 3438 | *f++ = '-'; |
| 3439 | *f = '-'; |
| 3440 | } |
| 3441 | return n2; |
| 3442 | } |
| 3443 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 3444 | { |
| 3445 | if (__left_) |
| 3446 | return __left_->fix_forward_references(t_begin, t_end); |
| 3447 | return true; |
| 3448 | } |
| 3449 | }; |
| 3450 | |
| 3451 | class __operator_not_equal |
| 3452 | : public __node |
| 3453 | { |
| 3454 | public: |
| 3455 | |
| 3456 | __operator_not_equal() {} |
| 3457 | __operator_not_equal(__node* op1, __node* op2) |
| 3458 | { |
| 3459 | __left_ = op1; |
| 3460 | __right_ = op2; |
| 3461 | } |
| 3462 | virtual size_t first_size() const |
| 3463 | { |
| 3464 | if (__cached_size_ == -1) |
| 3465 | { |
| 3466 | if (__left_) |
| 3467 | const_cast<long&>(__cached_size_) = __left_->size() + 8 + __right_->size(); |
| 3468 | else |
| 3469 | const_cast<long&>(__cached_size_) = sizeof("operator!=") - 1; |
| 3470 | } |
| 3471 | return __cached_size_; |
| 3472 | } |
| 3473 | virtual char* first_demangled_name(char* buf) const |
| 3474 | { |
| 3475 | if (__left_) |
| 3476 | { |
| 3477 | *buf++ = '('; |
| 3478 | buf = __left_->get_demangled_name(buf); |
| 3479 | strncpy(buf, ") != (", 6); |
| 3480 | buf += 6; |
| 3481 | buf = __right_->get_demangled_name(buf); |
| 3482 | *buf++ = ')'; |
| 3483 | } |
| 3484 | else |
| 3485 | { |
| 3486 | strncpy(buf, "operator!=", sizeof("operator!=") - 1); |
| 3487 | buf += sizeof("operator!=") - 1; |
| 3488 | } |
| 3489 | return buf; |
| 3490 | } |
| 3491 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 3492 | { |
| 3493 | const ptrdiff_t r = l - f; |
| 3494 | if (__left_) |
| 3495 | { |
| 3496 | const ptrdiff_t n1 = 8; |
| 3497 | if (r < n1) |
| 3498 | return n1 + __left_->print(l, l) + __right_->print(l, l); |
| 3499 | ptrdiff_t sz1 = __left_->print(f+1, l); |
| 3500 | if (r < n1 + sz1) |
| 3501 | return n1 + sz1 + __right_->print(l, l); |
| 3502 | ptrdiff_t sz2 = __right_->print(f+(n1-1)+sz1, l); |
| 3503 | if (r >= n1 + sz1 + sz2) |
| 3504 | { |
| 3505 | *f = '('; |
| 3506 | f += 1 + sz1; |
| 3507 | *f++ = ')'; |
| 3508 | *f++ = ' '; |
| 3509 | *f++ = '!'; |
| 3510 | *f++ = '='; |
| 3511 | *f++ = ' '; |
| 3512 | *f = '('; |
| 3513 | f += 1 + sz2; |
| 3514 | *f = ')'; |
| 3515 | } |
| 3516 | return n1 + sz1 + sz2; |
| 3517 | } |
| 3518 | const ptrdiff_t n2 = sizeof("operator!=") - 1; |
| 3519 | if (r >= n2) |
| 3520 | { |
| 3521 | *f++ = 'o'; |
| 3522 | *f++ = 'p'; |
| 3523 | *f++ = 'e'; |
| 3524 | *f++ = 'r'; |
| 3525 | *f++ = 'a'; |
| 3526 | *f++ = 't'; |
| 3527 | *f++ = 'o'; |
| 3528 | *f++ = 'r'; |
| 3529 | *f++ = '!'; |
| 3530 | *f = '='; |
| 3531 | } |
| 3532 | return n2; |
| 3533 | } |
| 3534 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 3535 | { |
| 3536 | bool r = true; |
| 3537 | if (__left_) |
| 3538 | r = r && __left_->fix_forward_references(t_begin, t_end); |
| 3539 | if (__right_) |
| 3540 | r = r && __right_->fix_forward_references(t_begin, t_end); |
| 3541 | return r; |
| 3542 | } |
| 3543 | }; |
| 3544 | |
| 3545 | class __operator_negate |
| 3546 | : public __node |
| 3547 | { |
| 3548 | public: |
| 3549 | |
| 3550 | __operator_negate() {} |
| 3551 | explicit __operator_negate(__node* op) |
| 3552 | { |
| 3553 | __left_ = op; |
| 3554 | } |
| 3555 | virtual size_t first_size() const |
| 3556 | { |
| 3557 | if (__cached_size_ == -1) |
| 3558 | { |
| 3559 | if (__left_) |
| 3560 | const_cast<long&>(__cached_size_) = 3+__left_->size(); |
| 3561 | else |
| 3562 | const_cast<long&>(__cached_size_) = sizeof("operator-") - 1; |
| 3563 | } |
| 3564 | return __cached_size_; |
| 3565 | } |
| 3566 | virtual char* first_demangled_name(char* buf) const |
| 3567 | { |
| 3568 | if (__left_) |
| 3569 | { |
| 3570 | *buf++ = '-'; |
| 3571 | *buf++ = '('; |
| 3572 | buf = __left_->get_demangled_name(buf); |
| 3573 | *buf++ = ')'; |
| 3574 | } |
| 3575 | else |
| 3576 | { |
| 3577 | strncpy(buf, "operator-", sizeof("operator-") - 1); |
| 3578 | buf += sizeof("operator-") - 1; |
| 3579 | } |
| 3580 | return buf; |
| 3581 | } |
| 3582 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 3583 | { |
| 3584 | const ptrdiff_t r = l - f; |
| 3585 | if (__left_) |
| 3586 | { |
| 3587 | const ptrdiff_t n1 = 3; |
| 3588 | if (r < n1) |
| 3589 | return n1 + __left_->print(l, l); |
| 3590 | ptrdiff_t sz1 = __left_->print(f+2, l); |
| 3591 | if (r >= n1 + sz1) |
| 3592 | { |
| 3593 | *f++ = '-'; |
| 3594 | *f = '('; |
| 3595 | f += 1 + sz1; |
| 3596 | *f = ')'; |
| 3597 | } |
| 3598 | return n1 + sz1; |
| 3599 | } |
| 3600 | const ptrdiff_t n2 = sizeof("operator-") - 1; |
| 3601 | if (r >= n2) |
| 3602 | { |
| 3603 | *f++ = 'o'; |
| 3604 | *f++ = 'p'; |
| 3605 | *f++ = 'e'; |
| 3606 | *f++ = 'r'; |
| 3607 | *f++ = 'a'; |
| 3608 | *f++ = 't'; |
| 3609 | *f++ = 'o'; |
| 3610 | *f++ = 'r'; |
| 3611 | *f = '-'; |
| 3612 | } |
| 3613 | return n2; |
| 3614 | } |
| 3615 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 3616 | { |
| 3617 | if (__left_) |
| 3618 | return __left_->fix_forward_references(t_begin, t_end); |
| 3619 | return true; |
| 3620 | } |
| 3621 | }; |
| 3622 | |
| 3623 | class __operator_logical_not |
| 3624 | : public __node |
| 3625 | { |
| 3626 | public: |
| 3627 | |
| 3628 | __operator_logical_not() {} |
| 3629 | explicit __operator_logical_not(__node* op) |
| 3630 | { |
| 3631 | __left_ = op; |
| 3632 | } |
| 3633 | virtual size_t first_size() const |
| 3634 | { |
| 3635 | if (__cached_size_ == -1) |
| 3636 | { |
| 3637 | if (__left_) |
| 3638 | const_cast<long&>(__cached_size_) = 3+__left_->size(); |
| 3639 | else |
| 3640 | const_cast<long&>(__cached_size_) = sizeof("operator!") - 1; |
| 3641 | } |
| 3642 | return __cached_size_; |
| 3643 | } |
| 3644 | virtual char* first_demangled_name(char* buf) const |
| 3645 | { |
| 3646 | if (__left_) |
| 3647 | { |
| 3648 | *buf++ = '!'; |
| 3649 | *buf++ = '('; |
| 3650 | buf = __left_->get_demangled_name(buf); |
| 3651 | *buf++ = ')'; |
| 3652 | } |
| 3653 | else |
| 3654 | { |
| 3655 | strncpy(buf, "operator!", sizeof("operator!") - 1); |
| 3656 | buf += sizeof("operator!") - 1; |
| 3657 | } |
| 3658 | return buf; |
| 3659 | } |
| 3660 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 3661 | { |
| 3662 | const ptrdiff_t r = l - f; |
| 3663 | if (__left_) |
| 3664 | { |
| 3665 | const ptrdiff_t n1 = 3; |
| 3666 | if (r < n1) |
| 3667 | return n1 + __left_->print(l, l); |
| 3668 | ptrdiff_t sz1 = __left_->print(f+2, l); |
| 3669 | if (r >= n1 + sz1) |
| 3670 | { |
| 3671 | *f++ = '!'; |
| 3672 | *f = '('; |
| 3673 | f += 1 + sz1; |
| 3674 | *f = ')'; |
| 3675 | } |
| 3676 | return n1 + sz1; |
| 3677 | } |
| 3678 | const ptrdiff_t n2 = sizeof("operator!") - 1; |
| 3679 | if (r >= n2) |
| 3680 | { |
| 3681 | *f++ = 'o'; |
| 3682 | *f++ = 'p'; |
| 3683 | *f++ = 'e'; |
| 3684 | *f++ = 'r'; |
| 3685 | *f++ = 'a'; |
| 3686 | *f++ = 't'; |
| 3687 | *f++ = 'o'; |
| 3688 | *f++ = 'r'; |
| 3689 | *f = '!'; |
| 3690 | } |
| 3691 | return n2; |
| 3692 | } |
| 3693 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 3694 | { |
| 3695 | if (__left_) |
| 3696 | return __left_->fix_forward_references(t_begin, t_end); |
| 3697 | return true; |
| 3698 | } |
| 3699 | }; |
| 3700 | |
| 3701 | class __operator_logical_or |
| 3702 | : public __node |
| 3703 | { |
| 3704 | public: |
| 3705 | |
| 3706 | __operator_logical_or() {} |
| 3707 | __operator_logical_or(__node* op1, __node* op2) |
| 3708 | { |
| 3709 | __left_ = op1; |
| 3710 | __right_ = op2; |
| 3711 | } |
| 3712 | virtual size_t first_size() const |
| 3713 | { |
| 3714 | if (__cached_size_ == -1) |
| 3715 | { |
| 3716 | if (__left_) |
| 3717 | const_cast<long&>(__cached_size_) = __left_->size() + 8 + __right_->size(); |
| 3718 | else |
| 3719 | const_cast<long&>(__cached_size_) = sizeof("operator||") - 1; |
| 3720 | } |
| 3721 | return __cached_size_; |
| 3722 | } |
| 3723 | virtual char* first_demangled_name(char* buf) const |
| 3724 | { |
| 3725 | if (__left_) |
| 3726 | { |
| 3727 | *buf++ = '('; |
| 3728 | buf = __left_->get_demangled_name(buf); |
| 3729 | strncpy(buf, ") || (", 6); |
| 3730 | buf += 6; |
| 3731 | buf = __right_->get_demangled_name(buf); |
| 3732 | *buf++ = ')'; |
| 3733 | } |
| 3734 | else |
| 3735 | { |
| 3736 | strncpy(buf, "operator||", sizeof("operator||") - 1); |
| 3737 | buf += sizeof("operator||") - 1; |
| 3738 | } |
| 3739 | return buf; |
| 3740 | } |
| 3741 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 3742 | { |
| 3743 | const ptrdiff_t r = l - f; |
| 3744 | if (__left_) |
| 3745 | { |
| 3746 | const ptrdiff_t n1 = 8; |
| 3747 | if (r < n1) |
| 3748 | return n1 + __left_->print(l, l) + __right_->print(l, l); |
| 3749 | ptrdiff_t sz1 = __left_->print(f+1, l); |
| 3750 | if (r < n1 + sz1) |
| 3751 | return n1 + sz1 + __right_->print(l, l); |
| 3752 | ptrdiff_t sz2 = __right_->print(f+(n1-1)+sz1, l); |
| 3753 | if (r >= n1 + sz1 + sz2) |
| 3754 | { |
| 3755 | *f = '('; |
| 3756 | f += 1 + sz1; |
| 3757 | *f++ = ')'; |
| 3758 | *f++ = ' '; |
| 3759 | *f++ = '|'; |
| 3760 | *f++ = '|'; |
| 3761 | *f++ = ' '; |
| 3762 | *f = '('; |
| 3763 | f += 1 + sz2; |
| 3764 | *f = ')'; |
| 3765 | } |
| 3766 | return n1 + sz1 + sz2; |
| 3767 | } |
| 3768 | const ptrdiff_t n2 = sizeof("operator||") - 1; |
| 3769 | if (r >= n2) |
| 3770 | { |
| 3771 | *f++ = 'o'; |
| 3772 | *f++ = 'p'; |
| 3773 | *f++ = 'e'; |
| 3774 | *f++ = 'r'; |
| 3775 | *f++ = 'a'; |
| 3776 | *f++ = 't'; |
| 3777 | *f++ = 'o'; |
| 3778 | *f++ = 'r'; |
| 3779 | *f++ = '|'; |
| 3780 | *f = '|'; |
| 3781 | } |
| 3782 | return n2; |
| 3783 | } |
| 3784 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 3785 | { |
| 3786 | bool r = true; |
| 3787 | if (__left_) |
| 3788 | r = r && __left_->fix_forward_references(t_begin, t_end); |
| 3789 | if (__right_) |
| 3790 | r = r && __right_->fix_forward_references(t_begin, t_end); |
| 3791 | return r; |
| 3792 | } |
| 3793 | }; |
| 3794 | |
| 3795 | class __operator_bit_or |
| 3796 | : public __node |
| 3797 | { |
| 3798 | public: |
| 3799 | |
| 3800 | __operator_bit_or() {} |
| 3801 | __operator_bit_or(__node* op1, __node* op2) |
| 3802 | { |
| 3803 | __left_ = op1; |
| 3804 | __right_ = op2; |
| 3805 | } |
| 3806 | virtual size_t first_size() const |
| 3807 | { |
| 3808 | if (__cached_size_ == -1) |
| 3809 | { |
| 3810 | if (__left_) |
| 3811 | const_cast<long&>(__cached_size_) = __left_->size() + 7 + __right_->size(); |
| 3812 | else |
| 3813 | const_cast<long&>(__cached_size_) = sizeof("operator|") - 1; |
| 3814 | } |
| 3815 | return __cached_size_; |
| 3816 | } |
| 3817 | virtual char* first_demangled_name(char* buf) const |
| 3818 | { |
| 3819 | if (__left_) |
| 3820 | { |
| 3821 | *buf++ = '('; |
| 3822 | buf = __left_->get_demangled_name(buf); |
| 3823 | strncpy(buf, ") | (", 5); |
| 3824 | buf += 5; |
| 3825 | buf = __right_->get_demangled_name(buf); |
| 3826 | *buf++ = ')'; |
| 3827 | } |
| 3828 | else |
| 3829 | { |
| 3830 | strncpy(buf, "operator|", sizeof("operator|") - 1); |
| 3831 | buf += sizeof("operator|") - 1; |
| 3832 | } |
| 3833 | return buf; |
| 3834 | } |
| 3835 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 3836 | { |
| 3837 | const ptrdiff_t r = l - f; |
| 3838 | if (__left_) |
| 3839 | { |
| 3840 | const ptrdiff_t n1 = 7; |
| 3841 | if (r < n1) |
| 3842 | return n1 + __left_->print(l, l) + __right_->print(l, l); |
| 3843 | ptrdiff_t sz1 = __left_->print(f+1, l); |
| 3844 | if (r < n1 + sz1) |
| 3845 | return n1 + sz1 + __right_->print(l, l); |
| 3846 | ptrdiff_t sz2 = __right_->print(f+(n1-1)+sz1, l); |
| 3847 | if (r >= n1 + sz1 + sz2) |
| 3848 | { |
| 3849 | *f = '('; |
| 3850 | f += 1 + sz1; |
| 3851 | *f++ = ')'; |
| 3852 | *f++ = ' '; |
| 3853 | *f++ = '|'; |
| 3854 | *f++ = ' '; |
| 3855 | *f = '('; |
| 3856 | f += 1 + sz2; |
| 3857 | *f = ')'; |
| 3858 | } |
| 3859 | return n1 + sz1 + sz2; |
| 3860 | } |
| 3861 | const ptrdiff_t n2 = sizeof("operator|") - 1; |
| 3862 | if (r >= n2) |
| 3863 | { |
| 3864 | *f++ = 'o'; |
| 3865 | *f++ = 'p'; |
| 3866 | *f++ = 'e'; |
| 3867 | *f++ = 'r'; |
| 3868 | *f++ = 'a'; |
| 3869 | *f++ = 't'; |
| 3870 | *f++ = 'o'; |
| 3871 | *f++ = 'r'; |
| 3872 | *f = '|'; |
| 3873 | } |
| 3874 | return n2; |
| 3875 | } |
| 3876 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 3877 | { |
| 3878 | bool r = true; |
| 3879 | if (__left_) |
| 3880 | r = r && __left_->fix_forward_references(t_begin, t_end); |
| 3881 | if (__right_) |
| 3882 | r = r && __right_->fix_forward_references(t_begin, t_end); |
| 3883 | return r; |
| 3884 | } |
| 3885 | }; |
| 3886 | |
| 3887 | class __operator_or_equal |
| 3888 | : public __node |
| 3889 | { |
| 3890 | public: |
| 3891 | |
| 3892 | __operator_or_equal() {} |
| 3893 | __operator_or_equal(__node* op1, __node* op2) |
| 3894 | { |
| 3895 | __left_ = op1; |
| 3896 | __right_ = op2; |
| 3897 | } |
| 3898 | virtual size_t first_size() const |
| 3899 | { |
| 3900 | if (__cached_size_ == -1) |
| 3901 | { |
| 3902 | if (__left_) |
| 3903 | const_cast<long&>(__cached_size_) = __left_->size() + 8 + __right_->size(); |
| 3904 | else |
| 3905 | const_cast<long&>(__cached_size_) = sizeof("operator|=") - 1; |
| 3906 | } |
| 3907 | return __cached_size_; |
| 3908 | } |
| 3909 | virtual char* first_demangled_name(char* buf) const |
| 3910 | { |
| 3911 | if (__left_) |
| 3912 | { |
| 3913 | *buf++ = '('; |
| 3914 | buf = __left_->get_demangled_name(buf); |
| 3915 | strncpy(buf, ") |= (", 6); |
| 3916 | buf += 6; |
| 3917 | buf = __right_->get_demangled_name(buf); |
| 3918 | *buf++ = ')'; |
| 3919 | } |
| 3920 | else |
| 3921 | { |
| 3922 | strncpy(buf, "operator|=", sizeof("operator|=") - 1); |
| 3923 | buf += sizeof("operator|=") - 1; |
| 3924 | } |
| 3925 | return buf; |
| 3926 | } |
| 3927 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 3928 | { |
| 3929 | const ptrdiff_t r = l - f; |
| 3930 | if (__left_) |
| 3931 | { |
| 3932 | const ptrdiff_t n1 = 8; |
| 3933 | if (r < n1) |
| 3934 | return n1 + __left_->print(l, l) + __right_->print(l, l); |
| 3935 | ptrdiff_t sz1 = __left_->print(f+1, l); |
| 3936 | if (r < n1 + sz1) |
| 3937 | return n1 + sz1 + __right_->print(l, l); |
| 3938 | ptrdiff_t sz2 = __right_->print(f+(n1-1)+sz1, l); |
| 3939 | if (r >= n1 + sz1 + sz2) |
| 3940 | { |
| 3941 | *f = '('; |
| 3942 | f += 1 + sz1; |
| 3943 | *f++ = ')'; |
| 3944 | *f++ = ' '; |
| 3945 | *f++ = '|'; |
| 3946 | *f++ = '='; |
| 3947 | *f++ = ' '; |
| 3948 | *f = '('; |
| 3949 | f += 1 + sz2; |
| 3950 | *f = ')'; |
| 3951 | } |
| 3952 | return n1 + sz1 + sz2; |
| 3953 | } |
| 3954 | const ptrdiff_t n2 = sizeof("operator|=") - 1; |
| 3955 | if (r >= n2) |
| 3956 | { |
| 3957 | *f++ = 'o'; |
| 3958 | *f++ = 'p'; |
| 3959 | *f++ = 'e'; |
| 3960 | *f++ = 'r'; |
| 3961 | *f++ = 'a'; |
| 3962 | *f++ = 't'; |
| 3963 | *f++ = 'o'; |
| 3964 | *f++ = 'r'; |
| 3965 | *f++ = '|'; |
| 3966 | *f = '='; |
| 3967 | } |
| 3968 | return n2; |
| 3969 | } |
| 3970 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 3971 | { |
| 3972 | bool r = true; |
| 3973 | if (__left_) |
| 3974 | r = r && __left_->fix_forward_references(t_begin, t_end); |
| 3975 | if (__right_) |
| 3976 | r = r && __right_->fix_forward_references(t_begin, t_end); |
| 3977 | return r; |
| 3978 | } |
| 3979 | }; |
| 3980 | |
| 3981 | class __operator_pointer_to_member |
| 3982 | : public __node |
| 3983 | { |
| 3984 | public: |
| 3985 | |
| 3986 | __operator_pointer_to_member() {} |
| 3987 | __operator_pointer_to_member(__node* op1, __node* op2) |
| 3988 | { |
| 3989 | __left_ = op1; |
| 3990 | __right_ = op2; |
| 3991 | } |
| 3992 | virtual size_t first_size() const |
| 3993 | { |
| 3994 | if (__cached_size_ == -1) |
| 3995 | { |
| 3996 | if (__left_) |
| 3997 | const_cast<long&>(__cached_size_) = __left_->size() + 9 + __right_->size(); |
| 3998 | else |
| 3999 | const_cast<long&>(__cached_size_) = sizeof("operator->*") - 1; |
| 4000 | } |
| 4001 | return __cached_size_; |
| 4002 | } |
| 4003 | virtual char* first_demangled_name(char* buf) const |
| 4004 | { |
| 4005 | if (__left_) |
| 4006 | { |
| 4007 | *buf++ = '('; |
| 4008 | buf = __left_->get_demangled_name(buf); |
| 4009 | strncpy(buf, ") ->* (", 7); |
| 4010 | buf += 7; |
| 4011 | buf = __right_->get_demangled_name(buf); |
| 4012 | *buf++ = ')'; |
| 4013 | } |
| 4014 | else |
| 4015 | { |
| 4016 | strncpy(buf, "operator->*", sizeof("operator->*") - 1); |
| 4017 | buf += sizeof("operator->*") - 1; |
| 4018 | } |
| 4019 | return buf; |
| 4020 | } |
| 4021 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 4022 | { |
| 4023 | const ptrdiff_t r = l - f; |
| 4024 | if (__left_) |
| 4025 | { |
| 4026 | const ptrdiff_t n1 = 9; |
| 4027 | if (r < n1) |
| 4028 | return n1 + __left_->print(l, l) + __right_->print(l, l); |
| 4029 | ptrdiff_t sz1 = __left_->print(f+1, l); |
| 4030 | if (r < n1 + sz1) |
| 4031 | return n1 + sz1 + __right_->print(l, l); |
| 4032 | ptrdiff_t sz2 = __right_->print(f+(n1-1)+sz1, l); |
| 4033 | if (r >= n1 + sz1 + sz2) |
| 4034 | { |
| 4035 | *f = '('; |
| 4036 | f += 1 + sz1; |
| 4037 | *f++ = ')'; |
| 4038 | *f++ = ' '; |
| 4039 | *f++ = '-'; |
| 4040 | *f++ = '>'; |
| 4041 | *f++ = '*'; |
| 4042 | *f++ = ' '; |
| 4043 | *f = '('; |
| 4044 | f += 1 + sz2; |
| 4045 | *f = ')'; |
| 4046 | } |
| 4047 | return n1 + sz1 + sz2; |
| 4048 | } |
| 4049 | const ptrdiff_t n2 = sizeof("operator->*") - 1; |
| 4050 | if (r >= n2) |
| 4051 | { |
| 4052 | *f++ = 'o'; |
| 4053 | *f++ = 'p'; |
| 4054 | *f++ = 'e'; |
| 4055 | *f++ = 'r'; |
| 4056 | *f++ = 'a'; |
| 4057 | *f++ = 't'; |
| 4058 | *f++ = 'o'; |
| 4059 | *f++ = 'r'; |
| 4060 | *f++ = '-'; |
| 4061 | *f++ = '>'; |
| 4062 | *f = '*'; |
| 4063 | } |
| 4064 | return n2; |
| 4065 | } |
| 4066 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 4067 | { |
| 4068 | bool r = true; |
| 4069 | if (__left_) |
| 4070 | r = r && __left_->fix_forward_references(t_begin, t_end); |
| 4071 | if (__right_) |
| 4072 | r = r && __right_->fix_forward_references(t_begin, t_end); |
| 4073 | return r; |
| 4074 | } |
| 4075 | }; |
| 4076 | |
| 4077 | class __operator_plus |
| 4078 | : public __node |
| 4079 | { |
| 4080 | public: |
| 4081 | |
| 4082 | __operator_plus() {} |
| 4083 | __operator_plus(__node* op1, __node* op2) |
| 4084 | { |
| 4085 | __left_ = op1; |
| 4086 | __right_ = op2; |
| 4087 | } |
| 4088 | virtual size_t first_size() const |
| 4089 | { |
| 4090 | if (__cached_size_ == -1) |
| 4091 | { |
| 4092 | if (__left_) |
| 4093 | const_cast<long&>(__cached_size_) = __left_->size() + 7 + __right_->size(); |
| 4094 | else |
| 4095 | const_cast<long&>(__cached_size_) = sizeof("operator+") - 1; |
| 4096 | } |
| 4097 | return __cached_size_; |
| 4098 | } |
| 4099 | virtual char* first_demangled_name(char* buf) const |
| 4100 | { |
| 4101 | if (__left_) |
| 4102 | { |
| 4103 | *buf++ = '('; |
| 4104 | buf = __left_->get_demangled_name(buf); |
| 4105 | strncpy(buf, ") + (", 5); |
| 4106 | buf += 5; |
| 4107 | buf = __right_->get_demangled_name(buf); |
| 4108 | *buf++ = ')'; |
| 4109 | } |
| 4110 | else |
| 4111 | { |
| 4112 | strncpy(buf, "operator+", sizeof("operator+") - 1); |
| 4113 | buf += sizeof("operator+") - 1; |
| 4114 | } |
| 4115 | return buf; |
| 4116 | } |
| 4117 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 4118 | { |
| 4119 | const ptrdiff_t r = l - f; |
| 4120 | if (__left_) |
| 4121 | { |
| 4122 | const ptrdiff_t n1 = 7; |
| 4123 | if (r < n1) |
| 4124 | return n1 + __left_->print(l, l) + __right_->print(l, l); |
| 4125 | ptrdiff_t sz1 = __left_->print(f+1, l); |
| 4126 | if (r < n1 + sz1) |
| 4127 | return n1 + sz1 + __right_->print(l, l); |
| 4128 | ptrdiff_t sz2 = __right_->print(f+(n1-1)+sz1, l); |
| 4129 | if (r >= n1 + sz1 + sz2) |
| 4130 | { |
| 4131 | *f = '('; |
| 4132 | f += 1 + sz1; |
| 4133 | *f++ = ')'; |
| 4134 | *f++ = ' '; |
| 4135 | *f++ = '+'; |
| 4136 | *f++ = ' '; |
| 4137 | *f = '('; |
| 4138 | f += 1 + sz2; |
| 4139 | *f = ')'; |
| 4140 | } |
| 4141 | return n1 + sz1 + sz2; |
| 4142 | } |
| 4143 | const ptrdiff_t n2 = sizeof("operator+") - 1; |
| 4144 | if (r >= n2) |
| 4145 | { |
| 4146 | *f++ = 'o'; |
| 4147 | *f++ = 'p'; |
| 4148 | *f++ = 'e'; |
| 4149 | *f++ = 'r'; |
| 4150 | *f++ = 'a'; |
| 4151 | *f++ = 't'; |
| 4152 | *f++ = 'o'; |
| 4153 | *f++ = 'r'; |
| 4154 | *f = '+'; |
| 4155 | } |
| 4156 | return n2; |
| 4157 | } |
| 4158 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 4159 | { |
| 4160 | bool r = true; |
| 4161 | if (__left_) |
| 4162 | r = r && __left_->fix_forward_references(t_begin, t_end); |
| 4163 | if (__right_) |
| 4164 | r = r && __right_->fix_forward_references(t_begin, t_end); |
| 4165 | return r; |
| 4166 | } |
| 4167 | }; |
| 4168 | |
| 4169 | class __operator_plus_equal |
| 4170 | : public __node |
| 4171 | { |
| 4172 | public: |
| 4173 | |
| 4174 | __operator_plus_equal() {} |
| 4175 | __operator_plus_equal(__node* op1, __node* op2) |
| 4176 | { |
| 4177 | __left_ = op1; |
| 4178 | __right_ = op2; |
| 4179 | } |
| 4180 | virtual size_t first_size() const |
| 4181 | { |
| 4182 | if (__cached_size_ == -1) |
| 4183 | { |
| 4184 | if (__left_) |
| 4185 | const_cast<long&>(__cached_size_) = __left_->size() + 8 + __right_->size(); |
| 4186 | else |
| 4187 | const_cast<long&>(__cached_size_) = sizeof("operator+=") - 1; |
| 4188 | } |
| 4189 | return __cached_size_; |
| 4190 | } |
| 4191 | virtual char* first_demangled_name(char* buf) const |
| 4192 | { |
| 4193 | if (__left_) |
| 4194 | { |
| 4195 | *buf++ = '('; |
| 4196 | buf = __left_->get_demangled_name(buf); |
| 4197 | strncpy(buf, ") += (", 6); |
| 4198 | buf += 6; |
| 4199 | buf = __right_->get_demangled_name(buf); |
| 4200 | *buf++ = ')'; |
| 4201 | } |
| 4202 | else |
| 4203 | { |
| 4204 | strncpy(buf, "operator+=", sizeof("operator+=") - 1); |
| 4205 | buf += sizeof("operator+=") - 1; |
| 4206 | } |
| 4207 | return buf; |
| 4208 | } |
| 4209 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 4210 | { |
| 4211 | const ptrdiff_t r = l - f; |
| 4212 | if (__left_) |
| 4213 | { |
| 4214 | const ptrdiff_t n1 = 8; |
| 4215 | if (r < n1) |
| 4216 | return n1 + __left_->print(l, l) + __right_->print(l, l); |
| 4217 | ptrdiff_t sz1 = __left_->print(f+1, l); |
| 4218 | if (r < n1 + sz1) |
| 4219 | return n1 + sz1 + __right_->print(l, l); |
| 4220 | ptrdiff_t sz2 = __right_->print(f+(n1-1)+sz1, l); |
| 4221 | if (r >= n1 + sz1 + sz2) |
| 4222 | { |
| 4223 | *f = '('; |
| 4224 | f += 1 + sz1; |
| 4225 | *f++ = ')'; |
| 4226 | *f++ = ' '; |
| 4227 | *f++ = '+'; |
| 4228 | *f++ = '='; |
| 4229 | *f++ = ' '; |
| 4230 | *f = '('; |
| 4231 | f += 1 + sz2; |
| 4232 | *f = ')'; |
| 4233 | } |
| 4234 | return n1 + sz1 + sz2; |
| 4235 | } |
| 4236 | const ptrdiff_t n2 = sizeof("operator+=") - 1; |
| 4237 | if (r >= n2) |
| 4238 | { |
| 4239 | *f++ = 'o'; |
| 4240 | *f++ = 'p'; |
| 4241 | *f++ = 'e'; |
| 4242 | *f++ = 'r'; |
| 4243 | *f++ = 'a'; |
| 4244 | *f++ = 't'; |
| 4245 | *f++ = 'o'; |
| 4246 | *f++ = 'r'; |
| 4247 | *f++ = '+'; |
| 4248 | *f = '='; |
| 4249 | } |
| 4250 | return n2; |
| 4251 | } |
| 4252 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 4253 | { |
| 4254 | bool r = true; |
| 4255 | if (__left_) |
| 4256 | r = r && __left_->fix_forward_references(t_begin, t_end); |
| 4257 | if (__right_) |
| 4258 | r = r && __right_->fix_forward_references(t_begin, t_end); |
| 4259 | return r; |
| 4260 | } |
| 4261 | }; |
| 4262 | |
| 4263 | class __operator_increment |
| 4264 | : public __node |
| 4265 | { |
| 4266 | public: |
| 4267 | |
| 4268 | __operator_increment() {} |
| 4269 | explicit __operator_increment(bool prefix, __node* op) |
| 4270 | { |
| 4271 | __size_ = prefix; |
| 4272 | __left_ = op; |
| 4273 | } |
| 4274 | virtual size_t first_size() const |
| 4275 | { |
| 4276 | if (__cached_size_ == -1) |
| 4277 | { |
| 4278 | if (__left_) |
| 4279 | const_cast<long&>(__cached_size_) = 4+__left_->size(); |
| 4280 | else |
| 4281 | const_cast<long&>(__cached_size_) = sizeof("operator++") - 1; |
| 4282 | } |
| 4283 | return __cached_size_; |
| 4284 | } |
| 4285 | virtual char* first_demangled_name(char* buf) const |
| 4286 | { |
| 4287 | if (__left_) |
| 4288 | { |
| 4289 | if (__size_) |
| 4290 | { |
| 4291 | *buf++ = '+'; |
| 4292 | *buf++ = '+'; |
| 4293 | *buf++ = '('; |
| 4294 | } |
| 4295 | else |
| 4296 | *buf++ = '('; |
| 4297 | buf = __left_->get_demangled_name(buf); |
| 4298 | if (__size_) |
| 4299 | *buf++ = ')'; |
| 4300 | else |
| 4301 | { |
| 4302 | *buf++ = ')'; |
| 4303 | *buf++ = '+'; |
| 4304 | *buf++ = '+'; |
| 4305 | } |
| 4306 | } |
| 4307 | else |
| 4308 | { |
| 4309 | strncpy(buf, "operator++", sizeof("operator++") - 1); |
| 4310 | buf += sizeof("operator++") - 1; |
| 4311 | } |
| 4312 | return buf; |
| 4313 | } |
| 4314 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 4315 | { |
| 4316 | const ptrdiff_t r = l - f; |
| 4317 | if (__left_) |
| 4318 | { |
| 4319 | const ptrdiff_t n1 = 4; |
| 4320 | if (r < n1) |
| 4321 | return n1 + __left_->print(l, l); |
| 4322 | ptrdiff_t sz1 = __left_->print(f + (__size_ ? 3 : 1), l); |
| 4323 | if (r >= n1 + sz1) |
| 4324 | { |
| 4325 | if (__size_) |
| 4326 | { |
| 4327 | *f++ = '+'; |
| 4328 | *f++ = '+'; |
| 4329 | *f = '('; |
| 4330 | f += 1+sz1; |
| 4331 | *f = ')'; |
| 4332 | } |
| 4333 | else |
| 4334 | { |
| 4335 | *f = '('; |
| 4336 | f += 1+sz1; |
| 4337 | *f++ = ')'; |
| 4338 | *f++ = '+'; |
| 4339 | *f = '+'; |
| 4340 | } |
| 4341 | } |
| 4342 | return n1 + sz1; |
| 4343 | } |
| 4344 | const ptrdiff_t n2 = sizeof("operator++") - 1; |
| 4345 | if (r >= n2) |
| 4346 | { |
| 4347 | *f++ = 'o'; |
| 4348 | *f++ = 'p'; |
| 4349 | *f++ = 'e'; |
| 4350 | *f++ = 'r'; |
| 4351 | *f++ = 'a'; |
| 4352 | *f++ = 't'; |
| 4353 | *f++ = 'o'; |
| 4354 | *f++ = 'r'; |
| 4355 | *f++ = '+'; |
| 4356 | *f = '+'; |
| 4357 | } |
| 4358 | return n2; |
| 4359 | } |
| 4360 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 4361 | { |
| 4362 | if (__left_) |
| 4363 | return __left_->fix_forward_references(t_begin, t_end); |
| 4364 | return true; |
| 4365 | } |
| 4366 | }; |
| 4367 | |
| 4368 | class __operator_unary_plus |
| 4369 | : public __node |
| 4370 | { |
| 4371 | public: |
| 4372 | |
| 4373 | __operator_unary_plus() {} |
| 4374 | explicit __operator_unary_plus(__node* op) |
| 4375 | { |
| 4376 | __left_ = op; |
| 4377 | } |
| 4378 | virtual size_t first_size() const |
| 4379 | { |
| 4380 | if (__cached_size_ == -1) |
| 4381 | { |
| 4382 | if (__left_) |
| 4383 | const_cast<long&>(__cached_size_) = 3+__left_->size(); |
| 4384 | else |
| 4385 | const_cast<long&>(__cached_size_) = sizeof("operator+") - 1; |
| 4386 | } |
| 4387 | return __cached_size_; |
| 4388 | } |
| 4389 | virtual char* first_demangled_name(char* buf) const |
| 4390 | { |
| 4391 | if (__left_) |
| 4392 | { |
| 4393 | *buf++ = '+'; |
| 4394 | *buf++ = '('; |
| 4395 | buf = __left_->get_demangled_name(buf); |
| 4396 | *buf++ = ')'; |
| 4397 | } |
| 4398 | else |
| 4399 | { |
| 4400 | strncpy(buf, "operator+", sizeof("operator+") - 1); |
| 4401 | buf += sizeof("operator+") - 1; |
| 4402 | } |
| 4403 | return buf; |
| 4404 | } |
| 4405 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 4406 | { |
| 4407 | const ptrdiff_t r = l - f; |
| 4408 | if (__left_) |
| 4409 | { |
| 4410 | const ptrdiff_t n1 = 3; |
| 4411 | if (r < n1) |
| 4412 | return n1 + __left_->print(l, l); |
| 4413 | ptrdiff_t sz1 = __left_->print(f+2, l); |
| 4414 | if (r >= n1 + sz1) |
| 4415 | { |
| 4416 | *f++ = '+'; |
| 4417 | *f = '('; |
| 4418 | f += 1 + sz1; |
| 4419 | *f = ')'; |
| 4420 | } |
| 4421 | return n1 + sz1; |
| 4422 | } |
| 4423 | const ptrdiff_t n2 = sizeof("operator+") - 1; |
| 4424 | if (r >= n2) |
| 4425 | { |
| 4426 | *f++ = 'o'; |
| 4427 | *f++ = 'p'; |
| 4428 | *f++ = 'e'; |
| 4429 | *f++ = 'r'; |
| 4430 | *f++ = 'a'; |
| 4431 | *f++ = 't'; |
| 4432 | *f++ = 'o'; |
| 4433 | *f++ = 'r'; |
| 4434 | *f = '+'; |
| 4435 | } |
| 4436 | return n2; |
| 4437 | } |
| 4438 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 4439 | { |
| 4440 | if (__left_) |
| 4441 | return __left_->fix_forward_references(t_begin, t_end); |
| 4442 | return true; |
| 4443 | } |
| 4444 | }; |
| 4445 | |
| 4446 | class __operator_arrow |
| 4447 | : public __node |
| 4448 | { |
| 4449 | public: |
| 4450 | |
| 4451 | __operator_arrow() {} |
| 4452 | __operator_arrow(__node* op1, __node* op2) |
| 4453 | { |
| 4454 | __left_ = op1; |
| 4455 | __right_ = op2; |
| 4456 | } |
| 4457 | virtual size_t first_size() const |
| 4458 | { |
| 4459 | if (__cached_size_ == -1) |
| 4460 | { |
| 4461 | if (__left_) |
| 4462 | const_cast<long&>(__cached_size_) = __left_->size() + 8 + __right_->size(); |
| 4463 | else |
| 4464 | const_cast<long&>(__cached_size_) = sizeof("operator->") - 1; |
| 4465 | } |
| 4466 | return __cached_size_; |
| 4467 | } |
| 4468 | virtual char* first_demangled_name(char* buf) const |
| 4469 | { |
| 4470 | if (__left_) |
| 4471 | { |
| 4472 | *buf++ = '('; |
| 4473 | buf = __left_->get_demangled_name(buf); |
| 4474 | strncpy(buf, ") -> (", 6); |
| 4475 | buf += 6; |
| 4476 | buf = __right_->get_demangled_name(buf); |
| 4477 | *buf++ = ')'; |
| 4478 | } |
| 4479 | else |
| 4480 | { |
| 4481 | strncpy(buf, "operator->", sizeof("operator->") - 1); |
| 4482 | buf += sizeof("operator->") - 1; |
| 4483 | } |
| 4484 | return buf; |
| 4485 | } |
| 4486 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 4487 | { |
| 4488 | const ptrdiff_t r = l - f; |
| 4489 | if (__left_) |
| 4490 | { |
| 4491 | const ptrdiff_t n1 = 8; |
| 4492 | if (r < n1) |
| 4493 | return n1 + __left_->print(l, l) + __right_->print(l, l); |
| 4494 | ptrdiff_t sz1 = __left_->print(f+1, l); |
| 4495 | if (r < n1 + sz1) |
| 4496 | return n1 + sz1 + __right_->print(l, l); |
| 4497 | ptrdiff_t sz2 = __right_->print(f+(n1-1)+sz1, l); |
| 4498 | if (r >= n1 + sz1 + sz2) |
| 4499 | { |
| 4500 | *f = '('; |
| 4501 | f += 1 + sz1; |
| 4502 | *f++ = ')'; |
| 4503 | *f++ = ' '; |
| 4504 | *f++ = '-'; |
| 4505 | *f++ = '>'; |
| 4506 | *f++ = ' '; |
| 4507 | *f = '('; |
| 4508 | f += 1 + sz2; |
| 4509 | *f = ')'; |
| 4510 | } |
| 4511 | return n1 + sz1 + sz2; |
| 4512 | } |
| 4513 | const ptrdiff_t n2 = sizeof("operator->") - 1; |
| 4514 | if (r >= n2) |
| 4515 | { |
| 4516 | *f++ = 'o'; |
| 4517 | *f++ = 'p'; |
| 4518 | *f++ = 'e'; |
| 4519 | *f++ = 'r'; |
| 4520 | *f++ = 'a'; |
| 4521 | *f++ = 't'; |
| 4522 | *f++ = 'o'; |
| 4523 | *f++ = 'r'; |
| 4524 | *f++ = '-'; |
| 4525 | *f = '>'; |
| 4526 | } |
| 4527 | return n2; |
| 4528 | } |
| 4529 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 4530 | { |
| 4531 | bool r = true; |
| 4532 | if (__left_) |
| 4533 | r = r && __left_->fix_forward_references(t_begin, t_end); |
| 4534 | if (__right_) |
| 4535 | r = r && __right_->fix_forward_references(t_begin, t_end); |
| 4536 | return r; |
| 4537 | } |
| 4538 | }; |
| 4539 | |
| 4540 | class __operator_conditional |
| 4541 | : public __node |
| 4542 | { |
| 4543 | public: |
| 4544 | |
| 4545 | __operator_conditional() {} |
| 4546 | __operator_conditional(__node* op1, __node* op2, __node* op3) |
| 4547 | { |
| 4548 | __name_ = (const char*)op1; |
| 4549 | __left_ = op2; |
| 4550 | __right_ = op3; |
| 4551 | } |
| 4552 | virtual size_t first_size() const |
| 4553 | { |
| 4554 | if (__cached_size_ == -1) |
| 4555 | { |
| 4556 | if (__left_) |
| 4557 | { |
| 4558 | __node* op1 = (__node*)__name_; |
| 4559 | const_cast<long&>(__cached_size_) = op1->size() + __left_->size() + 12 + __right_->size(); |
| 4560 | } |
| 4561 | else |
| 4562 | const_cast<long&>(__cached_size_) = sizeof("operator?") - 1; |
| 4563 | } |
| 4564 | return __cached_size_; |
| 4565 | } |
| 4566 | virtual char* first_demangled_name(char* buf) const |
| 4567 | { |
| 4568 | if (__left_) |
| 4569 | { |
| 4570 | __node* op1 = (__node*)__name_; |
| 4571 | *buf++ = '('; |
| 4572 | buf = op1->get_demangled_name(buf); |
| 4573 | strncpy(buf, ") ? (", 5); |
| 4574 | buf += 5; |
| 4575 | buf = __left_->get_demangled_name(buf); |
| 4576 | strncpy(buf, ") : (", 5); |
| 4577 | buf += 5; |
| 4578 | buf = __right_->get_demangled_name(buf); |
| 4579 | *buf++ = ')'; |
| 4580 | } |
| 4581 | else |
| 4582 | { |
| 4583 | strncpy(buf, "operator?", sizeof("operator?") - 1); |
| 4584 | buf += sizeof("operator?") - 1; |
| 4585 | } |
| 4586 | return buf; |
| 4587 | } |
| 4588 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 4589 | { |
| 4590 | const ptrdiff_t r = l - f; |
| 4591 | if (__left_) |
| 4592 | { |
| 4593 | const ptrdiff_t n1 = 12; |
| 4594 | __node* op1 = (__node*)__name_; |
| 4595 | if (r < n1) |
| 4596 | return n1 + op1->print(l, l) + __left_->print(l, l) + |
| 4597 | __right_->print(l, l); |
| 4598 | ptrdiff_t sz1 = op1->print(f+1, l); |
| 4599 | if (r < n1 + sz1) |
| 4600 | return n1 + sz1 + __left_->print(l, l) + __right_->print(l, l); |
| 4601 | ptrdiff_t sz2 = __left_->print(f+6+sz1, l); |
| 4602 | if (r < n1 + sz1 + sz2) |
| 4603 | return n1 + sz1 + sz2 + __right_->print(l, l); |
| 4604 | ptrdiff_t sz3 = __right_->print(f+11+sz1+sz2, l); |
| 4605 | if (r >= n1 + sz1 + sz2 + sz3) |
| 4606 | { |
| 4607 | *f = '('; |
| 4608 | f += 1 + sz1; |
| 4609 | *f++ = ')'; |
| 4610 | *f++ = ' '; |
| 4611 | *f++ = '?'; |
| 4612 | *f++ = ' '; |
| 4613 | *f = '('; |
| 4614 | f += 1 + sz2; |
| 4615 | *f++ = ')'; |
| 4616 | *f++ = ' '; |
| 4617 | *f++ = ':'; |
| 4618 | *f++ = ' '; |
| 4619 | *f = '('; |
| 4620 | f += 1 + sz3; |
| 4621 | *f = ')'; |
| 4622 | } |
| 4623 | return n1 + sz1 + sz2 + sz3; |
| 4624 | } |
| 4625 | const ptrdiff_t n2 = sizeof("operator?") - 1; |
| 4626 | if (r >= n2) |
| 4627 | { |
| 4628 | *f++ = 'o'; |
| 4629 | *f++ = 'p'; |
| 4630 | *f++ = 'e'; |
| 4631 | *f++ = 'r'; |
| 4632 | *f++ = 'a'; |
| 4633 | *f++ = 't'; |
| 4634 | *f++ = 'o'; |
| 4635 | *f++ = 'r'; |
| 4636 | *f = '?'; |
| 4637 | } |
| 4638 | return n2; |
| 4639 | } |
| 4640 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 4641 | { |
| 4642 | bool r = true; |
| 4643 | if (__name_) |
| 4644 | r = r && ((__node*)__name_)->fix_forward_references(t_begin, t_end); |
| 4645 | if (__left_) |
| 4646 | r = r && __left_->fix_forward_references(t_begin, t_end); |
| 4647 | if (__right_) |
| 4648 | r = r && __right_->fix_forward_references(t_begin, t_end); |
| 4649 | return r; |
| 4650 | } |
| 4651 | }; |
| 4652 | |
| 4653 | class __operator_mod |
| 4654 | : public __node |
| 4655 | { |
| 4656 | public: |
| 4657 | |
| 4658 | __operator_mod() {} |
| 4659 | __operator_mod(__node* op1, __node* op2) |
| 4660 | { |
| 4661 | __left_ = op1; |
| 4662 | __right_ = op2; |
| 4663 | } |
| 4664 | virtual size_t first_size() const |
| 4665 | { |
| 4666 | if (__cached_size_ == -1) |
| 4667 | { |
| 4668 | if (__left_) |
| 4669 | const_cast<long&>(__cached_size_) = __left_->size() + 7 + __right_->size(); |
| 4670 | else |
| 4671 | const_cast<long&>(__cached_size_) = sizeof("operator%") - 1; |
| 4672 | } |
| 4673 | return __cached_size_; |
| 4674 | } |
| 4675 | virtual char* first_demangled_name(char* buf) const |
| 4676 | { |
| 4677 | if (__left_) |
| 4678 | { |
| 4679 | *buf++ = '('; |
| 4680 | buf = __left_->get_demangled_name(buf); |
| 4681 | strncpy(buf, ") % (", 5); |
| 4682 | buf += 5; |
| 4683 | buf = __right_->get_demangled_name(buf); |
| 4684 | *buf++ = ')'; |
| 4685 | } |
| 4686 | else |
| 4687 | { |
| 4688 | strncpy(buf, "operator%", sizeof("operator%") - 1); |
| 4689 | buf += sizeof("operator%") - 1; |
| 4690 | } |
| 4691 | return buf; |
| 4692 | } |
| 4693 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 4694 | { |
| 4695 | const ptrdiff_t r = l - f; |
| 4696 | if (__left_) |
| 4697 | { |
| 4698 | const ptrdiff_t n1 = 7; |
| 4699 | if (r < n1) |
| 4700 | return n1 + __left_->print(l, l) + __right_->print(l, l); |
| 4701 | ptrdiff_t sz1 = __left_->print(f+1, l); |
| 4702 | if (r < n1 + sz1) |
| 4703 | return n1 + sz1 + __right_->print(l, l); |
| 4704 | ptrdiff_t sz2 = __right_->print(f+(n1-1)+sz1, l); |
| 4705 | if (r >= n1 + sz1 + sz2) |
| 4706 | { |
| 4707 | *f = '('; |
| 4708 | f += 1 + sz1; |
| 4709 | *f++ = ')'; |
| 4710 | *f++ = ' '; |
| 4711 | *f++ = '%'; |
| 4712 | *f++ = ' '; |
| 4713 | *f = '('; |
| 4714 | f += 1 + sz2; |
| 4715 | *f = ')'; |
| 4716 | } |
| 4717 | return n1 + sz1 + sz2; |
| 4718 | } |
| 4719 | const ptrdiff_t n2 = sizeof("operator%") - 1; |
| 4720 | if (r >= n2) |
| 4721 | { |
| 4722 | *f++ = 'o'; |
| 4723 | *f++ = 'p'; |
| 4724 | *f++ = 'e'; |
| 4725 | *f++ = 'r'; |
| 4726 | *f++ = 'a'; |
| 4727 | *f++ = 't'; |
| 4728 | *f++ = 'o'; |
| 4729 | *f++ = 'r'; |
| 4730 | *f = '%'; |
| 4731 | } |
| 4732 | return n2; |
| 4733 | } |
| 4734 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 4735 | { |
| 4736 | bool r = true; |
| 4737 | if (__left_) |
| 4738 | r = r && __left_->fix_forward_references(t_begin, t_end); |
| 4739 | if (__right_) |
| 4740 | r = r && __right_->fix_forward_references(t_begin, t_end); |
| 4741 | return r; |
| 4742 | } |
| 4743 | }; |
| 4744 | |
| 4745 | class __operator_mod_equal |
| 4746 | : public __node |
| 4747 | { |
| 4748 | public: |
| 4749 | |
| 4750 | __operator_mod_equal() {} |
| 4751 | __operator_mod_equal(__node* op1, __node* op2) |
| 4752 | { |
| 4753 | __left_ = op1; |
| 4754 | __right_ = op2; |
| 4755 | } |
| 4756 | virtual size_t first_size() const |
| 4757 | { |
| 4758 | if (__cached_size_ == -1) |
| 4759 | { |
| 4760 | if (__left_) |
| 4761 | const_cast<long&>(__cached_size_) = __left_->size() + 8 + __right_->size(); |
| 4762 | else |
| 4763 | const_cast<long&>(__cached_size_) = sizeof("operator%=") - 1; |
| 4764 | } |
| 4765 | return __cached_size_; |
| 4766 | } |
| 4767 | virtual char* first_demangled_name(char* buf) const |
| 4768 | { |
| 4769 | if (__left_) |
| 4770 | { |
| 4771 | *buf++ = '('; |
| 4772 | buf = __left_->get_demangled_name(buf); |
| 4773 | strncpy(buf, ") %= (", 6); |
| 4774 | buf += 6; |
| 4775 | buf = __right_->get_demangled_name(buf); |
| 4776 | *buf++ = ')'; |
| 4777 | } |
| 4778 | else |
| 4779 | { |
| 4780 | strncpy(buf, "operator%=", sizeof("operator%=") - 1); |
| 4781 | buf += sizeof("operator%=") - 1; |
| 4782 | } |
| 4783 | return buf; |
| 4784 | } |
| 4785 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 4786 | { |
| 4787 | const ptrdiff_t r = l - f; |
| 4788 | if (__left_) |
| 4789 | { |
| 4790 | const ptrdiff_t n1 = 8; |
| 4791 | if (r < n1) |
| 4792 | return n1 + __left_->print(l, l) + __right_->print(l, l); |
| 4793 | ptrdiff_t sz1 = __left_->print(f+1, l); |
| 4794 | if (r < n1 + sz1) |
| 4795 | return n1 + sz1 + __right_->print(l, l); |
| 4796 | ptrdiff_t sz2 = __right_->print(f+(n1-1)+sz1, l); |
| 4797 | if (r >= n1 + sz1 + sz2) |
| 4798 | { |
| 4799 | *f = '('; |
| 4800 | f += 1 + sz1; |
| 4801 | *f++ = ')'; |
| 4802 | *f++ = ' '; |
| 4803 | *f++ = '%'; |
| 4804 | *f++ = '='; |
| 4805 | *f++ = ' '; |
| 4806 | *f = '('; |
| 4807 | f += 1 + sz2; |
| 4808 | *f = ')'; |
| 4809 | } |
| 4810 | return n1 + sz1 + sz2; |
| 4811 | } |
| 4812 | const ptrdiff_t n2 = sizeof("operator%=") - 1; |
| 4813 | if (r >= n2) |
| 4814 | { |
| 4815 | *f++ = 'o'; |
| 4816 | *f++ = 'p'; |
| 4817 | *f++ = 'e'; |
| 4818 | *f++ = 'r'; |
| 4819 | *f++ = 'a'; |
| 4820 | *f++ = 't'; |
| 4821 | *f++ = 'o'; |
| 4822 | *f++ = 'r'; |
| 4823 | *f++ = '%'; |
| 4824 | *f = '='; |
| 4825 | } |
| 4826 | return n2; |
| 4827 | } |
| 4828 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 4829 | { |
| 4830 | bool r = true; |
| 4831 | if (__left_) |
| 4832 | r = r && __left_->fix_forward_references(t_begin, t_end); |
| 4833 | if (__right_) |
| 4834 | r = r && __right_->fix_forward_references(t_begin, t_end); |
| 4835 | return r; |
| 4836 | } |
| 4837 | }; |
| 4838 | |
| 4839 | class __operator_right_shift |
| 4840 | : public __node |
| 4841 | { |
| 4842 | public: |
| 4843 | |
| 4844 | __operator_right_shift() {} |
| 4845 | __operator_right_shift(__node* op1, __node* op2) |
| 4846 | { |
| 4847 | __left_ = op1; |
| 4848 | __right_ = op2; |
| 4849 | } |
| 4850 | virtual size_t first_size() const |
| 4851 | { |
| 4852 | if (__cached_size_ == -1) |
| 4853 | { |
| 4854 | if (__left_) |
| 4855 | const_cast<long&>(__cached_size_) = __left_->size() + 8 + __right_->size(); |
| 4856 | else |
| 4857 | const_cast<long&>(__cached_size_) = sizeof("operator>>") - 1; |
| 4858 | } |
| 4859 | return __cached_size_; |
| 4860 | } |
| 4861 | virtual char* first_demangled_name(char* buf) const |
| 4862 | { |
| 4863 | if (__left_) |
| 4864 | { |
| 4865 | *buf++ = '('; |
| 4866 | buf = __left_->get_demangled_name(buf); |
| 4867 | strncpy(buf, ") >> (", 6); |
| 4868 | buf += 6; |
| 4869 | buf = __right_->get_demangled_name(buf); |
| 4870 | *buf++ = ')'; |
| 4871 | } |
| 4872 | else |
| 4873 | { |
| 4874 | strncpy(buf, "operator>>", sizeof("operator>>") - 1); |
| 4875 | buf += sizeof("operator>>") - 1; |
| 4876 | } |
| 4877 | return buf; |
| 4878 | } |
| 4879 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 4880 | { |
| 4881 | const ptrdiff_t r = l - f; |
| 4882 | if (__left_) |
| 4883 | { |
| 4884 | const ptrdiff_t n1 = 8; |
| 4885 | if (r < n1) |
| 4886 | return n1 + __left_->print(l, l) + __right_->print(l, l); |
| 4887 | ptrdiff_t sz1 = __left_->print(f+1, l); |
| 4888 | if (r < n1 + sz1) |
| 4889 | return n1 + sz1 + __right_->print(l, l); |
| 4890 | ptrdiff_t sz2 = __right_->print(f+(n1-1)+sz1, l); |
| 4891 | if (r >= n1 + sz1 + sz2) |
| 4892 | { |
| 4893 | *f = '('; |
| 4894 | f += 1 + sz1; |
| 4895 | *f++ = ')'; |
| 4896 | *f++ = ' '; |
| 4897 | *f++ = '>'; |
| 4898 | *f++ = '>'; |
| 4899 | *f++ = ' '; |
| 4900 | *f = '('; |
| 4901 | f += 1 + sz2; |
| 4902 | *f = ')'; |
| 4903 | } |
| 4904 | return n1 + sz1 + sz2; |
| 4905 | } |
| 4906 | const ptrdiff_t n2 = sizeof("operator>>") - 1; |
| 4907 | if (r >= n2) |
| 4908 | { |
| 4909 | *f++ = 'o'; |
| 4910 | *f++ = 'p'; |
| 4911 | *f++ = 'e'; |
| 4912 | *f++ = 'r'; |
| 4913 | *f++ = 'a'; |
| 4914 | *f++ = 't'; |
| 4915 | *f++ = 'o'; |
| 4916 | *f++ = 'r'; |
| 4917 | *f++ = '>'; |
| 4918 | *f = '>'; |
| 4919 | } |
| 4920 | return n2; |
| 4921 | } |
| 4922 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 4923 | { |
| 4924 | bool r = true; |
| 4925 | if (__left_) |
| 4926 | r = r && __left_->fix_forward_references(t_begin, t_end); |
| 4927 | if (__right_) |
| 4928 | r = r && __right_->fix_forward_references(t_begin, t_end); |
| 4929 | return r; |
| 4930 | } |
| 4931 | }; |
| 4932 | |
| 4933 | class __operator_right_shift_equal |
| 4934 | : public __node |
| 4935 | { |
| 4936 | public: |
| 4937 | |
| 4938 | __operator_right_shift_equal() {} |
| 4939 | __operator_right_shift_equal(__node* op1, __node* op2) |
| 4940 | { |
| 4941 | __left_ = op1; |
| 4942 | __right_ = op2; |
| 4943 | } |
| 4944 | virtual size_t first_size() const |
| 4945 | { |
| 4946 | if (__cached_size_ == -1) |
| 4947 | { |
| 4948 | if (__left_) |
| 4949 | const_cast<long&>(__cached_size_) = __left_->size() + 9 + __right_->size(); |
| 4950 | else |
| 4951 | const_cast<long&>(__cached_size_) = sizeof("operator>>=") - 1; |
| 4952 | } |
| 4953 | return __cached_size_; |
| 4954 | } |
| 4955 | virtual char* first_demangled_name(char* buf) const |
| 4956 | { |
| 4957 | if (__left_) |
| 4958 | { |
| 4959 | *buf++ = '('; |
| 4960 | buf = __left_->get_demangled_name(buf); |
| 4961 | strncpy(buf, ") >>= (", 7); |
| 4962 | buf += 7; |
| 4963 | buf = __right_->get_demangled_name(buf); |
| 4964 | *buf++ = ')'; |
| 4965 | } |
| 4966 | else |
| 4967 | { |
| 4968 | strncpy(buf, "operator>>=", sizeof("operator>>=") - 1); |
| 4969 | buf += sizeof("operator>>=") - 1; |
| 4970 | } |
| 4971 | return buf; |
| 4972 | } |
| 4973 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 4974 | { |
| 4975 | const ptrdiff_t r = l - f; |
| 4976 | if (__left_) |
| 4977 | { |
| 4978 | const ptrdiff_t n1 = 9; |
| 4979 | if (r < n1) |
| 4980 | return n1 + __left_->print(l, l) + __right_->print(l, l); |
| 4981 | ptrdiff_t sz1 = __left_->print(f+1, l); |
| 4982 | if (r < n1 + sz1) |
| 4983 | return n1 + sz1 + __right_->print(l, l); |
| 4984 | ptrdiff_t sz2 = __right_->print(f+(n1-1)+sz1, l); |
| 4985 | if (r >= n1 + sz1 + sz2) |
| 4986 | { |
| 4987 | *f = '('; |
| 4988 | f += 1 + sz1; |
| 4989 | *f++ = ')'; |
| 4990 | *f++ = ' '; |
| 4991 | *f++ = '>'; |
| 4992 | *f++ = '>'; |
| 4993 | *f++ = '='; |
| 4994 | *f++ = ' '; |
| 4995 | *f = '('; |
| 4996 | f += 1 + sz2; |
| 4997 | *f = ')'; |
| 4998 | } |
| 4999 | return n1 + sz1 + sz2; |
| 5000 | } |
| 5001 | const ptrdiff_t n2 = sizeof("operator>>=") - 1; |
| 5002 | if (r >= n2) |
| 5003 | { |
| 5004 | *f++ = 'o'; |
| 5005 | *f++ = 'p'; |
| 5006 | *f++ = 'e'; |
| 5007 | *f++ = 'r'; |
| 5008 | *f++ = 'a'; |
| 5009 | *f++ = 't'; |
| 5010 | *f++ = 'o'; |
| 5011 | *f++ = 'r'; |
| 5012 | *f++ = '>'; |
| 5013 | *f++ = '>'; |
| 5014 | *f = '='; |
| 5015 | } |
| 5016 | return n2; |
| 5017 | } |
| 5018 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 5019 | { |
| 5020 | bool r = true; |
| 5021 | if (__left_) |
| 5022 | r = r && __left_->fix_forward_references(t_begin, t_end); |
| 5023 | if (__right_) |
| 5024 | r = r && __right_->fix_forward_references(t_begin, t_end); |
| 5025 | return r; |
| 5026 | } |
| 5027 | }; |
| 5028 | |
| 5029 | class __operator_sizeof_type |
| 5030 | : public __node |
| 5031 | { |
| 5032 | public: |
| 5033 | |
| 5034 | __operator_sizeof_type() {} |
| 5035 | __operator_sizeof_type(__node* op) |
| 5036 | { |
| 5037 | __right_ = op; |
| 5038 | } |
| 5039 | virtual size_t first_size() const |
| 5040 | { |
| 5041 | if (__cached_size_ == -1) |
| 5042 | { |
| 5043 | if (__right_) |
| 5044 | const_cast<long&>(__cached_size_) = __right_->size() + 9; |
| 5045 | else |
| 5046 | const_cast<long&>(__cached_size_) = sizeof("operator sizeof") - 1; |
| 5047 | } |
| 5048 | return __cached_size_; |
| 5049 | } |
| 5050 | virtual char* first_demangled_name(char* buf) const |
| 5051 | { |
| 5052 | if (__right_) |
| 5053 | { |
| 5054 | strncpy(buf, "sizeof (", 8); |
| 5055 | buf += 8; |
| 5056 | buf = __right_->get_demangled_name(buf); |
| 5057 | *buf++ = ')'; |
| 5058 | } |
| 5059 | else |
| 5060 | { |
| 5061 | strncpy(buf, "operator sizeof", sizeof("operator sizeof") - 1); |
| 5062 | buf += sizeof("operator sizeof") - 1; |
| 5063 | } |
| 5064 | return buf; |
| 5065 | } |
| 5066 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 5067 | { |
| 5068 | const ptrdiff_t r = l - f; |
| 5069 | if (__right_) |
| 5070 | { |
| 5071 | const ptrdiff_t n1 = sizeof("sizeof ()") - 1; |
| 5072 | if (r < n1) |
| 5073 | return n1 + __right_->print(l, l); |
| 5074 | ptrdiff_t sz1 = __right_->print(f+(n1-1), l); |
| 5075 | if (r >= n1 + sz1) |
| 5076 | { |
| 5077 | *f++ = 's'; |
| 5078 | *f++ = 'i'; |
| 5079 | *f++ = 'z'; |
| 5080 | *f++ = 'e'; |
| 5081 | *f++ = 'o'; |
| 5082 | *f++ = 'f'; |
| 5083 | *f++ = ' '; |
| 5084 | *f = '('; |
| 5085 | f += 1 + sz1; |
| 5086 | *f = ')'; |
| 5087 | } |
| 5088 | return n1 + sz1; |
| 5089 | } |
| 5090 | const ptrdiff_t n2 = sizeof("operator sizeof") - 1; |
| 5091 | if (r >= n2) |
| 5092 | { |
| 5093 | *f++ = 'o'; |
| 5094 | *f++ = 'p'; |
| 5095 | *f++ = 'e'; |
| 5096 | *f++ = 'r'; |
| 5097 | *f++ = 'a'; |
| 5098 | *f++ = 't'; |
| 5099 | *f++ = 'o'; |
| 5100 | *f++ = 'r'; |
| 5101 | *f++ = ' '; |
| 5102 | *f++ = 's'; |
| 5103 | *f++ = 'i'; |
| 5104 | *f++ = 'z'; |
| 5105 | *f++ = 'e'; |
| 5106 | *f++ = 'o'; |
| 5107 | *f = 'f'; |
| 5108 | } |
| 5109 | return n2; |
| 5110 | } |
| 5111 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 5112 | { |
| 5113 | if (__right_) |
| 5114 | return __right_->fix_forward_references(t_begin, t_end); |
| 5115 | return true; |
| 5116 | } |
| 5117 | }; |
| 5118 | |
| 5119 | class __operator_sizeof_expression |
| 5120 | : public __node |
| 5121 | { |
| 5122 | public: |
| 5123 | |
| 5124 | __operator_sizeof_expression() {} |
| 5125 | __operator_sizeof_expression(__node* op) |
| 5126 | { |
| 5127 | __right_ = op; |
| 5128 | } |
| 5129 | virtual size_t first_size() const |
| 5130 | { |
| 5131 | if (__cached_size_ == -1) |
| 5132 | { |
| 5133 | if (__right_) |
| 5134 | const_cast<long&>(__cached_size_) = __right_->size() + 9; |
| 5135 | else |
| 5136 | const_cast<long&>(__cached_size_) = sizeof("operator sizeof") - 1; |
| 5137 | } |
| 5138 | return __cached_size_; |
| 5139 | } |
| 5140 | virtual char* first_demangled_name(char* buf) const |
| 5141 | { |
| 5142 | if (__right_) |
| 5143 | { |
| 5144 | strncpy(buf, "sizeof (", 8); |
| 5145 | buf += 8; |
| 5146 | buf = __right_->get_demangled_name(buf); |
| 5147 | *buf++ = ')'; |
| 5148 | } |
| 5149 | else |
| 5150 | { |
| 5151 | strncpy(buf, "operator sizeof", sizeof("operator sizeof") - 1); |
| 5152 | buf += sizeof("operator sizeof") - 1; |
| 5153 | } |
| 5154 | return buf; |
| 5155 | } |
| 5156 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 5157 | { |
| 5158 | const ptrdiff_t r = l - f; |
| 5159 | if (__right_) |
| 5160 | { |
| 5161 | const ptrdiff_t n1 = sizeof("sizeof ()") - 1; |
| 5162 | if (r < n1) |
| 5163 | return n1 + __right_->print(l, l); |
| 5164 | ptrdiff_t sz1 = __right_->print(f+(n1-1), l); |
| 5165 | if (r >= n1 + sz1) |
| 5166 | { |
| 5167 | *f++ = 's'; |
| 5168 | *f++ = 'i'; |
| 5169 | *f++ = 'z'; |
| 5170 | *f++ = 'e'; |
| 5171 | *f++ = 'o'; |
| 5172 | *f++ = 'f'; |
| 5173 | *f++ = ' '; |
| 5174 | *f = '('; |
| 5175 | f += 1 + sz1; |
| 5176 | *f = ')'; |
| 5177 | } |
| 5178 | return n1 + sz1; |
| 5179 | } |
| 5180 | const ptrdiff_t n2 = sizeof("operator sizeof") - 1; |
| 5181 | if (r >= n2) |
| 5182 | { |
| 5183 | *f++ = 'o'; |
| 5184 | *f++ = 'p'; |
| 5185 | *f++ = 'e'; |
| 5186 | *f++ = 'r'; |
| 5187 | *f++ = 'a'; |
| 5188 | *f++ = 't'; |
| 5189 | *f++ = 'o'; |
| 5190 | *f++ = 'r'; |
| 5191 | *f++ = ' '; |
| 5192 | *f++ = 's'; |
| 5193 | *f++ = 'i'; |
| 5194 | *f++ = 'z'; |
| 5195 | *f++ = 'e'; |
| 5196 | *f++ = 'o'; |
| 5197 | *f = 'f'; |
| 5198 | } |
| 5199 | return n2; |
| 5200 | } |
| 5201 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 5202 | { |
| 5203 | if (__right_) |
| 5204 | return __right_->fix_forward_references(t_begin, t_end); |
| 5205 | return true; |
| 5206 | } |
| 5207 | }; |
| 5208 | |
| 5209 | class __typeid |
| 5210 | : public __node |
| 5211 | { |
| 5212 | public: |
| 5213 | |
| 5214 | __typeid(__node* op) |
| 5215 | { |
| 5216 | __right_ = op; |
| 5217 | } |
| 5218 | virtual size_t first_size() const |
| 5219 | { |
| 5220 | if (__cached_size_ == -1) |
| 5221 | const_cast<long&>(__cached_size_) = __right_->size() + 8; |
| 5222 | return __cached_size_; |
| 5223 | } |
| 5224 | virtual char* first_demangled_name(char* buf) const |
| 5225 | { |
| 5226 | strncpy(buf, "typeid(", 7); |
| 5227 | buf += 7; |
| 5228 | buf = __right_->get_demangled_name(buf); |
| 5229 | *buf++ = ')'; |
| 5230 | return buf; |
| 5231 | } |
| 5232 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 5233 | { |
| 5234 | const ptrdiff_t r = l - f; |
| 5235 | const ptrdiff_t n1 = sizeof("typeid()") - 1; |
| 5236 | if (r < n1) |
| 5237 | return n1 + __right_->print(l, l); |
| 5238 | ptrdiff_t sz1 = __right_->print(f+(n1-1), l); |
| 5239 | if (r >= n1 + sz1) |
| 5240 | { |
| 5241 | *f++ = 't'; |
| 5242 | *f++ = 'y'; |
| 5243 | *f++ = 'p'; |
| 5244 | *f++ = 'e'; |
| 5245 | *f++ = 'i'; |
| 5246 | *f++ = 'd'; |
| 5247 | *f = '('; |
| 5248 | f += 1 + sz1; |
| 5249 | *f = ')'; |
| 5250 | } |
| 5251 | return n1 + sz1; |
| 5252 | } |
| 5253 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 5254 | { |
| 5255 | return __right_->fix_forward_references(t_begin, t_end); |
| 5256 | } |
| 5257 | }; |
| 5258 | |
| 5259 | class __throw |
| 5260 | : public __node |
| 5261 | { |
| 5262 | public: |
| 5263 | |
| 5264 | __throw(__node* op) |
| 5265 | { |
| 5266 | __right_ = op; |
| 5267 | } |
| 5268 | virtual size_t first_size() const |
| 5269 | { |
| 5270 | if (__cached_size_ == -1) |
| 5271 | const_cast<long&>(__cached_size_) = __right_->size() + 6; |
| 5272 | return __cached_size_; |
| 5273 | } |
| 5274 | virtual char* first_demangled_name(char* buf) const |
| 5275 | { |
| 5276 | strncpy(buf, "throw ", 6); |
| 5277 | return __right_->get_demangled_name(buf+6); |
| 5278 | } |
| 5279 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 5280 | { |
| 5281 | const ptrdiff_t r = l - f; |
| 5282 | const ptrdiff_t n1 = sizeof("throw ") - 1; |
| 5283 | if (r < n1) |
| 5284 | return n1 + __right_->print(l, l); |
| 5285 | ptrdiff_t sz1 = __right_->print(f+n1, l); |
| 5286 | if (r >= n1 + sz1) |
| 5287 | { |
| 5288 | *f++ = 't'; |
| 5289 | *f++ = 'h'; |
| 5290 | *f++ = 'r'; |
| 5291 | *f++ = 'o'; |
| 5292 | *f++ = 'w'; |
| 5293 | *f = ' '; |
| 5294 | } |
| 5295 | return n1 + sz1; |
| 5296 | } |
| 5297 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 5298 | { |
| 5299 | return __right_->fix_forward_references(t_begin, t_end); |
| 5300 | } |
| 5301 | }; |
| 5302 | |
| 5303 | class __rethrow |
| 5304 | : public __node |
| 5305 | { |
| 5306 | static const ptrdiff_t n = sizeof("throw") - 1; |
| 5307 | public: |
| 5308 | |
| 5309 | virtual size_t first_size() const {return n;} |
| 5310 | virtual char* first_demangled_name(char* buf) const |
| 5311 | { |
| 5312 | strncpy(buf, "throw", n); |
| 5313 | return buf+n; |
| 5314 | } |
| 5315 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 5316 | { |
| 5317 | const ptrdiff_t r = l - f; |
| 5318 | if (r >= n) |
| 5319 | { |
| 5320 | *f++ = 't'; |
| 5321 | *f++ = 'h'; |
| 5322 | *f++ = 'r'; |
| 5323 | *f++ = 'o'; |
| 5324 | *f = 'w'; |
| 5325 | } |
| 5326 | return n; |
| 5327 | } |
| 5328 | }; |
| 5329 | |
| 5330 | class __operator_sizeof_param_pack |
| 5331 | : public __node |
| 5332 | { |
| 5333 | public: |
| 5334 | |
| 5335 | __operator_sizeof_param_pack(__node* op) |
| 5336 | { |
| 5337 | __right_ = op; |
| 5338 | } |
| 5339 | virtual size_t first_size() const |
| 5340 | { |
| 5341 | if (__cached_size_ == -1) |
| 5342 | const_cast<long&>(__cached_size_) = __right_->size() + 11; |
| 5343 | return __cached_size_; |
| 5344 | } |
| 5345 | virtual char* first_demangled_name(char* buf) const |
| 5346 | { |
| 5347 | strncpy(buf, "sizeof...(", 10); |
| 5348 | buf += 10; |
| 5349 | buf = __right_->get_demangled_name(buf); |
| 5350 | *buf++ = ')'; |
| 5351 | return buf; |
| 5352 | } |
| 5353 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 5354 | { |
| 5355 | const ptrdiff_t r = l - f; |
| 5356 | const ptrdiff_t n1 = sizeof("sizeof...()") - 1; |
| 5357 | if (r < n1) |
| 5358 | return n1 + __right_->print(l, l); |
| 5359 | ptrdiff_t sz1 = __right_->print(f+(n1-1), l); |
| 5360 | if (r >= n1 + sz1) |
| 5361 | { |
| 5362 | *f++ = 's'; |
| 5363 | *f++ = 'i'; |
| 5364 | *f++ = 'z'; |
| 5365 | *f++ = 'e'; |
| 5366 | *f++ = 'o'; |
| 5367 | *f++ = 'f'; |
| 5368 | *f++ = '.'; |
| 5369 | *f++ = '.'; |
| 5370 | *f++ = '.'; |
| 5371 | *f = '('; |
| 5372 | f += 1+sz1; |
| 5373 | *f = ')'; |
| 5374 | } |
| 5375 | return n1 + sz1; |
| 5376 | } |
| 5377 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 5378 | { |
| 5379 | return __right_->fix_forward_references(t_begin, t_end); |
| 5380 | } |
| 5381 | }; |
| 5382 | |
| 5383 | class __const_cast |
| 5384 | : public __node |
| 5385 | { |
| 5386 | public: |
| 5387 | |
| 5388 | __const_cast(__node* op1, __node* op2) |
| 5389 | { |
| 5390 | __left_ = op1; |
| 5391 | __right_ = op2; |
| 5392 | } |
| 5393 | virtual size_t first_size() const |
| 5394 | { |
| 5395 | if (__cached_size_ == -1) |
| 5396 | const_cast<long&>(__cached_size_) = __left_->size() + 14 + __right_->size(); |
| 5397 | return __cached_size_; |
| 5398 | } |
| 5399 | virtual char* first_demangled_name(char* buf) const |
| 5400 | { |
| 5401 | strncpy(buf, "const_cast<", 11); |
| 5402 | buf += 11; |
| 5403 | buf = __left_->get_demangled_name(buf); |
| 5404 | *buf++ = '>'; |
| 5405 | *buf++ = '('; |
| 5406 | buf = __right_->get_demangled_name(buf); |
| 5407 | *buf++ = ')'; |
| 5408 | return buf; |
| 5409 | } |
| 5410 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 5411 | { |
| 5412 | const ptrdiff_t r = l - f; |
| 5413 | const ptrdiff_t n1 = sizeof("const_cast<>()") - 1; |
| 5414 | if (r < n1) |
| 5415 | return n1 + __left_->print(l, l) + __right_->print(l, l); |
| 5416 | ptrdiff_t sz1 = __left_->print(f+(n1-3), l); |
| 5417 | if (r < n1 + sz1) |
| 5418 | return n1 + sz1 + __right_->print(l, l); |
| 5419 | ptrdiff_t sz2 = __right_->print(f+sz1+(n1-1), l); |
| 5420 | if (r >= n1 + sz1 + sz2) |
| 5421 | { |
| 5422 | *f++ = 'c'; |
| 5423 | *f++ = 'o'; |
| 5424 | *f++ = 'n'; |
| 5425 | *f++ = 's'; |
| 5426 | *f++ = 't'; |
| 5427 | *f++ = '_'; |
| 5428 | *f++ = 'c'; |
| 5429 | *f++ = 'a'; |
| 5430 | *f++ = 's'; |
| 5431 | *f++ = 't'; |
| 5432 | *f = '<'; |
| 5433 | f += 1+sz1; |
| 5434 | *f++ = '>'; |
| 5435 | *f = '('; |
| 5436 | f += 1+sz2; |
| 5437 | *f = ')'; |
| 5438 | } |
| 5439 | return n1 + sz1 + sz2; |
| 5440 | } |
| 5441 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 5442 | { |
| 5443 | return __left_->fix_forward_references(t_begin, t_end) && |
| 5444 | __right_->fix_forward_references(t_begin, t_end); |
| 5445 | } |
| 5446 | }; |
| 5447 | |
| 5448 | class __dynamic_cast |
| 5449 | : public __node |
| 5450 | { |
| 5451 | public: |
| 5452 | |
| 5453 | __dynamic_cast(__node* op1, __node* op2) |
| 5454 | { |
| 5455 | __left_ = op1; |
| 5456 | __right_ = op2; |
| 5457 | } |
| 5458 | virtual size_t first_size() const |
| 5459 | { |
| 5460 | if (__cached_size_ == -1) |
| 5461 | const_cast<long&>(__cached_size_) = __left_->size() + 16 + __right_->size(); |
| 5462 | return __cached_size_; |
| 5463 | } |
| 5464 | virtual char* first_demangled_name(char* buf) const |
| 5465 | { |
| 5466 | strncpy(buf, "dynamic_cast<", 13); |
| 5467 | buf += 13; |
| 5468 | buf = __left_->get_demangled_name(buf); |
| 5469 | *buf++ = '>'; |
| 5470 | *buf++ = '('; |
| 5471 | buf = __right_->get_demangled_name(buf); |
| 5472 | *buf++ = ')'; |
| 5473 | return buf; |
| 5474 | } |
| 5475 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 5476 | { |
| 5477 | const ptrdiff_t r = l - f; |
| 5478 | const ptrdiff_t n1 = sizeof("dynamic_cast<>()") - 1; |
| 5479 | if (r < n1) |
| 5480 | return n1 + __left_->print(l, l) + __right_->print(l, l); |
| 5481 | ptrdiff_t sz1 = __left_->print(f+(n1-3), l); |
| 5482 | if (r < n1 + sz1) |
| 5483 | return n1 + sz1 + __right_->print(l, l); |
| 5484 | ptrdiff_t sz2 = __right_->print(f+sz1+(n1-1), l); |
| 5485 | if (r >= n1 + sz1 + sz2) |
| 5486 | { |
| 5487 | *f++ = 'd'; |
| 5488 | *f++ = 'y'; |
| 5489 | *f++ = 'n'; |
| 5490 | *f++ = 'a'; |
| 5491 | *f++ = 'm'; |
| 5492 | *f++ = 'i'; |
| 5493 | *f++ = 'c'; |
| 5494 | *f++ = '_'; |
| 5495 | *f++ = 'c'; |
| 5496 | *f++ = 'a'; |
| 5497 | *f++ = 's'; |
| 5498 | *f++ = 't'; |
| 5499 | *f = '<'; |
| 5500 | f += 1+sz1; |
| 5501 | *f++ = '>'; |
| 5502 | *f = '('; |
| 5503 | f += 1+sz2; |
| 5504 | *f = ')'; |
| 5505 | } |
| 5506 | return n1 + sz1 + sz2; |
| 5507 | } |
| 5508 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 5509 | { |
| 5510 | return __left_->fix_forward_references(t_begin, t_end) && |
| 5511 | __right_->fix_forward_references(t_begin, t_end); |
| 5512 | } |
| 5513 | }; |
| 5514 | |
| 5515 | class __reinterpret_cast |
| 5516 | : public __node |
| 5517 | { |
| 5518 | public: |
| 5519 | |
| 5520 | __reinterpret_cast(__node* op1, __node* op2) |
| 5521 | { |
| 5522 | __left_ = op1; |
| 5523 | __right_ = op2; |
| 5524 | } |
| 5525 | virtual size_t first_size() const |
| 5526 | { |
| 5527 | if (__cached_size_ == -1) |
| 5528 | const_cast<long&>(__cached_size_) = __left_->size() + 20 + __right_->size(); |
| 5529 | return __cached_size_; |
| 5530 | } |
| 5531 | virtual char* first_demangled_name(char* buf) const |
| 5532 | { |
| 5533 | strncpy(buf, "reinterpret_cast<", 17); |
| 5534 | buf += 17; |
| 5535 | buf = __left_->get_demangled_name(buf); |
| 5536 | *buf++ = '>'; |
| 5537 | *buf++ = '('; |
| 5538 | buf = __right_->get_demangled_name(buf); |
| 5539 | *buf++ = ')'; |
| 5540 | return buf; |
| 5541 | } |
| 5542 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 5543 | { |
| 5544 | const ptrdiff_t r = l - f; |
| 5545 | const ptrdiff_t n1 = sizeof("reinterpret_cast<>()") - 1; |
| 5546 | if (r < n1) |
| 5547 | return n1 + __left_->print(l, l) + __right_->print(l, l); |
| 5548 | ptrdiff_t sz1 = __left_->print(f+(n1-3), l); |
| 5549 | if (r < n1 + sz1) |
| 5550 | return n1 + sz1 + __right_->print(l, l); |
| 5551 | ptrdiff_t sz2 = __right_->print(f+sz1+(n1-1), l); |
| 5552 | if (r >= n1 + sz1 + sz2) |
| 5553 | { |
| 5554 | *f++ = 'r'; |
| 5555 | *f++ = 'e'; |
| 5556 | *f++ = 'i'; |
| 5557 | *f++ = 'n'; |
| 5558 | *f++ = 't'; |
| 5559 | *f++ = 'e'; |
| 5560 | *f++ = 'r'; |
| 5561 | *f++ = 'p'; |
| 5562 | *f++ = 'r'; |
| 5563 | *f++ = 'e'; |
| 5564 | *f++ = 't'; |
| 5565 | *f++ = '_'; |
| 5566 | *f++ = 'c'; |
| 5567 | *f++ = 'a'; |
| 5568 | *f++ = 's'; |
| 5569 | *f++ = 't'; |
| 5570 | *f = '<'; |
| 5571 | f += 1+sz1; |
| 5572 | *f++ = '>'; |
| 5573 | *f = '('; |
| 5574 | f += 1+sz2; |
| 5575 | *f = ')'; |
| 5576 | } |
| 5577 | return n1 + sz1 + sz2; |
| 5578 | } |
| 5579 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 5580 | { |
| 5581 | return __left_->fix_forward_references(t_begin, t_end) && |
| 5582 | __right_->fix_forward_references(t_begin, t_end); |
| 5583 | } |
| 5584 | }; |
| 5585 | |
| 5586 | class __static_cast |
| 5587 | : public __node |
| 5588 | { |
| 5589 | public: |
| 5590 | |
| 5591 | __static_cast(__node* op1, __node* op2) |
| 5592 | { |
| 5593 | __left_ = op1; |
| 5594 | __right_ = op2; |
| 5595 | } |
| 5596 | virtual size_t first_size() const |
| 5597 | { |
| 5598 | if (__cached_size_ == -1) |
| 5599 | const_cast<long&>(__cached_size_) = __left_->size() + 15 + __right_->size(); |
| 5600 | return __cached_size_; |
| 5601 | } |
| 5602 | virtual char* first_demangled_name(char* buf) const |
| 5603 | { |
| 5604 | strncpy(buf, "static_cast<", 12); |
| 5605 | buf += 12; |
| 5606 | buf = __left_->get_demangled_name(buf); |
| 5607 | *buf++ = '>'; |
| 5608 | *buf++ = '('; |
| 5609 | buf = __right_->get_demangled_name(buf); |
| 5610 | *buf++ = ')'; |
| 5611 | return buf; |
| 5612 | } |
| 5613 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 5614 | { |
| 5615 | const ptrdiff_t r = l - f; |
| 5616 | const ptrdiff_t n1 = sizeof("static_cast<>()") - 1; |
| 5617 | if (r < n1) |
| 5618 | return n1 + __left_->print(l, l) + __right_->print(l, l); |
| 5619 | ptrdiff_t sz1 = __left_->print(f+(n1-3), l); |
| 5620 | if (r < n1 + sz1) |
| 5621 | return n1 + sz1 + __right_->print(l, l); |
| 5622 | ptrdiff_t sz2 = __right_->print(f+sz1+(n1-1), l); |
| 5623 | if (r >= n1 + sz1 + sz2) |
| 5624 | { |
| 5625 | *f++ = 's'; |
| 5626 | *f++ = 't'; |
| 5627 | *f++ = 'a'; |
| 5628 | *f++ = 't'; |
| 5629 | *f++ = 'i'; |
| 5630 | *f++ = 'c'; |
| 5631 | *f++ = '_'; |
| 5632 | *f++ = 'c'; |
| 5633 | *f++ = 'a'; |
| 5634 | *f++ = 's'; |
| 5635 | *f++ = 't'; |
| 5636 | *f = '<'; |
| 5637 | f += 1+sz1; |
| 5638 | *f++ = '>'; |
| 5639 | *f = '('; |
| 5640 | f += 1+sz2; |
| 5641 | *f = ')'; |
| 5642 | } |
| 5643 | return n1 + sz1 + sz2; |
| 5644 | } |
| 5645 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 5646 | { |
| 5647 | return __left_->fix_forward_references(t_begin, t_end) && |
| 5648 | __right_->fix_forward_references(t_begin, t_end); |
| 5649 | } |
| 5650 | }; |
| 5651 | |
| 5652 | class __call_expr |
| 5653 | : public __node |
| 5654 | { |
| 5655 | public: |
| 5656 | |
| 5657 | __call_expr(__node* op1, __node* op2) |
| 5658 | { |
| 5659 | __left_ = op1; |
| 5660 | __right_ = op2; |
| 5661 | } |
| 5662 | virtual size_t first_size() const |
| 5663 | { |
| 5664 | if (__cached_size_ == -1) |
| 5665 | { |
| 5666 | size_t off = __left_->size() + 2; |
| 5667 | if (__right_) |
| 5668 | off += __right_->size(); |
| 5669 | const_cast<long&>(__cached_size_) = off; |
| 5670 | } |
| 5671 | return __cached_size_; |
| 5672 | } |
| 5673 | virtual char* first_demangled_name(char* buf) const |
| 5674 | { |
| 5675 | buf = __left_->get_demangled_name(buf); |
| 5676 | *buf++ = '('; |
| 5677 | if (__right_) |
| 5678 | buf = __right_->get_demangled_name(buf); |
| 5679 | *buf++ = ')'; |
| 5680 | return buf; |
| 5681 | } |
| 5682 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 5683 | { |
| 5684 | const ptrdiff_t r = l - f; |
| 5685 | const ptrdiff_t n1 = sizeof("()") - 1; |
| 5686 | if (r < n1) |
| 5687 | return n1 + __left_->print(l, l) + (__right_ ? __right_->print(l, l) : 0); |
| 5688 | ptrdiff_t sz1 = __left_->print(f, l); |
| 5689 | if (r < n1 + sz1) |
| 5690 | return n1 + sz1 + (__right_ ? __right_->print(l, l) : 0); |
| 5691 | ptrdiff_t sz2 = __right_ ? __right_->print(f+sz1+1, l) : 0; |
| 5692 | if (r >= n1 + sz1 + sz2) |
| 5693 | { |
| 5694 | f += sz1; |
| 5695 | *f = '('; |
| 5696 | f += 1+sz2; |
| 5697 | *f = ')'; |
| 5698 | } |
| 5699 | return n1 + sz1 + sz2; |
| 5700 | } |
| 5701 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 5702 | { |
| 5703 | bool r = __left_->fix_forward_references(t_begin, t_end); |
| 5704 | if (__right_) |
| 5705 | r = r && __right_->fix_forward_references(t_begin, t_end); |
| 5706 | return r; |
| 5707 | } |
| 5708 | }; |
| 5709 | |
| 5710 | class __delete_array_expr |
| 5711 | : public __node |
| 5712 | { |
| 5713 | public: |
| 5714 | |
| 5715 | __delete_array_expr(bool global, __node* op) |
| 5716 | { |
| 5717 | __size_ = global; |
| 5718 | __right_ = op; |
| 5719 | } |
| 5720 | virtual size_t first_size() const |
| 5721 | { |
| 5722 | if (__cached_size_ == -1) |
| 5723 | const_cast<long&>(__cached_size_) = (__size_ ? 2 : 0) + 9 + __right_->size(); |
| 5724 | return __cached_size_; |
| 5725 | } |
| 5726 | virtual char* first_demangled_name(char* buf) const |
| 5727 | { |
| 5728 | if (__size_) |
| 5729 | { |
| 5730 | *buf++ = ':'; |
| 5731 | *buf++ = ':'; |
| 5732 | } |
| 5733 | strncpy(buf, "delete[] ", 9); |
| 5734 | return __right_->get_demangled_name(buf+9); |
| 5735 | } |
| 5736 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 5737 | { |
| 5738 | const ptrdiff_t r = l - f; |
| 5739 | const ptrdiff_t n1 = sizeof("delete[] ") - 1 + (__size_ ? 2 : 0); |
| 5740 | if (r < n1) |
| 5741 | return n1 + __right_->print(l, l); |
| 5742 | ptrdiff_t sz1 = __right_->print(f+n1, l); |
| 5743 | if (r >= n1 + sz1) |
| 5744 | { |
| 5745 | if (__size_) |
| 5746 | { |
| 5747 | *f++ = ':'; |
| 5748 | *f++ = ':'; |
| 5749 | } |
| 5750 | *f++ = 'd'; |
| 5751 | *f++ = 'e'; |
| 5752 | *f++ = 'l'; |
| 5753 | *f++ = 'e'; |
| 5754 | *f++ = 't'; |
| 5755 | *f++ = 'e'; |
| 5756 | *f++ = '['; |
| 5757 | *f++ = ']'; |
| 5758 | *f = ' '; |
| 5759 | } |
| 5760 | return n1 + sz1; |
| 5761 | } |
| 5762 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 5763 | { |
| 5764 | return __right_->fix_forward_references(t_begin, t_end); |
| 5765 | } |
| 5766 | }; |
| 5767 | |
| 5768 | class __delete_expr |
| 5769 | : public __node |
| 5770 | { |
| 5771 | public: |
| 5772 | |
| 5773 | __delete_expr(bool global, __node* op) |
| 5774 | { |
| 5775 | __size_ = global; |
| 5776 | __right_ = op; |
| 5777 | } |
| 5778 | virtual size_t first_size() const |
| 5779 | { |
| 5780 | if (__cached_size_ == -1) |
| 5781 | const_cast<long&>(__cached_size_) = (__size_ ? 2 : 0) + 7 + __right_->size(); |
| 5782 | return __cached_size_; |
| 5783 | } |
| 5784 | virtual char* first_demangled_name(char* buf) const |
| 5785 | { |
| 5786 | if (__size_) |
| 5787 | { |
| 5788 | *buf++ = ':'; |
| 5789 | *buf++ = ':'; |
| 5790 | } |
| 5791 | strncpy(buf, "delete ", 7); |
| 5792 | return __right_->get_demangled_name(buf+7); |
| 5793 | } |
| 5794 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 5795 | { |
| 5796 | const ptrdiff_t r = l - f; |
| 5797 | const ptrdiff_t n1 = sizeof("delete ") - 1 + (__size_ ? 2 : 0); |
| 5798 | if (r < n1) |
| 5799 | return n1 + __right_->print(l, l); |
| 5800 | ptrdiff_t sz1 = __right_->print(f+n1, l); |
| 5801 | if (r >= n1 + sz1) |
| 5802 | { |
| 5803 | if (__size_) |
| 5804 | { |
| 5805 | *f++ = ':'; |
| 5806 | *f++ = ':'; |
| 5807 | } |
| 5808 | *f++ = 'd'; |
| 5809 | *f++ = 'e'; |
| 5810 | *f++ = 'l'; |
| 5811 | *f++ = 'e'; |
| 5812 | *f++ = 't'; |
| 5813 | *f++ = 'e'; |
| 5814 | *f = ' '; |
| 5815 | } |
| 5816 | return n1 + sz1; |
| 5817 | } |
| 5818 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 5819 | { |
| 5820 | return __right_->fix_forward_references(t_begin, t_end); |
| 5821 | } |
| 5822 | }; |
| 5823 | |
| 5824 | class __new_expr |
| 5825 | : public __node |
| 5826 | { |
| 5827 | public: |
| 5828 | |
| 5829 | __new_expr(bool global, bool is_array, bool has_init, |
| 5830 | __node* expr, __node* type, __node* init) |
| 5831 | { |
| 5832 | __size_ = (unsigned)global | |
| 5833 | ((unsigned)is_array << 1) | |
| 5834 | ((unsigned)has_init << 2); |
| 5835 | __left_ = expr; |
| 5836 | __name_ = (const char*)type; |
| 5837 | __right_ = init; |
| 5838 | } |
| 5839 | virtual size_t first_size() const |
| 5840 | { |
| 5841 | if (__cached_size_ == -1) |
| 5842 | { |
| 5843 | size_t off = 4; |
| 5844 | if (__size_ & 1) |
| 5845 | off += 2; |
| 5846 | if (__size_ & 2) |
| 5847 | off += 2; |
| 5848 | if (__left_) |
| 5849 | { |
| 5850 | off += 2; |
| 5851 | off += __left_->size(); |
| 5852 | } |
| 5853 | __node* type = (__node*)__name_; |
| 5854 | off += type->size(); |
| 5855 | if (__size_ & 4) |
| 5856 | { |
| 5857 | off += 2; |
| 5858 | if (__right_) |
| 5859 | off += __right_->size(); |
| 5860 | } |
| 5861 | const_cast<long&>(__cached_size_) = off; |
| 5862 | } |
| 5863 | return __cached_size_; |
| 5864 | } |
| 5865 | virtual char* first_demangled_name(char* buf) const |
| 5866 | { |
| 5867 | if (__size_ & 1) |
| 5868 | { |
| 5869 | *buf++ = ':'; |
| 5870 | *buf++ = ':'; |
| 5871 | } |
| 5872 | *buf++ = 'n'; |
| 5873 | *buf++ = 'e'; |
| 5874 | *buf++ = 'w'; |
| 5875 | if (__size_ & 2) |
| 5876 | { |
| 5877 | *buf++ = '['; |
| 5878 | *buf++ = ']'; |
| 5879 | } |
| 5880 | if (__left_) |
| 5881 | { |
| 5882 | *buf++ = '('; |
| 5883 | buf = __left_->get_demangled_name(buf); |
| 5884 | *buf++ = ')'; |
| 5885 | } |
| 5886 | *buf++ = ' '; |
| 5887 | __node* type = (__node*)__name_; |
| 5888 | buf = type->get_demangled_name(buf); |
| 5889 | if (__size_ & 4) |
| 5890 | { |
| 5891 | *buf++ = '('; |
| 5892 | if (__right_) |
| 5893 | buf = __right_->get_demangled_name(buf); |
| 5894 | *buf++ = ')'; |
| 5895 | } |
| 5896 | return buf; |
| 5897 | } |
| 5898 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 5899 | { |
| 5900 | const ptrdiff_t r = l - f; |
| 5901 | const ptrdiff_t n1 = sizeof("new ") - 1 + (__size_ & 1 ? 2 : 0) + |
| 5902 | (__size_ & 2 ? 2 : 0) + (__left_ ? 2 : 0) + (__size_ & 4 ? 2 : 0); |
| 5903 | __node* type = (__node*)__name_; |
| 5904 | if (r < n1) |
| 5905 | return n1 + (__left_ ? __left_->print(l, l) : 0) + |
| 5906 | type->print(l, l) + |
| 5907 | (__right_ ? __right_->print(l, l) : 0); |
| 5908 | ptrdiff_t sz1 = __left_ ? __left_->print(f+4+ |
| 5909 | (__size_ & 1 ? 2 : 0) + |
| 5910 | (__size_ & 2 ? 2 : 0), l) : 0; |
| 5911 | if (r < n1 + sz1) |
| 5912 | return n1 + sz1 + type->print(l, l) + |
| 5913 | (__right_ ? __right_->print(l, l) : 0); |
| 5914 | ptrdiff_t sz2 = type->print(f+(n1-(__size_ & 4 ? 2 : 0)+sz1), l); |
| 5915 | if (r < n1 + sz1 + sz2) |
| 5916 | return n1 + sz1 + sz2 + (__right_ ? __right_->print(l, l) : 0); |
| 5917 | ptrdiff_t sz3 = __right_ ? __right_->print(f+(n1-1)+sz1+sz2, l) : 0; |
| 5918 | if (r >= n1 + sz1 + sz2 + sz3) |
| 5919 | { |
| 5920 | if (__size_ & 1) |
| 5921 | { |
| 5922 | *f++ = ':'; |
| 5923 | *f++ = ':'; |
| 5924 | } |
| 5925 | *f++ = 'n'; |
| 5926 | *f++ = 'e'; |
| 5927 | *f++ = 'w'; |
| 5928 | if (__size_ & 2) |
| 5929 | { |
| 5930 | *f++ = '['; |
| 5931 | *f++ = ']'; |
| 5932 | } |
| 5933 | if (__left_) |
| 5934 | { |
| 5935 | *f = '('; |
| 5936 | f += 1 + sz1; |
| 5937 | *f++ = ')'; |
| 5938 | } |
| 5939 | *f = ' '; |
| 5940 | if (__size_ & 4) |
| 5941 | { |
| 5942 | f += 1 + sz2; |
| 5943 | *f = '('; |
| 5944 | f += 1 + sz3; |
| 5945 | *f = ')'; |
| 5946 | } |
| 5947 | } |
| 5948 | return n1 + sz1 + sz2 + sz3; |
| 5949 | } |
| 5950 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 5951 | { |
| 5952 | __node* type = (__node*)__name_; |
| 5953 | bool r = type->fix_forward_references(t_begin, t_end); |
| 5954 | if (__left_) |
| 5955 | r = r && __left_->fix_forward_references(t_begin, t_end);; |
| 5956 | if (__right_) |
| 5957 | r = r && __right_->fix_forward_references(t_begin, t_end);; |
| 5958 | return r; |
| 5959 | } |
| 5960 | }; |
| 5961 | |
| 5962 | class __dot_star_expr |
| 5963 | : public __node |
| 5964 | { |
| 5965 | public: |
| 5966 | |
| 5967 | __dot_star_expr(__node* op1, __node* op2) |
| 5968 | { |
| 5969 | __left_ = op1; |
| 5970 | __right_ = op2; |
| 5971 | } |
| 5972 | virtual size_t first_size() const |
| 5973 | { |
| 5974 | if (__cached_size_ == -1) |
| 5975 | const_cast<long&>(__cached_size_) = __left_->size() + 2 + __right_->size(); |
| 5976 | return __cached_size_; |
| 5977 | } |
| 5978 | virtual char* first_demangled_name(char* buf) const |
| 5979 | { |
| 5980 | buf = __left_->get_demangled_name(buf); |
| 5981 | *buf++ = '.'; |
| 5982 | *buf++ = '*'; |
| 5983 | return __right_->get_demangled_name(buf); |
| 5984 | } |
| 5985 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 5986 | { |
| 5987 | const ptrdiff_t r = l - f; |
| 5988 | const ptrdiff_t n = sizeof(".*") - 1; |
| 5989 | if (r < n) |
| 5990 | return n + __left_->print(l, l) + __right_->print(l, l); |
| 5991 | ptrdiff_t sz1 = __left_->print(f, l); |
| 5992 | if (r < n + sz1) |
| 5993 | return n + sz1 + __right_->print(l, l); |
| 5994 | ptrdiff_t sz2 = __right_->print(f+sz1+n, l); |
| 5995 | if (r >= n + sz1 + sz2) |
| 5996 | { |
| 5997 | f += sz1; |
| 5998 | *f++ = '.'; |
| 5999 | *f = '*'; |
| 6000 | } |
| 6001 | return n + sz1 + sz2; |
| 6002 | } |
| 6003 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 6004 | { |
| 6005 | return __left_->fix_forward_references(t_begin, t_end) && |
| 6006 | __right_->fix_forward_references(t_begin, t_end); |
| 6007 | } |
| 6008 | }; |
| 6009 | |
| 6010 | class __dot_expr |
| 6011 | : public __node |
| 6012 | { |
| 6013 | public: |
| 6014 | |
| 6015 | __dot_expr(__node* op1, __node* op2) |
| 6016 | { |
| 6017 | __left_ = op1; |
| 6018 | __right_ = op2; |
| 6019 | } |
| 6020 | virtual size_t first_size() const |
| 6021 | { |
| 6022 | if (__cached_size_ == -1) |
| 6023 | const_cast<long&>(__cached_size_) = __left_->size() + 1 + __right_->size(); |
| 6024 | return __cached_size_; |
| 6025 | } |
| 6026 | virtual char* first_demangled_name(char* buf) const |
| 6027 | { |
| 6028 | buf = __left_->get_demangled_name(buf); |
| 6029 | *buf++ = '.'; |
| 6030 | return __right_->get_demangled_name(buf); |
| 6031 | } |
| 6032 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 6033 | { |
| 6034 | const ptrdiff_t r = l - f; |
| 6035 | const ptrdiff_t n = sizeof(".") - 1; |
| 6036 | if (r < n) |
| 6037 | return n + __left_->print(l, l) + __right_->print(l, l); |
| 6038 | ptrdiff_t sz1 = __left_->print(f, l); |
| 6039 | if (r < n + sz1) |
| 6040 | return n + sz1 + __right_->print(l, l); |
| 6041 | ptrdiff_t sz2 = __right_->print(f+sz1+n, l); |
| 6042 | if (r >= n + sz1 + sz2) |
| 6043 | f[sz1] = '.'; |
| 6044 | return n + sz1 + sz2; |
| 6045 | } |
| 6046 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 6047 | { |
| 6048 | return __left_->fix_forward_references(t_begin, t_end) && |
| 6049 | __right_->fix_forward_references(t_begin, t_end); |
| 6050 | } |
| 6051 | }; |
| 6052 | |
| 6053 | class __arrow_expr |
| 6054 | : public __node |
| 6055 | { |
| 6056 | public: |
| 6057 | |
| 6058 | __arrow_expr(__node* op1, __node* op2) |
| 6059 | { |
| 6060 | __left_ = op1; |
| 6061 | __right_ = op2; |
| 6062 | } |
| 6063 | virtual size_t first_size() const |
| 6064 | { |
| 6065 | if (__cached_size_ == -1) |
| 6066 | const_cast<long&>(__cached_size_) = __left_->size() + 2 + __right_->size(); |
| 6067 | return __cached_size_; |
| 6068 | } |
| 6069 | virtual char* first_demangled_name(char* buf) const |
| 6070 | { |
| 6071 | buf = __left_->get_demangled_name(buf); |
| 6072 | *buf++ = '-'; |
| 6073 | *buf++ = '>'; |
| 6074 | return __right_->get_demangled_name(buf); |
| 6075 | } |
| 6076 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 6077 | { |
| 6078 | const ptrdiff_t r = l - f; |
| 6079 | const ptrdiff_t n = sizeof("->") - 1; |
| 6080 | if (r < n) |
| 6081 | return n + __left_->print(l, l) + __right_->print(l, l); |
| 6082 | ptrdiff_t sz1 = __left_->print(f, l); |
| 6083 | if (r < n + sz1) |
| 6084 | return n + sz1 + __right_->print(l, l); |
| 6085 | ptrdiff_t sz2 = __right_->print(f+sz1+n, l); |
| 6086 | if (r >= n + sz1 + sz2) |
| 6087 | { |
| 6088 | f += sz1; |
| 6089 | *f++ = '-'; |
| 6090 | *f = '>'; |
| 6091 | } |
| 6092 | return n + sz1 + sz2; |
| 6093 | } |
| 6094 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 6095 | { |
| 6096 | return __left_->fix_forward_references(t_begin, t_end) && |
| 6097 | __right_->fix_forward_references(t_begin, t_end); |
| 6098 | } |
| 6099 | }; |
| 6100 | |
| 6101 | class __std_qualified_name |
| 6102 | : public __node |
| 6103 | { |
| 6104 | static const ptrdiff_t n = sizeof("std") - 1; |
| 6105 | public: |
| 6106 | |
| 6107 | __std_qualified_name() |
| 6108 | { |
| 6109 | } |
| 6110 | virtual size_t first_size() const |
| 6111 | { |
| 6112 | return n; |
| 6113 | } |
| 6114 | |
| 6115 | virtual char* first_demangled_name(char* buf) const |
| 6116 | { |
| 6117 | *buf++ = 's'; |
| 6118 | *buf++ = 't'; |
| 6119 | *buf++ = 'd'; |
| 6120 | return buf; |
| 6121 | } |
| 6122 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 6123 | { |
| 6124 | const ptrdiff_t r = l - f; |
| 6125 | if (r >= n) |
| 6126 | { |
| 6127 | *f++ = 's'; |
| 6128 | *f++ = 't'; |
| 6129 | *f = 'd'; |
| 6130 | } |
| 6131 | return n; |
| 6132 | } |
| 6133 | }; |
| 6134 | |
| 6135 | class __sub_allocator |
| 6136 | : public __node |
| 6137 | { |
| 6138 | static const ptrdiff_t n = sizeof("std::allocator") - 1; |
| 6139 | public: |
| 6140 | |
| 6141 | virtual size_t first_size() const |
| 6142 | { |
| 6143 | return n; |
| 6144 | } |
| 6145 | virtual char* first_demangled_name(char* buf) const |
| 6146 | { |
| 6147 | strncpy(buf, "std::allocator", n); |
| 6148 | return buf + n; |
| 6149 | } |
| 6150 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 6151 | { |
| 6152 | const ptrdiff_t r = l - f; |
| 6153 | if (r >= n) |
| 6154 | { |
| 6155 | *f++ = 's'; |
| 6156 | *f++ = 't'; |
| 6157 | *f++ = 'd'; |
| 6158 | *f++ = ':'; |
| 6159 | *f++ = ':'; |
| 6160 | *f++ = 'a'; |
| 6161 | *f++ = 'l'; |
| 6162 | *f++ = 'l'; |
| 6163 | *f++ = 'o'; |
| 6164 | *f++ = 'c'; |
| 6165 | *f++ = 'a'; |
| 6166 | *f++ = 't'; |
| 6167 | *f++ = 'o'; |
| 6168 | *f = 'r'; |
| 6169 | } |
| 6170 | return n; |
| 6171 | } |
| 6172 | }; |
| 6173 | |
| 6174 | class __sub_basic_string |
| 6175 | : public __node |
| 6176 | { |
| 6177 | static const ptrdiff_t n = sizeof("std::basic_string") - 1; |
| 6178 | public: |
| 6179 | |
| 6180 | virtual size_t first_size() const |
| 6181 | { |
| 6182 | return n; |
| 6183 | } |
| 6184 | virtual char* first_demangled_name(char* buf) const |
| 6185 | { |
| 6186 | strncpy(buf, "std::basic_string", n); |
| 6187 | return buf + n; |
| 6188 | } |
| 6189 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 6190 | { |
| 6191 | const ptrdiff_t r = l - f; |
| 6192 | if (r >= n) |
| 6193 | { |
| 6194 | *f++ = 's'; |
| 6195 | *f++ = 't'; |
| 6196 | *f++ = 'd'; |
| 6197 | *f++ = ':'; |
| 6198 | *f++ = ':'; |
| 6199 | *f++ = 'b'; |
| 6200 | *f++ = 'a'; |
| 6201 | *f++ = 's'; |
| 6202 | *f++ = 'i'; |
| 6203 | *f++ = 'c'; |
| 6204 | *f++ = '_'; |
| 6205 | *f++ = 's'; |
| 6206 | *f++ = 't'; |
| 6207 | *f++ = 'r'; |
| 6208 | *f++ = 'i'; |
| 6209 | *f++ = 'n'; |
| 6210 | *f = 'g'; |
| 6211 | } |
| 6212 | return n; |
| 6213 | } |
| 6214 | }; |
| 6215 | |
| 6216 | class __sub_string |
| 6217 | : public __node |
| 6218 | { |
| 6219 | static const size_t n = sizeof("std::string") - 1; |
| 6220 | static const size_t ne = sizeof("std::basic_string<char, std::char_traits<char>, std::allocator<char> >") - 1; |
| 6221 | public: |
| 6222 | |
| 6223 | virtual size_t first_size() const |
| 6224 | { |
| 6225 | if (__size_) |
| 6226 | return ne; |
| 6227 | return n; |
| 6228 | } |
| 6229 | virtual char* first_demangled_name(char* buf) const |
| 6230 | { |
| 6231 | if (__size_) |
| 6232 | { |
| 6233 | strncpy(buf, "std::basic_string<char, std::char_traits<char>, std::allocator<char> >", ne); |
| 6234 | buf += ne; |
| 6235 | } |
| 6236 | else |
| 6237 | { |
| 6238 | strncpy(buf, "std::string", n); |
| 6239 | buf += n; |
| 6240 | } |
| 6241 | return buf; |
| 6242 | } |
| 6243 | |
| 6244 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 6245 | { |
| 6246 | const ptrdiff_t r = l - f; |
| 6247 | if (__size_) |
| 6248 | { |
| 6249 | const ptrdiff_t n1 = |
| 6250 | sizeof("std::basic_string<char, std::char_traits<char>," |
| 6251 | " std::allocator<char> >") - 1; |
| 6252 | if (r >= n1) |
| 6253 | strncpy(f, "std::basic_string<char, std::char_traits<char>," |
| 6254 | " std::allocator<char> >", n1); |
| 6255 | return n1; |
| 6256 | } |
| 6257 | const ptrdiff_t n2 = sizeof("std::string") - 1; |
| 6258 | if (r >= n2) |
| 6259 | { |
| 6260 | *f++ = 's'; |
| 6261 | *f++ = 't'; |
| 6262 | *f++ = 'd'; |
| 6263 | *f++ = ':'; |
| 6264 | *f++ = ':'; |
| 6265 | *f++ = 's'; |
| 6266 | *f++ = 't'; |
| 6267 | *f++ = 'r'; |
| 6268 | *f++ = 'i'; |
| 6269 | *f++ = 'n'; |
| 6270 | *f = 'g'; |
| 6271 | } |
| 6272 | return n2; |
| 6273 | } |
| 6274 | virtual size_t base_size() const |
| 6275 | { |
| 6276 | return 12; |
| 6277 | } |
| 6278 | virtual char* get_base_name(char* buf) const |
| 6279 | { |
| 6280 | strncpy(buf, "basic_string", 12); |
| 6281 | return buf + 12; |
| 6282 | } |
| 6283 | virtual ptrdiff_t print_base_name(char* f, char* l) const |
| 6284 | { |
| 6285 | const ptrdiff_t r = l - f; |
| 6286 | const ptrdiff_t n = sizeof("basic_string") - 1; |
| 6287 | if (r >= n) |
| 6288 | { |
| 6289 | *f++ = 'b'; |
| 6290 | *f++ = 'a'; |
| 6291 | *f++ = 's'; |
| 6292 | *f++ = 'i'; |
| 6293 | *f++ = 'c'; |
| 6294 | *f++ = '_'; |
| 6295 | *f++ = 's'; |
| 6296 | *f++ = 't'; |
| 6297 | *f++ = 'r'; |
| 6298 | *f++ = 'i'; |
| 6299 | *f++ = 'n'; |
| 6300 | *f = 'g'; |
| 6301 | } |
| 6302 | return n; |
| 6303 | } |
| 6304 | |
| 6305 | virtual __node* base_name() const |
| 6306 | { |
| 6307 | const_cast<size_t&>(__size_) = true; |
| 6308 | return const_cast<__node*>(static_cast<const __node*>(this)); |
| 6309 | } |
| 6310 | }; |
| 6311 | |
| 6312 | class __sub_istream |
| 6313 | : public __node |
| 6314 | { |
| 6315 | static const ptrdiff_t n = sizeof("std::istream") - 1; |
| 6316 | public: |
| 6317 | |
| 6318 | virtual size_t first_size() const {return n;} |
| 6319 | virtual char* first_demangled_name(char* buf) const |
| 6320 | { |
| 6321 | strncpy(buf, "std::istream", n); |
| 6322 | return buf + n; |
| 6323 | } |
| 6324 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 6325 | { |
| 6326 | const ptrdiff_t r = l - f; |
| 6327 | if (r >= n) |
| 6328 | { |
| 6329 | *f++ = 's'; |
| 6330 | *f++ = 't'; |
| 6331 | *f++ = 'd'; |
| 6332 | *f++ = ':'; |
| 6333 | *f++ = ':'; |
| 6334 | *f++ = 'i'; |
| 6335 | *f++ = 's'; |
| 6336 | *f++ = 't'; |
| 6337 | *f++ = 'r'; |
| 6338 | *f++ = 'e'; |
| 6339 | *f++ = 'a'; |
| 6340 | *f = 'm'; |
| 6341 | } |
| 6342 | return n; |
| 6343 | } |
| 6344 | }; |
| 6345 | |
| 6346 | class __sub_ostream |
| 6347 | : public __node |
| 6348 | { |
| 6349 | static const ptrdiff_t n = sizeof("std::ostream") - 1; |
| 6350 | public: |
| 6351 | |
| 6352 | virtual size_t first_size() const {return n;} |
| 6353 | virtual char* first_demangled_name(char* buf) const |
| 6354 | { |
| 6355 | strncpy(buf, "std::ostream", n); |
| 6356 | return buf + n; |
| 6357 | } |
| 6358 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 6359 | { |
| 6360 | const ptrdiff_t r = l - f; |
| 6361 | if (r >= n) |
| 6362 | { |
| 6363 | *f++ = 's'; |
| 6364 | *f++ = 't'; |
| 6365 | *f++ = 'd'; |
| 6366 | *f++ = ':'; |
| 6367 | *f++ = ':'; |
| 6368 | *f++ = 'o'; |
| 6369 | *f++ = 's'; |
| 6370 | *f++ = 't'; |
| 6371 | *f++ = 'r'; |
| 6372 | *f++ = 'e'; |
| 6373 | *f++ = 'a'; |
| 6374 | *f = 'm'; |
| 6375 | } |
| 6376 | return n; |
| 6377 | } |
| 6378 | }; |
| 6379 | |
| 6380 | class __sub_iostream |
| 6381 | : public __node |
| 6382 | { |
| 6383 | static const ptrdiff_t n = sizeof("std::iostream") - 1; |
| 6384 | public: |
| 6385 | |
| 6386 | virtual size_t first_size() const {return n;} |
| 6387 | virtual char* first_demangled_name(char* buf) const |
| 6388 | { |
| 6389 | strncpy(buf, "std::iostream", n); |
| 6390 | return buf + n; |
| 6391 | } |
| 6392 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 6393 | { |
| 6394 | const ptrdiff_t r = l - f; |
| 6395 | if (r >= n) |
| 6396 | { |
| 6397 | *f++ = 's'; |
| 6398 | *f++ = 't'; |
| 6399 | *f++ = 'd'; |
| 6400 | *f++ = ':'; |
| 6401 | *f++ = ':'; |
| 6402 | *f++ = 'i'; |
| 6403 | *f++ = 'o'; |
| 6404 | *f++ = 's'; |
| 6405 | *f++ = 't'; |
| 6406 | *f++ = 'r'; |
| 6407 | *f++ = 'e'; |
| 6408 | *f++ = 'a'; |
| 6409 | *f = 'm'; |
| 6410 | } |
| 6411 | return n; |
| 6412 | } |
| 6413 | }; |
| 6414 | |
| 6415 | class __sub |
| 6416 | : public __node |
| 6417 | { |
| 6418 | public: |
| 6419 | |
| 6420 | explicit __sub(__node* arg) |
| 6421 | { |
| 6422 | __left_ = arg; |
| 6423 | } |
| 6424 | explicit __sub(size_t arg) |
| 6425 | { |
| 6426 | __size_ = arg; |
| 6427 | } |
| 6428 | virtual size_t first_size() const |
| 6429 | { |
| 6430 | return __left_->first_size(); |
| 6431 | } |
| 6432 | virtual char* first_demangled_name(char* buf) const |
| 6433 | { |
| 6434 | return __left_->first_demangled_name(buf); |
| 6435 | } |
| 6436 | virtual size_t second_size() const |
| 6437 | { |
| 6438 | return __left_->second_size(); |
| 6439 | } |
| 6440 | virtual char* second_demangled_name(char* buf) const |
| 6441 | { |
| 6442 | return __left_->second_demangled_name(buf); |
| 6443 | } |
| 6444 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 6445 | { |
| 6446 | return __left_->print_first(f, l); |
| 6447 | } |
| 6448 | virtual ptrdiff_t print_second(char* f, char* l) const |
| 6449 | { |
| 6450 | return __left_->print_second(f, l); |
| 6451 | } |
| 6452 | virtual bool ends_with_template() const |
| 6453 | { |
| 6454 | return __left_->ends_with_template(); |
| 6455 | } |
| 6456 | virtual __node* base_name() const |
| 6457 | { |
| 6458 | return __left_->base_name(); |
| 6459 | } |
| 6460 | virtual bool is_reference_or_pointer_to_function_or_array() const |
| 6461 | { |
| 6462 | return __left_->is_reference_or_pointer_to_function_or_array(); |
| 6463 | } |
| 6464 | virtual bool is_function() const |
| 6465 | { |
| 6466 | return __left_->is_function(); |
| 6467 | } |
| 6468 | virtual bool is_cv_qualifer() const |
| 6469 | { |
| 6470 | return __left_->is_cv_qualifer(); |
| 6471 | } |
| 6472 | virtual bool is_ctor_dtor_conv() const |
| 6473 | { |
| 6474 | return __left_->is_ctor_dtor_conv(); |
| 6475 | } |
| 6476 | virtual bool is_array() const |
| 6477 | { |
| 6478 | return __left_->is_array(); |
| 6479 | } |
| 6480 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 6481 | { |
| 6482 | if (__left_ == 0) |
| 6483 | { |
| 6484 | if (__size_ < t_end - t_begin) |
| 6485 | { |
| 6486 | __left_ = t_begin[__size_]; |
| 6487 | __size_ = 0; |
| 6488 | } |
| 6489 | else |
| 6490 | return false; |
| 6491 | } |
| 6492 | return true; |
| 6493 | } |
| 6494 | virtual size_t list_len() const |
| 6495 | { |
| 6496 | return __left_->list_len(); |
| 6497 | } |
| 6498 | virtual bool is_sub() const |
| 6499 | { |
| 6500 | return true; |
| 6501 | } |
| 6502 | }; |
| 6503 | |
| 6504 | class __unscoped_template_name |
| 6505 | : public __node |
| 6506 | { |
| 6507 | public: |
| 6508 | __unscoped_template_name(__node* name, __node* args) |
| 6509 | {__left_ = name; __right_ = args;} |
| 6510 | |
| 6511 | virtual size_t first_size() const |
| 6512 | { |
| 6513 | if (__cached_size_ == -1) |
| 6514 | const_cast<long&>(__cached_size_) = __left_->size() + __right_->size(); |
| 6515 | return __cached_size_; |
| 6516 | } |
| 6517 | virtual char* first_demangled_name(char* buf) const |
| 6518 | { |
| 6519 | buf = __left_->get_demangled_name(buf); |
| 6520 | return __right_->get_demangled_name(buf); |
| 6521 | } |
| 6522 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 6523 | { |
| 6524 | const ptrdiff_t r = l - f; |
| 6525 | ptrdiff_t sz1 = __left_->print(f, l); |
| 6526 | if (r < sz1) |
| 6527 | return sz1 + __right_->print(l, l); |
| 6528 | return sz1 + __right_->print(f + sz1, l); |
| 6529 | } |
| 6530 | virtual bool ends_with_template() const |
| 6531 | { |
| 6532 | return __right_->ends_with_template(); |
| 6533 | } |
| 6534 | virtual __node* base_name() const |
| 6535 | { |
| 6536 | return __left_->base_name(); |
| 6537 | } |
| 6538 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 6539 | { |
| 6540 | return __left_->fix_forward_references(t_begin, t_end) && |
| 6541 | __right_->fix_forward_references(t_begin, t_end); |
| 6542 | } |
| 6543 | }; |
| 6544 | |
| 6545 | // length == 0: __left_ == NULL |
| 6546 | // length == 1: __left_ != NULL, __right_ == NULL |
| 6547 | // length > 1: __left_ != NULL, __right_ != NULL |
| 6548 | class __list |
| 6549 | : public __node |
| 6550 | { |
| 6551 | public: |
| 6552 | explicit __list(__node* type) |
| 6553 | {__left_ = type;} |
| 6554 | |
| 6555 | virtual size_t first_size() const |
| 6556 | { |
| 6557 | if (__cached_size_ == -1) |
| 6558 | { |
| 6559 | if (__left_ == NULL) |
| 6560 | const_cast<long&>(__cached_size_) = 0; |
| 6561 | else if (__right_ == NULL) |
| 6562 | const_cast<long&>(__cached_size_) = __left_->size(); |
| 6563 | else |
| 6564 | { |
| 6565 | size_t off = __right_->size(); |
| 6566 | if (off > 0) |
| 6567 | off += 2; |
| 6568 | const_cast<long&>(__cached_size_) = __left_->size() + off; |
| 6569 | } |
| 6570 | } |
| 6571 | return __cached_size_; |
| 6572 | } |
| 6573 | virtual char* first_demangled_name(char* buf) const |
| 6574 | { |
| 6575 | if (__left_ != NULL) |
| 6576 | { |
| 6577 | char* t = __left_->get_demangled_name(buf + (__size_ ? 2 : 0)); |
| 6578 | if (__size_ == 0) |
| 6579 | buf = t; |
| 6580 | else if (t != buf+2) |
| 6581 | { |
| 6582 | *buf++ = ','; |
| 6583 | *buf++ = ' '; |
| 6584 | buf = t; |
| 6585 | } |
| 6586 | if (__right_) |
| 6587 | buf = __right_->get_demangled_name(buf); |
| 6588 | } |
| 6589 | return buf; |
| 6590 | } |
| 6591 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 6592 | { |
| 6593 | if (__left_ == 0) |
| 6594 | return 0; |
| 6595 | const ptrdiff_t r = l - f; |
| 6596 | ptrdiff_t n = 0; |
| 6597 | if (__size_) |
| 6598 | { |
| 6599 | n = 2; |
| 6600 | if (r < n) |
| 6601 | { |
| 6602 | ptrdiff_t sz1 = __left_->print(l, l); |
| 6603 | if (sz1 == 0) |
| 6604 | n = 0; |
| 6605 | return n + sz1 + (__right_ ? __right_->print(l, l) : 0); |
| 6606 | } |
| 6607 | } |
| 6608 | const ptrdiff_t sz1 = __left_->print(f+n, l); |
| 6609 | if (sz1 == 0) |
| 6610 | n = 0; |
| 6611 | else if (n != 0) |
| 6612 | { |
| 6613 | f[0] = ','; |
| 6614 | f[1] = ' '; |
| 6615 | } |
| 6616 | const ptrdiff_t sz2 = __right_ ? __right_->print(f+std::min(n+sz1, r), l) : 0; |
| 6617 | return n + sz1 + sz2; |
| 6618 | } |
| 6619 | virtual bool ends_with_template() const |
| 6620 | { |
| 6621 | if (__right_ != NULL) |
| 6622 | return __right_->ends_with_template(); |
| 6623 | if (__left_ != NULL) |
| 6624 | return __left_->ends_with_template(); |
| 6625 | return false; |
| 6626 | } |
| 6627 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 6628 | { |
| 6629 | bool r = true; |
| 6630 | if (__left_) |
| 6631 | r = r && __left_->fix_forward_references(t_begin, t_end); |
| 6632 | if (__right_) |
| 6633 | r = r && __right_->fix_forward_references(t_begin, t_end); |
| 6634 | return r; |
| 6635 | } |
| 6636 | virtual size_t list_len() const |
| 6637 | { |
| 6638 | if (!__left_) |
| 6639 | return 0; |
| 6640 | if (!__right_) |
| 6641 | return 1; |
| 6642 | return 1 + __right_->list_len(); |
| 6643 | } |
| 6644 | }; |
| 6645 | |
| 6646 | class __template_args |
| 6647 | : public __node |
| 6648 | { |
| 6649 | public: |
| 6650 | __template_args(__node* name, __node* list) |
| 6651 | { |
| 6652 | __left_ = name; |
| 6653 | __right_ = list; |
| 6654 | } |
| 6655 | |
| 6656 | virtual size_t first_size() const |
| 6657 | { |
| 6658 | if (__cached_size_ == -1) |
| 6659 | { |
| 6660 | size_t off = 2; |
| 6661 | if (__right_) |
| 6662 | { |
| 6663 | if (__right_->ends_with_template()) |
| 6664 | ++off; |
| 6665 | off += __right_->size(); |
| 6666 | } |
| 6667 | const_cast<long&>(__cached_size_) = __left_->size() + off; |
| 6668 | } |
| 6669 | return __cached_size_; |
| 6670 | } |
| 6671 | virtual char* first_demangled_name(char* buf) const |
| 6672 | { |
| 6673 | buf = __left_->get_demangled_name(buf); |
| 6674 | *buf++ = '<'; |
| 6675 | if (__right_) |
| 6676 | { |
| 6677 | buf = __right_->get_demangled_name(buf); |
| 6678 | if (buf[-1] == '>') |
| 6679 | *buf++ = ' '; |
| 6680 | } |
| 6681 | *buf++ = '>'; |
| 6682 | return buf; |
| 6683 | } |
| 6684 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 6685 | { |
| 6686 | const ptrdiff_t r = l - f; |
| 6687 | const ptrdiff_t sz1 = __left_->print(f, l); |
| 6688 | ptrdiff_t sz2 = 0; |
| 6689 | ptrdiff_t n = 2; |
| 6690 | if (__right_) |
| 6691 | { |
| 6692 | sz2 = __right_->print(f+std::min(sz1+1, r), l); |
| 6693 | if (r >= sz1 + sz2 + 2) |
| 6694 | { |
| 6695 | if (f[sz1+sz2] == '>') |
| 6696 | { |
| 6697 | f[sz1+sz2+1] = ' '; |
| 6698 | ++n; |
| 6699 | } |
| 6700 | } |
| 6701 | else if (__right_->ends_with_template()) |
| 6702 | ++n; |
| 6703 | } |
| 6704 | if (r >= sz1 + sz2 + n) |
| 6705 | { |
| 6706 | f[sz1] = '<'; |
| 6707 | f[sz1+sz2+n-1] = '>'; |
| 6708 | } |
| 6709 | return n + sz1 + sz2; |
| 6710 | } |
| 6711 | |
| 6712 | virtual bool ends_with_template() const |
| 6713 | { |
| 6714 | return true; |
| 6715 | } |
| 6716 | virtual __node* base_name() const |
| 6717 | { |
| 6718 | return __left_->base_name(); |
| 6719 | } |
| 6720 | virtual bool is_ctor_dtor_conv() const |
| 6721 | { |
| 6722 | return __left_->is_ctor_dtor_conv(); |
| 6723 | } |
| 6724 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 6725 | { |
| 6726 | bool r = __left_->fix_forward_references(t_begin, t_end); |
| 6727 | if (__right_) |
| 6728 | r = r && __right_->fix_forward_references(t_begin, t_end); |
| 6729 | return r; |
| 6730 | } |
| 6731 | }; |
| 6732 | |
| 6733 | class __function_args |
| 6734 | : public __node |
| 6735 | { |
| 6736 | public: |
| 6737 | __function_args(__node* list) |
| 6738 | {__right_ = list;} |
| 6739 | |
| 6740 | virtual size_t first_size() const |
| 6741 | { |
| 6742 | if (__cached_size_ == -1) |
| 6743 | const_cast<long&>(__cached_size_) = 2 + __right_->size(); |
| 6744 | return __cached_size_; |
| 6745 | } |
| 6746 | virtual char* first_demangled_name(char* buf) const |
| 6747 | { |
| 6748 | *buf++ = '('; |
| 6749 | buf = __right_->get_demangled_name(buf); |
| 6750 | *buf++ = ')'; |
| 6751 | return buf; |
| 6752 | } |
| 6753 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 6754 | { |
| 6755 | const ptrdiff_t r = l - f; |
| 6756 | const ptrdiff_t n = 2; |
| 6757 | if (r < n) |
| 6758 | return n + __right_->print(l, l); |
| 6759 | ptrdiff_t sz1 = __right_->print(f+1, l); |
| 6760 | if (r >= n + sz1) |
| 6761 | { |
| 6762 | *f = '('; |
| 6763 | f += 1 + sz1; |
| 6764 | *f = ')'; |
| 6765 | } |
| 6766 | return n + sz1; |
| 6767 | } |
| 6768 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 6769 | { |
| 6770 | return __right_->fix_forward_references(t_begin, t_end); |
| 6771 | } |
| 6772 | }; |
| 6773 | |
| 6774 | class __cv_qualifiers |
| 6775 | : public __node |
| 6776 | { |
| 6777 | public: |
| 6778 | __cv_qualifiers(size_t cv, __node* type) |
| 6779 | { |
| 6780 | __left_ = type; |
| 6781 | __size_ = __left_->is_function() ? cv << 5 : cv; |
| 6782 | } |
| 6783 | |
| 6784 | virtual size_t first_size() const |
| 6785 | { |
| 6786 | size_t s = __left_->first_size(); |
| 6787 | if (__size_ & 4) |
| 6788 | s += sizeof(" restrict")-1; |
| 6789 | if (__size_ & 2) |
| 6790 | s += sizeof(" volatile")-1; |
| 6791 | if (__size_ & 1) |
| 6792 | s += sizeof(" const")-1; |
| 6793 | if (__size_ & 8) |
| 6794 | s += sizeof(" &")-1; |
| 6795 | if (__size_ & 16) |
| 6796 | s += sizeof(" &&")-1; |
| 6797 | return s; |
| 6798 | } |
| 6799 | virtual char* first_demangled_name(char* buf) const |
| 6800 | { |
| 6801 | buf = __left_->first_demangled_name(buf); |
| 6802 | if (__size_ & 1) |
| 6803 | { |
| 6804 | const size_t n = sizeof(" const")-1; |
| 6805 | strncpy(buf, " const", n); |
| 6806 | buf += n; |
| 6807 | } |
| 6808 | if (__size_ & 2) |
| 6809 | { |
| 6810 | const size_t n = sizeof(" volatile")-1; |
| 6811 | strncpy(buf, " volatile", n); |
| 6812 | buf += n; |
| 6813 | } |
| 6814 | if (__size_ & 4) |
| 6815 | { |
| 6816 | const size_t n = sizeof(" restrict")-1; |
| 6817 | strncpy(buf, " restrict", n); |
| 6818 | buf += n; |
| 6819 | } |
| 6820 | if (__size_ & 8) |
| 6821 | { |
| 6822 | *buf++ = ' '; |
| 6823 | *buf++ = '&'; |
| 6824 | } |
| 6825 | if (__size_ & 16) |
| 6826 | { |
| 6827 | *buf++ = ' '; |
| 6828 | *buf++ = '&'; |
| 6829 | *buf++ = '&'; |
| 6830 | } |
| 6831 | return buf; |
| 6832 | } |
| 6833 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 6834 | { |
| 6835 | const ptrdiff_t r = l - f; |
| 6836 | const ptrdiff_t sz = __left_->print_first(f, l); |
| 6837 | ptrdiff_t n = 0; |
| 6838 | if (__size_ & 0x1F) |
| 6839 | { |
| 6840 | if (__size_ & 1) |
| 6841 | { |
| 6842 | const ptrdiff_t d = sizeof(" const")-1; |
| 6843 | if (r >= sz + n + d) |
| 6844 | { |
| 6845 | char* t = f + sz + n; |
| 6846 | *t++ = ' '; |
| 6847 | *t++ = 'c'; |
| 6848 | *t++ = 'o'; |
| 6849 | *t++ = 'n'; |
| 6850 | *t++ = 's'; |
| 6851 | *t = 't'; |
| 6852 | } |
| 6853 | n += d; |
| 6854 | } |
| 6855 | if (__size_ & 2) |
| 6856 | { |
| 6857 | const ptrdiff_t d = sizeof(" volatile")-1; |
| 6858 | if (r >= sz + n + d) |
| 6859 | { |
| 6860 | char* t = f + sz + n; |
| 6861 | *t++ = ' '; |
| 6862 | *t++ = 'v'; |
| 6863 | *t++ = 'o'; |
| 6864 | *t++ = 'l'; |
| 6865 | *t++ = 'a'; |
| 6866 | *t++ = 't'; |
| 6867 | *t++ = 'i'; |
| 6868 | *t++ = 'l'; |
| 6869 | *t = 'e'; |
| 6870 | } |
| 6871 | n += d; |
| 6872 | } |
| 6873 | if (__size_ & 4) |
| 6874 | { |
| 6875 | const ptrdiff_t d = sizeof(" restrict")-1; |
| 6876 | if (r >= sz + n + d) |
| 6877 | { |
| 6878 | char* t = f + sz + n; |
| 6879 | *t++ = ' '; |
| 6880 | *t++ = 'r'; |
| 6881 | *t++ = 'e'; |
| 6882 | *t++ = 's'; |
| 6883 | *t++ = 't'; |
| 6884 | *t++ = 'r'; |
| 6885 | *t++ = 'i'; |
| 6886 | *t++ = 'c'; |
| 6887 | *t = 't'; |
| 6888 | } |
| 6889 | n += d; |
| 6890 | } |
| 6891 | if (__size_ & 8) |
| 6892 | { |
| 6893 | const ptrdiff_t d = sizeof(" &")-1; |
| 6894 | if (r >= sz + n + d) |
| 6895 | { |
| 6896 | char* t = f + sz + n; |
| 6897 | *t++ = ' '; |
| 6898 | *t = '&'; |
| 6899 | } |
| 6900 | n += d; |
| 6901 | } |
| 6902 | if (__size_ & 16) |
| 6903 | { |
| 6904 | const ptrdiff_t d = sizeof(" &&")-1; |
| 6905 | if (r >= sz + n + d) |
| 6906 | { |
| 6907 | char* t = f + sz + n; |
| 6908 | *t++ = ' '; |
| 6909 | *t++ = '&'; |
| 6910 | *t = '&'; |
| 6911 | } |
| 6912 | n += d; |
| 6913 | } |
| 6914 | } |
| 6915 | return n + sz; |
| 6916 | } |
| 6917 | virtual size_t second_size() const |
| 6918 | { |
| 6919 | size_t s = __left_->second_size(); |
| 6920 | if (__size_ & 128) |
| 6921 | s += sizeof(" restrict")-1; |
| 6922 | if (__size_ & 64) |
| 6923 | s += sizeof(" volatile")-1; |
| 6924 | if (__size_ & 32) |
| 6925 | s += sizeof(" const")-1; |
| 6926 | if (__size_ & 256) |
| 6927 | s += sizeof(" &")-1; |
| 6928 | if (__size_ & 512) |
| 6929 | s += sizeof(" &&")-1; |
| 6930 | return s; |
| 6931 | } |
| 6932 | virtual char* second_demangled_name(char* buf) const |
| 6933 | { |
| 6934 | buf = __left_->second_demangled_name(buf); |
| 6935 | if (__size_ & 32) |
| 6936 | { |
| 6937 | const size_t n = sizeof(" const")-1; |
| 6938 | strncpy(buf, " const", n); |
| 6939 | buf += n; |
| 6940 | } |
| 6941 | if (__size_ & 64) |
| 6942 | { |
| 6943 | const size_t n = sizeof(" volatile")-1; |
| 6944 | strncpy(buf, " volatile", n); |
| 6945 | buf += n; |
| 6946 | } |
| 6947 | if (__size_ & 128) |
| 6948 | { |
| 6949 | const size_t n = sizeof(" restrict")-1; |
| 6950 | strncpy(buf, " restrict", n); |
| 6951 | buf += n; |
| 6952 | } |
| 6953 | if (__size_ & 256) |
| 6954 | { |
| 6955 | *buf++ = ' '; |
| 6956 | *buf++ = '&'; |
| 6957 | } |
| 6958 | if (__size_ & 512) |
| 6959 | { |
| 6960 | *buf++ = ' '; |
| 6961 | *buf++ = '&'; |
| 6962 | *buf++ = '&'; |
| 6963 | } |
| 6964 | return buf; |
| 6965 | } |
| 6966 | virtual ptrdiff_t print_second(char* f, char* l) const |
| 6967 | { |
| 6968 | const ptrdiff_t r = l - f; |
| 6969 | const ptrdiff_t sz = __left_->print_second(f, l); |
| 6970 | ptrdiff_t n = 0; |
| 6971 | if (__size_ & 0x3E0) |
| 6972 | { |
| 6973 | if (__size_ & 32) |
| 6974 | { |
| 6975 | const ptrdiff_t d = sizeof(" const")-1; |
| 6976 | if (r >= sz + n + d) |
| 6977 | { |
| 6978 | char* t = f + sz + n; |
| 6979 | *t++ = ' '; |
| 6980 | *t++ = 'c'; |
| 6981 | *t++ = 'o'; |
| 6982 | *t++ = 'n'; |
| 6983 | *t++ = 's'; |
| 6984 | *t = 't'; |
| 6985 | } |
| 6986 | n += d; |
| 6987 | } |
| 6988 | if (__size_ & 64) |
| 6989 | { |
| 6990 | const ptrdiff_t d = sizeof(" volatile")-1; |
| 6991 | if (r >= sz + n + d) |
| 6992 | { |
| 6993 | char* t = f + sz + n; |
| 6994 | *t++ = ' '; |
| 6995 | *t++ = 'v'; |
| 6996 | *t++ = 'o'; |
| 6997 | *t++ = 'l'; |
| 6998 | *t++ = 'a'; |
| 6999 | *t++ = 't'; |
| 7000 | *t++ = 'i'; |
| 7001 | *t++ = 'l'; |
| 7002 | *t = 'e'; |
| 7003 | } |
| 7004 | n += d; |
| 7005 | } |
| 7006 | if (__size_ & 128) |
| 7007 | { |
| 7008 | const ptrdiff_t d = sizeof(" restrict")-1; |
| 7009 | if (r >= sz + n + d) |
| 7010 | { |
| 7011 | char* t = f + sz + n; |
| 7012 | *t++ = ' '; |
| 7013 | *t++ = 'r'; |
| 7014 | *t++ = 'e'; |
| 7015 | *t++ = 's'; |
| 7016 | *t++ = 't'; |
| 7017 | *t++ = 'r'; |
| 7018 | *t++ = 'i'; |
| 7019 | *t++ = 'c'; |
| 7020 | *t = 't'; |
| 7021 | } |
| 7022 | n += d; |
| 7023 | } |
| 7024 | if (__size_ & 256) |
| 7025 | { |
| 7026 | const ptrdiff_t d = sizeof(" &")-1; |
| 7027 | if (r >= sz + n + d) |
| 7028 | { |
| 7029 | char* t = f + sz + n; |
| 7030 | *t++ = ' '; |
| 7031 | *t = '&'; |
| 7032 | } |
| 7033 | n += d; |
| 7034 | } |
| 7035 | if (__size_ & 512) |
| 7036 | { |
| 7037 | const ptrdiff_t d = sizeof(" &&")-1; |
| 7038 | if (r >= sz + n + d) |
| 7039 | { |
| 7040 | char* t = f + sz + n; |
| 7041 | *t++ = ' '; |
| 7042 | *t++ = '&'; |
| 7043 | *t = '&'; |
| 7044 | } |
| 7045 | n += d; |
| 7046 | } |
| 7047 | } |
| 7048 | return n + sz; |
| 7049 | } |
| 7050 | virtual __node* base_name() const |
| 7051 | { |
| 7052 | return __left_->base_name(); |
| 7053 | } |
| 7054 | virtual bool is_reference_or_pointer_to_function_or_array() const |
| 7055 | { |
| 7056 | return __left_->is_reference_or_pointer_to_function_or_array(); |
| 7057 | } |
| 7058 | virtual bool is_function() const |
| 7059 | { |
| 7060 | return __left_->is_function(); |
| 7061 | } |
| 7062 | virtual bool is_cv_qualifer() const |
| 7063 | { |
| 7064 | return true; |
| 7065 | } |
| 7066 | virtual __node* extract_cv(__node*& rt) const |
| 7067 | { |
| 7068 | if (rt == this) |
| 7069 | { |
| 7070 | rt = __left_; |
| 7071 | return const_cast<__node*>(static_cast<const __node*>(this)); |
| 7072 | } |
| 7073 | return 0; |
| 7074 | } |
| 7075 | virtual bool ends_with_template() const |
| 7076 | { |
| 7077 | return __left_->ends_with_template(); |
| 7078 | } |
| 7079 | virtual bool is_ctor_dtor_conv() const |
| 7080 | { |
| 7081 | return __left_->is_ctor_dtor_conv(); |
| 7082 | } |
| 7083 | virtual bool is_array() const |
| 7084 | { |
| 7085 | return __left_->is_array(); |
| 7086 | } |
| 7087 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 7088 | { |
| 7089 | return __left_->fix_forward_references(t_begin, t_end); |
| 7090 | } |
| 7091 | virtual size_t list_len() const |
| 7092 | { |
| 7093 | return __left_->list_len(); |
| 7094 | } |
| 7095 | }; |
| 7096 | |
| 7097 | class __extended_qualifier |
| 7098 | : public __node |
| 7099 | { |
| 7100 | public: |
| 7101 | __extended_qualifier(__node* name, __node* type) |
| 7102 | { |
| 7103 | __left_ = type; |
| 7104 | __right_ = name; |
| 7105 | __size_ = __left_->is_function() ? 1 : 0; |
| 7106 | } |
| 7107 | |
| 7108 | virtual size_t first_size() const |
| 7109 | { |
| 7110 | size_t s = __left_->first_size(); |
| 7111 | if (__size_ == 0) |
| 7112 | s += __right_->size() + 1; |
| 7113 | return s; |
| 7114 | } |
| 7115 | virtual char* first_demangled_name(char* buf) const |
| 7116 | { |
| 7117 | buf = __left_->first_demangled_name(buf); |
| 7118 | if (__size_ == 0) |
| 7119 | { |
| 7120 | *buf++ = ' '; |
| 7121 | buf = __right_->get_demangled_name(buf); |
| 7122 | } |
| 7123 | return buf; |
| 7124 | } |
| 7125 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 7126 | { |
| 7127 | const ptrdiff_t r = l - f; |
| 7128 | const ptrdiff_t sz1 = __left_->print_first(f, l); |
| 7129 | ptrdiff_t sz2 = 0; |
| 7130 | ptrdiff_t n = 0; |
| 7131 | if (__size_ == 0) |
| 7132 | { |
| 7133 | if (r < sz1 + 1) |
| 7134 | return sz1 + 1 + __right_->print(l, l); |
| 7135 | sz2 = __right_->print(f+1+sz1, l); |
| 7136 | n = 1; |
| 7137 | f[sz1] = ' '; |
| 7138 | } |
| 7139 | return n + sz1 + sz2; |
| 7140 | } |
| 7141 | virtual size_t second_size() const |
| 7142 | { |
| 7143 | size_t s = __left_->second_size(); |
| 7144 | if (__size_ == 1) |
| 7145 | s += __right_->size() + 1; |
| 7146 | return s; |
| 7147 | } |
| 7148 | virtual char* second_demangled_name(char* buf) const |
| 7149 | { |
| 7150 | buf = __left_->second_demangled_name(buf); |
| 7151 | if (__size_ == 1) |
| 7152 | { |
| 7153 | *buf++ = ' '; |
| 7154 | buf = __right_->get_demangled_name(buf); |
| 7155 | } |
| 7156 | return buf; |
| 7157 | } |
| 7158 | virtual ptrdiff_t print_second(char* f, char* l) const |
| 7159 | { |
| 7160 | const ptrdiff_t r = l - f; |
| 7161 | const ptrdiff_t sz1 = __left_->print_second(f, l); |
| 7162 | ptrdiff_t sz2 = 0; |
| 7163 | ptrdiff_t n = 0; |
| 7164 | if (__size_ == 1) |
| 7165 | { |
| 7166 | if (r < sz1 + 1) |
| 7167 | return sz1 + 1 + __right_->print(l, l); |
| 7168 | sz2 = __right_->print(f+1+sz1, l); |
| 7169 | n = 1; |
| 7170 | f[sz1] = ' '; |
| 7171 | } |
| 7172 | return n + sz1 + sz2; |
| 7173 | } |
| 7174 | virtual __node* base_name() const |
| 7175 | { |
| 7176 | return __left_->base_name(); |
| 7177 | } |
| 7178 | virtual bool is_reference_or_pointer_to_function_or_array() const |
| 7179 | { |
| 7180 | return __left_->is_reference_or_pointer_to_function_or_array(); |
| 7181 | } |
| 7182 | virtual bool is_function() const |
| 7183 | { |
| 7184 | return __left_->is_function(); |
| 7185 | } |
| 7186 | virtual bool is_cv_qualifer() const |
| 7187 | { |
| 7188 | return true; |
| 7189 | } |
| 7190 | virtual __node* extract_cv(__node*& rt) const |
| 7191 | { |
| 7192 | if (rt == this) |
| 7193 | { |
| 7194 | rt = __left_; |
| 7195 | return const_cast<__node*>(static_cast<const __node*>(this)); |
| 7196 | } |
| 7197 | return 0; |
| 7198 | } |
| 7199 | virtual bool ends_with_template() const |
| 7200 | { |
| 7201 | return __left_->ends_with_template(); |
| 7202 | } |
| 7203 | virtual bool is_ctor_dtor_conv() const |
| 7204 | { |
| 7205 | return __left_->is_ctor_dtor_conv(); |
| 7206 | } |
| 7207 | virtual bool is_array() const |
| 7208 | { |
| 7209 | return __left_->is_array(); |
| 7210 | } |
| 7211 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 7212 | { |
| 7213 | return __left_->fix_forward_references(t_begin, t_end); |
| 7214 | } |
| 7215 | virtual size_t list_len() const |
| 7216 | { |
| 7217 | return __left_->list_len(); |
| 7218 | } |
| 7219 | }; |
| 7220 | |
| 7221 | class __function |
| 7222 | : public __node |
| 7223 | { |
| 7224 | public: |
| 7225 | |
| 7226 | __function(__node* name, __node* signature, size_t ret_goes_first = true) |
| 7227 | { |
| 7228 | __size_ = ret_goes_first; |
| 7229 | __left_ = name; |
| 7230 | __right_ = signature; |
| 7231 | } |
| 7232 | |
| 7233 | virtual size_t first_size() const |
| 7234 | { |
| 7235 | size_t off = 0; |
| 7236 | if (__size_) |
| 7237 | { |
| 7238 | off = __right_->first_size(); |
| 7239 | if (off > 0 && (__left_ == NULL || |
| 7240 | !__right_->__left_->is_reference_or_pointer_to_function_or_array())) |
| 7241 | ++off; |
| 7242 | } |
| 7243 | else |
| 7244 | off = 5; |
| 7245 | if (__left_) |
| 7246 | off += __left_->first_size(); |
| 7247 | else |
| 7248 | ++off; |
| 7249 | return off; |
| 7250 | } |
| 7251 | |
| 7252 | virtual size_t second_size() const |
| 7253 | { |
| 7254 | size_t off = 0; |
| 7255 | if (__left_ == NULL) |
| 7256 | off = 1; |
| 7257 | off += __right_->second_size(); |
| 7258 | if (!__size_) |
| 7259 | { |
| 7260 | off += 2; |
| 7261 | off += __right_->first_size(); |
| 7262 | } |
| 7263 | return off; |
| 7264 | } |
| 7265 | |
| 7266 | virtual char* first_demangled_name(char* buf) const |
| 7267 | { |
| 7268 | if (__size_) |
| 7269 | { |
| 7270 | const char* t = buf; |
| 7271 | buf = __right_->first_demangled_name(buf); |
| 7272 | if (buf != t && (__left_ == NULL || |
| 7273 | !__right_->__left_->is_reference_or_pointer_to_function_or_array())) |
| 7274 | *buf++ = ' '; |
| 7275 | } |
| 7276 | else |
| 7277 | { |
| 7278 | strncpy(buf, "auto ", 5); |
| 7279 | buf += 5; |
| 7280 | } |
| 7281 | if (__left_) |
| 7282 | buf = __left_->first_demangled_name(buf); |
| 7283 | else |
| 7284 | *buf++ = '('; |
| 7285 | return buf; |
| 7286 | } |
| 7287 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 7288 | { |
| 7289 | const ptrdiff_t r = l - f; |
| 7290 | ptrdiff_t n = 0; |
| 7291 | ptrdiff_t sz1 = 0; |
| 7292 | ptrdiff_t sz2 = 0; |
| 7293 | if (__size_) |
| 7294 | { |
| 7295 | sz1 = __right_->print_first(f, l); |
| 7296 | if (sz1 != 0 && (__left_ == NULL || |
| 7297 | !__right_->__left_->is_reference_or_pointer_to_function_or_array())) |
| 7298 | { |
| 7299 | ++n; |
| 7300 | if (r >= sz1 + 1) |
| 7301 | f[sz1] = ' '; |
| 7302 | } |
| 7303 | } |
| 7304 | else |
| 7305 | { |
| 7306 | n = 5; |
| 7307 | if (r >= 5) |
| 7308 | { |
| 7309 | char* t = f; |
| 7310 | *t++ = 'a'; |
| 7311 | *t++ = 'u'; |
| 7312 | *t++ = 't'; |
| 7313 | *t++ = 'o'; |
| 7314 | *t++ = ' '; |
| 7315 | } |
| 7316 | } |
| 7317 | if (__left_) |
| 7318 | sz2 = __left_->print_first(f + std::min(n + sz1, r), l); |
| 7319 | else |
| 7320 | { |
| 7321 | ++n; |
| 7322 | if (r >= n + sz1) |
| 7323 | f[n+sz1-1] = '('; |
| 7324 | } |
| 7325 | return n + sz1 + sz2; |
| 7326 | } |
| 7327 | |
| 7328 | virtual char* second_demangled_name(char* buf) const |
| 7329 | { |
| 7330 | if (__left_ == NULL) |
| 7331 | *buf++ = ')'; |
| 7332 | buf = __right_->second_demangled_name(buf); |
| 7333 | if (!__size_) |
| 7334 | { |
| 7335 | *buf++ = '-'; |
| 7336 | *buf++ = '>'; |
| 7337 | buf = __right_->first_demangled_name(buf); |
| 7338 | } |
| 7339 | return buf; |
| 7340 | } |
| 7341 | virtual ptrdiff_t print_second(char* f, char* l) const |
| 7342 | { |
| 7343 | const ptrdiff_t r = l - f; |
| 7344 | ptrdiff_t n = 0; |
| 7345 | ptrdiff_t sz1 = 0; |
| 7346 | ptrdiff_t sz2 = 0; |
| 7347 | if (__left_ == NULL) |
| 7348 | { |
| 7349 | n = 1; |
| 7350 | if (r >= 1) |
| 7351 | *f = ')'; |
| 7352 | } |
| 7353 | sz1 = __right_->print_second(f+std::min(r, n), l); |
| 7354 | if (!__size_) |
| 7355 | { |
| 7356 | if (r > n+sz1+1) |
| 7357 | { |
| 7358 | f[n+sz1] = '-'; |
| 7359 | f[n+sz1+1] = '>'; |
| 7360 | } |
| 7361 | n += 2; |
| 7362 | sz2 = __right_->print_first(f+std::min(r, n+sz1), l); |
| 7363 | } |
| 7364 | return n + sz1 + sz2; |
| 7365 | } |
| 7366 | |
Howard Hinnant | f36e6a6 | 2011-08-12 17:33:10 +0000 | [diff] [blame] | 7367 | virtual char* get_demangled_name(char* buf) const |
| 7368 | { |
| 7369 | if (__size_) |
| 7370 | { |
| 7371 | const char* t = buf; |
| 7372 | buf = __right_->first_demangled_name(buf); |
| 7373 | if (buf != t && (__left_ == NULL || |
| 7374 | !__right_->__left_->is_reference_or_pointer_to_function_or_array())) |
| 7375 | *buf++ = ' '; |
| 7376 | } |
| 7377 | else |
| 7378 | { |
| 7379 | strncpy(buf, "auto ", 5); |
| 7380 | buf += 5; |
| 7381 | } |
| 7382 | if (__left_) |
| 7383 | buf = __left_->first_demangled_name(buf); |
| 7384 | buf = __right_->second_demangled_name(buf); |
| 7385 | if (!__size_) |
| 7386 | { |
| 7387 | *buf++ = '-'; |
| 7388 | *buf++ = '>'; |
| 7389 | buf = __right_->first_demangled_name(buf); |
| 7390 | } |
| 7391 | return buf; |
| 7392 | } |
| 7393 | |
| 7394 | virtual size_t size() const |
| 7395 | { |
| 7396 | if (__cached_size_ == -1) |
| 7397 | { |
| 7398 | size_t off = 0; |
| 7399 | if (__size_) |
| 7400 | { |
| 7401 | off = __right_->first_size(); |
| 7402 | if (off > 0 && (__left_ == NULL || |
| 7403 | !__right_->__left_->is_reference_or_pointer_to_function_or_array())) |
| 7404 | ++off; |
| 7405 | } |
| 7406 | else |
| 7407 | off = 5; |
| 7408 | if (__left_) |
| 7409 | off += __left_->first_size(); |
| 7410 | off += __right_->second_size(); |
| 7411 | if (!__size_) |
| 7412 | { |
| 7413 | off += 2; |
| 7414 | off += __right_->first_size(); |
| 7415 | } |
| 7416 | const_cast<long&>(__cached_size_) = off; |
| 7417 | } |
| 7418 | return __cached_size_; |
| 7419 | } |
| 7420 | |
| 7421 | virtual ptrdiff_t print(char* f, char* l) const |
| 7422 | { |
| 7423 | const ptrdiff_t r = l - f; |
| 7424 | ptrdiff_t n = 0; |
| 7425 | ptrdiff_t sz1 = 0; |
| 7426 | ptrdiff_t sz2 = 0; |
| 7427 | if (__size_) |
| 7428 | { |
| 7429 | sz1 = __right_->print_first(f, l); |
| 7430 | if (sz1 != 0 && (__left_ == NULL || |
| 7431 | !__right_->__left_->is_reference_or_pointer_to_function_or_array())) |
| 7432 | { |
| 7433 | ++n; |
| 7434 | if (r >= sz1 + 1) |
| 7435 | f[sz1] = ' '; |
| 7436 | } |
| 7437 | } |
| 7438 | else |
| 7439 | { |
| 7440 | n = 5; |
| 7441 | if (r >= 5) |
| 7442 | { |
| 7443 | char* t = f; |
| 7444 | *t++ = 'a'; |
| 7445 | *t++ = 'u'; |
| 7446 | *t++ = 't'; |
| 7447 | *t++ = 'o'; |
| 7448 | *t++ = ' '; |
| 7449 | } |
| 7450 | } |
| 7451 | if (__left_) |
| 7452 | sz2 = __left_->print_first(f + std::min(n + sz1, r), l); |
| 7453 | n += sz1 + sz2; |
| 7454 | sz2 = 0; |
| 7455 | sz1 = __right_->print_second(f+std::min(r, n), l); |
| 7456 | if (!__size_) |
| 7457 | { |
| 7458 | if (r > n+sz1+1) |
| 7459 | { |
| 7460 | f[n+sz1] = '-'; |
| 7461 | f[n+sz1+1] = '>'; |
| 7462 | } |
| 7463 | n += 2; |
| 7464 | sz2 = __right_->print_first(f+std::min(r, n+sz1), l); |
| 7465 | } |
| 7466 | return n + sz1 + sz2; |
| 7467 | } |
| 7468 | |
Howard Hinnant | 4fbf16a | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 7469 | virtual bool is_function() const |
| 7470 | { |
| 7471 | return true; |
| 7472 | } |
| 7473 | virtual bool is_ctor_dtor_conv() const |
| 7474 | { |
| 7475 | return __left_->is_ctor_dtor_conv(); |
| 7476 | } |
| 7477 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 7478 | { |
| 7479 | bool r = true; |
| 7480 | if (__left_) |
| 7481 | r = r && __left_->fix_forward_references(t_begin, t_end); |
| 7482 | r = r && __right_->fix_forward_references(t_begin, t_end); |
| 7483 | return r; |
| 7484 | } |
| 7485 | }; |
| 7486 | |
| 7487 | class __function_signature |
| 7488 | : public __node |
| 7489 | { |
| 7490 | public: |
| 7491 | __function_signature(__node* ret, __node* args) |
| 7492 | { |
| 7493 | __left_ = ret; |
| 7494 | __right_ = args; |
| 7495 | } |
| 7496 | virtual size_t first_size() const |
| 7497 | { |
| 7498 | return __left_ ? __left_->first_size() : 0; |
| 7499 | } |
| 7500 | |
| 7501 | virtual size_t second_size() const |
| 7502 | { |
| 7503 | return 2 + (__right_ ? __right_->size() : 0) |
| 7504 | + (__left_ ? __left_->second_size() : 0); |
| 7505 | } |
| 7506 | |
| 7507 | virtual char* first_demangled_name(char* buf) const |
| 7508 | { |
| 7509 | if (__left_) |
| 7510 | buf = __left_->first_demangled_name(buf); |
| 7511 | return buf; |
| 7512 | } |
| 7513 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 7514 | { |
| 7515 | return __left_ ? __left_->print_first(f, l) : 0; |
| 7516 | } |
| 7517 | |
| 7518 | virtual char* second_demangled_name(char* buf) const |
| 7519 | { |
| 7520 | *buf++ = '('; |
| 7521 | if (__right_) |
| 7522 | buf = __right_->get_demangled_name(buf); |
| 7523 | *buf++ = ')'; |
| 7524 | if (__left_) |
| 7525 | buf = __left_->second_demangled_name(buf); |
| 7526 | return buf; |
| 7527 | } |
| 7528 | virtual ptrdiff_t print_second(char* f, char* l) const |
| 7529 | { |
| 7530 | const ptrdiff_t r = l - f; |
| 7531 | const ptrdiff_t sz1 = __right_ ? __right_->print(f+std::min<ptrdiff_t>(1, r), l) : 0; |
| 7532 | const ptrdiff_t sz2 = __left_ ? __left_->print_second(f+std::min(2+sz1, r), l) : 0; |
| 7533 | if (r >= 2 + sz1 + sz2) |
| 7534 | { |
| 7535 | *f = '('; |
| 7536 | f += 1 + sz1; |
| 7537 | *f = ')'; |
| 7538 | } |
| 7539 | return 2 + sz1 + sz2; |
| 7540 | } |
| 7541 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 7542 | { |
| 7543 | bool r = true; |
| 7544 | if (__left_) |
| 7545 | r = r && __left_->fix_forward_references(t_begin, t_end); |
| 7546 | if (__right_) |
| 7547 | r = r && __right_->fix_forward_references(t_begin, t_end); |
| 7548 | return r; |
| 7549 | } |
| 7550 | }; |
| 7551 | |
| 7552 | class __pointer_to |
| 7553 | : public __node |
| 7554 | { |
| 7555 | public: |
| 7556 | |
| 7557 | explicit __pointer_to(__node* type) |
| 7558 | { |
| 7559 | __left_ = type; |
| 7560 | } |
| 7561 | virtual size_t first_size() const |
| 7562 | { |
| 7563 | return __left_->first_size() + (__left_->is_array() ? 3 : 1); |
| 7564 | } |
| 7565 | virtual size_t second_size() const |
| 7566 | { |
| 7567 | return __left_->second_size() + (__left_->is_array() ? 1 : 0); |
| 7568 | } |
| 7569 | virtual char* first_demangled_name(char* buf) const |
| 7570 | { |
| 7571 | buf = __left_->first_demangled_name(buf); |
| 7572 | if (__left_->is_array()) |
| 7573 | { |
| 7574 | *buf++ = ' '; |
| 7575 | *buf++ = '('; |
| 7576 | *buf++ = '*'; |
| 7577 | } |
| 7578 | else |
| 7579 | *buf++ = '*'; |
| 7580 | return buf; |
| 7581 | } |
| 7582 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 7583 | { |
| 7584 | const ptrdiff_t r = l - f; |
| 7585 | const ptrdiff_t sz = __left_->print_first(f, l); |
| 7586 | ptrdiff_t n; |
| 7587 | if (__left_->is_array()) |
| 7588 | { |
| 7589 | n = 3; |
| 7590 | if (r >= sz + n) |
| 7591 | { |
| 7592 | f += sz; |
| 7593 | *f++ = ' '; |
| 7594 | *f++ = '('; |
| 7595 | *f = '*'; |
| 7596 | } |
| 7597 | } |
| 7598 | else |
| 7599 | { |
| 7600 | n = 1; |
| 7601 | if (r >= sz + n) |
| 7602 | f[sz] = '*'; |
| 7603 | } |
| 7604 | return sz + n; |
| 7605 | } |
| 7606 | virtual char* second_demangled_name(char* buf) const |
| 7607 | { |
| 7608 | if (__left_->is_array()) |
| 7609 | *buf++ = ')'; |
| 7610 | return __left_->second_demangled_name(buf); |
| 7611 | } |
| 7612 | virtual ptrdiff_t print_second(char* f, char* l) const |
| 7613 | { |
| 7614 | const ptrdiff_t r = l - f; |
| 7615 | ptrdiff_t n = 0; |
| 7616 | if (__left_->is_array()) |
| 7617 | { |
| 7618 | n = 1; |
| 7619 | if (r > n) |
| 7620 | *f = ')'; |
| 7621 | } |
| 7622 | return __left_->print_second(f + std::min(n, r), l) + n; |
| 7623 | } |
| 7624 | virtual __node* base_name() const |
| 7625 | { |
| 7626 | return __left_->base_name(); |
| 7627 | } |
| 7628 | virtual bool is_reference_or_pointer_to_function_or_array() const |
| 7629 | { |
| 7630 | return __left_->is_function() || |
| 7631 | __left_->is_reference_or_pointer_to_function_or_array(); |
| 7632 | } |
| 7633 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 7634 | { |
| 7635 | return __left_->fix_forward_references(t_begin, t_end); |
| 7636 | } |
| 7637 | virtual size_t list_len() const |
| 7638 | { |
| 7639 | return __left_->list_len(); |
| 7640 | } |
| 7641 | }; |
| 7642 | |
| 7643 | class __lvalue_reference_to |
| 7644 | : public __node |
| 7645 | { |
| 7646 | public: |
| 7647 | |
| 7648 | explicit __lvalue_reference_to(__node* type) |
| 7649 | { |
| 7650 | __left_ = type; |
| 7651 | } |
| 7652 | virtual size_t first_size() const |
| 7653 | { |
| 7654 | return __left_->first_size() + (__left_->is_array() ? 3 : 1); |
| 7655 | } |
| 7656 | virtual size_t second_size() const |
| 7657 | { |
| 7658 | return __left_->second_size() + (__left_->is_array() ? 1 : 0); |
| 7659 | } |
| 7660 | virtual char* first_demangled_name(char* buf) const |
| 7661 | { |
| 7662 | buf = __left_->first_demangled_name(buf); |
| 7663 | if (__left_->is_array()) |
| 7664 | { |
| 7665 | *buf++ = ' '; |
| 7666 | *buf++ = '('; |
| 7667 | *buf++ = '&'; |
| 7668 | } |
| 7669 | else |
| 7670 | *buf++ = '&'; |
| 7671 | return buf; |
| 7672 | } |
| 7673 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 7674 | { |
| 7675 | const ptrdiff_t r = l - f; |
| 7676 | const ptrdiff_t sz = __left_->print_first(f, l); |
| 7677 | ptrdiff_t n; |
| 7678 | if (__left_->is_array()) |
| 7679 | { |
| 7680 | n = 3; |
| 7681 | if (r >= sz + n) |
| 7682 | { |
| 7683 | f += sz; |
| 7684 | *f++ = ' '; |
| 7685 | *f++ = '('; |
| 7686 | *f = '&'; |
| 7687 | } |
| 7688 | } |
| 7689 | else |
| 7690 | { |
| 7691 | n = 1; |
| 7692 | if (r >= sz + n) |
| 7693 | f[sz] = '&'; |
| 7694 | } |
| 7695 | return sz + n; |
| 7696 | } |
| 7697 | virtual char* second_demangled_name(char* buf) const |
| 7698 | { |
| 7699 | if (__left_->is_array()) |
| 7700 | *buf++ = ')'; |
| 7701 | return __left_->second_demangled_name(buf); |
| 7702 | } |
| 7703 | virtual ptrdiff_t print_second(char* f, char* l) const |
| 7704 | { |
| 7705 | const ptrdiff_t r = l - f; |
| 7706 | ptrdiff_t n = 0; |
| 7707 | if (__left_->is_array()) |
| 7708 | { |
| 7709 | n = 1; |
| 7710 | if (r > n) |
| 7711 | *f = ')'; |
| 7712 | } |
| 7713 | return __left_->print_second(f + std::min(n, r), l) + n; |
| 7714 | } |
| 7715 | virtual __node* base_name() const |
| 7716 | { |
| 7717 | return __left_->base_name(); |
| 7718 | } |
| 7719 | virtual bool is_reference_or_pointer_to_function_or_array() const |
| 7720 | { |
| 7721 | return __left_->is_function(); |
| 7722 | } |
| 7723 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 7724 | { |
| 7725 | return __left_->fix_forward_references(t_begin, t_end); |
| 7726 | } |
| 7727 | virtual size_t list_len() const |
| 7728 | { |
| 7729 | return __left_->list_len(); |
| 7730 | } |
| 7731 | }; |
| 7732 | |
| 7733 | class __rvalue_reference_to |
| 7734 | : public __node |
| 7735 | { |
| 7736 | public: |
| 7737 | |
| 7738 | explicit __rvalue_reference_to(__node* type) |
| 7739 | { |
| 7740 | __left_ = type; |
| 7741 | } |
| 7742 | virtual size_t first_size() const |
| 7743 | { |
| 7744 | return __left_->first_size() + (__left_->is_array() ? 4 : 2); |
| 7745 | } |
| 7746 | virtual size_t second_size() const |
| 7747 | { |
| 7748 | return __left_->second_size() + (__left_->is_array() ? 1 : 0); |
| 7749 | } |
| 7750 | virtual char* first_demangled_name(char* buf) const |
| 7751 | { |
| 7752 | buf = __left_->first_demangled_name(buf); |
| 7753 | if (__left_->is_array()) |
| 7754 | { |
| 7755 | strncpy(buf, " (&&", 4); |
| 7756 | buf += 4; |
| 7757 | } |
| 7758 | else |
| 7759 | { |
| 7760 | *buf++ = '&'; |
| 7761 | *buf++ = '&'; |
| 7762 | } |
| 7763 | return buf; |
| 7764 | } |
| 7765 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 7766 | { |
| 7767 | const ptrdiff_t r = l - f; |
| 7768 | const ptrdiff_t sz = __left_->print_first(f, l); |
| 7769 | ptrdiff_t n; |
| 7770 | if (__left_->is_array()) |
| 7771 | { |
| 7772 | n = 4; |
| 7773 | if (r >= sz + n) |
| 7774 | { |
| 7775 | f += sz; |
| 7776 | *f++ = ' '; |
| 7777 | *f++ = '('; |
| 7778 | *f++ = '&'; |
| 7779 | *f = '&'; |
| 7780 | } |
| 7781 | } |
| 7782 | else |
| 7783 | { |
| 7784 | n = 2; |
| 7785 | if (r >= sz + n) |
| 7786 | { |
| 7787 | f += sz; |
| 7788 | *f++ = '&'; |
| 7789 | *f = '&'; |
| 7790 | } |
| 7791 | } |
| 7792 | return sz + n; |
| 7793 | } |
| 7794 | virtual char* second_demangled_name(char* buf) const |
| 7795 | { |
| 7796 | if (__left_->is_array()) |
| 7797 | *buf++ = ')'; |
| 7798 | return __left_->second_demangled_name(buf); |
| 7799 | } |
| 7800 | virtual ptrdiff_t print_second(char* f, char* l) const |
| 7801 | { |
| 7802 | const ptrdiff_t r = l - f; |
| 7803 | ptrdiff_t n = 0; |
| 7804 | if (__left_->is_array()) |
| 7805 | { |
| 7806 | n = 1; |
| 7807 | if (r > n) |
| 7808 | *f = ')'; |
| 7809 | } |
| 7810 | return __left_->print_second(f + std::min(n, r), l) + n; |
| 7811 | } |
| 7812 | virtual __node* base_name() const |
| 7813 | { |
| 7814 | return __left_->base_name(); |
| 7815 | } |
| 7816 | virtual bool is_reference_or_pointer_to_function_or_array() const |
| 7817 | { |
| 7818 | return __left_->is_function(); |
| 7819 | } |
| 7820 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 7821 | { |
| 7822 | return __left_->fix_forward_references(t_begin, t_end); |
| 7823 | } |
| 7824 | virtual size_t list_len() const |
| 7825 | { |
| 7826 | return __left_->list_len(); |
| 7827 | } |
| 7828 | }; |
| 7829 | |
| 7830 | class __d_complex |
| 7831 | : public __node |
| 7832 | { |
| 7833 | static const size_t n = sizeof(" complex") - 1; |
| 7834 | public: |
| 7835 | |
| 7836 | explicit __d_complex(__node* type) |
| 7837 | { |
| 7838 | __left_ = type; |
| 7839 | } |
| 7840 | virtual size_t first_size() const |
| 7841 | { |
| 7842 | if (__cached_size_ == -1) |
| 7843 | const_cast<long&>(__cached_size_) = n + __left_->size(); |
| 7844 | return __cached_size_; |
| 7845 | } |
| 7846 | virtual char* first_demangled_name(char* buf) const |
| 7847 | { |
| 7848 | buf = __left_->get_demangled_name(buf); |
| 7849 | strncpy(buf, " complex", n); |
| 7850 | return buf + n; |
| 7851 | } |
| 7852 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 7853 | { |
| 7854 | const ptrdiff_t r = l - f; |
| 7855 | const ptrdiff_t sz = __left_->print(f, l); |
| 7856 | const ptrdiff_t n = sizeof(" complex") - 1; |
| 7857 | if (r >= sz + n) |
| 7858 | { |
| 7859 | f += sz; |
| 7860 | *f++ = ' '; |
| 7861 | *f++ = 'c'; |
| 7862 | *f++ = 'o'; |
| 7863 | *f++ = 'm'; |
| 7864 | *f++ = 'p'; |
| 7865 | *f++ = 'l'; |
| 7866 | *f++ = 'e'; |
| 7867 | *f = 'x'; |
| 7868 | } |
| 7869 | return sz + n; |
| 7870 | } |
| 7871 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 7872 | { |
| 7873 | return __left_->fix_forward_references(t_begin, t_end); |
| 7874 | } |
| 7875 | }; |
| 7876 | |
| 7877 | class __imaginary |
| 7878 | : public __node |
| 7879 | { |
| 7880 | static const size_t n = sizeof(" imaginary") - 1; |
| 7881 | public: |
| 7882 | |
| 7883 | explicit __imaginary(__node* type) |
| 7884 | { |
| 7885 | __left_ = type; |
| 7886 | } |
| 7887 | virtual size_t first_size() const |
| 7888 | { |
| 7889 | if (__cached_size_ == -1) |
| 7890 | const_cast<long&>(__cached_size_) = n + __left_->size(); |
| 7891 | return __cached_size_; |
| 7892 | } |
| 7893 | virtual char* first_demangled_name(char* buf) const |
| 7894 | { |
| 7895 | buf = __left_->get_demangled_name(buf); |
| 7896 | strncpy(buf, " imaginary", n); |
| 7897 | return buf + n; |
| 7898 | } |
| 7899 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 7900 | { |
| 7901 | const ptrdiff_t r = l - f; |
| 7902 | const ptrdiff_t sz = __left_->print(f, l); |
| 7903 | const ptrdiff_t n = sizeof(" imaginary") - 1; |
| 7904 | if (r >= sz + n) |
| 7905 | { |
| 7906 | f += sz; |
| 7907 | *f++ = ' '; |
| 7908 | *f++ = 'i'; |
| 7909 | *f++ = 'm'; |
| 7910 | *f++ = 'a'; |
| 7911 | *f++ = 'g'; |
| 7912 | *f++ = 'i'; |
| 7913 | *f++ = 'n'; |
| 7914 | *f++ = 'a'; |
| 7915 | *f++ = 'r'; |
| 7916 | *f = 'y'; |
| 7917 | } |
| 7918 | return sz + n; |
| 7919 | } |
| 7920 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 7921 | { |
| 7922 | return __left_->fix_forward_references(t_begin, t_end); |
| 7923 | } |
| 7924 | }; |
| 7925 | |
| 7926 | class __pack_expansion |
| 7927 | : public __node |
| 7928 | { |
| 7929 | public: |
| 7930 | |
| 7931 | explicit __pack_expansion(__node* type) |
| 7932 | { |
| 7933 | __left_ = type; |
| 7934 | } |
| 7935 | virtual size_t first_size() const |
| 7936 | { |
| 7937 | if (__cached_size_ == -1) |
| 7938 | { |
| 7939 | size_t len = __left_->list_len(); |
| 7940 | size_t off = 0; |
| 7941 | if (len != 0) |
| 7942 | { |
| 7943 | if (__left_->is_sub() || len == 1) |
| 7944 | off = __left_->size(); |
| 7945 | else |
| 7946 | { |
| 7947 | __node* top = __left_; |
| 7948 | __node* bottom = top; |
| 7949 | while (!bottom->__left_->is_sub()) |
| 7950 | bottom = bottom->__left_; |
| 7951 | __node* sub = bottom->__left_; |
| 7952 | __node* i = sub->__left_; |
| 7953 | bool first = true; |
| 7954 | top->reset_cached_size(); |
| 7955 | while (i) |
| 7956 | { |
| 7957 | if (!first) |
| 7958 | off += 2; |
| 7959 | bottom->__left_ = i->__left_; |
| 7960 | off += top->size(); |
| 7961 | top->reset_cached_size(); |
| 7962 | i = i->__right_; |
| 7963 | first = false; |
| 7964 | } |
| 7965 | bottom->__left_ = sub; |
| 7966 | } |
| 7967 | } |
| 7968 | const_cast<long&>(__cached_size_) = off; |
| 7969 | } |
| 7970 | return __cached_size_; |
| 7971 | } |
| 7972 | virtual char* first_demangled_name(char* buf) const |
| 7973 | { |
| 7974 | size_t len = __left_->list_len(); |
| 7975 | if (len != 0) |
| 7976 | { |
| 7977 | if (__left_->is_sub() || len == 1) |
| 7978 | buf = __left_->get_demangled_name(buf); |
| 7979 | else |
| 7980 | { |
| 7981 | __node* top = __left_; |
| 7982 | __node* bottom = top; |
| 7983 | while (!bottom->__left_->is_sub()) |
| 7984 | bottom = bottom->__left_; |
| 7985 | __node* sub = bottom->__left_; |
| 7986 | __node* i = sub->__left_; |
| 7987 | bool first = true; |
| 7988 | top->reset_cached_size(); |
| 7989 | while (i) |
| 7990 | { |
| 7991 | if (!first) |
| 7992 | { |
| 7993 | *buf++ = ','; |
| 7994 | *buf++ = ' '; |
| 7995 | } |
| 7996 | bottom->__left_ = i->__left_; |
| 7997 | buf = top->get_demangled_name(buf); |
| 7998 | top->reset_cached_size(); |
| 7999 | i = i->__right_; |
| 8000 | first = false; |
| 8001 | } |
| 8002 | bottom->__left_ = sub; |
| 8003 | } |
| 8004 | } |
| 8005 | return buf; |
| 8006 | } |
| 8007 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 8008 | { |
| 8009 | const ptrdiff_t r = l - f; |
| 8010 | const ptrdiff_t len = __left_->list_len(); |
| 8011 | ptrdiff_t sz = 0; |
| 8012 | if (len != 0) |
| 8013 | { |
| 8014 | if (__left_->is_sub() || len == 1) |
| 8015 | sz = __left_->print(f, l); |
| 8016 | else |
| 8017 | { |
| 8018 | __node* top = __left_; |
| 8019 | __node* bottom = top; |
| 8020 | while (!bottom->__left_->is_sub()) |
| 8021 | bottom = bottom->__left_; |
| 8022 | __node* sub = bottom->__left_; |
| 8023 | __node* i = sub->__left_; |
| 8024 | bool first = true; |
| 8025 | while (i) |
| 8026 | { |
| 8027 | if (!first) |
| 8028 | { |
| 8029 | if (r >= sz+2) |
| 8030 | { |
| 8031 | f[sz] = ','; |
| 8032 | f[sz+1] = ' '; |
| 8033 | } |
| 8034 | sz += 2; |
| 8035 | } |
| 8036 | bottom->__left_ = i->__left_; |
| 8037 | sz += top->print(f+std::min(sz, r), l); |
| 8038 | i = i->__right_; |
| 8039 | first = false; |
| 8040 | } |
| 8041 | bottom->__left_ = sub; |
| 8042 | } |
| 8043 | } |
| 8044 | return sz; |
| 8045 | } |
| 8046 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 8047 | { |
| 8048 | return __left_->fix_forward_references(t_begin, t_end); |
| 8049 | } |
| 8050 | }; |
| 8051 | |
| 8052 | class __void |
| 8053 | : public __node |
| 8054 | { |
| 8055 | static const size_t n = sizeof("void") - 1; |
| 8056 | public: |
| 8057 | |
| 8058 | virtual size_t first_size() const {return n;} |
| 8059 | virtual char* first_demangled_name(char* buf) const |
| 8060 | { |
| 8061 | strncpy(buf, "void", n); |
| 8062 | return buf + n; |
| 8063 | } |
| 8064 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 8065 | { |
| 8066 | const ptrdiff_t r = l - f; |
| 8067 | if (r >= n) |
| 8068 | { |
| 8069 | *f++ = 'v'; |
| 8070 | *f++ = 'o'; |
| 8071 | *f++ = 'i'; |
| 8072 | *f = 'd'; |
| 8073 | } |
| 8074 | return n; |
| 8075 | } |
| 8076 | }; |
| 8077 | |
| 8078 | class __wchar_t |
| 8079 | : public __node |
| 8080 | { |
| 8081 | static const size_t n = sizeof("wchar_t") - 1; |
| 8082 | public: |
| 8083 | |
| 8084 | virtual size_t first_size() const {return n;} |
| 8085 | virtual char* first_demangled_name(char* buf) const |
| 8086 | { |
| 8087 | strncpy(buf, "wchar_t", n); |
| 8088 | return buf + n; |
| 8089 | } |
| 8090 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 8091 | { |
| 8092 | const ptrdiff_t r = l - f; |
| 8093 | if (r >= n) |
| 8094 | { |
| 8095 | *f++ = 'w'; |
| 8096 | *f++ = 'c'; |
| 8097 | *f++ = 'h'; |
| 8098 | *f++ = 'a'; |
| 8099 | *f++ = 'r'; |
| 8100 | *f++ = '_'; |
| 8101 | *f = 't'; |
| 8102 | } |
| 8103 | return n; |
| 8104 | } |
| 8105 | }; |
| 8106 | |
| 8107 | class __wchar_t_literal |
| 8108 | : public __node |
| 8109 | { |
| 8110 | public: |
| 8111 | explicit __wchar_t_literal(const char* __first, const char* __last) |
| 8112 | { |
| 8113 | __name_ = __first; |
| 8114 | __size_ = __last - __first; |
| 8115 | } |
| 8116 | |
| 8117 | virtual size_t first_size() const |
| 8118 | { |
| 8119 | return __size_+9; |
| 8120 | } |
| 8121 | virtual char* first_demangled_name(char* buf) const |
| 8122 | { |
| 8123 | strncpy(buf, "(wchar_t)", 9); |
| 8124 | buf += 9; |
| 8125 | strncpy(buf, __name_, __size_); |
| 8126 | return buf + __size_; |
| 8127 | } |
| 8128 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 8129 | { |
| 8130 | const ptrdiff_t r = l - f; |
| 8131 | const ptrdiff_t n = sizeof("(wchar_t)") - 1; |
| 8132 | if (r >= n + __size_) |
| 8133 | { |
| 8134 | *f++ = '('; |
| 8135 | *f++ = 'w'; |
| 8136 | *f++ = 'c'; |
| 8137 | *f++ = 'h'; |
| 8138 | *f++ = 'a'; |
| 8139 | *f++ = 'r'; |
| 8140 | *f++ = '_'; |
| 8141 | *f++ = 't'; |
| 8142 | *f++ = ')'; |
| 8143 | strncpy(f, __name_, __size_); |
| 8144 | } |
| 8145 | return n + __size_; |
| 8146 | } |
| 8147 | }; |
| 8148 | |
| 8149 | class __bool |
| 8150 | : public __node |
| 8151 | { |
| 8152 | static const size_t n = sizeof("bool") - 1; |
| 8153 | public: |
| 8154 | |
| 8155 | virtual size_t first_size() const {return n;} |
| 8156 | virtual char* first_demangled_name(char* buf) const |
| 8157 | { |
| 8158 | strncpy(buf, "bool", n); |
| 8159 | return buf + n; |
| 8160 | } |
| 8161 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 8162 | { |
| 8163 | const ptrdiff_t r = l - f; |
| 8164 | if (r >= n) |
| 8165 | { |
| 8166 | *f++ = 'b'; |
| 8167 | *f++ = 'o'; |
| 8168 | *f++ = 'o'; |
| 8169 | *f = 'l'; |
| 8170 | } |
| 8171 | return n; |
| 8172 | } |
| 8173 | }; |
| 8174 | |
| 8175 | class __bool_literal |
| 8176 | : public __node |
| 8177 | { |
| 8178 | public: |
| 8179 | explicit __bool_literal(const char* __name, unsigned __size) |
| 8180 | { |
| 8181 | __name_ = __name; |
| 8182 | __size_ = __size; |
| 8183 | } |
| 8184 | |
| 8185 | virtual size_t first_size() const |
| 8186 | { |
| 8187 | return __size_; |
| 8188 | } |
| 8189 | virtual char* first_demangled_name(char* buf) const |
| 8190 | { |
| 8191 | strncpy(buf, __name_, __size_); |
| 8192 | return buf + __size_; |
| 8193 | } |
| 8194 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 8195 | { |
| 8196 | const ptrdiff_t r = l - f; |
| 8197 | if (r >= __size_) |
| 8198 | strncpy(f, __name_, __size_); |
| 8199 | return __size_; |
| 8200 | } |
| 8201 | }; |
| 8202 | |
| 8203 | class __char |
| 8204 | : public __node |
| 8205 | { |
| 8206 | static const size_t n = sizeof("char") - 1; |
| 8207 | public: |
| 8208 | |
| 8209 | virtual size_t first_size() const {return n;} |
| 8210 | virtual char* first_demangled_name(char* buf) const |
| 8211 | { |
| 8212 | strncpy(buf, "char", n); |
| 8213 | return buf + n; |
| 8214 | } |
| 8215 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 8216 | { |
| 8217 | const ptrdiff_t r = l - f; |
| 8218 | if (r >= n) |
| 8219 | { |
| 8220 | *f++ = 'c'; |
| 8221 | *f++ = 'h'; |
| 8222 | *f++ = 'a'; |
| 8223 | *f = 'r'; |
| 8224 | } |
| 8225 | return n; |
| 8226 | } |
| 8227 | }; |
| 8228 | |
| 8229 | class __char_literal |
| 8230 | : public __node |
| 8231 | { |
| 8232 | public: |
| 8233 | explicit __char_literal(const char* __first, const char* __last) |
| 8234 | { |
| 8235 | __name_ = __first; |
| 8236 | __size_ = __last - __first; |
| 8237 | } |
| 8238 | |
| 8239 | virtual size_t first_size() const |
| 8240 | { |
| 8241 | return __size_+6; |
| 8242 | } |
| 8243 | virtual char* first_demangled_name(char* buf) const |
| 8244 | { |
| 8245 | strncpy(buf, "(char)", 6); |
| 8246 | buf += 6; |
| 8247 | if (*__name_ == 'n') |
| 8248 | { |
| 8249 | *buf++ = '-'; // strncpy(buf+6, "-", 1); |
| 8250 | strncpy(buf, __name_+1, __size_-1); |
| 8251 | buf += __size_ - 1; |
| 8252 | } |
| 8253 | else |
| 8254 | { |
| 8255 | strncpy(buf, __name_, __size_); |
| 8256 | buf += __size_; |
| 8257 | } |
| 8258 | return buf; |
| 8259 | } |
| 8260 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 8261 | { |
| 8262 | const ptrdiff_t r = l - f; |
| 8263 | const ptrdiff_t n = sizeof("(char)") - 1; |
| 8264 | if (r >= __size_ + n) |
| 8265 | { |
| 8266 | *f++ = '('; |
| 8267 | *f++ = 'c'; |
| 8268 | *f++ = 'h'; |
| 8269 | *f++ = 'a'; |
| 8270 | *f++ = 'r'; |
| 8271 | *f++ = ')'; |
| 8272 | if (*__name_ == 'n') |
| 8273 | { |
| 8274 | *f++ = '-'; |
| 8275 | strncpy(f, __name_+1, __size_-1); |
| 8276 | } |
| 8277 | else |
| 8278 | strncpy(f, __name_, __size_); |
| 8279 | } |
| 8280 | return __size_ + n; |
| 8281 | } |
| 8282 | }; |
| 8283 | |
| 8284 | class __signed_char |
| 8285 | : public __node |
| 8286 | { |
| 8287 | static const size_t n = sizeof("signed char") - 1; |
| 8288 | public: |
| 8289 | |
| 8290 | virtual size_t first_size() const {return n;} |
| 8291 | virtual char* first_demangled_name(char* buf) const |
| 8292 | { |
| 8293 | strncpy(buf, "signed char", n); |
| 8294 | return buf + n; |
| 8295 | } |
| 8296 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 8297 | { |
| 8298 | const ptrdiff_t r = l - f; |
| 8299 | if (r >= n) |
| 8300 | { |
| 8301 | *f++ = 's'; |
| 8302 | *f++ = 'i'; |
| 8303 | *f++ = 'g'; |
| 8304 | *f++ = 'n'; |
| 8305 | *f++ = 'e'; |
| 8306 | *f++ = 'd'; |
| 8307 | *f++ = ' '; |
| 8308 | *f++ = 'c'; |
| 8309 | *f++ = 'h'; |
| 8310 | *f++ = 'a'; |
| 8311 | *f = 'r'; |
| 8312 | } |
| 8313 | return n; |
| 8314 | } |
| 8315 | }; |
| 8316 | |
| 8317 | class __signed_char_literal |
| 8318 | : public __node |
| 8319 | { |
| 8320 | public: |
| 8321 | explicit __signed_char_literal(const char* __first, const char* __last) |
| 8322 | { |
| 8323 | __name_ = __first; |
| 8324 | __size_ = __last - __first; |
| 8325 | } |
| 8326 | |
| 8327 | virtual size_t first_size() const |
| 8328 | { |
| 8329 | return __size_+13; |
| 8330 | } |
| 8331 | virtual char* first_demangled_name(char* buf) const |
| 8332 | { |
| 8333 | strncpy(buf, "(signed char)", 13); |
| 8334 | buf += 13; |
| 8335 | if (*__name_ == 'n') |
| 8336 | { |
| 8337 | *buf++ = '-'; |
| 8338 | strncpy(buf, __name_+1, __size_-1); |
| 8339 | buf += __size_ - 1; |
| 8340 | } |
| 8341 | else |
| 8342 | { |
| 8343 | strncpy(buf, __name_, __size_); |
| 8344 | buf += __size_; |
| 8345 | } |
| 8346 | return buf; |
| 8347 | } |
| 8348 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 8349 | { |
| 8350 | const ptrdiff_t r = l - f; |
| 8351 | const ptrdiff_t n = sizeof("(signed char)") - 1; |
| 8352 | if (r >= __size_ + n) |
| 8353 | { |
| 8354 | *f++ = '('; |
| 8355 | *f++ = 's'; |
| 8356 | *f++ = 'i'; |
| 8357 | *f++ = 'g'; |
| 8358 | *f++ = 'n'; |
| 8359 | *f++ = 'e'; |
| 8360 | *f++ = 'd'; |
| 8361 | *f++ = ' '; |
| 8362 | *f++ = 'c'; |
| 8363 | *f++ = 'h'; |
| 8364 | *f++ = 'a'; |
| 8365 | *f++ = 'r'; |
| 8366 | *f++ = ')'; |
| 8367 | if (*__name_ == 'n') |
| 8368 | { |
| 8369 | *f++ = '-'; |
| 8370 | strncpy(f, __name_+1, __size_-1); |
| 8371 | } |
| 8372 | else |
| 8373 | strncpy(f, __name_, __size_); |
| 8374 | } |
| 8375 | return __size_ + n; |
| 8376 | } |
| 8377 | }; |
| 8378 | |
| 8379 | class __unsigned_char |
| 8380 | : public __node |
| 8381 | { |
| 8382 | static const size_t n = sizeof("unsigned char") - 1; |
| 8383 | public: |
| 8384 | |
| 8385 | virtual size_t first_size() const {return n;} |
| 8386 | virtual char* first_demangled_name(char* buf) const |
| 8387 | { |
| 8388 | strncpy(buf, "unsigned char", n); |
| 8389 | return buf + n; |
| 8390 | } |
| 8391 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 8392 | { |
| 8393 | const ptrdiff_t r = l - f; |
| 8394 | if (r >= n) |
| 8395 | { |
| 8396 | *f++ = 'u'; |
| 8397 | *f++ = 'n'; |
| 8398 | *f++ = 's'; |
| 8399 | *f++ = 'i'; |
| 8400 | *f++ = 'g'; |
| 8401 | *f++ = 'n'; |
| 8402 | *f++ = 'e'; |
| 8403 | *f++ = 'd'; |
| 8404 | *f++ = ' '; |
| 8405 | *f++ = 'c'; |
| 8406 | *f++ = 'h'; |
| 8407 | *f++ = 'a'; |
| 8408 | *f = 'r'; |
| 8409 | } |
| 8410 | return n; |
| 8411 | } |
| 8412 | }; |
| 8413 | |
| 8414 | class __unsigned_char_literal |
| 8415 | : public __node |
| 8416 | { |
| 8417 | public: |
| 8418 | explicit __unsigned_char_literal(const char* __first, const char* __last) |
| 8419 | { |
| 8420 | __name_ = __first; |
| 8421 | __size_ = __last - __first; |
| 8422 | } |
| 8423 | |
| 8424 | virtual size_t first_size() const |
| 8425 | { |
| 8426 | return __size_+15; |
| 8427 | } |
| 8428 | virtual char* first_demangled_name(char* buf) const |
| 8429 | { |
| 8430 | strncpy(buf, "(unsigned char)", 15); |
| 8431 | buf += 15; |
| 8432 | strncpy(buf, __name_, __size_); |
| 8433 | return buf + __size_; |
| 8434 | } |
| 8435 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 8436 | { |
| 8437 | const ptrdiff_t r = l - f; |
| 8438 | const ptrdiff_t n = sizeof("(unsigned char)") - 1; |
| 8439 | if (r >= __size_ + n) |
| 8440 | { |
| 8441 | *f++ = '('; |
| 8442 | *f++ = 'u'; |
| 8443 | *f++ = 'n'; |
| 8444 | *f++ = 's'; |
| 8445 | *f++ = 'i'; |
| 8446 | *f++ = 'g'; |
| 8447 | *f++ = 'n'; |
| 8448 | *f++ = 'e'; |
| 8449 | *f++ = 'd'; |
| 8450 | *f++ = ' '; |
| 8451 | *f++ = 'c'; |
| 8452 | *f++ = 'h'; |
| 8453 | *f++ = 'a'; |
| 8454 | *f++ = 'r'; |
| 8455 | *f++ = ')'; |
| 8456 | strncpy(f, __name_, __size_); |
| 8457 | } |
| 8458 | return __size_ + n; |
| 8459 | } |
| 8460 | }; |
| 8461 | |
| 8462 | class __short |
| 8463 | : public __node |
| 8464 | { |
| 8465 | static const size_t n = sizeof("short") - 1; |
| 8466 | public: |
| 8467 | |
| 8468 | virtual size_t first_size() const {return n;} |
| 8469 | virtual char* first_demangled_name(char* buf) const |
| 8470 | { |
| 8471 | strncpy(buf, "short", n); |
| 8472 | return buf + n; |
| 8473 | } |
| 8474 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 8475 | { |
| 8476 | const ptrdiff_t r = l - f; |
| 8477 | if (r >= n) |
| 8478 | { |
| 8479 | *f++ = 's'; |
| 8480 | *f++ = 'h'; |
| 8481 | *f++ = 'o'; |
| 8482 | *f++ = 'r'; |
| 8483 | *f = 't'; |
| 8484 | } |
| 8485 | return n; |
| 8486 | } |
| 8487 | }; |
| 8488 | |
| 8489 | class __short_literal |
| 8490 | : public __node |
| 8491 | { |
| 8492 | public: |
| 8493 | explicit __short_literal(const char* __first, const char* __last) |
| 8494 | { |
| 8495 | __name_ = __first; |
| 8496 | __size_ = __last - __first; |
| 8497 | } |
| 8498 | |
| 8499 | virtual size_t first_size() const |
| 8500 | { |
| 8501 | return __size_+7; |
| 8502 | } |
| 8503 | virtual char* first_demangled_name(char* buf) const |
| 8504 | { |
| 8505 | strncpy(buf, "(short)", 7); |
| 8506 | buf += 7; |
| 8507 | if (*__name_ == 'n') |
| 8508 | { |
| 8509 | *buf++ = '-'; |
| 8510 | strncpy(buf, __name_+1, __size_-1); |
| 8511 | buf += __size_ - 1; |
| 8512 | } |
| 8513 | else |
| 8514 | { |
| 8515 | strncpy(buf, __name_, __size_); |
| 8516 | buf += __size_; |
| 8517 | } |
| 8518 | return buf; |
| 8519 | } |
| 8520 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 8521 | { |
| 8522 | const ptrdiff_t r = l - f; |
| 8523 | const ptrdiff_t n = sizeof("(short)") - 1; |
| 8524 | if (r >= __size_ + n) |
| 8525 | { |
| 8526 | *f++ = '('; |
| 8527 | *f++ = 's'; |
| 8528 | *f++ = 'h'; |
| 8529 | *f++ = 'o'; |
| 8530 | *f++ = 'r'; |
| 8531 | *f++ = 't'; |
| 8532 | *f++ = ')'; |
| 8533 | if (*__name_ == 'n') |
| 8534 | { |
| 8535 | *f++ = '-'; |
| 8536 | strncpy(f, __name_+1, __size_-1); |
| 8537 | } |
| 8538 | else |
| 8539 | strncpy(f, __name_, __size_); |
| 8540 | } |
| 8541 | return __size_ + n; |
| 8542 | } |
| 8543 | }; |
| 8544 | |
| 8545 | class __unsigned_short |
| 8546 | : public __node |
| 8547 | { |
| 8548 | static const size_t n = sizeof("unsigned short") - 1; |
| 8549 | public: |
| 8550 | |
| 8551 | virtual size_t first_size() const {return n;} |
| 8552 | virtual char* first_demangled_name(char* buf) const |
| 8553 | { |
| 8554 | strncpy(buf, "unsigned short", n); |
| 8555 | return buf + n; |
| 8556 | } |
| 8557 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 8558 | { |
| 8559 | const ptrdiff_t r = l - f; |
| 8560 | if (r >= n) |
| 8561 | { |
| 8562 | *f++ = 'u'; |
| 8563 | *f++ = 'n'; |
| 8564 | *f++ = 's'; |
| 8565 | *f++ = 'i'; |
| 8566 | *f++ = 'g'; |
| 8567 | *f++ = 'n'; |
| 8568 | *f++ = 'e'; |
| 8569 | *f++ = 'd'; |
| 8570 | *f++ = ' '; |
| 8571 | *f++ = 's'; |
| 8572 | *f++ = 'h'; |
| 8573 | *f++ = 'o'; |
| 8574 | *f++ = 'r'; |
| 8575 | *f = 't'; |
| 8576 | } |
| 8577 | return n; |
| 8578 | } |
| 8579 | }; |
| 8580 | |
| 8581 | class __unsigned_short_literal |
| 8582 | : public __node |
| 8583 | { |
| 8584 | public: |
| 8585 | explicit __unsigned_short_literal(const char* __first, const char* __last) |
| 8586 | { |
| 8587 | __name_ = __first; |
| 8588 | __size_ = __last - __first; |
| 8589 | } |
| 8590 | |
| 8591 | virtual size_t first_size() const |
| 8592 | { |
| 8593 | return __size_+16; |
| 8594 | } |
| 8595 | virtual char* first_demangled_name(char* buf) const |
| 8596 | { |
| 8597 | strncpy(buf, "(unsigned short)", 16); |
| 8598 | buf += 16; |
| 8599 | strncpy(buf, __name_, __size_); |
| 8600 | return buf + __size_; |
| 8601 | } |
| 8602 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 8603 | { |
| 8604 | const ptrdiff_t r = l - f; |
| 8605 | const ptrdiff_t n = sizeof("(unsigned short)") - 1; |
| 8606 | if (r >= __size_ + n) |
| 8607 | { |
| 8608 | *f++ = '('; |
| 8609 | *f++ = 'u'; |
| 8610 | *f++ = 'n'; |
| 8611 | *f++ = 's'; |
| 8612 | *f++ = 'i'; |
| 8613 | *f++ = 'g'; |
| 8614 | *f++ = 'n'; |
| 8615 | *f++ = 'e'; |
| 8616 | *f++ = 'd'; |
| 8617 | *f++ = ' '; |
| 8618 | *f++ = 's'; |
| 8619 | *f++ = 'h'; |
| 8620 | *f++ = 'o'; |
| 8621 | *f++ = 'r'; |
| 8622 | *f++ = 't'; |
| 8623 | *f++ = ')'; |
| 8624 | strncpy(f, __name_, __size_); |
| 8625 | } |
| 8626 | return __size_ + n; |
| 8627 | } |
| 8628 | }; |
| 8629 | |
| 8630 | class __int |
| 8631 | : public __node |
| 8632 | { |
| 8633 | static const size_t n = sizeof("int") - 1; |
| 8634 | public: |
| 8635 | |
| 8636 | virtual size_t first_size() const {return n;} |
| 8637 | virtual char* first_demangled_name(char* buf) const |
| 8638 | { |
| 8639 | *buf++ = 'i'; |
| 8640 | *buf++ = 'n'; |
| 8641 | *buf++ = 't'; |
| 8642 | return buf; |
| 8643 | } |
| 8644 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 8645 | { |
| 8646 | const ptrdiff_t r = l - f; |
| 8647 | if (r >= n) |
| 8648 | { |
| 8649 | *f++ = 'i'; |
| 8650 | *f++ = 'n'; |
| 8651 | *f = 't'; |
| 8652 | } |
| 8653 | return n; |
| 8654 | } |
| 8655 | }; |
| 8656 | |
| 8657 | class __int_literal |
| 8658 | : public __node |
| 8659 | { |
| 8660 | public: |
| 8661 | explicit __int_literal(const char* __first, const char* __last) |
| 8662 | { |
| 8663 | __name_ = __first; |
| 8664 | __size_ = __last - __first; |
| 8665 | } |
| 8666 | |
| 8667 | virtual size_t first_size() const |
| 8668 | { |
| 8669 | return __size_; |
| 8670 | } |
| 8671 | virtual char* first_demangled_name(char* buf) const |
| 8672 | { |
| 8673 | if (*__name_ == 'n') |
| 8674 | { |
| 8675 | *buf++ = '-'; |
| 8676 | strncpy(buf, __name_+1, __size_-1); |
| 8677 | buf += __size_ - 1; |
| 8678 | } |
| 8679 | else |
| 8680 | { |
| 8681 | strncpy(buf, __name_, __size_); |
| 8682 | buf += __size_; |
| 8683 | } |
| 8684 | return buf; |
| 8685 | } |
| 8686 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 8687 | { |
| 8688 | const ptrdiff_t r = l - f; |
| 8689 | if (r >= __size_) |
| 8690 | { |
| 8691 | if (*__name_ == 'n') |
| 8692 | { |
| 8693 | *f++ = '-'; |
| 8694 | strncpy(f, __name_+1, __size_-1); |
| 8695 | } |
| 8696 | else |
| 8697 | strncpy(f, __name_, __size_); |
| 8698 | } |
| 8699 | return __size_; |
| 8700 | } |
| 8701 | }; |
| 8702 | |
| 8703 | class __unsigned_int |
| 8704 | : public __node |
| 8705 | { |
| 8706 | static const size_t n = sizeof("unsigned int") - 1; |
| 8707 | public: |
| 8708 | |
| 8709 | virtual size_t first_size() const {return n;} |
| 8710 | virtual char* first_demangled_name(char* buf) const |
| 8711 | { |
| 8712 | strncpy(buf, "unsigned int", n); |
| 8713 | return buf + n; |
| 8714 | } |
| 8715 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 8716 | { |
| 8717 | const ptrdiff_t r = l - f; |
| 8718 | if (r >= n) |
| 8719 | { |
| 8720 | *f++ = 'u'; |
| 8721 | *f++ = 'n'; |
| 8722 | *f++ = 's'; |
| 8723 | *f++ = 'i'; |
| 8724 | *f++ = 'g'; |
| 8725 | *f++ = 'n'; |
| 8726 | *f++ = 'e'; |
| 8727 | *f++ = 'd'; |
| 8728 | *f++ = ' '; |
| 8729 | *f++ = 'i'; |
| 8730 | *f++ = 'n'; |
| 8731 | *f = 't'; |
| 8732 | } |
| 8733 | return n; |
| 8734 | } |
| 8735 | }; |
| 8736 | |
| 8737 | class __unsigned_int_literal |
| 8738 | : public __node |
| 8739 | { |
| 8740 | public: |
| 8741 | explicit __unsigned_int_literal(const char* __first, const char* __last) |
| 8742 | { |
| 8743 | __name_ = __first; |
| 8744 | __size_ = __last - __first; |
| 8745 | } |
| 8746 | |
| 8747 | virtual size_t first_size() const |
| 8748 | { |
| 8749 | return __size_+1; |
| 8750 | } |
| 8751 | virtual char* first_demangled_name(char* buf) const |
| 8752 | { |
| 8753 | strncpy(buf, __name_, __size_); |
| 8754 | buf += __size_; |
| 8755 | *buf++ = 'u'; |
| 8756 | return buf; |
| 8757 | } |
| 8758 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 8759 | { |
| 8760 | const ptrdiff_t r = l - f; |
| 8761 | const ptrdiff_t n = sizeof("u") - 1; |
| 8762 | if (r >= __size_ + n) |
| 8763 | { |
| 8764 | strncpy(f, __name_, __size_); |
| 8765 | f[__size_] = 'u'; |
| 8766 | } |
| 8767 | return __size_ + n; |
| 8768 | } |
| 8769 | }; |
| 8770 | |
| 8771 | class __long |
| 8772 | : public __node |
| 8773 | { |
| 8774 | static const size_t n = sizeof("long") - 1; |
| 8775 | public: |
| 8776 | |
| 8777 | virtual size_t first_size() const {return n;} |
| 8778 | virtual char* first_demangled_name(char* buf) const |
| 8779 | { |
| 8780 | strncpy(buf, "long", n); |
| 8781 | return buf + n; |
| 8782 | } |
| 8783 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 8784 | { |
| 8785 | const ptrdiff_t r = l - f; |
| 8786 | if (r >= n) |
| 8787 | { |
| 8788 | *f++ = 'l'; |
| 8789 | *f++ = 'o'; |
| 8790 | *f++ = 'n'; |
| 8791 | *f = 'g'; |
| 8792 | } |
| 8793 | return n; |
| 8794 | } |
| 8795 | }; |
| 8796 | |
| 8797 | class __long_literal |
| 8798 | : public __node |
| 8799 | { |
| 8800 | public: |
| 8801 | explicit __long_literal(const char* __first, const char* __last) |
| 8802 | { |
| 8803 | __name_ = __first; |
| 8804 | __size_ = __last - __first; |
| 8805 | } |
| 8806 | |
| 8807 | virtual size_t first_size() const |
| 8808 | { |
| 8809 | return __size_+1; |
| 8810 | } |
| 8811 | virtual char* first_demangled_name(char* buf) const |
| 8812 | { |
| 8813 | if (*__name_ == 'n') |
| 8814 | { |
| 8815 | *buf++ = '-'; // strncpy(buf, "-", 1); |
| 8816 | strncpy(buf, __name_+1, __size_-1); |
| 8817 | buf += __size_ - 1; |
| 8818 | } |
| 8819 | else |
| 8820 | { |
| 8821 | strncpy(buf, __name_, __size_); |
| 8822 | buf += __size_; |
| 8823 | } |
| 8824 | *buf++ = 'l'; |
| 8825 | return buf; |
| 8826 | } |
| 8827 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 8828 | { |
| 8829 | const ptrdiff_t r = l - f; |
| 8830 | const ptrdiff_t n = sizeof("l") - 1; |
| 8831 | if (r >= __size_ + n) |
| 8832 | { |
| 8833 | if (*__name_ == 'n') |
| 8834 | { |
| 8835 | *f++ = '-'; |
| 8836 | strncpy(f, __name_+1, __size_-1); |
| 8837 | f += __size_-1; |
| 8838 | } |
| 8839 | else |
| 8840 | { |
| 8841 | strncpy(f, __name_, __size_); |
| 8842 | f += __size_; |
| 8843 | } |
| 8844 | *f = 'l'; |
| 8845 | } |
| 8846 | return __size_ + n; |
| 8847 | } |
| 8848 | }; |
| 8849 | |
| 8850 | class __unsigned_long |
| 8851 | : public __node |
| 8852 | { |
| 8853 | static const size_t n = sizeof("unsigned long") - 1; |
| 8854 | public: |
| 8855 | |
| 8856 | virtual size_t first_size() const {return n;} |
| 8857 | virtual char* first_demangled_name(char* buf) const |
| 8858 | { |
| 8859 | strncpy(buf, "unsigned long", n); |
| 8860 | return buf + n; |
| 8861 | } |
| 8862 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 8863 | { |
| 8864 | const ptrdiff_t r = l - f; |
| 8865 | if (r >= n) |
| 8866 | { |
| 8867 | *f++ = 'u'; |
| 8868 | *f++ = 'n'; |
| 8869 | *f++ = 's'; |
| 8870 | *f++ = 'i'; |
| 8871 | *f++ = 'g'; |
| 8872 | *f++ = 'n'; |
| 8873 | *f++ = 'e'; |
| 8874 | *f++ = 'd'; |
| 8875 | *f++ = ' '; |
| 8876 | *f++ = 'l'; |
| 8877 | *f++ = 'o'; |
| 8878 | *f++ = 'n'; |
| 8879 | *f = 'g'; |
| 8880 | } |
| 8881 | return n; |
| 8882 | } |
| 8883 | }; |
| 8884 | |
| 8885 | class __unsigned_long_literal |
| 8886 | : public __node |
| 8887 | { |
| 8888 | public: |
| 8889 | explicit __unsigned_long_literal(const char* __first, const char* __last) |
| 8890 | { |
| 8891 | __name_ = __first; |
| 8892 | __size_ = __last - __first; |
| 8893 | } |
| 8894 | |
| 8895 | virtual size_t first_size() const |
| 8896 | { |
| 8897 | return __size_+2; |
| 8898 | } |
| 8899 | virtual char* first_demangled_name(char* buf) const |
| 8900 | { |
| 8901 | strncpy(buf, __name_, __size_); |
| 8902 | buf += __size_; |
| 8903 | *buf++ = 'u'; |
| 8904 | *buf++ = 'l'; |
| 8905 | return buf; |
| 8906 | } |
| 8907 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 8908 | { |
| 8909 | const ptrdiff_t r = l - f; |
| 8910 | const ptrdiff_t n = sizeof("ul") - 1; |
| 8911 | if (r >= __size_ + n) |
| 8912 | { |
| 8913 | strncpy(f, __name_, __size_); |
| 8914 | f += __size_; |
| 8915 | *f++ = 'u'; |
| 8916 | *f = 'l'; |
| 8917 | } |
| 8918 | return __size_ + n; |
| 8919 | } |
| 8920 | }; |
| 8921 | |
| 8922 | class __long_long |
| 8923 | : public __node |
| 8924 | { |
| 8925 | static const size_t n = sizeof("long long") - 1; |
| 8926 | public: |
| 8927 | |
| 8928 | virtual size_t first_size() const {return n;} |
| 8929 | virtual char* first_demangled_name(char* buf) const |
| 8930 | { |
| 8931 | strncpy(buf, "long long", n); |
| 8932 | return buf + n; |
| 8933 | } |
| 8934 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 8935 | { |
| 8936 | const ptrdiff_t r = l - f; |
| 8937 | if (r >= n) |
| 8938 | { |
| 8939 | *f++ = 'l'; |
| 8940 | *f++ = 'o'; |
| 8941 | *f++ = 'n'; |
| 8942 | *f++ = 'g'; |
| 8943 | *f++ = ' '; |
| 8944 | *f++ = 'l'; |
| 8945 | *f++ = 'o'; |
| 8946 | *f++ = 'n'; |
| 8947 | *f = 'g'; |
| 8948 | } |
| 8949 | return n; |
| 8950 | } |
| 8951 | }; |
| 8952 | |
| 8953 | class __long_long_literal |
| 8954 | : public __node |
| 8955 | { |
| 8956 | public: |
| 8957 | explicit __long_long_literal(const char* __first, const char* __last) |
| 8958 | { |
| 8959 | __name_ = __first; |
| 8960 | __size_ = __last - __first; |
| 8961 | } |
| 8962 | |
| 8963 | virtual size_t first_size() const |
| 8964 | { |
| 8965 | return __size_+2; |
| 8966 | } |
| 8967 | virtual char* first_demangled_name(char* buf) const |
| 8968 | { |
| 8969 | if (*__name_ == 'n') |
| 8970 | { |
| 8971 | *buf++ = '-'; |
| 8972 | strncpy(buf, __name_+1, __size_-1); |
| 8973 | buf += __size_ - 1; |
| 8974 | } |
| 8975 | else |
| 8976 | { |
| 8977 | strncpy(buf, __name_, __size_); |
| 8978 | buf += __size_; |
| 8979 | } |
| 8980 | *buf++ = 'l'; |
| 8981 | *buf++ = 'l'; |
| 8982 | return buf; |
| 8983 | } |
| 8984 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 8985 | { |
| 8986 | const ptrdiff_t r = l - f; |
| 8987 | const ptrdiff_t n = sizeof("ll") - 1; |
| 8988 | if (r >= __size_ + n) |
| 8989 | { |
| 8990 | if (*__name_ == 'n') |
| 8991 | { |
| 8992 | *f++ = '-'; |
| 8993 | strncpy(f, __name_+1, __size_-1); |
| 8994 | f += __size_-1; |
| 8995 | } |
| 8996 | else |
| 8997 | { |
| 8998 | strncpy(f, __name_, __size_); |
| 8999 | f += __size_; |
| 9000 | } |
| 9001 | *f++ = 'l'; |
| 9002 | *f = 'l'; |
| 9003 | } |
| 9004 | return __size_ + n; |
| 9005 | } |
| 9006 | }; |
| 9007 | |
| 9008 | class __unsigned_long_long |
| 9009 | : public __node |
| 9010 | { |
| 9011 | static const size_t n = sizeof("unsigned long long") - 1; |
| 9012 | public: |
| 9013 | |
| 9014 | virtual size_t first_size() const {return n;} |
| 9015 | virtual char* first_demangled_name(char* buf) const |
| 9016 | { |
| 9017 | strncpy(buf, "unsigned long long", n); |
| 9018 | return buf + n; |
| 9019 | } |
| 9020 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 9021 | { |
| 9022 | const ptrdiff_t r = l - f; |
| 9023 | if (r >= n) |
| 9024 | { |
| 9025 | *f++ = 'u'; |
| 9026 | *f++ = 'n'; |
| 9027 | *f++ = 's'; |
| 9028 | *f++ = 'i'; |
| 9029 | *f++ = 'g'; |
| 9030 | *f++ = 'n'; |
| 9031 | *f++ = 'e'; |
| 9032 | *f++ = 'd'; |
| 9033 | *f++ = ' '; |
| 9034 | *f++ = 'l'; |
| 9035 | *f++ = 'o'; |
| 9036 | *f++ = 'n'; |
| 9037 | *f++ = 'g'; |
| 9038 | *f++ = ' '; |
| 9039 | *f++ = 'l'; |
| 9040 | *f++ = 'o'; |
| 9041 | *f++ = 'n'; |
| 9042 | *f = 'g'; |
| 9043 | } |
| 9044 | return n; |
| 9045 | } |
| 9046 | }; |
| 9047 | |
| 9048 | class __unsigned_long_long_literal |
| 9049 | : public __node |
| 9050 | { |
| 9051 | public: |
| 9052 | explicit __unsigned_long_long_literal(const char* __first, const char* __last) |
| 9053 | { |
| 9054 | __name_ = __first; |
| 9055 | __size_ = __last - __first; |
| 9056 | } |
| 9057 | |
| 9058 | virtual size_t first_size() const |
| 9059 | { |
| 9060 | return __size_+3; |
| 9061 | } |
| 9062 | virtual char* first_demangled_name(char* buf) const |
| 9063 | { |
| 9064 | strncpy(buf, __name_, __size_); |
| 9065 | buf += __size_; |
| 9066 | *buf++ = 'u'; |
| 9067 | *buf++ = 'l'; |
| 9068 | *buf++ = 'l'; |
| 9069 | return buf; |
| 9070 | } |
| 9071 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 9072 | { |
| 9073 | const ptrdiff_t r = l - f; |
| 9074 | const ptrdiff_t n = sizeof("ull") - 1; |
| 9075 | if (r >= __size_ + n) |
| 9076 | { |
| 9077 | strncpy(f, __name_, __size_); |
| 9078 | f += __size_; |
| 9079 | *f++ = 'u'; |
| 9080 | *f++ = 'l'; |
| 9081 | *f = 'l'; |
| 9082 | } |
| 9083 | return __size_ + n; |
| 9084 | } |
| 9085 | }; |
| 9086 | |
| 9087 | class __int128 |
| 9088 | : public __node |
| 9089 | { |
| 9090 | static const size_t n = sizeof("__int128") - 1; |
| 9091 | public: |
| 9092 | |
| 9093 | virtual size_t first_size() const {return n;} |
| 9094 | virtual char* first_demangled_name(char* buf) const |
| 9095 | { |
| 9096 | strncpy(buf, "__int128", n); |
| 9097 | return buf + n; |
| 9098 | } |
| 9099 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 9100 | { |
| 9101 | const ptrdiff_t r = l - f; |
| 9102 | if (r >= n) |
| 9103 | { |
| 9104 | *f++ = '_'; |
| 9105 | *f++ = '_'; |
| 9106 | *f++ = 'i'; |
| 9107 | *f++ = 'n'; |
| 9108 | *f++ = 't'; |
| 9109 | *f++ = '1'; |
| 9110 | *f++ = '2'; |
| 9111 | *f = '8'; |
| 9112 | } |
| 9113 | return n; |
| 9114 | } |
| 9115 | }; |
| 9116 | |
| 9117 | class __int128_literal |
| 9118 | : public __node |
| 9119 | { |
| 9120 | public: |
| 9121 | explicit __int128_literal(const char* __first, const char* __last) |
| 9122 | { |
| 9123 | __name_ = __first; |
| 9124 | __size_ = __last - __first; |
| 9125 | } |
| 9126 | |
| 9127 | virtual size_t first_size() const |
| 9128 | { |
| 9129 | return __size_+10; |
| 9130 | } |
| 9131 | virtual char* first_demangled_name(char* buf) const |
| 9132 | { |
| 9133 | strncpy(buf, "(__int128)", 10); |
| 9134 | buf += 10; |
| 9135 | if (*__name_ == 'n') |
| 9136 | { |
| 9137 | *buf++ = '-'; |
| 9138 | strncpy(buf, __name_+1, __size_-1); |
| 9139 | buf += __size_ - 1; |
| 9140 | } |
| 9141 | else |
| 9142 | { |
| 9143 | strncpy(buf, __name_, __size_); |
| 9144 | buf += __size_; |
| 9145 | } |
| 9146 | return buf; |
| 9147 | } |
| 9148 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 9149 | { |
| 9150 | const ptrdiff_t r = l - f; |
| 9151 | const ptrdiff_t n = sizeof("(__int128)") - 1; |
| 9152 | if (r >= __size_ + n) |
| 9153 | { |
| 9154 | *f++ = '('; |
| 9155 | *f++ = '_'; |
| 9156 | *f++ = '_'; |
| 9157 | *f++ = 'i'; |
| 9158 | *f++ = 'n'; |
| 9159 | *f++ = 't'; |
| 9160 | *f++ = '1'; |
| 9161 | *f++ = '2'; |
| 9162 | *f++ = '8'; |
| 9163 | *f = ')'; |
| 9164 | if (*__name_ == 'n') |
| 9165 | { |
| 9166 | *f++ = '-'; |
| 9167 | strncpy(f, __name_+1, __size_-1); |
| 9168 | } |
| 9169 | else |
| 9170 | strncpy(f, __name_, __size_); |
| 9171 | } |
| 9172 | return __size_ + n; |
| 9173 | } |
| 9174 | }; |
| 9175 | |
| 9176 | class __unsigned_int128 |
| 9177 | : public __node |
| 9178 | { |
| 9179 | static const size_t n = sizeof("unsigned __int128") - 1; |
| 9180 | public: |
| 9181 | |
| 9182 | virtual size_t first_size() const {return n;} |
| 9183 | virtual char* first_demangled_name(char* buf) const |
| 9184 | { |
| 9185 | strncpy(buf, "unsigned __int128", n); |
| 9186 | return buf + n; |
| 9187 | } |
| 9188 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 9189 | { |
| 9190 | const ptrdiff_t r = l - f; |
| 9191 | if (r >= n) |
| 9192 | { |
| 9193 | *f++ = 'u'; |
| 9194 | *f++ = 'n'; |
| 9195 | *f++ = 's'; |
| 9196 | *f++ = 'i'; |
| 9197 | *f++ = 'g'; |
| 9198 | *f++ = 'n'; |
| 9199 | *f++ = 'e'; |
| 9200 | *f++ = 'd'; |
| 9201 | *f++ = ' '; |
| 9202 | *f++ = '_'; |
| 9203 | *f++ = '_'; |
| 9204 | *f++ = 'i'; |
| 9205 | *f++ = 'n'; |
| 9206 | *f++ = 't'; |
| 9207 | *f++ = '1'; |
| 9208 | *f++ = '2'; |
| 9209 | *f = '8'; |
| 9210 | } |
| 9211 | return n; |
| 9212 | } |
| 9213 | }; |
| 9214 | |
| 9215 | class __unsigned_int128_literal |
| 9216 | : public __node |
| 9217 | { |
| 9218 | public: |
| 9219 | explicit __unsigned_int128_literal(const char* __first, const char* __last) |
| 9220 | { |
| 9221 | __name_ = __first; |
| 9222 | __size_ = __last - __first; |
| 9223 | } |
| 9224 | |
| 9225 | virtual size_t first_size() const |
| 9226 | { |
| 9227 | return __size_+19; |
| 9228 | } |
| 9229 | virtual char* first_demangled_name(char* buf) const |
| 9230 | { |
| 9231 | strncpy(buf, "(unsigned __int128)", 19); |
| 9232 | buf += 19; |
| 9233 | strncpy(buf, __name_, __size_); |
| 9234 | return buf + __size_; |
| 9235 | } |
| 9236 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 9237 | { |
| 9238 | const ptrdiff_t r = l - f; |
| 9239 | const ptrdiff_t n = sizeof("(unsigned __int128)") - 1; |
| 9240 | if (r >= __size_ + n) |
| 9241 | { |
| 9242 | *f++ = '('; |
| 9243 | *f++ = 'u'; |
| 9244 | *f++ = 'n'; |
| 9245 | *f++ = 's'; |
| 9246 | *f++ = 'i'; |
| 9247 | *f++ = 'g'; |
| 9248 | *f++ = 'n'; |
| 9249 | *f++ = 'e'; |
| 9250 | *f++ = 'd'; |
| 9251 | *f++ = ' '; |
| 9252 | *f++ = '_'; |
| 9253 | *f++ = '_'; |
| 9254 | *f++ = 'i'; |
| 9255 | *f++ = 'n'; |
| 9256 | *f++ = 't'; |
| 9257 | *f++ = '1'; |
| 9258 | *f++ = '2'; |
| 9259 | *f++ = '8'; |
| 9260 | *f = ')'; |
| 9261 | strncpy(f, __name_, __size_); |
| 9262 | } |
| 9263 | return __size_ + n; |
| 9264 | } |
| 9265 | }; |
| 9266 | |
| 9267 | class __float_literal |
| 9268 | : public __node |
| 9269 | { |
| 9270 | public: |
| 9271 | explicit __float_literal(float value) |
| 9272 | { |
| 9273 | __value_ = value; |
| 9274 | } |
| 9275 | |
| 9276 | virtual size_t first_size() const |
| 9277 | { |
| 9278 | if (__cached_size_ == -1) |
| 9279 | { |
| 9280 | char num[20] = {0}; |
| 9281 | float v = static_cast<float>(__value_); |
| 9282 | const_cast<long&>(__cached_size_) = sprintf(num, "%a", v)+1; |
| 9283 | } |
| 9284 | return __cached_size_; |
| 9285 | } |
| 9286 | virtual char* first_demangled_name(char* buf) const |
| 9287 | { |
| 9288 | char num[20] = {0}; |
| 9289 | float v = static_cast<float>(__value_); |
| 9290 | int n = sprintf(num, "%a", v); |
| 9291 | strncpy(buf, num, n); |
| 9292 | buf += n; |
| 9293 | *buf++ = 'f'; |
| 9294 | return buf; |
| 9295 | } |
| 9296 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 9297 | { |
| 9298 | const ptrdiff_t r = l - f; |
| 9299 | char num[20] = {0}; |
| 9300 | float v = static_cast<float>(__value_); |
| 9301 | ptrdiff_t n = sprintf(num, "%a", v); |
| 9302 | if (r >= n+1) |
| 9303 | { |
| 9304 | strncpy(f, num, n); |
| 9305 | f[n] = 'f'; |
| 9306 | } |
| 9307 | ++n; |
| 9308 | return n; |
| 9309 | } |
| 9310 | }; |
| 9311 | |
| 9312 | class __float |
| 9313 | : public __node |
| 9314 | { |
| 9315 | static const size_t n = sizeof("float") - 1; |
| 9316 | public: |
| 9317 | |
| 9318 | virtual size_t first_size() const {return n;} |
| 9319 | virtual char* first_demangled_name(char* buf) const |
| 9320 | { |
| 9321 | strncpy(buf, "float", n); |
| 9322 | return buf + n; |
| 9323 | } |
| 9324 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 9325 | { |
| 9326 | const ptrdiff_t r = l - f; |
| 9327 | if (r >= n) |
| 9328 | { |
| 9329 | *f++ = 'f'; |
| 9330 | *f++ = 'l'; |
| 9331 | *f++ = 'o'; |
| 9332 | *f++ = 'a'; |
| 9333 | *f = 't'; |
| 9334 | } |
| 9335 | return n; |
| 9336 | } |
| 9337 | }; |
| 9338 | |
| 9339 | class __double_literal |
| 9340 | : public __node |
| 9341 | { |
| 9342 | public: |
| 9343 | explicit __double_literal(double value) |
| 9344 | { |
| 9345 | __value_ = value; |
| 9346 | } |
| 9347 | |
| 9348 | virtual size_t first_size() const |
| 9349 | { |
| 9350 | if (__cached_size_ == -1) |
| 9351 | { |
| 9352 | char num[30] = {0}; |
| 9353 | double v = static_cast<double>(__value_); |
| 9354 | const_cast<long&>(__cached_size_) = sprintf(num, "%a", v); |
| 9355 | } |
| 9356 | return __cached_size_; |
| 9357 | } |
| 9358 | virtual char* first_demangled_name(char* buf) const |
| 9359 | { |
| 9360 | char num[30] = {0}; |
| 9361 | double v = static_cast<double>(__value_); |
| 9362 | int n = sprintf(num, "%a", v); |
| 9363 | strncpy(buf, num, n); |
| 9364 | return buf + n; |
| 9365 | } |
| 9366 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 9367 | { |
| 9368 | const ptrdiff_t r = l - f; |
| 9369 | char num[30] = {0}; |
| 9370 | double v = static_cast<double>(__value_); |
| 9371 | const ptrdiff_t n = sprintf(num, "%a", v); |
| 9372 | if (r >= n) |
| 9373 | strncpy(f, num, n); |
| 9374 | return n; |
| 9375 | } |
| 9376 | }; |
| 9377 | |
| 9378 | class __double |
| 9379 | : public __node |
| 9380 | { |
| 9381 | static const size_t n = sizeof("double") - 1; |
| 9382 | public: |
| 9383 | |
| 9384 | virtual size_t first_size() const {return n;} |
| 9385 | virtual char* first_demangled_name(char* buf) const |
| 9386 | { |
| 9387 | strncpy(buf, "double", n); |
| 9388 | return buf + n; |
| 9389 | } |
| 9390 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 9391 | { |
| 9392 | const ptrdiff_t r = l - f; |
| 9393 | if (r >= n) |
| 9394 | { |
| 9395 | *f++ = 'd'; |
| 9396 | *f++ = 'o'; |
| 9397 | *f++ = 'u'; |
| 9398 | *f++ = 'b'; |
| 9399 | *f++ = 'l'; |
| 9400 | *f = 'e'; |
| 9401 | } |
| 9402 | return n; |
| 9403 | } |
| 9404 | }; |
| 9405 | |
| 9406 | class __long_double |
| 9407 | : public __node |
| 9408 | { |
| 9409 | static const size_t n = sizeof("long double") - 1; |
| 9410 | public: |
| 9411 | |
| 9412 | virtual size_t first_size() const {return n;} |
| 9413 | virtual char* first_demangled_name(char* buf) const |
| 9414 | { |
| 9415 | strncpy(buf, "long double", n); |
| 9416 | return buf + n; |
| 9417 | } |
| 9418 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 9419 | { |
| 9420 | const ptrdiff_t r = l - f; |
| 9421 | if (r >= n) |
| 9422 | { |
| 9423 | *f++ = 'l'; |
| 9424 | *f++ = 'o'; |
| 9425 | *f++ = 'n'; |
| 9426 | *f++ = 'g'; |
| 9427 | *f++ = ' '; |
| 9428 | *f++ = 'd'; |
| 9429 | *f++ = 'o'; |
| 9430 | *f++ = 'u'; |
| 9431 | *f++ = 'b'; |
| 9432 | *f++ = 'l'; |
| 9433 | *f = 'e'; |
| 9434 | } |
| 9435 | return n; |
| 9436 | } |
| 9437 | }; |
| 9438 | |
| 9439 | class __float128 |
| 9440 | : public __node |
| 9441 | { |
| 9442 | static const size_t n = sizeof("__float128") - 1; |
| 9443 | public: |
| 9444 | |
| 9445 | virtual size_t first_size() const {return n;} |
| 9446 | virtual char* first_demangled_name(char* buf) const |
| 9447 | { |
| 9448 | strncpy(buf, "__float128", n); |
| 9449 | return buf + n; |
| 9450 | } |
| 9451 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 9452 | { |
| 9453 | const ptrdiff_t r = l - f; |
| 9454 | if (r >= n) |
| 9455 | { |
| 9456 | *f++ = '_'; |
| 9457 | *f++ = '_'; |
| 9458 | *f++ = 'f'; |
| 9459 | *f++ = 'l'; |
| 9460 | *f++ = 'o'; |
| 9461 | *f++ = 'a'; |
| 9462 | *f++ = 't'; |
| 9463 | *f++ = '1'; |
| 9464 | *f++ = '2'; |
| 9465 | *f = '8'; |
| 9466 | } |
| 9467 | return n; |
| 9468 | } |
| 9469 | }; |
| 9470 | |
| 9471 | class __ellipsis |
| 9472 | : public __node |
| 9473 | { |
| 9474 | static const size_t n = sizeof("...") - 1; |
| 9475 | public: |
| 9476 | |
| 9477 | virtual size_t first_size() const {return n;} |
| 9478 | virtual char* first_demangled_name(char* buf) const |
| 9479 | { |
| 9480 | *buf++ = '.'; |
| 9481 | *buf++ = '.'; |
| 9482 | *buf++ = '.'; |
| 9483 | return buf; |
| 9484 | } |
| 9485 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 9486 | { |
| 9487 | const ptrdiff_t r = l - f; |
| 9488 | if (r >= n) |
| 9489 | { |
| 9490 | *f++ = '.'; |
| 9491 | *f++ = '.'; |
| 9492 | *f = '.'; |
| 9493 | } |
| 9494 | return n; |
| 9495 | } |
| 9496 | }; |
| 9497 | |
| 9498 | class __decimal64 |
| 9499 | : public __node |
| 9500 | { |
| 9501 | static const size_t n = sizeof("decimal64") - 1; |
| 9502 | public: |
| 9503 | |
| 9504 | virtual size_t first_size() const {return n;} |
| 9505 | virtual char* first_demangled_name(char* buf) const |
| 9506 | { |
| 9507 | strncpy(buf, "decimal64", n); |
| 9508 | return buf + n; |
| 9509 | } |
| 9510 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 9511 | { |
| 9512 | const ptrdiff_t r = l - f; |
| 9513 | if (r >= n) |
| 9514 | { |
| 9515 | *f++ = 'd'; |
| 9516 | *f++ = 'e'; |
| 9517 | *f++ = 'c'; |
| 9518 | *f++ = 'i'; |
| 9519 | *f++ = 'm'; |
| 9520 | *f++ = 'a'; |
| 9521 | *f++ = 'l'; |
| 9522 | *f++ = '6'; |
| 9523 | *f = '4'; |
| 9524 | } |
| 9525 | return n; |
| 9526 | } |
| 9527 | }; |
| 9528 | |
| 9529 | class __decimal128 |
| 9530 | : public __node |
| 9531 | { |
| 9532 | static const size_t n = sizeof("decimal128") - 1; |
| 9533 | public: |
| 9534 | |
| 9535 | virtual size_t first_size() const {return n;} |
| 9536 | virtual char* first_demangled_name(char* buf) const |
| 9537 | { |
| 9538 | strncpy(buf, "decimal128", n); |
| 9539 | return buf + n; |
| 9540 | } |
| 9541 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 9542 | { |
| 9543 | const ptrdiff_t r = l - f; |
| 9544 | if (r >= n) |
| 9545 | { |
| 9546 | *f++ = 'd'; |
| 9547 | *f++ = 'e'; |
| 9548 | *f++ = 'c'; |
| 9549 | *f++ = 'i'; |
| 9550 | *f++ = 'm'; |
| 9551 | *f++ = 'a'; |
| 9552 | *f++ = 'l'; |
| 9553 | *f++ = '1'; |
| 9554 | *f++ = '2'; |
| 9555 | *f = '8'; |
| 9556 | } |
| 9557 | return n; |
| 9558 | } |
| 9559 | }; |
| 9560 | |
| 9561 | class __decimal32 |
| 9562 | : public __node |
| 9563 | { |
| 9564 | static const size_t n = sizeof("decimal32") - 1; |
| 9565 | public: |
| 9566 | |
| 9567 | virtual size_t first_size() const {return n;} |
| 9568 | virtual char* first_demangled_name(char* buf) const |
| 9569 | { |
| 9570 | strncpy(buf, "decimal32", n); |
| 9571 | return buf + n; |
| 9572 | } |
| 9573 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 9574 | { |
| 9575 | const ptrdiff_t r = l - f; |
| 9576 | if (r >= n) |
| 9577 | { |
| 9578 | *f++ = 'd'; |
| 9579 | *f++ = 'e'; |
| 9580 | *f++ = 'c'; |
| 9581 | *f++ = 'i'; |
| 9582 | *f++ = 'm'; |
| 9583 | *f++ = 'a'; |
| 9584 | *f++ = 'l'; |
| 9585 | *f++ = '3'; |
| 9586 | *f = '2'; |
| 9587 | } |
| 9588 | return n; |
| 9589 | } |
| 9590 | }; |
| 9591 | |
| 9592 | class __decimal16 |
| 9593 | : public __node |
| 9594 | { |
| 9595 | static const size_t n = sizeof("decimal16") - 1; |
| 9596 | public: |
| 9597 | |
| 9598 | virtual size_t first_size() const {return n;} |
| 9599 | virtual char* first_demangled_name(char* buf) const |
| 9600 | { |
| 9601 | strncpy(buf, "decimal16", n); |
| 9602 | return buf + n; |
| 9603 | } |
| 9604 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 9605 | { |
| 9606 | const ptrdiff_t r = l - f; |
| 9607 | if (r >= n) |
| 9608 | { |
| 9609 | *f++ = 'd'; |
| 9610 | *f++ = 'e'; |
| 9611 | *f++ = 'c'; |
| 9612 | *f++ = 'i'; |
| 9613 | *f++ = 'm'; |
| 9614 | *f++ = 'a'; |
| 9615 | *f++ = 'l'; |
| 9616 | *f++ = '1'; |
| 9617 | *f = '6'; |
| 9618 | } |
| 9619 | return n; |
| 9620 | } |
| 9621 | }; |
| 9622 | |
| 9623 | class __d_char32_t |
| 9624 | : public __node |
| 9625 | { |
| 9626 | static const size_t n = sizeof("char32_t") - 1; |
| 9627 | public: |
| 9628 | |
| 9629 | virtual size_t first_size() const {return n;} |
| 9630 | virtual char* first_demangled_name(char* buf) const |
| 9631 | { |
| 9632 | strncpy(buf, "char32_t", n); |
| 9633 | return buf + n; |
| 9634 | } |
| 9635 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 9636 | { |
| 9637 | const ptrdiff_t r = l - f; |
| 9638 | if (r >= n) |
| 9639 | { |
| 9640 | *f++ = 'c'; |
| 9641 | *f++ = 'h'; |
| 9642 | *f++ = 'a'; |
| 9643 | *f++ = 'r'; |
| 9644 | *f++ = '3'; |
| 9645 | *f++ = '2'; |
| 9646 | *f++ = '_'; |
| 9647 | *f = 't'; |
| 9648 | } |
| 9649 | return n; |
| 9650 | } |
| 9651 | }; |
| 9652 | |
| 9653 | class __d_char16_t |
| 9654 | : public __node |
| 9655 | { |
| 9656 | static const size_t n = sizeof("char16_t") - 1; |
| 9657 | public: |
| 9658 | |
| 9659 | virtual size_t first_size() const {return n;} |
| 9660 | virtual char* first_demangled_name(char* buf) const |
| 9661 | { |
| 9662 | strncpy(buf, "char16_t", n); |
| 9663 | return buf + n; |
| 9664 | } |
| 9665 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 9666 | { |
| 9667 | const ptrdiff_t r = l - f; |
| 9668 | if (r >= n) |
| 9669 | { |
| 9670 | *f++ = 'c'; |
| 9671 | *f++ = 'h'; |
| 9672 | *f++ = 'a'; |
| 9673 | *f++ = 'r'; |
| 9674 | *f++ = '1'; |
| 9675 | *f++ = '6'; |
| 9676 | *f++ = '_'; |
| 9677 | *f = 't'; |
| 9678 | } |
| 9679 | return n; |
| 9680 | } |
| 9681 | }; |
| 9682 | |
| 9683 | class __auto |
| 9684 | : public __node |
| 9685 | { |
| 9686 | static const size_t n = sizeof("auto") - 1; |
| 9687 | public: |
| 9688 | |
| 9689 | virtual size_t first_size() const {return n;} |
| 9690 | virtual char* first_demangled_name(char* buf) const |
| 9691 | { |
| 9692 | strncpy(buf, "auto", n); |
| 9693 | return buf + n; |
| 9694 | } |
| 9695 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 9696 | { |
| 9697 | const ptrdiff_t r = l - f; |
| 9698 | if (r >= n) |
| 9699 | { |
| 9700 | *f++ = 'a'; |
| 9701 | *f++ = 'u'; |
| 9702 | *f++ = 't'; |
| 9703 | *f = 'o'; |
| 9704 | } |
| 9705 | return n; |
| 9706 | } |
| 9707 | }; |
| 9708 | |
| 9709 | class __nullptr_t |
| 9710 | : public __node |
| 9711 | { |
| 9712 | static const size_t n = sizeof("std::nullptr_t") - 1; |
| 9713 | public: |
| 9714 | |
| 9715 | virtual size_t first_size() const {return n;} |
| 9716 | virtual char* first_demangled_name(char* buf) const |
| 9717 | { |
| 9718 | strncpy(buf, "std::nullptr_t", n); |
| 9719 | return buf + n; |
| 9720 | } |
| 9721 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 9722 | { |
| 9723 | const ptrdiff_t r = l - f; |
| 9724 | if (r >= n) |
| 9725 | { |
| 9726 | *f++ = 's'; |
| 9727 | *f++ = 't'; |
| 9728 | *f++ = 'd'; |
| 9729 | *f++ = ':'; |
| 9730 | *f++ = ':'; |
| 9731 | *f++ = 'n'; |
| 9732 | *f++ = 'u'; |
| 9733 | *f++ = 'l'; |
| 9734 | *f++ = 'l'; |
| 9735 | *f++ = 'p'; |
| 9736 | *f++ = 't'; |
| 9737 | *f++ = 'r'; |
| 9738 | *f++ = '_'; |
| 9739 | *f = 't'; |
| 9740 | } |
| 9741 | return n; |
| 9742 | } |
| 9743 | }; |
| 9744 | |
| 9745 | class __array |
| 9746 | : public __node |
| 9747 | { |
| 9748 | public: |
| 9749 | |
| 9750 | explicit __array(__node* type) |
| 9751 | { |
| 9752 | __left_ = type; |
| 9753 | } |
| 9754 | |
| 9755 | __array(__node* type, size_t dim) |
| 9756 | { |
| 9757 | __left_ = type; |
| 9758 | __size_ = dim; |
| 9759 | } |
| 9760 | |
| 9761 | __array(__node* type, __node* dim) |
| 9762 | { |
| 9763 | __left_ = type; |
| 9764 | __right_ = dim; |
| 9765 | } |
| 9766 | |
| 9767 | virtual size_t size() const |
| 9768 | { |
| 9769 | if (__cached_size_ == -1) |
| 9770 | { |
| 9771 | size_t r = __left_->size() + 3; |
| 9772 | if (__right_ != 0) |
| 9773 | r += __right_->size(); |
| 9774 | else if (__size_ != 0) |
| 9775 | r += snprintf(0, 0, "%ld", __size_); |
| 9776 | const_cast<long&>(__cached_size_) = r; |
| 9777 | } |
| 9778 | return __cached_size_; |
| 9779 | } |
| 9780 | |
| 9781 | virtual char* get_demangled_name(char* buf) const |
| 9782 | { |
| 9783 | buf = __left_->get_demangled_name(buf); |
| 9784 | *buf++ = ' '; |
| 9785 | *buf++ = '['; |
| 9786 | if (__right_ != 0) |
| 9787 | buf = __right_->get_demangled_name(buf); |
| 9788 | else if (__size_ != 0) |
| 9789 | { |
| 9790 | size_t rs = sprintf(buf, "%ld", __size_); |
| 9791 | buf += rs; |
| 9792 | } |
| 9793 | *buf++ = ']'; |
| 9794 | return buf; |
| 9795 | } |
| 9796 | virtual ptrdiff_t print(char* f, char* l) const |
| 9797 | { |
| 9798 | const ptrdiff_t r = l - f; |
| 9799 | const ptrdiff_t n = 3; |
| 9800 | const ptrdiff_t sz1 = __left_->print(f, l); |
| 9801 | char buf[20]; |
| 9802 | ptrdiff_t sz2 = 0; |
| 9803 | if (__right_ != 0) |
| 9804 | sz2 = __right_->print(f+std::min(sz1+(n-1), r), l); |
| 9805 | else if (__size_ != 0) |
| 9806 | { |
| 9807 | sz2 = sprintf(buf, "%ld", __size_); |
| 9808 | if (r >= sz1 + sz2 + n) |
| 9809 | strncpy(f+sz1+2, buf, sz2); |
| 9810 | } |
| 9811 | if (r >= sz1 + sz2 + n) |
| 9812 | { |
| 9813 | f += sz1; |
| 9814 | *f++ = ' '; |
| 9815 | *f = '['; |
| 9816 | f += 1 + sz2; |
| 9817 | *f = ']'; |
| 9818 | } |
| 9819 | return sz1 + sz2 + n; |
| 9820 | } |
| 9821 | |
| 9822 | virtual size_t first_size() const |
| 9823 | { |
| 9824 | return __left_->first_size(); |
| 9825 | } |
| 9826 | |
| 9827 | virtual char* first_demangled_name(char* buf) const |
| 9828 | { |
| 9829 | return __left_->first_demangled_name(buf); |
| 9830 | } |
| 9831 | |
| 9832 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 9833 | { |
| 9834 | return __left_->print_first(f, l); |
| 9835 | } |
| 9836 | |
| 9837 | virtual size_t second_size() const |
| 9838 | { |
| 9839 | size_t r = 2 + __left_->second_size(); |
| 9840 | if (!__left_->is_array()) |
| 9841 | ++r; |
| 9842 | if (__right_ != 0) |
| 9843 | r += __right_->size(); |
| 9844 | else if (__size_ != 0) |
| 9845 | r += snprintf(0, 0, "%ld", __size_); |
| 9846 | return r; |
| 9847 | } |
| 9848 | |
| 9849 | virtual char* second_demangled_name(char* buf) const |
| 9850 | { |
| 9851 | *buf++ = ' '; |
| 9852 | *buf++ = '['; |
| 9853 | if (__right_ != 0) |
| 9854 | buf = __right_->get_demangled_name(buf); |
| 9855 | else if (__size_ != 0) |
| 9856 | { |
| 9857 | size_t off = sprintf(buf, "%ld", __size_); |
| 9858 | buf += off; |
| 9859 | } |
| 9860 | char* t = buf; |
| 9861 | buf = __left_->second_demangled_name(buf); |
| 9862 | *t = ']'; |
| 9863 | if (buf == t) |
| 9864 | ++buf; |
| 9865 | return buf; |
| 9866 | } |
| 9867 | virtual ptrdiff_t print_second(char* f, char* l) const |
| 9868 | { |
| 9869 | const ptrdiff_t r = l - f; |
| 9870 | ptrdiff_t n = 2; |
| 9871 | char buf[20]; |
| 9872 | ptrdiff_t sz2 = 0; |
| 9873 | if (__right_ != 0) |
| 9874 | sz2 = __right_->print(f+std::min(n, r), l); |
| 9875 | else if (__size_ != 0) |
| 9876 | { |
| 9877 | sz2 = sprintf(buf, "%ld", __size_); |
| 9878 | if (r >= sz2 + 3) |
| 9879 | strncpy(f+2, buf, sz2); |
| 9880 | } |
| 9881 | const ptrdiff_t sz1 = __left_->print_second(f+std::min(2+sz2, r), l); |
| 9882 | if (sz1 == 0) |
| 9883 | ++n; |
| 9884 | if (r >= sz1 + sz2 + n) |
| 9885 | { |
| 9886 | *f++ = ' '; |
| 9887 | *f = '['; |
| 9888 | f += 1 + sz2; |
| 9889 | *f = ']'; |
| 9890 | } |
| 9891 | return sz1 + sz2 + n; |
| 9892 | } |
| 9893 | virtual bool is_array() const |
| 9894 | { |
| 9895 | return true; |
| 9896 | } |
| 9897 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 9898 | { |
| 9899 | bool r = __left_->fix_forward_references(t_begin, t_end); |
| 9900 | if (__right_) |
| 9901 | r = r && __right_->fix_forward_references(t_begin, t_end); |
| 9902 | return r; |
| 9903 | } |
| 9904 | }; |
| 9905 | |
| 9906 | class __pointer_to_member_type |
| 9907 | : public __node |
| 9908 | { |
| 9909 | public: |
| 9910 | |
| 9911 | __pointer_to_member_type(__node* class_type, __node* member_type) |
| 9912 | { |
| 9913 | __left_ = class_type; |
| 9914 | __right_ = member_type; |
| 9915 | } |
| 9916 | |
| 9917 | virtual size_t first_size() const |
| 9918 | { |
| 9919 | if (__cached_size_ == -1) |
| 9920 | const_cast<long&>(__cached_size_) = __left_->size() + 3 + __right_->size(); |
| 9921 | return __cached_size_; |
| 9922 | } |
| 9923 | virtual char* first_demangled_name(char* buf) const |
| 9924 | { |
| 9925 | buf = __right_->first_demangled_name(buf); |
| 9926 | buf = __left_->get_demangled_name(buf); |
| 9927 | *buf++ = ':'; |
| 9928 | *buf++ = ':'; |
| 9929 | *buf++ = '*'; |
| 9930 | return __right_->second_demangled_name(buf); |
| 9931 | } |
| 9932 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 9933 | { |
| 9934 | const ptrdiff_t r = l - f; |
| 9935 | const ptrdiff_t n = 3; |
| 9936 | const ptrdiff_t sz1 = __right_->print_first(f, l); |
| 9937 | const ptrdiff_t sz2 = __left_->print(f+std::min(sz1, r), l); |
| 9938 | const ptrdiff_t sz3 = __right_->print_second(f+std::min(sz1+sz2+n, r), l); |
| 9939 | if (r >= sz1 + sz2 + sz3 + n) |
| 9940 | { |
| 9941 | f += sz1 + sz2; |
| 9942 | *f++ = ':'; |
| 9943 | *f++ = ':'; |
| 9944 | *f = '*'; |
| 9945 | } |
| 9946 | return sz1 + sz2 + sz3 + n; |
| 9947 | } |
| 9948 | virtual __node* base_name() const |
| 9949 | { |
| 9950 | return __left_->base_name(); |
| 9951 | } |
| 9952 | virtual bool is_reference_or_pointer_to_function_or_array() const |
| 9953 | { |
| 9954 | return __right_->is_function(); |
| 9955 | } |
| 9956 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 9957 | { |
| 9958 | return __left_->fix_forward_references(t_begin, t_end) && |
| 9959 | __right_->fix_forward_references(t_begin, t_end); |
| 9960 | } |
| 9961 | }; |
| 9962 | |
| 9963 | class __decltype_node |
| 9964 | : public __node |
| 9965 | { |
| 9966 | public: |
| 9967 | |
| 9968 | explicit __decltype_node(__node* expr) |
| 9969 | { |
| 9970 | __right_ = expr; |
| 9971 | } |
| 9972 | |
| 9973 | virtual size_t first_size() const |
| 9974 | { |
| 9975 | if (__cached_size_ == -1) |
| 9976 | const_cast<long&>(__cached_size_) = 10 + __right_->size(); |
| 9977 | return __cached_size_; |
| 9978 | } |
| 9979 | |
| 9980 | virtual char* first_demangled_name(char* buf) const |
| 9981 | { |
| 9982 | strncpy(buf, "decltype(", 9); |
| 9983 | buf += 9; |
| 9984 | buf = __right_->get_demangled_name(buf); |
| 9985 | *buf++ = ')'; |
| 9986 | return buf; |
| 9987 | } |
| 9988 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 9989 | { |
| 9990 | const ptrdiff_t r = l - f; |
| 9991 | const ptrdiff_t n = sizeof("decltype()") - 1; |
| 9992 | const ptrdiff_t sz1 = __right_->print(f+std::min(n-1, r), l); |
| 9993 | if (r >= sz1 + n) |
| 9994 | { |
| 9995 | *f++ = 'd'; |
| 9996 | *f++ = 'e'; |
| 9997 | *f++ = 'c'; |
| 9998 | *f++ = 'l'; |
| 9999 | *f++ = 't'; |
| 10000 | *f++ = 'y'; |
| 10001 | *f++ = 'p'; |
| 10002 | *f++ = 'e'; |
| 10003 | *f = '('; |
| 10004 | f += 1 + sz1; |
| 10005 | *f = ')'; |
| 10006 | } |
| 10007 | return sz1 + n; |
| 10008 | } |
| 10009 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 10010 | { |
| 10011 | return __right_->fix_forward_references(t_begin, t_end); |
| 10012 | } |
| 10013 | }; |
| 10014 | |
| 10015 | class __nested_delimeter |
| 10016 | : public __node |
| 10017 | { |
| 10018 | public: |
| 10019 | |
| 10020 | explicit __nested_delimeter(__node* prev, __node* arg) |
| 10021 | { |
| 10022 | __left_ = prev; |
| 10023 | __right_ = arg; |
| 10024 | } |
| 10025 | |
| 10026 | virtual size_t first_size() const |
| 10027 | { |
| 10028 | if (__cached_size_ == -1) |
| 10029 | const_cast<long&>(__cached_size_) = __left_->size() + __right_->size() + 2; |
| 10030 | return __cached_size_; |
| 10031 | } |
| 10032 | |
| 10033 | virtual char* first_demangled_name(char* buf) const |
| 10034 | { |
| 10035 | buf = __left_->get_demangled_name(buf); |
| 10036 | *buf++ = ':'; |
| 10037 | *buf++ = ':'; |
| 10038 | return __right_->get_demangled_name(buf); |
| 10039 | } |
| 10040 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 10041 | { |
| 10042 | const ptrdiff_t r = l - f; |
| 10043 | const ptrdiff_t n = sizeof("::") - 1; |
| 10044 | const ptrdiff_t sz1 = __left_->print(f, l); |
| 10045 | if (r >= sz1 + n) |
| 10046 | { |
| 10047 | f += sz1; |
| 10048 | *f++ = ':'; |
| 10049 | *f++ = ':'; |
| 10050 | } |
| 10051 | const ptrdiff_t sz2 = __right_->print(f, l); |
| 10052 | return sz1 + n + sz2; |
| 10053 | } |
| 10054 | |
| 10055 | virtual bool ends_with_template() const |
| 10056 | { |
| 10057 | return __right_->ends_with_template(); |
| 10058 | } |
| 10059 | virtual __node* base_name() const |
| 10060 | { |
| 10061 | return __right_->base_name(); |
| 10062 | } |
| 10063 | virtual bool is_ctor_dtor_conv() const |
| 10064 | { |
| 10065 | return __right_->is_ctor_dtor_conv(); |
| 10066 | } |
| 10067 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 10068 | { |
| 10069 | return __left_->fix_forward_references(t_begin, t_end) && |
| 10070 | __right_->fix_forward_references(t_begin, t_end); |
| 10071 | } |
| 10072 | virtual __node* extract_cv(__node*& rt) const |
| 10073 | { |
| 10074 | return __right_->extract_cv(const_cast<__node*&>(__right_)); |
| 10075 | } |
| 10076 | }; |
| 10077 | |
| 10078 | class __unresolved_name |
| 10079 | : public __node |
| 10080 | { |
| 10081 | public: |
| 10082 | |
| 10083 | __unresolved_name(__node* prev, __node* arg) |
| 10084 | { |
| 10085 | __left_ = prev; |
| 10086 | __right_ = arg; |
| 10087 | } |
| 10088 | |
| 10089 | __unresolved_name(bool global, __node* prev, __node* arg) |
| 10090 | { |
| 10091 | __size_ = global; |
| 10092 | __left_ = prev; |
| 10093 | __right_ = arg; |
| 10094 | } |
| 10095 | |
| 10096 | virtual size_t first_size() const |
| 10097 | { |
| 10098 | if (__cached_size_ == -1) |
| 10099 | const_cast<long&>(__cached_size_) = (__left_ ? __left_->size() + 2 : 0) + |
| 10100 | __right_->size() + __size_ * 2; |
| 10101 | return __cached_size_; |
| 10102 | } |
| 10103 | |
| 10104 | virtual char* first_demangled_name(char* buf) const |
| 10105 | { |
| 10106 | if (__size_) |
| 10107 | { |
| 10108 | *buf++ = ':'; |
| 10109 | *buf++ = ':'; |
| 10110 | } |
| 10111 | if (__left_) |
| 10112 | { |
| 10113 | buf = __left_->get_demangled_name(buf); |
| 10114 | *buf++ = ':'; |
| 10115 | *buf++ = ':'; |
| 10116 | } |
| 10117 | return __right_->get_demangled_name(buf); |
| 10118 | } |
| 10119 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 10120 | { |
| 10121 | const ptrdiff_t r = l - f; |
| 10122 | ptrdiff_t n = 0; |
| 10123 | if (__size_) |
| 10124 | { |
| 10125 | n = 2; |
| 10126 | if (r >= n) |
| 10127 | { |
| 10128 | f[0] = ':'; |
| 10129 | f[1] = ':'; |
| 10130 | } |
| 10131 | } |
| 10132 | ptrdiff_t sz1 = 0; |
| 10133 | if (__left_) |
| 10134 | { |
| 10135 | sz1 = __left_->print(f+std::min(n, r), l); |
| 10136 | n += 2; |
| 10137 | if (r >= sz1 + n) |
| 10138 | { |
| 10139 | f[sz1 + n - 2] = ':'; |
| 10140 | f[sz1 + n - 1] = ':'; |
| 10141 | } |
| 10142 | } |
| 10143 | const ptrdiff_t sz2 = __right_->print(f+std::min(sz1+n, r), l); |
| 10144 | return sz1 + n + sz2; |
| 10145 | } |
| 10146 | |
| 10147 | virtual bool ends_with_template() const |
| 10148 | { |
| 10149 | return __right_->ends_with_template(); |
| 10150 | } |
| 10151 | virtual __node* base_name() const |
| 10152 | { |
| 10153 | return __right_->base_name(); |
| 10154 | } |
| 10155 | virtual bool is_ctor_dtor_conv() const |
| 10156 | { |
| 10157 | return __right_->is_ctor_dtor_conv(); |
| 10158 | } |
| 10159 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 10160 | { |
| 10161 | bool r = true; |
| 10162 | if (__left_) |
| 10163 | r = __left_->fix_forward_references(t_begin, t_end); |
| 10164 | return r && __right_->fix_forward_references(t_begin, t_end); |
| 10165 | } |
| 10166 | virtual __node* extract_cv(__node*& rt) const |
| 10167 | { |
| 10168 | return __right_->extract_cv(const_cast<__node*&>(__right_)); |
| 10169 | } |
| 10170 | }; |
| 10171 | |
| 10172 | class __string_literal |
| 10173 | : public __node |
| 10174 | { |
| 10175 | public: |
| 10176 | |
| 10177 | virtual size_t first_size() const |
| 10178 | { |
| 10179 | return 14; |
| 10180 | } |
| 10181 | |
| 10182 | virtual char* first_demangled_name(char* buf) const |
| 10183 | { |
| 10184 | strncpy(buf, "string literal", 14); |
| 10185 | return buf + 14; |
| 10186 | } |
| 10187 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 10188 | { |
| 10189 | const ptrdiff_t r = l - f; |
| 10190 | const ptrdiff_t n = sizeof("string literal") - 1; |
| 10191 | if (r >= n) |
| 10192 | { |
| 10193 | *f++ = 's'; |
| 10194 | *f++ = 't'; |
| 10195 | *f++ = 'r'; |
| 10196 | *f++ = 'i'; |
| 10197 | *f++ = 'n'; |
| 10198 | *f++ = 'g'; |
| 10199 | *f++ = ' '; |
| 10200 | *f++ = 'l'; |
| 10201 | *f++ = 'i'; |
| 10202 | *f++ = 't'; |
| 10203 | *f++ = 'e'; |
| 10204 | *f++ = 'r'; |
| 10205 | *f++ = 'a'; |
| 10206 | *f = 'l'; |
| 10207 | } |
| 10208 | return n; |
| 10209 | } |
| 10210 | }; |
| 10211 | |
| 10212 | class __constructor |
| 10213 | : public __node |
| 10214 | { |
| 10215 | public: |
| 10216 | |
| 10217 | explicit __constructor(__node* name) |
| 10218 | { |
| 10219 | __right_ = name; |
| 10220 | } |
| 10221 | |
| 10222 | virtual size_t first_size() const |
| 10223 | { |
| 10224 | if (__cached_size_ == -1) |
| 10225 | const_cast<long&>(__cached_size_) = __right_->base_size(); |
| 10226 | return __cached_size_; |
| 10227 | } |
| 10228 | |
| 10229 | virtual char* first_demangled_name(char* buf) const |
| 10230 | { |
| 10231 | return __right_->get_base_name(buf); |
| 10232 | } |
| 10233 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 10234 | { |
| 10235 | return __right_->print_base_name(f, l); |
| 10236 | } |
| 10237 | virtual __node* base_name() const |
| 10238 | { |
| 10239 | return __right_->base_name(); |
| 10240 | } |
| 10241 | virtual bool ends_with_template() const |
| 10242 | { |
| 10243 | return __right_->ends_with_template(); |
| 10244 | } |
| 10245 | virtual bool is_ctor_dtor_conv() const |
| 10246 | { |
| 10247 | return true; |
| 10248 | } |
| 10249 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 10250 | { |
| 10251 | return __right_->fix_forward_references(t_begin, t_end); |
| 10252 | } |
| 10253 | }; |
| 10254 | |
| 10255 | class __destructor |
| 10256 | : public __node |
| 10257 | { |
| 10258 | public: |
| 10259 | |
| 10260 | explicit __destructor(__node* name) |
| 10261 | { |
| 10262 | __right_ = name; |
| 10263 | } |
| 10264 | |
| 10265 | virtual size_t first_size() const |
| 10266 | { |
| 10267 | if (__cached_size_ == -1) |
| 10268 | const_cast<long&>(__cached_size_) = __right_->base_size() + 1; |
| 10269 | return __cached_size_; |
| 10270 | } |
| 10271 | |
| 10272 | virtual char* first_demangled_name(char* buf) const |
| 10273 | { |
| 10274 | *buf++ = '~'; |
| 10275 | return __right_->get_base_name(buf); |
| 10276 | } |
| 10277 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 10278 | { |
| 10279 | const ptrdiff_t r = l - f; |
| 10280 | const ptrdiff_t n = 1; |
| 10281 | const ptrdiff_t sz = __right_->print_base_name(f+std::min(n, r), l); |
| 10282 | if (r >= n + sz) |
| 10283 | *f = '~'; |
| 10284 | return n + sz; |
| 10285 | } |
| 10286 | virtual __node* base_name() const |
| 10287 | { |
| 10288 | return __right_->base_name(); |
| 10289 | } |
| 10290 | virtual bool is_ctor_dtor_conv() const |
| 10291 | { |
| 10292 | return true; |
| 10293 | } |
| 10294 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 10295 | { |
| 10296 | return __right_->fix_forward_references(t_begin, t_end); |
| 10297 | } |
| 10298 | }; |
| 10299 | |
| 10300 | class __dot_suffix |
| 10301 | : public __node |
| 10302 | { |
| 10303 | public: |
| 10304 | __dot_suffix(__node* name, const char* suffix, unsigned sz) |
| 10305 | { |
| 10306 | __left_ = name; |
| 10307 | __name_ = suffix; |
| 10308 | __size_ = sz; |
| 10309 | } |
| 10310 | |
| 10311 | virtual size_t first_size() const |
| 10312 | { |
| 10313 | if (__cached_size_ == -1) |
| 10314 | { |
| 10315 | size_t off = __left_->size(); |
| 10316 | off += __size_ + 3; |
| 10317 | const_cast<long&>(__cached_size_) = off; |
| 10318 | } |
| 10319 | return __cached_size_; |
| 10320 | } |
| 10321 | virtual char* first_demangled_name(char* buf) const |
| 10322 | { |
| 10323 | buf = __left_->get_demangled_name(buf); |
| 10324 | *buf++ = ' '; |
| 10325 | *buf++ = '('; |
| 10326 | strncpy(buf, __name_, __size_); |
| 10327 | buf += __size_; |
| 10328 | *buf++ = ')'; |
| 10329 | return buf; |
| 10330 | } |
| 10331 | virtual ptrdiff_t print_first(char* f, char* l) const |
| 10332 | { |
| 10333 | const ptrdiff_t r = l - f; |
| 10334 | const ptrdiff_t n = 3 + __size_; |
| 10335 | const ptrdiff_t sz = __left_->print(f, l); |
| 10336 | if (r >= n + sz) |
| 10337 | { |
| 10338 | f += sz; |
| 10339 | *f++ = ' '; |
| 10340 | *f++ = '('; |
| 10341 | strncpy(f, __name_, __size_); |
| 10342 | f += __size_; |
| 10343 | *f = ')'; |
| 10344 | } |
| 10345 | return n + sz; |
| 10346 | } |
| 10347 | virtual __node* base_name() const |
| 10348 | { |
| 10349 | return __left_->base_name(); |
| 10350 | } |
| 10351 | virtual bool fix_forward_references(__node** t_begin, __node** t_end) |
| 10352 | { |
| 10353 | return __left_->fix_forward_references(t_begin, t_end); |
| 10354 | } |
| 10355 | }; |
| 10356 | |
| 10357 | |
| 10358 | enum {invalid_args = -3, invalid_mangled_name, memory_alloc_failure, success, |
| 10359 | not_yet_implemented}; |
| 10360 | |
| 10361 | __demangle_tree::__demangle_tree(const char* mangled_name, char* buf, size_t bs) |
| 10362 | : __mangled_name_begin_(0), __mangled_name_end_(0), |
| 10363 | __status_(invalid_mangled_name), __root_(0), |
| 10364 | __node_begin_(0), __node_end_(0), __node_cap_(0), |
| 10365 | __sub_begin_(0), __sub_end_(0), __sub_cap_(0), |
| 10366 | __t_begin_(0), __t_end_(0), __t_cap_(0), |
| 10367 | __tag_templates_(true), |
| 10368 | __fix_forward_references_(false) |
| 10369 | { |
| 10370 | size_t n = strlen(mangled_name); |
| 10371 | size_t ms = n + 2*n*sizeof(__node) + 2*n*sizeof(__node*); |
| 10372 | char* m; |
| 10373 | if (ms <= bs) |
| 10374 | { |
| 10375 | m = buf; |
| 10376 | __owns_buf_ = false; |
| 10377 | } |
| 10378 | else |
| 10379 | { |
| 10380 | m = static_cast<char*>(malloc(ms)); |
| 10381 | __owns_buf_ = true; |
| 10382 | } |
| 10383 | if (m == NULL) |
| 10384 | { |
| 10385 | __status_ = memory_alloc_failure; |
| 10386 | return; |
| 10387 | } |
| 10388 | __node_begin_ = __node_end_ = (__node*)(m); |
| 10389 | __node_cap_ = __node_begin_ + 2*n; |
| 10390 | __sub_begin_ = __sub_end_ = (__node**)(__node_cap_); |
| 10391 | __sub_cap_ = __sub_begin_ + n; |
| 10392 | __t_begin_ = __t_end_ = (__node**)(__sub_cap_); |
| 10393 | __t_cap_ = __t_begin_ + n; |
| 10394 | __mangled_name_begin_ = (const char*)(__t_cap_); |
| 10395 | __mangled_name_end_ = __mangled_name_begin_ + n; |
| 10396 | strncpy(const_cast<char*>(__mangled_name_begin_), mangled_name, n); |
| 10397 | } |
| 10398 | |
| 10399 | __demangle_tree::~__demangle_tree() |
| 10400 | { |
| 10401 | if (__owns_buf_) |
| 10402 | free(__node_begin_); |
| 10403 | } |
| 10404 | |
| 10405 | __demangle_tree::__demangle_tree(__demangle_tree& t) |
| 10406 | : __mangled_name_begin_(t.__mangled_name_begin_), |
| 10407 | __mangled_name_end_(t.__mangled_name_end_), |
| 10408 | __status_(t.__status_), __root_(t.__root_), |
| 10409 | __node_begin_(t.__node_begin_), __node_end_(t.__node_end_), |
| 10410 | __node_cap_(t.__node_cap_), |
| 10411 | __sub_begin_(t.__sub_begin_), __sub_end_(t.__sub_end_), |
| 10412 | __sub_cap_(t.__sub_cap_), |
| 10413 | __t_begin_(t.__t_begin_), __t_end_(t.__t_end_), |
| 10414 | __t_cap_(t.__t_cap_), |
| 10415 | __tag_templates_(t.__tag_templates_), |
| 10416 | __fix_forward_references_(t.__fix_forward_references_), |
| 10417 | __owns_buf_(t.__owns_buf_) |
| 10418 | { |
| 10419 | t.__mangled_name_begin_ = 0; |
| 10420 | t.__mangled_name_end_ = 0; |
| 10421 | t.__status_ = invalid_mangled_name; |
| 10422 | t.__root_ = 0; |
| 10423 | t.__node_begin_ = t.__node_end_ = t.__node_cap_ = 0; |
| 10424 | t.__sub_begin_ = t.__sub_end_ = t.__sub_cap_ = 0; |
| 10425 | t.__t_begin_ = t.__t_end_ = t.__t_cap_ = 0; |
| 10426 | t.__owns_buf_ = false; |
| 10427 | } |
| 10428 | |
| 10429 | __demangle_tree::__demangle_tree(__demangle_tree_rv rv) |
| 10430 | : __mangled_name_begin_(rv.ptr_->__mangled_name_begin_), |
| 10431 | __mangled_name_end_(rv.ptr_->__mangled_name_end_), |
| 10432 | __status_(rv.ptr_->__status_), __root_(rv.ptr_->__root_), |
| 10433 | __node_begin_(rv.ptr_->__node_begin_), __node_end_(rv.ptr_->__node_end_), |
| 10434 | __node_cap_(rv.ptr_->__node_cap_), |
| 10435 | __sub_begin_(rv.ptr_->__sub_begin_), __sub_end_(rv.ptr_->__sub_end_), |
| 10436 | __sub_cap_(rv.ptr_->__sub_cap_), |
| 10437 | __t_begin_(rv.ptr_->__t_begin_), __t_end_(rv.ptr_->__t_end_), |
| 10438 | __t_cap_(rv.ptr_->__t_cap_), |
| 10439 | __tag_templates_(rv.ptr_->__tag_templates_), |
| 10440 | __fix_forward_references_(rv.ptr_->__fix_forward_references_), |
| 10441 | __owns_buf_(rv.ptr_->__owns_buf_) |
| 10442 | { |
| 10443 | rv.ptr_->__mangled_name_begin_ = 0; |
| 10444 | rv.ptr_->__mangled_name_end_ = 0; |
| 10445 | rv.ptr_->__status_ = invalid_mangled_name; |
| 10446 | rv.ptr_->__root_ = 0; |
| 10447 | rv.ptr_->__node_begin_ = rv.ptr_->__node_end_ = rv.ptr_->__node_cap_ = 0; |
| 10448 | rv.ptr_->__sub_begin_ = rv.ptr_->__sub_end_ = rv.ptr_->__sub_cap_ = 0; |
| 10449 | rv.ptr_->__t_begin_ = rv.ptr_->__t_end_ = rv.ptr_->__t_cap_ = 0; |
| 10450 | rv.ptr_->__owns_buf_ = false; |
| 10451 | } |
| 10452 | |
| 10453 | int |
| 10454 | __demangle_tree::__status() const |
| 10455 | { |
| 10456 | return __status_; |
| 10457 | } |
| 10458 | |
| 10459 | size_t |
| 10460 | __demangle_tree::size() const |
| 10461 | { |
| 10462 | return __status_ == success ? __root_->size() : 0; |
| 10463 | } |
| 10464 | |
| 10465 | char* |
| 10466 | __demangle_tree::__get_demangled_name(char* buf) const |
| 10467 | { |
| 10468 | if (__status_ == success) |
| 10469 | return __root_->get_demangled_name(buf); |
| 10470 | return 0; |
| 10471 | } |
| 10472 | |
| 10473 | template <class _Tp> |
| 10474 | bool |
| 10475 | __demangle_tree::__make() |
| 10476 | { |
| 10477 | if (__node_end_ < __node_cap_) |
| 10478 | { |
| 10479 | ::new (__node_end_) _Tp(); |
| 10480 | __root_ = __node_end_; |
| 10481 | ++__node_end_; |
| 10482 | return true; |
| 10483 | } |
| 10484 | __status_ = memory_alloc_failure; |
| 10485 | return false; |
| 10486 | } |
| 10487 | |
| 10488 | template <class _Tp, class _A0> |
| 10489 | bool |
| 10490 | __demangle_tree::__make(_A0 __a0) |
| 10491 | { |
| 10492 | if (__node_end_ < __node_cap_) |
| 10493 | { |
| 10494 | ::new (__node_end_) _Tp(__a0); |
| 10495 | __root_ = __node_end_; |
| 10496 | ++__node_end_; |
| 10497 | return true; |
| 10498 | } |
| 10499 | __status_ = memory_alloc_failure; |
| 10500 | return false; |
| 10501 | } |
| 10502 | |
| 10503 | template <class _Tp, class _A0, class _A1> |
| 10504 | bool |
| 10505 | __demangle_tree::__make(_A0 __a0, _A1 __a1) |
| 10506 | { |
| 10507 | if (__node_end_ < __node_cap_) |
| 10508 | { |
| 10509 | ::new (__node_end_) _Tp(__a0, __a1); |
| 10510 | __root_ = __node_end_; |
| 10511 | ++__node_end_; |
| 10512 | return true; |
| 10513 | } |
| 10514 | __status_ = memory_alloc_failure; |
| 10515 | return false; |
| 10516 | } |
| 10517 | |
| 10518 | template <class _Tp, class _A0, class _A1, class _A2> |
| 10519 | bool |
| 10520 | __demangle_tree::__make(_A0 __a0, _A1 __a1, _A2 __a2) |
| 10521 | { |
| 10522 | if (__node_end_ < __node_cap_) |
| 10523 | { |
| 10524 | ::new (__node_end_) _Tp(__a0, __a1, __a2); |
| 10525 | __root_ = __node_end_; |
| 10526 | ++__node_end_; |
| 10527 | return true; |
| 10528 | } |
| 10529 | __status_ = memory_alloc_failure; |
| 10530 | return false; |
| 10531 | } |
| 10532 | |
| 10533 | template <class _Tp, class _A0, class _A1, class _A2, class _A3> |
| 10534 | bool |
| 10535 | __demangle_tree::__make(_A0 __a0, _A1 __a1, _A2 __a2, _A3 __a3) |
| 10536 | { |
| 10537 | if (__node_end_ < __node_cap_) |
| 10538 | { |
| 10539 | ::new (__node_end_) _Tp(__a0, __a1, __a2, __a3); |
| 10540 | __root_ = __node_end_; |
| 10541 | ++__node_end_; |
| 10542 | return true; |
| 10543 | } |
| 10544 | __status_ = memory_alloc_failure; |
| 10545 | return false; |
| 10546 | } |
| 10547 | |
| 10548 | template <class _Tp, class _A0, class _A1, class _A2, class _A3, class _A4> |
| 10549 | bool |
| 10550 | __demangle_tree::__make(_A0 __a0, _A1 __a1, _A2 __a2, _A3 __a3, _A4 __a4) |
| 10551 | { |
| 10552 | if (__node_end_ < __node_cap_) |
| 10553 | { |
| 10554 | ::new (__node_end_) _Tp(__a0, __a1, __a2, __a3, __a4); |
| 10555 | __root_ = __node_end_; |
| 10556 | ++__node_end_; |
| 10557 | return true; |
| 10558 | } |
| 10559 | __status_ = memory_alloc_failure; |
| 10560 | return false; |
| 10561 | } |
| 10562 | |
| 10563 | template <class _Tp, class _A0, class _A1, class _A2, class _A3, class _A4, |
| 10564 | class _A5> |
| 10565 | bool |
| 10566 | __demangle_tree::__make(_A0 __a0, _A1 __a1, _A2 __a2, _A3 __a3, _A4 __a4, |
| 10567 | _A5 __a5) |
| 10568 | { |
| 10569 | if (__node_end_ < __node_cap_) |
| 10570 | { |
| 10571 | ::new (__node_end_) _Tp(__a0, __a1, __a2, __a3, __a4, __a5); |
| 10572 | __root_ = __node_end_; |
| 10573 | ++__node_end_; |
| 10574 | return true; |
| 10575 | } |
| 10576 | __status_ = memory_alloc_failure; |
| 10577 | return false; |
| 10578 | } |
| 10579 | |
| 10580 | // <CV-qualifiers> ::= [r] [V] [K] # restrict (C99), volatile, const |
| 10581 | // [R | O] # & or && |
| 10582 | |
| 10583 | const char* |
| 10584 | __demangle_tree::__parse_cv_qualifiers(const char* first, const char* last, |
| 10585 | unsigned& cv, bool look_for_ref_quals) |
| 10586 | { |
| 10587 | if (look_for_ref_quals) |
| 10588 | { |
| 10589 | for (; first != last; ++first) |
| 10590 | { |
| 10591 | switch (*first) |
| 10592 | { |
| 10593 | case 'r': |
| 10594 | cv |= 4; |
| 10595 | break; |
| 10596 | case 'V': |
| 10597 | cv |= 2; |
| 10598 | break; |
| 10599 | case 'K': |
| 10600 | cv |= 1; |
| 10601 | break; |
| 10602 | case 'R': |
| 10603 | cv |= 8; |
| 10604 | break; |
| 10605 | case 'O': |
| 10606 | cv |= 16; |
| 10607 | break; |
| 10608 | default: |
| 10609 | return first; |
| 10610 | } |
| 10611 | } |
| 10612 | } |
| 10613 | else |
| 10614 | { |
| 10615 | for (; first != last; ++first) |
| 10616 | { |
| 10617 | switch (*first) |
| 10618 | { |
| 10619 | case 'r': |
| 10620 | cv |= 4; |
| 10621 | break; |
| 10622 | case 'V': |
| 10623 | cv |= 2; |
| 10624 | break; |
| 10625 | case 'K': |
| 10626 | cv |= 1; |
| 10627 | break; |
| 10628 | default: |
| 10629 | return first; |
| 10630 | } |
| 10631 | } |
| 10632 | } |
| 10633 | return first; |
| 10634 | } |
| 10635 | |
| 10636 | // <builtin-type> ::= v # void |
| 10637 | // ::= w # wchar_t |
| 10638 | // ::= b # bool |
| 10639 | // ::= c # char |
| 10640 | // ::= a # signed char |
| 10641 | // ::= h # unsigned char |
| 10642 | // ::= s # short |
| 10643 | // ::= t # unsigned short |
| 10644 | // ::= i # int |
| 10645 | // ::= j # unsigned int |
| 10646 | // ::= l # long |
| 10647 | // ::= m # unsigned long |
| 10648 | // ::= x # long long, __int64 |
| 10649 | // ::= y # unsigned long long, __int64 |
| 10650 | // ::= n # __int128 |
| 10651 | // ::= o # unsigned __int128 |
| 10652 | // ::= f # float |
| 10653 | // ::= d # double |
| 10654 | // ::= e # long double, __float80 |
| 10655 | // ::= g # __float128 |
| 10656 | // ::= z # ellipsis |
| 10657 | // ::= Dd # IEEE 754r decimal floating point (64 bits) |
| 10658 | // ::= De # IEEE 754r decimal floating point (128 bits) |
| 10659 | // ::= Df # IEEE 754r decimal floating point (32 bits) |
| 10660 | // ::= Dh # IEEE 754r half-precision floating point (16 bits) |
| 10661 | // ::= Di # char32_t |
| 10662 | // ::= Ds # char16_t |
| 10663 | // ::= Da # auto (in dependent new-expressions) |
| 10664 | // ::= Dn # std::nullptr_t (i.e., decltype(nullptr)) |
| 10665 | // ::= u <source-name> # vendor extended type |
| 10666 | |
| 10667 | const char* |
| 10668 | __demangle_tree::__parse_builtin_type(const char* first, const char* last) |
| 10669 | { |
| 10670 | if (first != last) |
| 10671 | { |
| 10672 | switch (*first) |
| 10673 | { |
| 10674 | case 'v': |
| 10675 | if (__make<__void>()) |
| 10676 | ++first; |
| 10677 | break; |
| 10678 | case 'w': |
| 10679 | if (__make<__wchar_t>()) |
| 10680 | ++first; |
| 10681 | break; |
| 10682 | case 'b': |
| 10683 | if (__make<__bool>()) |
| 10684 | ++first; |
| 10685 | break; |
| 10686 | case 'c': |
| 10687 | if (__make<__char>()) |
| 10688 | ++first; |
| 10689 | break; |
| 10690 | case 'a': |
| 10691 | if (__make<__signed_char>()) |
| 10692 | ++first; |
| 10693 | break; |
| 10694 | case 'h': |
| 10695 | if (__make<__unsigned_char>()) |
| 10696 | ++first; |
| 10697 | break; |
| 10698 | case 's': |
| 10699 | if (__make<__short>()) |
| 10700 | ++first; |
| 10701 | break; |
| 10702 | case 't': |
| 10703 | if (__make<__unsigned_short>()) |
| 10704 | ++first; |
| 10705 | break; |
| 10706 | case 'i': |
| 10707 | if (__make<__int>()) |
| 10708 | ++first; |
| 10709 | break; |
| 10710 | case 'j': |
| 10711 | if (__make<__unsigned_int>()) |
| 10712 | ++first; |
| 10713 | break; |
| 10714 | case 'l': |
| 10715 | if (__make<__long>()) |
| 10716 | ++first; |
| 10717 | break; |
| 10718 | case 'm': |
| 10719 | if (__make<__unsigned_long>()) |
| 10720 | ++first; |
| 10721 | break; |
| 10722 | case 'x': |
| 10723 | if (__make<__long_long>()) |
| 10724 | ++first; |
| 10725 | break; |
| 10726 | case 'y': |
| 10727 | if (__make<__unsigned_long_long>()) |
| 10728 | ++first; |
| 10729 | break; |
| 10730 | case 'n': |
| 10731 | if (__make<__int128>()) |
| 10732 | ++first; |
| 10733 | break; |
| 10734 | case 'o': |
| 10735 | if (__make<__unsigned_int128>()) |
| 10736 | ++first; |
| 10737 | break; |
| 10738 | case 'f': |
| 10739 | if (__make<__float>()) |
| 10740 | ++first; |
| 10741 | break; |
| 10742 | case 'd': |
| 10743 | if (__make<__double>()) |
| 10744 | ++first; |
| 10745 | break; |
| 10746 | case 'e': |
| 10747 | if (__make<__long_double>()) |
| 10748 | ++first; |
| 10749 | break; |
| 10750 | case 'g': |
| 10751 | if (__make<__float128>()) |
| 10752 | ++first; |
| 10753 | break; |
| 10754 | case 'z': |
| 10755 | if (__make<__ellipsis>()) |
| 10756 | ++first; |
| 10757 | break; |
| 10758 | case 'D': |
| 10759 | if (first+1 != last) |
| 10760 | { |
| 10761 | switch (first[1]) |
| 10762 | { |
| 10763 | case 'd': |
| 10764 | if (__make<__decimal64>()) |
| 10765 | first += 2; |
| 10766 | break; |
| 10767 | case 'e': |
| 10768 | if (__make<__decimal128>()) |
| 10769 | first += 2; |
| 10770 | break; |
| 10771 | case 'f': |
| 10772 | if (__make<__decimal32>()) |
| 10773 | first += 2; |
| 10774 | break; |
| 10775 | case 'h': |
| 10776 | if (__make<__decimal16>()) |
| 10777 | first += 2; |
| 10778 | break; |
| 10779 | case 'i': |
| 10780 | if (__make<__d_char32_t>()) |
| 10781 | first += 2; |
| 10782 | break; |
| 10783 | case 's': |
| 10784 | if (__make<__d_char16_t>()) |
| 10785 | first += 2; |
| 10786 | break; |
| 10787 | case 'a': |
| 10788 | if (__make<__auto>()) |
| 10789 | first += 2; |
| 10790 | break; |
| 10791 | case 'n': |
| 10792 | if (__make<__nullptr_t>()) |
| 10793 | first += 2; |
| 10794 | break; |
| 10795 | } |
| 10796 | } |
| 10797 | break; |
| 10798 | } |
| 10799 | } |
| 10800 | return first; |
| 10801 | } |
| 10802 | |
| 10803 | // <bare-function-type> ::= <signature type>+ |
| 10804 | // # types are possible return type, then parameter types |
| 10805 | |
| 10806 | const char* |
| 10807 | __demangle_tree::__parse_bare_function_type(const char* first, const char* last) |
| 10808 | { |
| 10809 | if (first != last) |
| 10810 | { |
| 10811 | __tag_templates_ = false; |
| 10812 | const char* t = __parse_type(first, last); |
| 10813 | if (t != first && __make<__list>(__root_)) |
| 10814 | { |
| 10815 | const char* t0 = t; |
| 10816 | __node* head = __root_; |
| 10817 | __node* prev = head; |
| 10818 | while (true) |
| 10819 | { |
| 10820 | t = __parse_type(t0, last); |
| 10821 | if (t != t0) |
| 10822 | { |
| 10823 | if (__make<__list>(__root_)) |
| 10824 | { |
| 10825 | t0 = t; |
| 10826 | prev->__right_ = __root_; |
| 10827 | __root_->__size_ = prev->__size_ + 1; |
| 10828 | prev = __root_; |
| 10829 | } |
| 10830 | else |
| 10831 | break; |
| 10832 | } |
| 10833 | else |
| 10834 | { |
| 10835 | first = t; |
| 10836 | __root_ = head; |
| 10837 | break; |
| 10838 | } |
| 10839 | } |
| 10840 | } |
| 10841 | __tag_templates_ = true; |
| 10842 | } |
| 10843 | return first; |
| 10844 | } |
| 10845 | |
| 10846 | // <function-type> ::= F [Y] <bare-function-type> E |
| 10847 | |
| 10848 | const char* |
| 10849 | __demangle_tree::__parse_function_type(const char* first, const char* last) |
| 10850 | { |
| 10851 | if (first != last && *first == 'F') |
| 10852 | { |
| 10853 | const char* t = first+1; |
| 10854 | if (t != last) |
| 10855 | { |
| 10856 | bool externC = false; |
| 10857 | if (*t == 'Y') |
| 10858 | { |
| 10859 | externC = true; |
| 10860 | if (++t == last) |
| 10861 | return first; |
| 10862 | } |
| 10863 | const char* t1 = __parse_type(t, last); |
| 10864 | if (t1 != t) |
| 10865 | { |
| 10866 | __node* ret = __root_; |
| 10867 | t = t1; |
| 10868 | t1 = __parse_bare_function_type(t, last); |
| 10869 | if (t1 != t && t1 != last && *t1 == 'E') |
| 10870 | { |
| 10871 | if (dynamic_cast<__void*>(__root_->__left_) != NULL) |
| 10872 | __root_->__left_ = NULL; |
| 10873 | if (__make<__function_signature>(ret, __root_)) |
| 10874 | { |
| 10875 | if (__make<__function>((__node*)0, __root_)) |
| 10876 | first = t1+1; |
| 10877 | } |
| 10878 | } |
| 10879 | } |
| 10880 | } |
| 10881 | } |
| 10882 | return first; |
| 10883 | } |
| 10884 | |
| 10885 | const char* |
| 10886 | __demangle_tree::__parse_hex_number(const char* first, const char* last, unsigned long long& n) |
| 10887 | { |
| 10888 | const char* t = first; |
| 10889 | for (; t != last && isxdigit(*t); ++t) |
| 10890 | { |
| 10891 | if (t == first) |
| 10892 | n = 0; |
| 10893 | if (isdigit(*t)) |
| 10894 | n = n * 16 + *t - '0'; |
| 10895 | else if (isupper(*t)) |
| 10896 | n = n * 16 + *t - 'A' + 10; |
| 10897 | else |
| 10898 | n = n * 16 + *t - 'a' + 10; |
| 10899 | } |
| 10900 | first = t; |
| 10901 | return first; |
| 10902 | } |
| 10903 | |
| 10904 | // <expr-primary> ::= L <type> <value number> E # integer literal |
| 10905 | // ::= L <type> <value float> E # floating literal |
| 10906 | // ::= L <string type> E # string literal |
| 10907 | // ::= L <nullptr type> E # nullptr literal (i.e., "LDnE") |
| 10908 | // ::= L <type> <real-part float> _ <imag-part float> E # complex floating point literal (C 2000) |
| 10909 | // ::= L <mangled-name> E # external name |
| 10910 | |
| 10911 | const char* |
| 10912 | __demangle_tree::__parse_expr_primary(const char* first, const char* last) |
| 10913 | { |
| 10914 | if (last - first >= 4 && *first == 'L') |
| 10915 | { |
| 10916 | switch (first[1]) |
| 10917 | { |
| 10918 | case 'w': |
| 10919 | { |
| 10920 | const char* t = __parse_number(first+2, last); |
| 10921 | if (t != first+2 && t != last && *t == 'E') |
| 10922 | { |
| 10923 | if (__make<__wchar_t_literal>(first+2, t)) |
| 10924 | first = t+1; |
| 10925 | } |
| 10926 | } |
| 10927 | break; |
| 10928 | case 'b': |
| 10929 | if (first[3] == 'E') |
| 10930 | { |
| 10931 | switch (first[2]) |
| 10932 | { |
| 10933 | case '0': |
| 10934 | if (__make<__bool_literal>("false", 5)) |
| 10935 | first += 4; |
| 10936 | break; |
| 10937 | case '1': |
| 10938 | if (__make<__bool_literal>("true", 4)) |
| 10939 | first += 4; |
| 10940 | break; |
| 10941 | } |
| 10942 | } |
| 10943 | break; |
| 10944 | case 'c': |
| 10945 | { |
| 10946 | const char* t = __parse_number(first+2, last); |
| 10947 | if (t != first+2 && t != last && *t == 'E') |
| 10948 | { |
| 10949 | if (__make<__char_literal>(first+2, t)) |
| 10950 | first = t+1; |
| 10951 | } |
| 10952 | } |
| 10953 | break; |
| 10954 | case 'a': |
| 10955 | { |
| 10956 | const char* t = __parse_number(first+2, last); |
| 10957 | if (t != first+2 && t != last && *t == 'E') |
| 10958 | { |
| 10959 | if (__make<__signed_char_literal>(first+2, t)) |
| 10960 | first = t+1; |
| 10961 | } |
| 10962 | } |
| 10963 | break; |
| 10964 | case 'h': |
| 10965 | { |
| 10966 | const char* t = __parse_number(first+2, last); |
| 10967 | if (t != first+2 && t != last && *t == 'E') |
| 10968 | { |
| 10969 | if (__make<__unsigned_char_literal>(first+2, t)) |
| 10970 | first = t+1; |
| 10971 | } |
| 10972 | } |
| 10973 | break; |
| 10974 | case 's': |
| 10975 | { |
| 10976 | const char* t = __parse_number(first+2, last); |
| 10977 | if (t != first+2 && t != last && *t == 'E') |
| 10978 | { |
| 10979 | if (__make<__short_literal>(first+2, t)) |
| 10980 | first = t+1; |
| 10981 | } |
| 10982 | } |
| 10983 | break; |
| 10984 | case 't': |
| 10985 | { |
| 10986 | const char* t = __parse_number(first+2, last); |
| 10987 | if (t != first+2 && t != last && *t == 'E') |
| 10988 | { |
| 10989 | if (__make<__unsigned_short_literal>(first+2, t)) |
| 10990 | first = t+1; |
| 10991 | } |
| 10992 | } |
| 10993 | break; |
| 10994 | case 'i': |
| 10995 | { |
| 10996 | const char* t = __parse_number(first+2, last); |
| 10997 | if (t != first+2 && t != last && *t == 'E') |
| 10998 | { |
| 10999 | if (__make<__int_literal>(first+2, t)) |
| 11000 | first = t+1; |
| 11001 | } |
| 11002 | } |
| 11003 | break; |
| 11004 | case 'j': |
| 11005 | { |
| 11006 | const char* t = __parse_number(first+2, last); |
| 11007 | if (t != first+2 && t != last && *t == 'E') |
| 11008 | { |
| 11009 | if (__make<__unsigned_int_literal>(first+2, t)) |
| 11010 | first = t+1; |
| 11011 | } |
| 11012 | } |
| 11013 | break; |
| 11014 | case 'l': |
| 11015 | { |
| 11016 | const char* t = __parse_number(first+2, last); |
| 11017 | if (t != first+2 && t != last && *t == 'E') |
| 11018 | { |
| 11019 | if (__make<__long_literal>(first+2, t)) |
| 11020 | first = t+1; |
| 11021 | } |
| 11022 | } |
| 11023 | break; |
| 11024 | case 'm': |
| 11025 | { |
| 11026 | const char* t = __parse_number(first+2, last); |
| 11027 | if (t != first+2 && t != last && *t == 'E') |
| 11028 | { |
| 11029 | if (__make<__unsigned_long_literal>(first+2, t)) |
| 11030 | first = t+1; |
| 11031 | } |
| 11032 | } |
| 11033 | break; |
| 11034 | case 'x': |
| 11035 | { |
| 11036 | const char* t = __parse_number(first+2, last); |
| 11037 | if (t != first+2 && t != last && *t == 'E') |
| 11038 | { |
| 11039 | if (__make<__long_long_literal>(first+2, t)) |
| 11040 | first = t+1; |
| 11041 | } |
| 11042 | } |
| 11043 | break; |
| 11044 | case 'y': |
| 11045 | { |
| 11046 | const char* t = __parse_number(first+2, last); |
| 11047 | if (t != first+2 && t != last && *t == 'E') |
| 11048 | { |
| 11049 | if (__make<__unsigned_long_long_literal>(first+2, t)) |
| 11050 | first = t+1; |
| 11051 | } |
| 11052 | } |
| 11053 | break; |
| 11054 | case 'n': |
| 11055 | { |
| 11056 | const char* t = __parse_number(first+2, last); |
| 11057 | if (t != first+2 && t != last && *t == 'E') |
| 11058 | { |
| 11059 | if (__make<__int128_literal>(first+2, t)) |
| 11060 | first = t+1; |
| 11061 | } |
| 11062 | } |
| 11063 | break; |
| 11064 | case 'o': |
| 11065 | { |
| 11066 | const char* t = __parse_number(first+2, last); |
| 11067 | if (t != first+2 && t != last && *t == 'E') |
| 11068 | { |
| 11069 | if (__make<__unsigned_int128_literal>(first+2, t)) |
| 11070 | first = t+1; |
| 11071 | } |
| 11072 | } |
| 11073 | break; |
| 11074 | case 'f': |
| 11075 | { |
| 11076 | if (last - (first+2) <= 8) |
| 11077 | return first; |
| 11078 | unsigned long long j; |
| 11079 | const char* t = __parse_hex_number(first+2, first+10, j); |
| 11080 | if (t != first+2 && t != last && *t == 'E') |
| 11081 | { |
| 11082 | unsigned i = static_cast<unsigned>(j); |
| 11083 | float value = *(float*)&i; |
| 11084 | if (__make<__float_literal>(value)) |
| 11085 | first = t+1; |
| 11086 | } |
| 11087 | } |
| 11088 | break; |
| 11089 | case 'd': |
| 11090 | { |
| 11091 | if (last - (first+2) <= 16) |
| 11092 | return first; |
| 11093 | unsigned long long j; |
| 11094 | const char* t = __parse_hex_number(first+2, first+18, j); |
| 11095 | if (t != first+2 && t != last && *t == 'E') |
| 11096 | { |
| 11097 | double value = *(double*)&j; |
| 11098 | if (__make<__double_literal>(value)) |
| 11099 | first = t+1; |
| 11100 | } |
| 11101 | } |
| 11102 | break; |
| 11103 | case 'e': |
| 11104 | break; |
| 11105 | case '_': |
| 11106 | if (first[2] == 'Z') |
| 11107 | { |
| 11108 | const char* t = __parse_encoding(first+3, last); |
| 11109 | if (t != first+3 && t != last && *t == 'E') |
| 11110 | first = t+1; |
| 11111 | } |
| 11112 | break; |
| 11113 | default: |
| 11114 | { |
| 11115 | // might be named type |
| 11116 | const char* t = __parse_type(first+1, last); |
| 11117 | if (t != first+1 && t != last) |
| 11118 | { |
| 11119 | if (*t != 'E') |
| 11120 | { |
| 11121 | const char* n = t; |
| 11122 | for (; n != last && isdigit(*n); ++n) |
| 11123 | ; |
| 11124 | if (n != t && n != last && *n == 'E') |
| 11125 | { |
| 11126 | if (__make<__cast_literal>(__root_, t, n)) |
| 11127 | { |
| 11128 | first = n+1; |
| 11129 | break; |
| 11130 | } |
| 11131 | } |
| 11132 | } |
| 11133 | else |
| 11134 | { |
| 11135 | first = t+1; |
| 11136 | break; |
| 11137 | } |
| 11138 | } |
| 11139 | } |
| 11140 | assert(!"case in __parse_expr_primary not implemented"); |
| 11141 | } |
| 11142 | } |
| 11143 | return first; |
| 11144 | } |
| 11145 | |
| 11146 | const char* |
| 11147 | __demangle_tree::__parse_unnamed_type_name(const char* first, const char* last) |
| 11148 | { |
| 11149 | if (first != last && *first == 'U') |
| 11150 | { |
| 11151 | assert(!"__parse_unnamed_type_name not implemented"); |
| 11152 | } |
| 11153 | return first; |
| 11154 | } |
| 11155 | |
| 11156 | // <ctor-dtor-name> ::= C1 # complete object constructor |
| 11157 | // ::= C2 # base object constructor |
| 11158 | // ::= C3 # complete object allocating constructor |
| 11159 | // ::= D0 # deleting destructor |
| 11160 | // ::= D1 # complete object destructor |
| 11161 | // ::= D2 # base object destructor |
| 11162 | |
| 11163 | const char* |
| 11164 | __demangle_tree::__parse_ctor_dtor_name(const char* first, const char* last) |
| 11165 | { |
| 11166 | if (last-first >= 2) |
| 11167 | { |
| 11168 | switch (first[0]) |
| 11169 | { |
| 11170 | case 'C': |
| 11171 | switch (first[1]) |
| 11172 | { |
| 11173 | case '1': |
| 11174 | case '2': |
| 11175 | case '3': |
| 11176 | if (__make<__constructor>(__root_->base_name())) |
| 11177 | first += 2; |
| 11178 | break; |
| 11179 | } |
| 11180 | break; |
| 11181 | case 'D': |
| 11182 | switch (first[1]) |
| 11183 | { |
| 11184 | case '0': |
| 11185 | case '1': |
| 11186 | case '2': |
| 11187 | if (__make<__destructor>(__root_->base_name())) |
| 11188 | first += 2; |
| 11189 | break; |
| 11190 | } |
| 11191 | break; |
| 11192 | } |
| 11193 | } |
| 11194 | return first; |
| 11195 | } |
| 11196 | |
| 11197 | const char* |
| 11198 | __demangle_tree::__parse_unscoped_template_name(const char* first, const char* last) |
| 11199 | { |
| 11200 | assert(!"__parse_unscoped_template_name not implemented"); |
| 11201 | } |
| 11202 | |
| 11203 | // <discriminator> := _ <non-negative number> # when number < 10 |
| 11204 | // := __ <non-negative number> _ # when number >= 10 |
| 11205 | // extension := decimal-digit+ |
| 11206 | |
| 11207 | const char* |
| 11208 | __demangle_tree::__parse_discriminator(const char* first, const char* last) |
| 11209 | { |
| 11210 | // parse but ignore discriminator |
| 11211 | if (first != last) |
| 11212 | { |
| 11213 | if (*first == '_') |
| 11214 | { |
| 11215 | const char* t1 = first+1; |
| 11216 | if (t1 != last) |
| 11217 | { |
| 11218 | if (isdigit(*t1)) |
| 11219 | first = t1+1; |
| 11220 | else if (*t1 == '_') |
| 11221 | { |
| 11222 | for (++t1; t1 != last && isdigit(*t1); ++t1) |
| 11223 | ; |
| 11224 | if (t1 != last && *t1 == '_') |
| 11225 | first = t1 + 1; |
| 11226 | } |
| 11227 | } |
| 11228 | } |
| 11229 | else if (isdigit(*first)) |
| 11230 | { |
| 11231 | const char* t1 = first+1; |
| 11232 | for (; t1 != last && isdigit(*t1); ++t1) |
| 11233 | ; |
| 11234 | first = t1; |
| 11235 | } |
| 11236 | } |
| 11237 | return first; |
| 11238 | } |
| 11239 | |
| 11240 | // <local-name> := Z <function encoding> E <entity name> [<discriminator>] |
| 11241 | // := Z <function encoding> E s [<discriminator>] |
| 11242 | // := Z <function encoding> Ed [ <parameter number> ] _ <entity name> |
| 11243 | |
| 11244 | const char* |
| 11245 | __demangle_tree::__parse_local_name(const char* first, const char* last) |
| 11246 | { |
| 11247 | if (first != last && *first == 'Z') |
| 11248 | { |
| 11249 | const char* t = __parse_encoding(first+1, last); |
| 11250 | if (t != first+1 && t != last && *t == 'E' && ++t != last) |
| 11251 | { |
| 11252 | __node* encoding = __root_; |
| 11253 | switch (*t) |
| 11254 | { |
| 11255 | case 's': |
| 11256 | { |
| 11257 | const char*t1 = __parse_discriminator(t+1, last); |
| 11258 | if (__make<__string_literal>()) |
| 11259 | { |
| 11260 | if (__make<__nested_delimeter>(encoding, __root_)) |
| 11261 | first = t1; |
| 11262 | } |
| 11263 | } |
| 11264 | break; |
| 11265 | case 'd': |
| 11266 | assert(!"__parse_local_name d not implemented"); |
| 11267 | break; |
| 11268 | default: |
| 11269 | { |
| 11270 | const char*t1 = __parse_name(t, last); |
| 11271 | if (t1 != t) |
| 11272 | { |
| 11273 | // parse but ignore discriminator |
| 11274 | t1 = __parse_discriminator(t1, last); |
| 11275 | if (__make<__nested_delimeter>(encoding, __root_)) |
| 11276 | first = t1; |
| 11277 | } |
| 11278 | } |
| 11279 | break; |
| 11280 | } |
| 11281 | } |
| 11282 | } |
| 11283 | return first; |
| 11284 | } |
| 11285 | |
| 11286 | // <destructor-name> ::= <unresolved-type> # e.g., ~T or ~decltype(f()) |
| 11287 | // ::= <simple-id> # e.g., ~A<2*N> |
| 11288 | |
| 11289 | const char* |
| 11290 | __demangle_tree::__parse_destructor_name(const char* first, const char* last) |
| 11291 | { |
| 11292 | if (first != last) |
| 11293 | { |
| 11294 | const char* t = __parse_unresolved_type(first, last); |
| 11295 | if (t == first) |
| 11296 | t = __parse_simple_id(first, last); |
| 11297 | if (t != first && __make<__destructor>(__root_)) |
| 11298 | first = t; |
| 11299 | } |
| 11300 | return first; |
| 11301 | } |
| 11302 | |
| 11303 | // <simple-id> ::= <source-name> [ <template-args> ] |
| 11304 | |
| 11305 | const char* |
| 11306 | __demangle_tree::__parse_simple_id(const char* first, const char* last) |
| 11307 | { |
| 11308 | if (first != last) |
| 11309 | { |
| 11310 | const char* t = __parse_source_name(first, last); |
| 11311 | if (t != first) |
| 11312 | first = __parse_template_args(t, last); |
| 11313 | else |
| 11314 | first = t; |
| 11315 | } |
| 11316 | return first; |
| 11317 | } |
| 11318 | |
| 11319 | // <base-unresolved-name> ::= <simple-id> # unresolved name |
| 11320 | // extension ::= <operator-name> # unresolved operator-function-id |
| 11321 | // extension ::= <operator-name> <template-args> # unresolved operator template-id |
| 11322 | // ::= on <operator-name> # unresolved operator-function-id |
| 11323 | // ::= on <operator-name> <template-args> # unresolved operator template-id |
| 11324 | // ::= dn <destructor-name> # destructor or pseudo-destructor; |
| 11325 | // # e.g. ~X or ~X<N-1> |
| 11326 | |
| 11327 | const char* |
| 11328 | __demangle_tree::__parse_base_unresolved_name(const char* first, const char* last) |
| 11329 | { |
| 11330 | if (last - first >= 2) |
| 11331 | { |
| 11332 | if ((first[0] == 'o' || first[0] == 'd') && first[1] == 'n') |
| 11333 | { |
| 11334 | if (first[0] == 'o') |
| 11335 | { |
| 11336 | const char* t = __parse_operator_name(first+2, last); |
| 11337 | if (t != first+2) |
| 11338 | first = __parse_template_args(t, last); |
| 11339 | else |
| 11340 | first = t; |
| 11341 | } |
| 11342 | else |
| 11343 | { |
| 11344 | const char* t = __parse_destructor_name(first+2, last); |
| 11345 | if (t != first+2) |
| 11346 | first = t; |
| 11347 | } |
| 11348 | } |
| 11349 | else |
| 11350 | { |
| 11351 | const char* t = __parse_simple_id(first, last); |
| 11352 | if (t == first) |
| 11353 | { |
| 11354 | t = __parse_operator_name(first, last); |
| 11355 | if (t != first) |
| 11356 | t = __parse_template_args(t, last); |
| 11357 | } |
| 11358 | if (t != first) |
| 11359 | first = t; |
| 11360 | } |
| 11361 | } |
| 11362 | return first; |
| 11363 | } |
| 11364 | |
| 11365 | // <unresolved-type> ::= <template-param> |
| 11366 | // ::= <decltype> |
| 11367 | // ::= <substitution> |
| 11368 | |
| 11369 | const char* |
| 11370 | __demangle_tree::__parse_unresolved_type(const char* first, const char* last) |
| 11371 | { |
| 11372 | if (first != last) |
| 11373 | { |
| 11374 | const char* t; |
| 11375 | switch (*first) |
| 11376 | { |
| 11377 | case 'T': |
| 11378 | t = __parse_template_param(first, last); |
| 11379 | if (t != first) |
| 11380 | { |
| 11381 | if (__sub_end_ == __sub_cap_) |
| 11382 | __status_ = memory_alloc_failure; |
| 11383 | else |
| 11384 | { |
| 11385 | *__sub_end_++ = __root_; |
| 11386 | first = t; |
| 11387 | } |
| 11388 | } |
| 11389 | break; |
| 11390 | case 'D': |
| 11391 | t = __parse_decltype(first, last); |
| 11392 | if (t != first) |
| 11393 | { |
| 11394 | if (__sub_end_ == __sub_cap_) |
| 11395 | __status_ = memory_alloc_failure; |
| 11396 | else |
| 11397 | { |
| 11398 | *__sub_end_++ = __root_; |
| 11399 | first = t; |
| 11400 | } |
| 11401 | } |
| 11402 | break; |
| 11403 | case 'S': |
| 11404 | t = __parse_substitution(first, last); |
| 11405 | if (t != first) |
| 11406 | first = t; |
| 11407 | break; |
| 11408 | } |
| 11409 | } |
| 11410 | return first; |
| 11411 | } |
| 11412 | |
Howard Hinnant | 6f716a0 | 2011-06-22 19:27:39 +0000 | [diff] [blame] | 11413 | // <unresolved-qualifier-level> ::= <source-name> [ <template-args> ] |
| 11414 | |
| 11415 | const char* |
| 11416 | __demangle_tree::__parse_unresolved_qualifier_level(const char* first, const char* last) |
| 11417 | { |
| 11418 | if (first != last) |
| 11419 | { |
| 11420 | const char* t = __parse_source_name(first, last); |
| 11421 | if (t != first) |
| 11422 | first = __parse_template_args(t, last); |
| 11423 | } |
| 11424 | return first; |
| 11425 | } |
| 11426 | |
Howard Hinnant | 4fbf16a | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 11427 | // <unresolved-name> |
Howard Hinnant | 6f716a0 | 2011-06-22 19:27:39 +0000 | [diff] [blame] | 11428 | // extension ::= srN <unresolved-type> [<template-args>] <unresolved-qualifier-level>* E <base-unresolved-name> |
Howard Hinnant | 4fbf16a | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 11429 | // ::= [gs] <base-unresolved-name> # x or (with "gs") ::x |
| 11430 | // ::= [gs] sr <unresolved-qualifier-level>+ E <base-unresolved-name> |
| 11431 | // # A::x, N::y, A<T>::z; "gs" means leading "::" |
Howard Hinnant | 6f716a0 | 2011-06-22 19:27:39 +0000 | [diff] [blame] | 11432 | // ::= sr <unresolved-type> <base-unresolved-name> # T::x / decltype(p)::x |
| 11433 | // # T::N::x /decltype(p)::N::x |
| 11434 | // (ignored) ::= srN <unresolved-type> <unresolved-qualifier-level>+ E <base-unresolved-name> |
Howard Hinnant | 4fbf16a | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 11435 | |
| 11436 | const char* |
| 11437 | __demangle_tree::__parse_unresolved_name(const char* first, const char* last) |
| 11438 | { |
| 11439 | if (last - first > 2) |
| 11440 | { |
Howard Hinnant | 6f716a0 | 2011-06-22 19:27:39 +0000 | [diff] [blame] | 11441 | const char* t = first; |
| 11442 | bool global = false; |
| 11443 | if (t[0] == 'g' && t[1] == 's') |
Howard Hinnant | 4fbf16a | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 11444 | { |
Howard Hinnant | 6f716a0 | 2011-06-22 19:27:39 +0000 | [diff] [blame] | 11445 | global = true; |
| 11446 | t += 2; |
Howard Hinnant | 4fbf16a | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 11447 | } |
Howard Hinnant | 6f716a0 | 2011-06-22 19:27:39 +0000 | [diff] [blame] | 11448 | const char* t2 = __parse_base_unresolved_name(t, last); |
| 11449 | if (t2 != t) |
Howard Hinnant | 4fbf16a | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 11450 | { |
Howard Hinnant | 6f716a0 | 2011-06-22 19:27:39 +0000 | [diff] [blame] | 11451 | if (__make<__unresolved_name>(global, (__node*)0, __root_)) |
| 11452 | first = t2; |
| 11453 | } |
| 11454 | else if (last - t > 2 && t[0] == 's' && t[1] == 'r') |
| 11455 | { |
| 11456 | if (!global && t[2] == 'N') |
Howard Hinnant | 4fbf16a | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 11457 | { |
Howard Hinnant | 6f716a0 | 2011-06-22 19:27:39 +0000 | [diff] [blame] | 11458 | t2 = __parse_unresolved_type(t+3, last); |
| 11459 | if (t2 != t+3 && t2 != last) |
Howard Hinnant | 4fbf16a | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 11460 | { |
Howard Hinnant | 6f716a0 | 2011-06-22 19:27:39 +0000 | [diff] [blame] | 11461 | t = __parse_template_args(t2, last); |
| 11462 | if (t == last) |
Howard Hinnant | 4fbf16a | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 11463 | return first; |
Howard Hinnant | 6f716a0 | 2011-06-22 19:27:39 +0000 | [diff] [blame] | 11464 | __node* name = __root_; |
| 11465 | while (*t != 'E') |
Howard Hinnant | 4fbf16a | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 11466 | { |
Howard Hinnant | 6f716a0 | 2011-06-22 19:27:39 +0000 | [diff] [blame] | 11467 | t2 = __parse_unresolved_qualifier_level(t, last); |
| 11468 | if (t2 == t || t2 == last) |
Howard Hinnant | 4fbf16a | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 11469 | return first; |
| 11470 | if (!__make<__nested_delimeter>(name, __root_)) |
| 11471 | return first; |
| 11472 | name = __root_; |
Howard Hinnant | 6f716a0 | 2011-06-22 19:27:39 +0000 | [diff] [blame] | 11473 | t = t2; |
Howard Hinnant | 4fbf16a | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 11474 | } |
Howard Hinnant | 6f716a0 | 2011-06-22 19:27:39 +0000 | [diff] [blame] | 11475 | t2 = __parse_base_unresolved_name(++t, last); |
| 11476 | if (t2 != t && __make<__unresolved_name>(false, name, __root_)) |
| 11477 | first = t2; |
Howard Hinnant | 4fbf16a | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 11478 | } |
Howard Hinnant | 6f716a0 | 2011-06-22 19:27:39 +0000 | [diff] [blame] | 11479 | } |
| 11480 | else |
| 11481 | { |
| 11482 | if (!global) |
| 11483 | { |
| 11484 | t2 = __parse_unresolved_type(t+2, last); |
| 11485 | if (t2 != t+2) |
| 11486 | { |
| 11487 | t = t2; |
| 11488 | __node* name = __root_; |
| 11489 | t2 = __parse_base_unresolved_name(t, last); |
| 11490 | if (t2 != t && __make<__unresolved_name>(false, name, __root_)) |
| 11491 | return t2; |
| 11492 | return first; |
| 11493 | } |
| 11494 | } |
| 11495 | t2 = __parse_unresolved_qualifier_level(t+2, last); |
| 11496 | if (t2 != t+2 && t2 != last) |
| 11497 | { |
| 11498 | __node* name = __root_; |
| 11499 | t = t2; |
| 11500 | while (*t != 'E') |
| 11501 | { |
| 11502 | t2 = __parse_unresolved_qualifier_level(t, last); |
| 11503 | if (t2 == t || t2 == last) |
| 11504 | return first; |
| 11505 | if (!__make<__nested_delimeter>(name, __root_)) |
| 11506 | return first; |
| 11507 | name = __root_; |
| 11508 | t = t2; |
| 11509 | } |
| 11510 | t2 = __parse_base_unresolved_name(++t, last); |
| 11511 | if (t2 != t && __make<__unresolved_name>(global, name, __root_)) |
| 11512 | first = t2; |
| 11513 | } |
Howard Hinnant | 4fbf16a | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 11514 | } |
| 11515 | } |
| 11516 | } |
| 11517 | return first; |
| 11518 | } |
| 11519 | |
| 11520 | // <function-param> ::= fp <top-level CV-qualifiers> _ # L == 0, first parameter |
| 11521 | // ::= fp <top-level CV-qualifiers> <parameter-2 non-negative number> _ # L == 0, second and later parameters |
| 11522 | // ::= fL <L-1 non-negative number> p <top-level CV-qualifiers> _ # L > 0, first parameter |
| 11523 | // ::= fL <L-1 non-negative number> p <top-level CV-qualifiers> |
| 11524 | |
| 11525 | const char* |
| 11526 | __demangle_tree::__parse_function_param(const char* first, const char* last) |
| 11527 | { |
| 11528 | if (last - first >= 3 && *first == 'f') |
| 11529 | { |
| 11530 | if (first[1] == 'p') |
| 11531 | { |
| 11532 | assert(!"__parse_function_param not implemented"); |
| 11533 | } |
| 11534 | else if (first[1] == 'L') |
| 11535 | { |
| 11536 | assert(!"__parse_function_param not implemented"); |
| 11537 | } |
| 11538 | } |
| 11539 | return first; |
| 11540 | } |
| 11541 | |
| 11542 | // at <type> # alignof (a type) |
| 11543 | |
| 11544 | const char* |
| 11545 | __demangle_tree::__parse_alignof_expr(const char* first, const char* last) |
| 11546 | { |
| 11547 | if (last - first >= 3 && first[0] == 'a' && first[1] == 't') |
| 11548 | { |
| 11549 | const char* t = __parse_type(first+2, last); |
| 11550 | if (t != first+2) |
| 11551 | { |
| 11552 | if (__make<__operator_alignof_expression>(__root_)) |
| 11553 | first = t; |
| 11554 | } |
| 11555 | } |
| 11556 | return first; |
| 11557 | } |
| 11558 | |
| 11559 | // cc <type> <expression> # const_cast<type> (expression) |
| 11560 | |
| 11561 | const char* |
| 11562 | __demangle_tree::__parse_const_cast_expr(const char* first, const char* last) |
| 11563 | { |
| 11564 | if (last - first >= 3 && first[0] == 'c' && first[1] == 'c') |
| 11565 | { |
| 11566 | const char* t = __parse_type(first+2, last); |
| 11567 | if (t != first+2) |
| 11568 | { |
| 11569 | __node* type = __root_; |
| 11570 | const char* t1 = __parse_expression(t, last); |
| 11571 | if (t1 != t) |
| 11572 | { |
| 11573 | if (__make<__const_cast>(type, __root_)) |
| 11574 | first = t1; |
| 11575 | } |
| 11576 | } |
| 11577 | } |
| 11578 | return first; |
| 11579 | } |
| 11580 | |
| 11581 | // cl <expression>+ E # call |
| 11582 | |
| 11583 | const char* |
| 11584 | __demangle_tree::__parse_call_expr(const char* first, const char* last) |
| 11585 | { |
| 11586 | if (last - first >= 4 && first[0] == 'c' && first[1] == 'l') |
| 11587 | { |
| 11588 | const char* t = __parse_expression(first+2, last); |
| 11589 | if (t != first+2) |
| 11590 | { |
| 11591 | if (t == last) |
| 11592 | return first; |
| 11593 | __node* name = __root_; |
| 11594 | __node* args = 0; |
| 11595 | __node* prev = 0; |
| 11596 | while (*t != 'E') |
| 11597 | { |
| 11598 | const char* t1 = __parse_expression(t, last); |
| 11599 | if (t1 == t || t1 == last) |
| 11600 | return first; |
| 11601 | if (!__make<__list>(__root_)) |
| 11602 | return first; |
| 11603 | if (args == 0) |
| 11604 | args = __root_; |
| 11605 | if (prev) |
| 11606 | { |
| 11607 | prev->__right_ = __root_; |
| 11608 | __root_->__size_ = prev->__size_ + 1; |
| 11609 | } |
| 11610 | prev = __root_; |
| 11611 | t = t1; |
| 11612 | } |
| 11613 | ++t; |
| 11614 | if (__make<__call_expr>(name, args)) |
| 11615 | first = t; |
| 11616 | } |
| 11617 | } |
| 11618 | return first; |
| 11619 | } |
| 11620 | |
| 11621 | // cv <type> <expression> # conversion with one argument |
| 11622 | // cv <type> _ <expression>* E # conversion with a different number of arguments |
| 11623 | |
| 11624 | const char* |
| 11625 | __demangle_tree::__parse_conversion_expr(const char* first, const char* last) |
| 11626 | { |
| 11627 | if (last - first >= 3 && first[0] == 'c' && first[1] == 'v') |
| 11628 | { |
| 11629 | const char* t = __parse_type(first+2, last); |
| 11630 | if (t != first+2 && t != last) |
| 11631 | { |
| 11632 | __node* type = __root_; |
| 11633 | __node* args = 0; |
| 11634 | if (*t != '_') |
| 11635 | { |
| 11636 | const char* t1 = __parse_expression(t, last); |
| 11637 | if (t1 == t) |
| 11638 | return first; |
| 11639 | args = __root_; |
| 11640 | t = t1; |
| 11641 | } |
| 11642 | else |
| 11643 | { |
| 11644 | ++t; |
| 11645 | if (t == last) |
| 11646 | return first; |
| 11647 | __node* prev = 0; |
| 11648 | while (*t != 'E') |
| 11649 | { |
| 11650 | const char* t1 = __parse_expression(t, last); |
| 11651 | if (t1 == t || t1 == last) |
| 11652 | return first; |
| 11653 | if (!__make<__list>(__root_)) |
| 11654 | return first; |
| 11655 | if (args == 0) |
| 11656 | args = __root_; |
| 11657 | if (prev) |
| 11658 | { |
| 11659 | prev->__right_ = __root_; |
| 11660 | __root_->__size_ = prev->__size_ + 1; |
| 11661 | } |
| 11662 | prev = __root_; |
| 11663 | t = t1; |
| 11664 | } |
| 11665 | ++t; |
| 11666 | } |
| 11667 | if (__make<__operator_cast>(type, args)) |
| 11668 | first = t; |
| 11669 | } |
| 11670 | } |
| 11671 | return first; |
| 11672 | } |
| 11673 | |
| 11674 | // [gs] da <expression> # delete[] expression |
| 11675 | |
| 11676 | const char* |
| 11677 | __demangle_tree::__parse_delete_array_expr(const char* first, const char* last) |
| 11678 | { |
| 11679 | if (last - first >= 4) |
| 11680 | { |
| 11681 | const char* t = first; |
| 11682 | bool parsed_gs = false; |
| 11683 | if (t[0] == 'g' && t[1] == 's') |
| 11684 | { |
| 11685 | t += 2; |
| 11686 | parsed_gs = true; |
| 11687 | } |
| 11688 | if (t[0] == 'd' && t[1] == 'a') |
| 11689 | { |
| 11690 | t += 2; |
| 11691 | const char* t1 = __parse_expression(t, last); |
| 11692 | if (t1 != t) |
| 11693 | { |
| 11694 | if (__make<__delete_array_expr>(parsed_gs, __root_)) |
| 11695 | first = t1; |
| 11696 | } |
| 11697 | } |
| 11698 | } |
| 11699 | return first; |
| 11700 | } |
| 11701 | |
| 11702 | // dc <type> <expression> # dynamic_cast<type> (expression) |
| 11703 | |
| 11704 | const char* |
| 11705 | __demangle_tree::__parse_dynamic_cast_expr(const char* first, const char* last) |
| 11706 | { |
| 11707 | if (last - first >= 3 && first[0] == 'd' && first[1] == 'c') |
| 11708 | { |
| 11709 | const char* t = __parse_type(first+2, last); |
| 11710 | if (t != first+2) |
| 11711 | { |
| 11712 | __node* type = __root_; |
| 11713 | const char* t1 = __parse_expression(t, last); |
| 11714 | if (t1 != t) |
| 11715 | { |
| 11716 | if (__make<__dynamic_cast>(type, __root_)) |
| 11717 | first = t1; |
| 11718 | } |
| 11719 | } |
| 11720 | } |
| 11721 | return first; |
| 11722 | } |
| 11723 | |
| 11724 | // [gs] dl <expression> # delete expression |
| 11725 | |
| 11726 | const char* |
| 11727 | __demangle_tree::__parse_delete_expr(const char* first, const char* last) |
| 11728 | { |
| 11729 | if (last - first >= 4) |
| 11730 | { |
| 11731 | const char* t = first; |
| 11732 | bool parsed_gs = false; |
| 11733 | if (t[0] == 'g' && t[1] == 's') |
| 11734 | { |
| 11735 | t += 2; |
| 11736 | parsed_gs = true; |
| 11737 | } |
| 11738 | if (t[0] == 'd' && t[1] == 'l') |
| 11739 | { |
| 11740 | t += 2; |
| 11741 | const char* t1 = __parse_expression(t, last); |
| 11742 | if (t1 != t) |
| 11743 | { |
| 11744 | if (__make<__delete_expr>(parsed_gs, __root_)) |
| 11745 | first = t1; |
| 11746 | } |
| 11747 | } |
| 11748 | } |
| 11749 | return first; |
| 11750 | } |
| 11751 | |
| 11752 | // ds <expression> <expression> # expr.*expr |
| 11753 | |
| 11754 | const char* |
| 11755 | __demangle_tree::__parse_dot_star_expr(const char* first, const char* last) |
| 11756 | { |
| 11757 | if (last - first >= 3 && first[0] == 'd' && first[1] == 's') |
| 11758 | { |
| 11759 | const char* t = __parse_expression(first+2, last); |
| 11760 | if (t != first+2) |
| 11761 | { |
| 11762 | __node* expr = __root_; |
| 11763 | const char* t1 = __parse_expression(t, last); |
| 11764 | if (t1 != t) |
| 11765 | { |
| 11766 | if (__make<__dot_star_expr>(expr, __root_)) |
| 11767 | first = t1; |
| 11768 | } |
| 11769 | } |
| 11770 | } |
| 11771 | return first; |
| 11772 | } |
| 11773 | |
| 11774 | // dt <expression> <unresolved-name> # expr.name |
| 11775 | |
| 11776 | const char* |
| 11777 | __demangle_tree::__parse_dot_expr(const char* first, const char* last) |
| 11778 | { |
| 11779 | if (last - first >= 3 && first[0] == 'd' && first[1] == 't') |
| 11780 | { |
| 11781 | const char* t = __parse_expression(first+2, last); |
| 11782 | if (t != first+2) |
| 11783 | { |
| 11784 | __node* expr = __root_; |
| 11785 | const char* t1 = __parse_unresolved_name(t, last); |
| 11786 | if (t1 != t) |
| 11787 | { |
| 11788 | if (__make<__dot_expr>(expr, __root_)) |
| 11789 | first = t1; |
| 11790 | } |
| 11791 | } |
| 11792 | } |
| 11793 | return first; |
| 11794 | } |
| 11795 | |
| 11796 | // mm_ <expression> # prefix -- |
| 11797 | |
| 11798 | const char* |
| 11799 | __demangle_tree::__parse_decrement_expr(const char* first, const char* last) |
| 11800 | { |
| 11801 | if (last - first > 3 && first[0] == 'm' && first[1] == 'm' && first[2] == '_') |
| 11802 | { |
| 11803 | const char* t = __parse_expression(first+3, last); |
| 11804 | if (t != first+3) |
| 11805 | { |
| 11806 | if (__make<__operator_decrement>(true, __root_)) |
| 11807 | first = t; |
| 11808 | } |
| 11809 | } |
| 11810 | return first; |
| 11811 | } |
| 11812 | |
| 11813 | // pp_ <expression> # prefix ++ |
| 11814 | |
| 11815 | const char* |
| 11816 | __demangle_tree::__parse_increment_expr(const char* first, const char* last) |
| 11817 | { |
| 11818 | if (last - first > 3 && first[0] == 'p' && first[1] == 'p' && first[2] == '_') |
| 11819 | { |
| 11820 | const char* t = __parse_expression(first+3, last); |
| 11821 | if (t != first+3) |
| 11822 | { |
| 11823 | if (__make<__operator_increment>(true, __root_)) |
| 11824 | first = t; |
| 11825 | } |
| 11826 | } |
| 11827 | return first; |
| 11828 | } |
| 11829 | |
| 11830 | // [gs] nw <expression>* _ <type> E # new (expr-list) type |
| 11831 | // [gs] nw <expression>* _ <type> <initializer> # new (expr-list) type (init) |
| 11832 | // [gs] na <expression>* _ <type> E # new[] (expr-list) type |
| 11833 | // [gs] na <expression>* _ <type> <initializer> # new[] (expr-list) type (init) |
| 11834 | // <initializer> ::= pi <expression>* E # parenthesized initialization |
| 11835 | |
| 11836 | const char* |
| 11837 | __demangle_tree::__parse_new_expr(const char* first, const char* last) |
| 11838 | { |
| 11839 | if (last - first >= 4) |
| 11840 | { |
| 11841 | const char* t = first; |
| 11842 | bool parsed_gs = false; |
| 11843 | if (t[0] == 'g' && t[1] == 's') |
| 11844 | { |
| 11845 | t += 2; |
| 11846 | parsed_gs = true; |
| 11847 | } |
| 11848 | if (t[0] == 'n' && (t[1] == 'w' || t[1] == 'a')) |
| 11849 | { |
| 11850 | bool is_array = t[1] == 'a'; |
| 11851 | t += 2; |
| 11852 | if (t == last) |
| 11853 | return first; |
| 11854 | __node* expr = 0; |
| 11855 | __node* prev = 0; |
| 11856 | while (*t != '_') |
| 11857 | { |
| 11858 | const char* t1 = __parse_expression(t, last); |
| 11859 | if (t1 == t || t1 == last) |
| 11860 | return first; |
| 11861 | if (!__make<__list>(__root_)) |
| 11862 | return first; |
| 11863 | if (expr == 0) |
| 11864 | expr = __root_; |
| 11865 | if (prev) |
| 11866 | { |
| 11867 | prev->__right_ = __root_; |
| 11868 | __root_->__size_ = prev->__size_ + 1; |
| 11869 | } |
| 11870 | prev = __root_; |
| 11871 | t = t1; |
| 11872 | } |
| 11873 | ++t; |
| 11874 | const char* t1 = __parse_type(t, last); |
| 11875 | if (t1 == t || t1 == last) |
| 11876 | return first; |
| 11877 | t = t1; |
| 11878 | __node* type = __root_; |
| 11879 | __node* init = 0; |
| 11880 | prev = 0; |
| 11881 | bool has_init = false; |
| 11882 | if (last - t >= 3 && t[0] == 'p' && t[1] == 'i') |
| 11883 | { |
| 11884 | t += 2; |
| 11885 | has_init = true; |
| 11886 | while (*t != 'E') |
| 11887 | { |
| 11888 | t1 = __parse_expression(t, last); |
| 11889 | if (t1 == t || t1 == last) |
| 11890 | return first; |
| 11891 | if (!__make<__list>(__root_)) |
| 11892 | return first; |
| 11893 | if (init == 0) |
| 11894 | init = __root_; |
| 11895 | if (prev) |
| 11896 | { |
| 11897 | prev->__right_ = __root_; |
| 11898 | __root_->__size_ = prev->__size_ + 1; |
| 11899 | } |
| 11900 | prev = __root_; |
| 11901 | t = t1; |
| 11902 | } |
| 11903 | } |
| 11904 | if (*t != 'E') |
| 11905 | return first; |
| 11906 | if (__make<__new_expr>(parsed_gs, is_array, has_init, |
| 11907 | expr, type, init)) |
| 11908 | first = t; |
| 11909 | } |
| 11910 | } |
| 11911 | return first; |
| 11912 | } |
| 11913 | |
| 11914 | // pt <expression> <unresolved-name> # expr->name |
| 11915 | |
| 11916 | const char* |
| 11917 | __demangle_tree::__parse_arrow_expr(const char* first, const char* last) |
| 11918 | { |
| 11919 | if (last - first >= 3 && first[0] == 'p' && first[1] == 't') |
| 11920 | { |
| 11921 | const char* t = __parse_expression(first+2, last); |
| 11922 | if (t != first+2) |
| 11923 | { |
| 11924 | __node* expr = __root_; |
| 11925 | const char* t1 = __parse_unresolved_name(t, last); |
| 11926 | if (t1 != t) |
| 11927 | { |
| 11928 | if (__make<__arrow_expr>(expr, __root_)) |
| 11929 | first = t1; |
| 11930 | } |
| 11931 | } |
| 11932 | } |
| 11933 | return first; |
| 11934 | } |
| 11935 | |
| 11936 | // rc <type> <expression> # reinterpret_cast<type> (expression) |
| 11937 | |
| 11938 | const char* |
| 11939 | __demangle_tree::__parse_reinterpret_cast_expr(const char* first, const char* last) |
| 11940 | { |
| 11941 | if (last - first >= 3 && first[0] == 'r' && first[1] == 'c') |
| 11942 | { |
| 11943 | const char* t = __parse_type(first+2, last); |
| 11944 | if (t != first+2) |
| 11945 | { |
| 11946 | __node* type = __root_; |
| 11947 | const char* t1 = __parse_expression(t, last); |
| 11948 | if (t1 != t) |
| 11949 | { |
| 11950 | if (__make<__reinterpret_cast>(type, __root_)) |
| 11951 | first = t1; |
| 11952 | } |
| 11953 | } |
| 11954 | } |
| 11955 | return first; |
| 11956 | } |
| 11957 | |
| 11958 | // sc <type> <expression> # static_cast<type> (expression) |
| 11959 | |
| 11960 | const char* |
| 11961 | __demangle_tree::__parse_static_cast_expr(const char* first, const char* last) |
| 11962 | { |
| 11963 | if (last - first >= 3 && first[0] == 's' && first[1] == 'c') |
| 11964 | { |
| 11965 | const char* t = __parse_type(first+2, last); |
| 11966 | if (t != first+2) |
| 11967 | { |
| 11968 | __node* type = __root_; |
| 11969 | const char* t1 = __parse_expression(t, last); |
| 11970 | if (t1 != t) |
| 11971 | { |
| 11972 | if (__make<__static_cast>(type, __root_)) |
| 11973 | first = t1; |
| 11974 | } |
| 11975 | } |
| 11976 | } |
| 11977 | return first; |
| 11978 | } |
| 11979 | |
| 11980 | // st <type> # sizeof (a type) |
| 11981 | |
| 11982 | const char* |
| 11983 | __demangle_tree::__parse_sizeof_type_expr(const char* first, const char* last) |
| 11984 | { |
| 11985 | if (last - first >= 3 && first[0] == 's' && first[1] == 't') |
| 11986 | { |
| 11987 | const char* t = __parse_type(first+2, last); |
| 11988 | if (t != first+2) |
| 11989 | { |
| 11990 | if (__make<__operator_sizeof_expression>(__root_)) |
| 11991 | first = t; |
| 11992 | } |
| 11993 | } |
| 11994 | return first; |
| 11995 | } |
| 11996 | |
| 11997 | // sZ <template-param> # size of a parameter pack |
| 11998 | |
| 11999 | const char* |
| 12000 | __demangle_tree::__parse_sizeof_param_pack_expr(const char* first, const char* last) |
| 12001 | { |
| 12002 | if (last - first >= 3 && first[0] == 's' && first[1] == 'Z' && first[2] == 'T') |
| 12003 | { |
| 12004 | const char* t = __parse_template_param(first+2, last); |
| 12005 | if (t != first+2) |
| 12006 | { |
| 12007 | if (__make<__operator_sizeof_param_pack>(__root_)) |
| 12008 | first = t; |
| 12009 | } |
| 12010 | } |
| 12011 | return first; |
| 12012 | } |
| 12013 | |
| 12014 | // sZ <function-param> # size of a function parameter pack |
| 12015 | |
| 12016 | const char* |
| 12017 | __demangle_tree::__parse_sizeof_function_param_pack_expr(const char* first, const char* last) |
| 12018 | { |
| 12019 | if (last - first >= 3 && first[0] == 's' && first[1] == 'Z' && first[2] == 'f') |
| 12020 | { |
| 12021 | const char* t = __parse_function_param(first+2, last); |
| 12022 | if (t != first+2) |
| 12023 | { |
| 12024 | if (__make<__operator_sizeof_param_pack>(__root_)) |
| 12025 | first = t; |
| 12026 | } |
| 12027 | } |
| 12028 | return first; |
| 12029 | } |
| 12030 | |
| 12031 | // sp <expression> # pack expansion |
| 12032 | |
| 12033 | const char* |
| 12034 | __demangle_tree::__parse_pack_expansion(const char* first, const char* last) |
| 12035 | { |
| 12036 | if (last - first >= 3 && first[0] == 's' && first[1] == 'p') |
| 12037 | { |
| 12038 | const char* t = __parse_expression(first+2, last); |
| 12039 | if (t != first+2) |
| 12040 | { |
| 12041 | if (__make<__pack_expansion>(__root_)) |
| 12042 | first = t; |
| 12043 | } |
| 12044 | } |
| 12045 | return first; |
| 12046 | } |
| 12047 | |
| 12048 | // te <expression> # typeid (expression) |
| 12049 | // ti <type> # typeid (type) |
| 12050 | |
| 12051 | const char* |
| 12052 | __demangle_tree::__parse_typeid_expr(const char* first, const char* last) |
| 12053 | { |
| 12054 | if (last - first >= 3 && first[0] == 't' && (first[1] == 'e' || first[1] == 'i')) |
| 12055 | { |
| 12056 | const char* t; |
| 12057 | if (first[1] == 'e') |
| 12058 | t = __parse_expression(first+2, last); |
| 12059 | else |
| 12060 | t = __parse_type(first+2, last); |
| 12061 | if (t != first+2) |
| 12062 | { |
| 12063 | if (__make<__typeid>(__root_)) |
| 12064 | first = t; |
| 12065 | } |
| 12066 | } |
| 12067 | return first; |
| 12068 | } |
| 12069 | |
| 12070 | // tw <expression> # throw expression |
| 12071 | |
| 12072 | const char* |
| 12073 | __demangle_tree::__parse_throw_expr(const char* first, const char* last) |
| 12074 | { |
| 12075 | if (last - first >= 3 && first[0] == 't' && first[1] == 'w') |
| 12076 | { |
| 12077 | const char* t = __parse_expression(first+2, last); |
| 12078 | if (t != first+2) |
| 12079 | { |
| 12080 | if (__make<__throw>(__root_)) |
| 12081 | first = t; |
| 12082 | } |
| 12083 | } |
| 12084 | return first; |
| 12085 | } |
| 12086 | |
| 12087 | // <expression> ::= <unary operator-name> <expression> |
| 12088 | // ::= <binary operator-name> <expression> <expression> |
| 12089 | // ::= <ternary operator-name> <expression> <expression> <expression> |
| 12090 | // ::= cl <expression>+ E # call |
| 12091 | // ::= cv <type> <expression> # conversion with one argument |
| 12092 | // ::= cv <type> _ <expression>* E # conversion with a different number of arguments |
| 12093 | // ::= [gs] nw <expression>* _ <type> E # new (expr-list) type |
| 12094 | // ::= [gs] nw <expression>* _ <type> <initializer> # new (expr-list) type (init) |
| 12095 | // ::= [gs] na <expression>* _ <type> E # new[] (expr-list) type |
| 12096 | // ::= [gs] na <expression>* _ <type> <initializer> # new[] (expr-list) type (init) |
| 12097 | // ::= [gs] dl <expression> # delete expression |
| 12098 | // ::= [gs] da <expression> # delete[] expression |
| 12099 | // ::= pp_ <expression> # prefix ++ |
| 12100 | // ::= mm_ <expression> # prefix -- |
| 12101 | // ::= ti <type> # typeid (type) |
| 12102 | // ::= te <expression> # typeid (expression) |
| 12103 | // ::= dc <type> <expression> # dynamic_cast<type> (expression) |
| 12104 | // ::= sc <type> <expression> # static_cast<type> (expression) |
| 12105 | // ::= cc <type> <expression> # const_cast<type> (expression) |
| 12106 | // ::= rc <type> <expression> # reinterpret_cast<type> (expression) |
| 12107 | // ::= st <type> # sizeof (a type) |
| 12108 | // ::= at <type> # alignof (a type) |
| 12109 | // ::= <template-param> |
| 12110 | // ::= <function-param> |
| 12111 | // ::= dt <expression> <unresolved-name> # expr.name |
| 12112 | // ::= pt <expression> <unresolved-name> # expr->name |
| 12113 | // ::= ds <expression> <expression> # expr.*expr |
| 12114 | // ::= sZ <template-param> # size of a parameter pack |
| 12115 | // ::= sZ <function-param> # size of a function parameter pack |
| 12116 | // ::= sp <expression> # pack expansion |
| 12117 | // ::= tw <expression> # throw expression |
| 12118 | // ::= tr # throw with no operand (rethrow) |
| 12119 | // ::= <unresolved-name> # f(p), N::f(p), ::f(p), |
| 12120 | // # freestanding dependent name (e.g., T::x), |
| 12121 | // # objectless nonstatic member reference |
| 12122 | // ::= <expr-primary> |
| 12123 | |
| 12124 | const char* |
| 12125 | __demangle_tree::__parse_expression(const char* first, const char* last) |
| 12126 | { |
| 12127 | if (last - first >= 2) |
| 12128 | { |
| 12129 | const char* t = first; |
| 12130 | bool parsed_gs = false; |
| 12131 | if (last - first >= 4 && t[0] == 'g' && t[1] == 's') |
| 12132 | { |
| 12133 | t += 2; |
| 12134 | parsed_gs = true; |
| 12135 | } |
| 12136 | switch (*t) |
| 12137 | { |
| 12138 | case 'L': |
| 12139 | t = __parse_expr_primary(first, last); |
| 12140 | break; |
| 12141 | case 'T': |
| 12142 | t = __parse_template_param(first, last); |
| 12143 | break; |
| 12144 | case 'f': |
| 12145 | t = __parse_function_param(first, last); |
| 12146 | break; |
| 12147 | case 'a': |
| 12148 | if (t[1] == 't') |
| 12149 | t = __parse_alignof_expr(first, last); |
| 12150 | break; |
| 12151 | case 'c': |
| 12152 | switch (t[1]) |
| 12153 | { |
| 12154 | case 'c': |
| 12155 | t = __parse_const_cast_expr(first, last); |
| 12156 | break; |
| 12157 | case 'l': |
| 12158 | t = __parse_call_expr(first, last); |
| 12159 | break; |
| 12160 | case 'v': |
| 12161 | t = __parse_conversion_expr(first, last); |
| 12162 | break; |
| 12163 | } |
| 12164 | break; |
| 12165 | case 'd': |
| 12166 | switch (t[1]) |
| 12167 | { |
| 12168 | case 'a': |
| 12169 | t = __parse_delete_array_expr(first, last); |
| 12170 | break; |
| 12171 | case 'c': |
| 12172 | t = __parse_dynamic_cast_expr(first, last); |
| 12173 | break; |
| 12174 | case 'l': |
| 12175 | t = __parse_delete_expr(first, last); |
| 12176 | break; |
| 12177 | case 's': |
| 12178 | t = __parse_dot_star_expr(first, last); |
| 12179 | break; |
| 12180 | case 't': |
| 12181 | t = __parse_dot_expr(first, last); |
| 12182 | break; |
| 12183 | } |
| 12184 | break; |
| 12185 | case 'm': |
| 12186 | t = __parse_decrement_expr(first, last); |
| 12187 | break; |
| 12188 | case 'n': |
| 12189 | switch (t[1]) |
| 12190 | { |
| 12191 | case 'a': |
| 12192 | case 'w': |
| 12193 | t = __parse_new_expr(first, last); |
| 12194 | break; |
| 12195 | } |
| 12196 | break; |
| 12197 | case 'p': |
| 12198 | switch (t[1]) |
| 12199 | { |
| 12200 | case 'p': |
| 12201 | t = __parse_increment_expr(first, last); |
| 12202 | break; |
| 12203 | case 't': |
| 12204 | t = __parse_arrow_expr(first, last); |
| 12205 | break; |
| 12206 | } |
| 12207 | break; |
| 12208 | case 'r': |
| 12209 | t = __parse_reinterpret_cast_expr(first, last); |
| 12210 | break; |
| 12211 | case 's': |
| 12212 | switch (t[1]) |
| 12213 | { |
| 12214 | case 'c': |
| 12215 | t = __parse_static_cast_expr(first, last); |
| 12216 | break; |
| 12217 | case 'p': |
| 12218 | t = __parse_pack_expansion(first, last); |
| 12219 | break; |
| 12220 | case 't': |
| 12221 | t = __parse_sizeof_type_expr(first, last); |
| 12222 | break; |
| 12223 | case 'Z': |
| 12224 | if (last - t >= 3) |
| 12225 | { |
| 12226 | switch (t[2]) |
| 12227 | { |
| 12228 | case 'T': |
| 12229 | t = __parse_sizeof_param_pack_expr(first, last); |
| 12230 | break; |
| 12231 | case 'f': |
| 12232 | t = __parse_sizeof_function_param_pack_expr(first, last); |
| 12233 | break; |
| 12234 | } |
| 12235 | } |
| 12236 | break; |
| 12237 | } |
| 12238 | break; |
| 12239 | case 't': |
| 12240 | switch (t[1]) |
| 12241 | { |
| 12242 | case 'e': |
| 12243 | case 'i': |
| 12244 | t = __parse_typeid_expr(first, last); |
| 12245 | break; |
| 12246 | case 'r': |
| 12247 | if (__make<__rethrow>()) |
| 12248 | t = first +2; |
| 12249 | break; |
| 12250 | case 'w': |
| 12251 | t = __parse_throw_expr(first, last); |
| 12252 | break; |
| 12253 | } |
| 12254 | break; |
| 12255 | } |
| 12256 | if ((!parsed_gs && t == first) || (parsed_gs && t == first+2)) |
| 12257 | { |
| 12258 | int op; |
| 12259 | t = __parse_operator_name(first, last, &op); |
| 12260 | if (t == first) |
| 12261 | first = __parse_unresolved_name(first, last); |
| 12262 | else |
| 12263 | first = t; |
| 12264 | } |
| 12265 | else |
| 12266 | first = t; |
| 12267 | } |
| 12268 | return first; |
| 12269 | } |
| 12270 | |
| 12271 | // <array-type> ::= A <positive dimension number> _ <element type> |
| 12272 | // ::= A [<dimension expression>] _ <element type> |
| 12273 | |
| 12274 | const char* |
| 12275 | __demangle_tree::__parse_array_type(const char* first, const char* last) |
| 12276 | { |
| 12277 | if (first != last && *first == 'A' && first+1 != last) |
| 12278 | { |
| 12279 | if (first[1] == '_') |
| 12280 | { |
| 12281 | const char* t = __parse_type(first+2, last); |
| 12282 | if (t != first+2) |
| 12283 | { |
| 12284 | if (__make<__array>(__root_)) |
| 12285 | first = t; |
| 12286 | } |
| 12287 | } |
| 12288 | else if ('1' <= first[1] && first[1] <= '9') |
| 12289 | { |
| 12290 | size_t dim = first[1] - '0'; |
| 12291 | const char* t = first+2; |
| 12292 | for (; t != last && isdigit(*t); ++t) |
| 12293 | dim = dim * 10 + *t - '0'; |
| 12294 | if (t != last && *t == '_') |
| 12295 | { |
| 12296 | const char* t2 = __parse_type(t+1, last); |
| 12297 | if (t2 != t+1) |
| 12298 | { |
| 12299 | if (__make<__array>(__root_, dim)) |
| 12300 | first = t2; |
| 12301 | } |
| 12302 | } |
| 12303 | } |
| 12304 | else |
| 12305 | { |
| 12306 | const char* t = __parse_expression(first+1, last); |
| 12307 | if (t != first+1 && t != last && *t == '_') |
| 12308 | { |
| 12309 | __node* dim = __root_; |
| 12310 | const char* t2 = __parse_type(++t, last); |
| 12311 | if (t2 != t) |
| 12312 | { |
| 12313 | if (__make<__array>(__root_, dim)) |
| 12314 | first = t2; |
| 12315 | } |
| 12316 | } |
| 12317 | } |
| 12318 | } |
| 12319 | return first; |
| 12320 | } |
| 12321 | |
| 12322 | // <class-enum-type> ::= <name> |
| 12323 | |
| 12324 | const char* |
| 12325 | __demangle_tree::__parse_class_enum_type(const char* first, const char* last) |
| 12326 | { |
| 12327 | return __parse_name(first, last); |
| 12328 | } |
| 12329 | |
| 12330 | // <pointer-to-member-type> ::= M <class type> <member type> |
| 12331 | |
| 12332 | const char* |
| 12333 | __demangle_tree::__parse_pointer_to_member_type(const char* first, const char* last) |
| 12334 | { |
| 12335 | if (first != last && *first == 'M') |
| 12336 | { |
| 12337 | const char* t = __parse_type(first+1, last); |
| 12338 | if (t != first+1) |
| 12339 | { |
| 12340 | __node* class_type = __root_; |
| 12341 | const char* t2 = __parse_type(t, last, true, true); |
| 12342 | if (t2 != t) |
| 12343 | { |
| 12344 | if (__make<__pointer_to_member_type>(class_type, __root_)) |
| 12345 | first = t2; |
| 12346 | } |
| 12347 | } |
| 12348 | } |
| 12349 | return first; |
| 12350 | } |
| 12351 | |
| 12352 | // <decltype> ::= Dt <expression> E # decltype of an id-expression or class member access (C++0x) |
| 12353 | // ::= DT <expression> E # decltype of an expression (C++0x) |
| 12354 | |
| 12355 | const char* |
| 12356 | __demangle_tree::__parse_decltype(const char* first, const char* last) |
| 12357 | { |
| 12358 | if (last - first >= 4 && first[0] == 'D') |
| 12359 | { |
| 12360 | switch (first[1]) |
| 12361 | { |
| 12362 | case 't': |
| 12363 | case 'T': |
| 12364 | { |
| 12365 | const char* t = __parse_expression(first+2, last); |
| 12366 | if (t != first+2 && t != last && *t == 'E') |
| 12367 | { |
| 12368 | if (__make<__decltype_node>(__root_)) |
| 12369 | first = t+1; |
| 12370 | } |
| 12371 | } |
| 12372 | break; |
| 12373 | } |
| 12374 | } |
| 12375 | return first; |
| 12376 | } |
| 12377 | |
| 12378 | // <template-param> ::= T_ # first template parameter |
| 12379 | // ::= T <parameter-2 non-negative number> _ |
| 12380 | |
| 12381 | const char* |
| 12382 | __demangle_tree::__parse_template_param(const char* first, const char* last) |
| 12383 | { |
| 12384 | if (last - first >= 2) |
| 12385 | { |
| 12386 | if (*first == 'T') |
| 12387 | { |
| 12388 | if (first[1] == '_') |
| 12389 | { |
| 12390 | if (__t_begin_ != __t_end_) |
| 12391 | { |
| 12392 | if (__make<__sub>(*__t_begin_)) |
| 12393 | first += 2; |
| 12394 | } |
| 12395 | else |
| 12396 | { |
| 12397 | if (__make<__sub>(size_t(0))) |
| 12398 | { |
| 12399 | first += 2; |
| 12400 | __fix_forward_references_ = true; |
| 12401 | } |
| 12402 | } |
| 12403 | } |
| 12404 | else if (isdigit(first[1])) |
| 12405 | { |
| 12406 | const char* t = first+1; |
| 12407 | size_t sub = *t - '0'; |
| 12408 | for (++t; t != last && isdigit(*t); ++t) |
| 12409 | { |
| 12410 | sub *= 10; |
| 12411 | sub += *t - '0'; |
| 12412 | } |
| 12413 | if (t == last || *t != '_') |
| 12414 | return first; |
| 12415 | ++sub; |
| 12416 | if (sub < __t_end_ - __t_begin_) |
| 12417 | { |
| 12418 | if (__make<__sub>(__t_begin_[sub])) |
| 12419 | first = t+1; |
| 12420 | } |
| 12421 | else |
| 12422 | { |
| 12423 | if (__make<__sub>(sub)) |
| 12424 | { |
| 12425 | first = t+1; |
| 12426 | __fix_forward_references_ = true; |
| 12427 | } |
| 12428 | } |
| 12429 | } |
| 12430 | } |
| 12431 | } |
| 12432 | return first; |
| 12433 | } |
| 12434 | |
| 12435 | // <type> ::= <builtin-type> |
| 12436 | // ::= <function-type> |
| 12437 | // ::= <class-enum-type> |
| 12438 | // ::= <array-type> |
| 12439 | // ::= <pointer-to-member-type> |
| 12440 | // ::= <template-param> |
| 12441 | // ::= <template-template-param> <template-args> |
| 12442 | // ::= <decltype> |
| 12443 | // ::= <substitution> |
| 12444 | // ::= <CV-qualifiers> <type> |
| 12445 | // ::= P <type> # pointer-to |
| 12446 | // ::= R <type> # reference-to |
| 12447 | // ::= O <type> # rvalue reference-to (C++0x) |
| 12448 | // ::= C <type> # complex pair (C 2000) |
| 12449 | // ::= G <type> # imaginary (C 2000) |
| 12450 | // ::= Dp <type> # pack expansion (C++0x) |
| 12451 | // ::= U <source-name> <type> # vendor extended type qualifier |
| 12452 | |
| 12453 | const char* |
| 12454 | __demangle_tree::__parse_type(const char* first, const char* last, |
| 12455 | bool try_to_parse_template_args, |
| 12456 | bool look_for_ref_quals) |
| 12457 | { |
| 12458 | unsigned cv = 0; |
| 12459 | const char* t = __parse_cv_qualifiers(first, last, cv, look_for_ref_quals); |
| 12460 | if (t != first) |
| 12461 | { |
| 12462 | const char* t2 = __parse_type(t, last, try_to_parse_template_args); |
| 12463 | if (t2 != t) |
| 12464 | { |
| 12465 | if (__make<__cv_qualifiers>(cv, __root_)) |
| 12466 | { |
| 12467 | if (__sub_end_ == __sub_cap_) |
| 12468 | __status_ = memory_alloc_failure; |
| 12469 | else |
| 12470 | { |
| 12471 | *__sub_end_++ = __root_; |
| 12472 | first = t2; |
| 12473 | } |
| 12474 | } |
| 12475 | } |
| 12476 | return first; |
| 12477 | } |
| 12478 | if (first != last) |
| 12479 | { |
| 12480 | switch (*first) |
| 12481 | { |
| 12482 | case 'A': |
| 12483 | t = __parse_array_type(first, last); |
| 12484 | if (t != first) |
| 12485 | { |
| 12486 | if (__sub_end_ == __sub_cap_) |
| 12487 | __status_ = memory_alloc_failure; |
| 12488 | else |
| 12489 | { |
| 12490 | *__sub_end_++ = __root_; |
| 12491 | first = t; |
| 12492 | } |
| 12493 | } |
| 12494 | break; |
| 12495 | case 'C': |
| 12496 | t = __parse_type(first+1, last, try_to_parse_template_args); |
| 12497 | if (t != first+1) |
| 12498 | { |
| 12499 | if (__make<__d_complex>(__root_)) |
| 12500 | { |
| 12501 | if (__sub_end_ == __sub_cap_) |
| 12502 | __status_ = memory_alloc_failure; |
| 12503 | else |
| 12504 | { |
| 12505 | *__sub_end_++ = __root_; |
| 12506 | first = t; |
| 12507 | } |
| 12508 | } |
| 12509 | return first; |
| 12510 | } |
| 12511 | break; |
| 12512 | case 'F': |
| 12513 | t = __parse_function_type(first, last); |
| 12514 | if (t != first) |
| 12515 | { |
| 12516 | if (__sub_end_ == __sub_cap_) |
| 12517 | __status_ = memory_alloc_failure; |
| 12518 | else |
| 12519 | { |
| 12520 | *__sub_end_++ = __root_; |
| 12521 | first = t; |
| 12522 | } |
| 12523 | } |
| 12524 | break; |
| 12525 | case 'G': |
| 12526 | t = __parse_type(first+1, last, try_to_parse_template_args); |
| 12527 | if (t != first+1) |
| 12528 | { |
| 12529 | if (__make<__imaginary>(__root_)) |
| 12530 | { |
| 12531 | if (__sub_end_ == __sub_cap_) |
| 12532 | __status_ = memory_alloc_failure; |
| 12533 | else |
| 12534 | { |
| 12535 | *__sub_end_++ = __root_; |
| 12536 | first = t; |
| 12537 | } |
| 12538 | } |
| 12539 | return first; |
| 12540 | } |
| 12541 | break; |
| 12542 | case 'M': |
| 12543 | t = __parse_pointer_to_member_type(first, last); |
| 12544 | if (t != first) |
| 12545 | { |
| 12546 | if (__sub_end_ == __sub_cap_) |
| 12547 | __status_ = memory_alloc_failure; |
| 12548 | else |
| 12549 | { |
| 12550 | *__sub_end_++ = __root_; |
| 12551 | first = t; |
| 12552 | } |
| 12553 | } |
| 12554 | break; |
| 12555 | case 'O': |
| 12556 | t = __parse_type(first+1, last, try_to_parse_template_args); |
| 12557 | if (t != first+1) |
| 12558 | { |
| 12559 | if (__make<__rvalue_reference_to>(__root_)) |
| 12560 | { |
| 12561 | if (__sub_end_ == __sub_cap_) |
| 12562 | __status_ = memory_alloc_failure; |
| 12563 | else |
| 12564 | { |
| 12565 | *__sub_end_++ = __root_; |
| 12566 | first = t; |
| 12567 | } |
| 12568 | } |
| 12569 | return first; |
| 12570 | } |
| 12571 | break; |
| 12572 | case 'P': |
| 12573 | t = __parse_type(first+1, last, try_to_parse_template_args); |
| 12574 | if (t != first+1) |
| 12575 | { |
| 12576 | if (__make<__pointer_to>(__root_)) |
| 12577 | { |
| 12578 | if (__sub_end_ == __sub_cap_) |
| 12579 | __status_ = memory_alloc_failure; |
| 12580 | else |
| 12581 | { |
| 12582 | *__sub_end_++ = __root_; |
| 12583 | first = t; |
| 12584 | } |
| 12585 | } |
| 12586 | return first; |
| 12587 | } |
| 12588 | break; |
| 12589 | case 'R': |
| 12590 | t = __parse_type(first+1, last, try_to_parse_template_args); |
| 12591 | if (t != first+1) |
| 12592 | { |
| 12593 | if (__make<__lvalue_reference_to>(__root_)) |
| 12594 | { |
| 12595 | if (__sub_end_ == __sub_cap_) |
| 12596 | __status_ = memory_alloc_failure; |
| 12597 | else |
| 12598 | { |
| 12599 | *__sub_end_++ = __root_; |
| 12600 | first = t; |
| 12601 | } |
| 12602 | } |
| 12603 | return first; |
| 12604 | } |
| 12605 | break; |
| 12606 | case 'T': |
| 12607 | t = __parse_template_param(first, last); |
| 12608 | if (t != first) |
| 12609 | { |
| 12610 | if (__sub_end_ == __sub_cap_) |
| 12611 | __status_ = memory_alloc_failure; |
| 12612 | else |
| 12613 | { |
| 12614 | *__sub_end_++ = __root_; |
| 12615 | if (try_to_parse_template_args) |
| 12616 | { |
Howard Hinnant | 4fbf16a | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 12617 | const char* t2 = __parse_template_args(t, last); |
| 12618 | if (t2 != t) |
| 12619 | { |
| 12620 | if (__sub_end_ < __sub_cap_) |
| 12621 | { |
| 12622 | *__sub_end_++ = __root_; |
| 12623 | first = t2; |
| 12624 | } |
| 12625 | else |
| 12626 | __status_ = memory_alloc_failure; |
| 12627 | } |
| 12628 | else |
| 12629 | { |
| 12630 | first = t; |
| 12631 | } |
| 12632 | } |
| 12633 | else |
| 12634 | { |
| 12635 | first = t; |
| 12636 | } |
| 12637 | } |
| 12638 | } |
| 12639 | break; |
| 12640 | case 'U': |
| 12641 | if (first+1 != last) |
| 12642 | { |
| 12643 | t = __parse_source_name(first+1, last); |
| 12644 | if (t != first+1) |
| 12645 | { |
| 12646 | __node* name = __root_; |
| 12647 | const char* t2 = __parse_type(t, last, try_to_parse_template_args); |
| 12648 | if (t2 != t) |
| 12649 | { |
| 12650 | if (__make<__extended_qualifier>(name, __root_)) |
| 12651 | { |
| 12652 | if (__sub_end_ == __sub_cap_) |
| 12653 | __status_ = memory_alloc_failure; |
| 12654 | else |
| 12655 | { |
| 12656 | *__sub_end_++ = __root_; |
| 12657 | first = t2; |
| 12658 | } |
| 12659 | } |
| 12660 | return first; |
| 12661 | } |
| 12662 | } |
| 12663 | } |
| 12664 | break; |
| 12665 | case 'S': |
| 12666 | if (first+1 != last && first[1] == 't') |
| 12667 | { |
| 12668 | t = __parse_class_enum_type(first, last); |
| 12669 | if (t != first) |
| 12670 | { |
| 12671 | if (__sub_end_ == __sub_cap_) |
| 12672 | __status_ = memory_alloc_failure; |
| 12673 | else |
| 12674 | { |
| 12675 | *__sub_end_++ = __root_; |
| 12676 | first = t; |
| 12677 | } |
| 12678 | } |
| 12679 | } |
| 12680 | else |
| 12681 | { |
| 12682 | t = __parse_substitution(first, last); |
| 12683 | if (t != first) |
| 12684 | { |
| 12685 | first = t; |
| 12686 | // Parsed a substitution. If the substitution is a |
| 12687 | // <template-param> it might be followed by <template-args>. |
| 12688 | t = __parse_template_args(first, last); |
| 12689 | if (t != first) |
| 12690 | { |
| 12691 | // Need to create substitution for <template-template-param> <template-args> |
| 12692 | if (__sub_end_ == __sub_cap_) |
| 12693 | __status_ = memory_alloc_failure; |
| 12694 | else |
| 12695 | { |
| 12696 | *__sub_end_++ = __root_; |
| 12697 | first = t; |
| 12698 | } |
| 12699 | } |
| 12700 | } |
| 12701 | } |
| 12702 | break; |
| 12703 | case 'D': |
| 12704 | if (first+1 != last) |
| 12705 | { |
| 12706 | switch (first[1]) |
| 12707 | { |
| 12708 | case 'p': |
| 12709 | t = __parse_type(first+2, last, try_to_parse_template_args); |
| 12710 | if (t != first+1) |
| 12711 | { |
| 12712 | if (__make<__pack_expansion>(__root_)) |
| 12713 | { |
| 12714 | if (__sub_end_ == __sub_cap_) |
| 12715 | __status_ = memory_alloc_failure; |
| 12716 | else |
| 12717 | { |
| 12718 | *__sub_end_++ = __root_; |
| 12719 | first = t; |
| 12720 | } |
| 12721 | } |
| 12722 | return first; |
| 12723 | } |
| 12724 | break; |
| 12725 | case 't': |
| 12726 | case 'T': |
| 12727 | t = __parse_decltype(first, last); |
| 12728 | if (t != first) |
| 12729 | { |
| 12730 | if (__sub_end_ == __sub_cap_) |
| 12731 | __status_ = memory_alloc_failure; |
| 12732 | else |
| 12733 | { |
| 12734 | *__sub_end_++ = __root_; |
| 12735 | first = t; |
| 12736 | } |
| 12737 | return first; |
| 12738 | } |
| 12739 | break; |
| 12740 | } |
| 12741 | } |
| 12742 | // drop through |
| 12743 | default: |
| 12744 | // must check for builtin-types before class-enum-types to avoid |
| 12745 | // ambiguities with operator-names |
| 12746 | t = __parse_builtin_type(first, last); |
| 12747 | if (t != first) |
| 12748 | { |
| 12749 | first = t; |
| 12750 | } |
| 12751 | else |
| 12752 | { |
| 12753 | t = __parse_class_enum_type(first, last); |
| 12754 | if (t != first) |
| 12755 | { |
| 12756 | if (__sub_end_ == __sub_cap_) |
| 12757 | __status_ = memory_alloc_failure; |
| 12758 | else |
| 12759 | { |
| 12760 | *__sub_end_++ = __root_; |
| 12761 | first = t; |
| 12762 | } |
| 12763 | } |
| 12764 | } |
| 12765 | break; |
| 12766 | } |
| 12767 | } |
| 12768 | return first; |
| 12769 | } |
| 12770 | |
| 12771 | // <number> ::= [n] <non-negative decimal integer> |
| 12772 | |
| 12773 | const char* |
| 12774 | __demangle_tree::__parse_number(const char* first, const char* last) |
| 12775 | { |
| 12776 | if (first != last) |
| 12777 | { |
| 12778 | const char* t = first; |
| 12779 | if (*t == 'n') |
| 12780 | ++t; |
| 12781 | if (t != last) |
| 12782 | { |
| 12783 | if (*t == '0') |
| 12784 | { |
| 12785 | first = t+1; |
| 12786 | } |
| 12787 | else if ('1' <= *t && *t <= '9') |
| 12788 | { |
| 12789 | first = t+1; |
| 12790 | while (first != last && isdigit(*first)) |
| 12791 | ++first; |
| 12792 | } |
| 12793 | } |
| 12794 | } |
| 12795 | return first; |
| 12796 | } |
| 12797 | |
| 12798 | // <call-offset> ::= h <nv-offset> _ |
| 12799 | // ::= v <v-offset> _ |
| 12800 | // |
| 12801 | // <nv-offset> ::= <offset number> |
| 12802 | // # non-virtual base override |
| 12803 | // |
| 12804 | // <v-offset> ::= <offset number> _ <virtual offset number> |
| 12805 | // # virtual base override, with vcall offset |
| 12806 | |
| 12807 | const char* |
| 12808 | __demangle_tree::__parse_call_offset(const char* first, const char* last) |
| 12809 | { |
| 12810 | if (first != last) |
| 12811 | { |
| 12812 | switch (*first) |
| 12813 | { |
| 12814 | case 'h': |
| 12815 | { |
| 12816 | const char* t = __parse_number(first + 1, last); |
| 12817 | if (t != first + 1 && t != last && *t == '_') |
| 12818 | first = t + 1; |
| 12819 | } |
| 12820 | break; |
| 12821 | case 'v': |
| 12822 | { |
| 12823 | const char* t = __parse_number(first + 1, last); |
| 12824 | if (t != first + 1 && t != last && *t == '_') |
| 12825 | { |
| 12826 | const char* t2 = __parse_number(++t, last); |
| 12827 | if (t2 != t && t2 != last && *t2 == '_') |
| 12828 | first = t2 + 1; |
| 12829 | } |
| 12830 | } |
| 12831 | break; |
| 12832 | } |
| 12833 | } |
| 12834 | return first; |
| 12835 | } |
| 12836 | |
| 12837 | // <special-name> ::= TV <type> # virtual table |
| 12838 | // ::= TT <type> # VTT structure (construction vtable index) |
| 12839 | // ::= TI <type> # typeinfo structure |
| 12840 | // ::= TS <type> # typeinfo name (null-terminated byte string) |
| 12841 | // ::= Tc <call-offset> <call-offset> <base encoding> |
| 12842 | // # base is the nominal target function of thunk |
| 12843 | // # first call-offset is 'this' adjustment |
| 12844 | // # second call-offset is result adjustment |
| 12845 | // ::= T <call-offset> <base encoding> |
| 12846 | // # base is the nominal target function of thunk |
| 12847 | // ::= GV <object name> # Guard variable for one-time initialization |
| 12848 | // # No <type> |
| 12849 | |
| 12850 | const char* |
| 12851 | __demangle_tree::__parse_special_name(const char* first, const char* last) |
| 12852 | { |
| 12853 | if (last - first > 2) |
| 12854 | { |
| 12855 | const char* t; |
| 12856 | switch (*first) |
| 12857 | { |
| 12858 | case 'T': |
| 12859 | switch (first[1]) |
| 12860 | { |
| 12861 | case 'V': |
| 12862 | // TV <type> # virtual table |
| 12863 | t = __parse_type(first+2, last); |
| 12864 | if (t != first+2 && __make<__vtable>(__root_)) |
| 12865 | first = t; |
| 12866 | break; |
| 12867 | case 'T': |
| 12868 | // TT <type> # VTT structure (construction vtable index) |
| 12869 | t = __parse_type(first+2, last); |
| 12870 | if (t != first+2 && __make<__VTT>(__root_)) |
| 12871 | first = t; |
| 12872 | break; |
| 12873 | case 'I': |
| 12874 | // TI <type> # typeinfo structure |
| 12875 | t = __parse_type(first+2, last); |
| 12876 | if (t != first+2 && __make<__typeinfo>(__root_)) |
| 12877 | first = t; |
| 12878 | break; |
| 12879 | case 'S': |
| 12880 | // TS <type> # typeinfo name (null-terminated byte string) |
| 12881 | t = __parse_type(first+2, last); |
| 12882 | if (t != first+2 && __make<__typeinfo_name>(__root_)) |
| 12883 | first = t; |
| 12884 | break; |
| 12885 | case 'c': |
| 12886 | // Tc <call-offset> <call-offset> <base encoding> |
| 12887 | { |
| 12888 | const char* t0 = __parse_call_offset(first+2, last); |
| 12889 | if (t0 == first+2) |
| 12890 | break; |
| 12891 | const char* t1 = __parse_call_offset(t0, last); |
| 12892 | if (t1 == t0) |
| 12893 | break; |
| 12894 | t = __parse_encoding(t1, last); |
| 12895 | if (t != t1 && __make<__covariant_return_thunk>(__root_)) |
| 12896 | first = t; |
| 12897 | } |
| 12898 | break; |
| 12899 | default: |
| 12900 | // T <call-offset> <base encoding> |
| 12901 | { |
| 12902 | const char* t0 = __parse_call_offset(first+1, last); |
| 12903 | if (t0 == first+1) |
| 12904 | break; |
| 12905 | t = __parse_encoding(t0, last); |
| 12906 | if (t != t0) |
| 12907 | { |
| 12908 | if (first[2] == 'v') |
| 12909 | { |
| 12910 | if (__make<__virtual_thunk>(__root_)) |
| 12911 | first = t; |
| 12912 | } |
| 12913 | else |
| 12914 | { |
| 12915 | if (__make<__non_virtual_thunk>(__root_)) |
| 12916 | first = t; |
| 12917 | } |
| 12918 | } |
| 12919 | } |
| 12920 | break; |
| 12921 | } |
| 12922 | break; |
| 12923 | case 'G': |
| 12924 | if (first[1] == 'V') |
| 12925 | { |
| 12926 | // GV <object name> # Guard variable for one-time initialization |
| 12927 | t = __parse_name(first+2, last); |
| 12928 | if (t != first+2 && __make<__guard_variable>(__root_)) |
| 12929 | first = t; |
| 12930 | } |
| 12931 | break; |
| 12932 | } |
| 12933 | } |
| 12934 | return first; |
| 12935 | } |
| 12936 | |
| 12937 | // <operator-name> |
| 12938 | // ::= aa # && |
| 12939 | // ::= ad # & (unary) |
| 12940 | // ::= an # & |
| 12941 | // ::= aN # &= |
| 12942 | // ::= aS # = |
| 12943 | // ::= at # alignof (a type) |
| 12944 | // ::= az # alignof (an expression) |
| 12945 | // ::= cl # () |
| 12946 | // ::= cm # , |
| 12947 | // ::= co # ~ |
| 12948 | // ::= cv <type> # (cast) |
| 12949 | // ::= da # delete[] |
| 12950 | // ::= de # * (unary) |
| 12951 | // ::= dl # delete |
| 12952 | // ::= dv # / |
| 12953 | // ::= dV # /= |
| 12954 | // ::= eo # ^ |
| 12955 | // ::= eO # ^= |
| 12956 | // ::= eq # == |
| 12957 | // ::= ge # >= |
| 12958 | // ::= gt # > |
| 12959 | // ::= ix # [] |
| 12960 | // ::= le # <= |
| 12961 | // ::= ls # << |
| 12962 | // ::= lS # <<= |
| 12963 | // ::= lt # < |
| 12964 | // ::= mi # - |
| 12965 | // ::= mI # -= |
| 12966 | // ::= ml # * |
| 12967 | // ::= mL # *= |
| 12968 | // ::= mm # -- (postfix in <expression> context) |
| 12969 | // ::= na # new[] |
| 12970 | // ::= ne # != |
| 12971 | // ::= ng # - (unary) |
| 12972 | // ::= nt # ! |
| 12973 | // ::= nw # new |
| 12974 | // ::= oo # || |
| 12975 | // ::= or # | |
| 12976 | // ::= oR # |= |
| 12977 | // ::= pm # ->* |
| 12978 | // ::= pl # + |
| 12979 | // ::= pL # += |
| 12980 | // ::= pp # ++ (postfix in <expression> context) |
| 12981 | // ::= ps # + (unary) |
| 12982 | // ::= pt # -> |
| 12983 | // ::= qu # ? |
| 12984 | // ::= rm # % |
| 12985 | // ::= rM # %= |
| 12986 | // ::= rs # >> |
| 12987 | // ::= rS # >>= |
| 12988 | // ::= st # sizeof (a type) |
| 12989 | // ::= sz # sizeof (an expression) |
| 12990 | // ::= v <digit> <source-name> # vendor extended operator |
| 12991 | |
| 12992 | const char* |
| 12993 | __demangle_tree::__parse_operator_name(const char* first, const char* last, int* type) |
| 12994 | { |
| 12995 | if (last - first >= 2) |
| 12996 | { |
| 12997 | switch (*first) |
| 12998 | { |
| 12999 | case 'a': |
| 13000 | switch (first[1]) |
| 13001 | { |
| 13002 | case 'a': |
| 13003 | // && |
| 13004 | if (type) |
| 13005 | { |
| 13006 | const char* t = __parse_expression(first+2, last); |
| 13007 | if (t != first+2) |
| 13008 | { |
| 13009 | __node* op1 = __root_; |
| 13010 | const char* t2 = __parse_expression(t, last); |
| 13011 | if (t != t2) |
| 13012 | { |
| 13013 | if (__make<__operator_logical_and>(op1, __root_)) |
| 13014 | { |
| 13015 | *type = 2; |
| 13016 | first = t2; |
| 13017 | } |
| 13018 | } |
| 13019 | } |
| 13020 | } |
| 13021 | else |
| 13022 | { |
| 13023 | if (__make<__operator_logical_and>()) |
| 13024 | first += 2; |
| 13025 | } |
| 13026 | break; |
| 13027 | case 'd': |
| 13028 | // & (unary) |
| 13029 | if (type) |
| 13030 | { |
| 13031 | const char* t = __parse_expression(first+2, last); |
| 13032 | if (t != first+2) |
| 13033 | { |
| 13034 | if (__make<__operator_addressof>(__root_)) |
| 13035 | { |
| 13036 | *type = 1; |
| 13037 | first = t; |
| 13038 | } |
| 13039 | } |
| 13040 | } |
| 13041 | else |
| 13042 | { |
| 13043 | if (__make<__operator_addressof>()) |
| 13044 | first += 2; |
| 13045 | } |
| 13046 | break; |
| 13047 | case 'n': |
| 13048 | // & |
| 13049 | if (type) |
| 13050 | { |
| 13051 | const char* t = __parse_expression(first+2, last); |
| 13052 | if (t != first+2) |
| 13053 | { |
| 13054 | __node* op1 = __root_; |
| 13055 | const char* t2 = __parse_expression(t, last); |
| 13056 | if (t != t2) |
| 13057 | { |
| 13058 | if (__make<__operator_bit_and>(op1, __root_)) |
| 13059 | { |
| 13060 | *type = 2; |
| 13061 | first = t2; |
| 13062 | } |
| 13063 | } |
| 13064 | } |
| 13065 | } |
| 13066 | else |
| 13067 | { |
| 13068 | if (__make<__operator_bit_and>()) |
| 13069 | first += 2; |
| 13070 | } |
| 13071 | break; |
| 13072 | case 'N': |
| 13073 | // &= |
| 13074 | if (type) |
| 13075 | { |
| 13076 | const char* t = __parse_expression(first+2, last); |
| 13077 | if (t != first+2) |
| 13078 | { |
| 13079 | __node* op1 = __root_; |
| 13080 | const char* t2 = __parse_expression(t, last); |
| 13081 | if (t != t2) |
| 13082 | { |
| 13083 | if (__make<__operator_and_equal>(op1, __root_)) |
| 13084 | { |
| 13085 | *type = 2; |
| 13086 | first = t2; |
| 13087 | } |
| 13088 | } |
| 13089 | } |
| 13090 | } |
| 13091 | else |
| 13092 | { |
| 13093 | if (__make<__operator_and_equal>()) |
| 13094 | first += 2; |
| 13095 | } |
| 13096 | break; |
| 13097 | case 'S': |
| 13098 | // = |
| 13099 | if (type) |
| 13100 | { |
| 13101 | const char* t = __parse_expression(first+2, last); |
| 13102 | if (t != first+2) |
| 13103 | { |
| 13104 | __node* op1 = __root_; |
| 13105 | const char* t2 = __parse_expression(t, last); |
| 13106 | if (t != t2) |
| 13107 | { |
| 13108 | if (__make<__operator_equal>(op1, __root_)) |
| 13109 | { |
| 13110 | *type = 2; |
| 13111 | first = t2; |
| 13112 | } |
| 13113 | } |
| 13114 | } |
| 13115 | } |
| 13116 | else |
| 13117 | { |
| 13118 | if (__make<__operator_equal>()) |
| 13119 | first += 2; |
| 13120 | } |
| 13121 | break; |
| 13122 | case 't': |
| 13123 | // alignof (a type) |
| 13124 | if (type) |
| 13125 | { |
| 13126 | const char* t = __parse_expression(first+2, last); |
| 13127 | if (t != first+2) |
| 13128 | { |
| 13129 | if (__make<__operator_alignof_type>(__root_)) |
| 13130 | { |
| 13131 | *type = -1; |
| 13132 | first = t; |
| 13133 | } |
| 13134 | } |
| 13135 | } |
| 13136 | else |
| 13137 | { |
| 13138 | if (__make<__operator_alignof_type>()) |
| 13139 | first += 2; |
| 13140 | } |
| 13141 | break; |
| 13142 | case 'z': |
| 13143 | // alignof (an expression) |
| 13144 | if (type) |
| 13145 | { |
| 13146 | const char* t = __parse_expression(first+2, last); |
| 13147 | if (t != first+2) |
| 13148 | { |
| 13149 | if (__make<__operator_alignof_expression>(__root_)) |
| 13150 | { |
| 13151 | *type = -1; |
| 13152 | first = t; |
| 13153 | } |
| 13154 | } |
| 13155 | } |
| 13156 | else |
| 13157 | { |
| 13158 | if (__make<__operator_alignof_expression>()) |
| 13159 | first += 2; |
| 13160 | } |
| 13161 | break; |
| 13162 | } |
| 13163 | break; |
| 13164 | case 'c': |
| 13165 | switch (first[1]) |
| 13166 | { |
| 13167 | case 'l': |
| 13168 | // () |
| 13169 | if (__make<__operator_paren>()) |
| 13170 | { |
| 13171 | first += 2; |
| 13172 | if (type) |
| 13173 | *type = -1; |
| 13174 | } |
| 13175 | break; |
| 13176 | case 'm': |
| 13177 | // , |
| 13178 | if (type) |
| 13179 | { |
| 13180 | const char* t = __parse_expression(first+2, last); |
| 13181 | if (t != first+2) |
| 13182 | { |
| 13183 | __node* op1 = __root_; |
| 13184 | const char* t2 = __parse_expression(t, last); |
| 13185 | if (t != t2) |
| 13186 | { |
| 13187 | if (__make<__operator_comma>(op1, __root_)) |
| 13188 | { |
| 13189 | *type = 2; |
| 13190 | first = t2; |
| 13191 | } |
| 13192 | } |
| 13193 | } |
| 13194 | } |
| 13195 | else |
| 13196 | { |
| 13197 | if (__make<__operator_comma>()) |
| 13198 | first += 2; |
| 13199 | } |
| 13200 | break; |
| 13201 | case 'o': |
| 13202 | // ~ |
| 13203 | if (type) |
| 13204 | { |
| 13205 | const char* t = __parse_expression(first+2, last); |
| 13206 | if (t != first+2) |
| 13207 | { |
| 13208 | if (__make<__operator_tilda>(__root_)) |
| 13209 | { |
| 13210 | *type = 1; |
| 13211 | first = t; |
| 13212 | } |
| 13213 | } |
| 13214 | } |
| 13215 | else |
| 13216 | { |
| 13217 | if (__make<__operator_tilda>()) |
| 13218 | first += 2; |
| 13219 | } |
| 13220 | break; |
| 13221 | case 'v': |
| 13222 | // cast <type> |
| 13223 | { |
| 13224 | const char* t = __parse_type(first+2, last, false); |
| 13225 | if (t != first+2) |
| 13226 | { |
| 13227 | __node* cast_type = __root_; |
| 13228 | if (type) |
| 13229 | { |
| 13230 | const char* t2 = __parse_expression(t, last); |
| 13231 | if (t2 != t) |
| 13232 | { |
| 13233 | if (__make<__operator_cast>(cast_type, __root_)) |
| 13234 | { |
| 13235 | *type = -1; |
| 13236 | first = t2; |
| 13237 | } |
| 13238 | } |
| 13239 | } |
| 13240 | else |
| 13241 | { |
| 13242 | if (__make<__operator_cast>(cast_type)) |
| 13243 | first = t; |
| 13244 | } |
| 13245 | } |
| 13246 | } |
| 13247 | break; |
| 13248 | } |
| 13249 | break; |
| 13250 | case 'd': |
| 13251 | switch (first[1]) |
| 13252 | { |
| 13253 | case 'a': |
| 13254 | // delete[] |
| 13255 | if (__make<__operator_delete_array>()) |
| 13256 | { |
| 13257 | first += 2; |
| 13258 | if (type) |
| 13259 | *type = -1; |
| 13260 | } |
| 13261 | break; |
| 13262 | case 'e': |
| 13263 | // * (unary) |
| 13264 | if (type) |
| 13265 | { |
| 13266 | const char* t = __parse_expression(first+2, last); |
| 13267 | if (t != first+2) |
| 13268 | { |
| 13269 | if (__make<__operator_dereference>(__root_)) |
| 13270 | { |
| 13271 | *type = 1; |
| 13272 | first = t; |
| 13273 | } |
| 13274 | } |
| 13275 | } |
| 13276 | else |
| 13277 | { |
| 13278 | if (__make<__operator_dereference>()) |
| 13279 | first += 2; |
| 13280 | } |
| 13281 | break; |
| 13282 | case 'l': |
| 13283 | // delete |
| 13284 | if (__make<__operator_delete>()) |
| 13285 | { |
| 13286 | first += 2; |
| 13287 | if (type) |
| 13288 | *type = -1; |
| 13289 | } |
| 13290 | break; |
| 13291 | case 'v': |
| 13292 | // / |
| 13293 | if (type) |
| 13294 | { |
| 13295 | const char* t = __parse_expression(first+2, last); |
| 13296 | if (t != first+2) |
| 13297 | { |
| 13298 | __node* op1 = __root_; |
| 13299 | const char* t2 = __parse_expression(t, last); |
| 13300 | if (t != t2) |
| 13301 | { |
| 13302 | if (__make<__operator_divide>(op1, __root_)) |
| 13303 | { |
| 13304 | *type = 2; |
| 13305 | first = t2; |
| 13306 | } |
| 13307 | } |
| 13308 | } |
| 13309 | } |
| 13310 | else |
| 13311 | { |
| 13312 | if (__make<__operator_divide>()) |
| 13313 | first += 2; |
| 13314 | } |
| 13315 | break; |
| 13316 | case 'V': |
| 13317 | // /= |
| 13318 | if (type) |
| 13319 | { |
| 13320 | const char* t = __parse_expression(first+2, last); |
| 13321 | if (t != first+2) |
| 13322 | { |
| 13323 | __node* op1 = __root_; |
| 13324 | const char* t2 = __parse_expression(t, last); |
| 13325 | if (t != t2) |
| 13326 | { |
| 13327 | if (__make<__operator_divide_equal>(op1, __root_)) |
| 13328 | { |
| 13329 | *type = 2; |
| 13330 | first = t2; |
| 13331 | } |
| 13332 | } |
| 13333 | } |
| 13334 | } |
| 13335 | else |
| 13336 | { |
| 13337 | if (__make<__operator_divide_equal>()) |
| 13338 | first += 2; |
| 13339 | } |
| 13340 | break; |
| 13341 | } |
| 13342 | break; |
| 13343 | case 'e': |
| 13344 | switch (first[1]) |
| 13345 | { |
| 13346 | case 'o': |
| 13347 | // ^ |
| 13348 | if (type) |
| 13349 | { |
| 13350 | const char* t = __parse_expression(first+2, last); |
| 13351 | if (t != first+2) |
| 13352 | { |
| 13353 | __node* op1 = __root_; |
| 13354 | const char* t2 = __parse_expression(t, last); |
| 13355 | if (t != t2) |
| 13356 | { |
| 13357 | if (__make<__operator_xor>(op1, __root_)) |
| 13358 | { |
| 13359 | *type = 2; |
| 13360 | first = t2; |
| 13361 | } |
| 13362 | } |
| 13363 | } |
| 13364 | } |
| 13365 | else |
| 13366 | { |
| 13367 | if (__make<__operator_xor>()) |
| 13368 | first += 2; |
| 13369 | } |
| 13370 | break; |
| 13371 | case 'O': |
| 13372 | // ^= |
| 13373 | if (type) |
| 13374 | { |
| 13375 | const char* t = __parse_expression(first+2, last); |
| 13376 | if (t != first+2) |
| 13377 | { |
| 13378 | __node* op1 = __root_; |
| 13379 | const char* t2 = __parse_expression(t, last); |
| 13380 | if (t != t2) |
| 13381 | { |
| 13382 | if (__make<__operator_xor_equal>(op1, __root_)) |
| 13383 | { |
| 13384 | *type = 2; |
| 13385 | first = t2; |
| 13386 | } |
| 13387 | } |
| 13388 | } |
| 13389 | } |
| 13390 | else |
| 13391 | { |
| 13392 | if (__make<__operator_xor_equal>()) |
| 13393 | first += 2; |
| 13394 | } |
| 13395 | break; |
| 13396 | case 'q': |
| 13397 | // == |
| 13398 | if (type) |
| 13399 | { |
| 13400 | const char* t = __parse_expression(first+2, last); |
| 13401 | if (t != first+2) |
| 13402 | { |
| 13403 | __node* op1 = __root_; |
| 13404 | const char* t2 = __parse_expression(t, last); |
| 13405 | if (t != t2) |
| 13406 | { |
| 13407 | if (__make<__operator_equality>(op1, __root_)) |
| 13408 | { |
| 13409 | *type = 2; |
| 13410 | first = t2; |
| 13411 | } |
| 13412 | } |
| 13413 | } |
| 13414 | } |
| 13415 | else |
| 13416 | { |
| 13417 | if (__make<__operator_equality>()) |
| 13418 | first += 2; |
| 13419 | } |
| 13420 | break; |
| 13421 | } |
| 13422 | break; |
| 13423 | case 'g': |
| 13424 | switch (first[1]) |
| 13425 | { |
| 13426 | case 'e': |
| 13427 | // >= |
| 13428 | if (type) |
| 13429 | { |
| 13430 | const char* t = __parse_expression(first+2, last); |
| 13431 | if (t != first+2) |
| 13432 | { |
| 13433 | __node* op1 = __root_; |
| 13434 | const char* t2 = __parse_expression(t, last); |
| 13435 | if (t != t2) |
| 13436 | { |
| 13437 | if (__make<__operator_greater_equal>(op1, __root_)) |
| 13438 | { |
| 13439 | *type = 2; |
| 13440 | first = t2; |
| 13441 | } |
| 13442 | } |
| 13443 | } |
| 13444 | } |
| 13445 | else |
| 13446 | { |
| 13447 | if (__make<__operator_greater_equal>()) |
| 13448 | first += 2; |
| 13449 | } |
| 13450 | break; |
| 13451 | case 't': |
| 13452 | // > |
| 13453 | if (type) |
| 13454 | { |
| 13455 | const char* t = __parse_expression(first+2, last); |
| 13456 | if (t != first+2) |
| 13457 | { |
| 13458 | __node* op1 = __root_; |
| 13459 | const char* t2 = __parse_expression(t, last); |
| 13460 | if (t != t2) |
| 13461 | { |
| 13462 | if (__make<__operator_greater>(op1, __root_)) |
| 13463 | { |
| 13464 | *type = 2; |
| 13465 | first = t2; |
| 13466 | } |
| 13467 | } |
| 13468 | } |
| 13469 | } |
| 13470 | else |
| 13471 | { |
| 13472 | if (__make<__operator_greater>()) |
| 13473 | first += 2; |
| 13474 | } |
| 13475 | break; |
| 13476 | } |
| 13477 | break; |
| 13478 | case 'i': |
| 13479 | // [] |
| 13480 | if (first[1] == 'x' && __make<__operator_brackets>()) |
| 13481 | { |
| 13482 | first += 2; |
| 13483 | if (type) |
| 13484 | *type = -1; |
| 13485 | } |
| 13486 | break; |
| 13487 | case 'l': |
| 13488 | switch (first[1]) |
| 13489 | { |
| 13490 | case 'e': |
| 13491 | // <= |
| 13492 | if (type) |
| 13493 | { |
| 13494 | const char* t = __parse_expression(first+2, last); |
| 13495 | if (t != first+2) |
| 13496 | { |
| 13497 | __node* op1 = __root_; |
| 13498 | const char* t2 = __parse_expression(t, last); |
| 13499 | if (t != t2) |
| 13500 | { |
| 13501 | if (__make<__operator_less_equal>(op1, __root_)) |
| 13502 | { |
| 13503 | *type = 2; |
| 13504 | first = t2; |
| 13505 | } |
| 13506 | } |
| 13507 | } |
| 13508 | } |
| 13509 | else |
| 13510 | { |
| 13511 | if (__make<__operator_less_equal>()) |
| 13512 | first += 2; |
| 13513 | } |
| 13514 | break; |
| 13515 | case 's': |
| 13516 | // << |
| 13517 | if (type) |
| 13518 | { |
| 13519 | const char* t = __parse_expression(first+2, last); |
| 13520 | if (t != first+2) |
| 13521 | { |
| 13522 | __node* op1 = __root_; |
| 13523 | const char* t2 = __parse_expression(t, last); |
| 13524 | if (t != t2) |
| 13525 | { |
| 13526 | if (__make<__operator_left_shift>(op1, __root_)) |
| 13527 | { |
| 13528 | *type = 2; |
| 13529 | first = t2; |
| 13530 | } |
| 13531 | } |
| 13532 | } |
| 13533 | } |
| 13534 | else |
| 13535 | { |
| 13536 | if (__make<__operator_left_shift>()) |
| 13537 | first += 2; |
| 13538 | } |
| 13539 | break; |
| 13540 | case 'S': |
| 13541 | // <<= |
| 13542 | if (type) |
| 13543 | { |
| 13544 | const char* t = __parse_expression(first+2, last); |
| 13545 | if (t != first+2) |
| 13546 | { |
| 13547 | __node* op1 = __root_; |
| 13548 | const char* t2 = __parse_expression(t, last); |
| 13549 | if (t != t2) |
| 13550 | { |
| 13551 | if (__make<__operator_left_shift_equal>(op1, __root_)) |
| 13552 | { |
| 13553 | *type = 2; |
| 13554 | first = t2; |
| 13555 | } |
| 13556 | } |
| 13557 | } |
| 13558 | } |
| 13559 | else |
| 13560 | { |
| 13561 | if (__make<__operator_left_shift_equal>()) |
| 13562 | first += 2; |
| 13563 | } |
| 13564 | break; |
| 13565 | case 't': |
| 13566 | // < |
| 13567 | if (type) |
| 13568 | { |
| 13569 | const char* t = __parse_expression(first+2, last); |
| 13570 | if (t != first+2) |
| 13571 | { |
| 13572 | __node* op1 = __root_; |
| 13573 | const char* t2 = __parse_expression(t, last); |
| 13574 | if (t != t2) |
| 13575 | { |
| 13576 | if (__make<__operator_less>(op1, __root_)) |
| 13577 | { |
| 13578 | *type = 2; |
| 13579 | first = t2; |
| 13580 | } |
| 13581 | } |
| 13582 | } |
| 13583 | } |
| 13584 | else |
| 13585 | { |
| 13586 | if (__make<__operator_less>()) |
| 13587 | first += 2; |
| 13588 | } |
| 13589 | break; |
| 13590 | } |
| 13591 | break; |
| 13592 | case 'm': |
| 13593 | switch (first[1]) |
| 13594 | { |
| 13595 | case 'i': |
| 13596 | // - |
| 13597 | if (type) |
| 13598 | { |
| 13599 | const char* t = __parse_expression(first+2, last); |
| 13600 | if (t != first+2) |
| 13601 | { |
| 13602 | __node* op1 = __root_; |
| 13603 | const char* t2 = __parse_expression(t, last); |
| 13604 | if (t != t2) |
| 13605 | { |
| 13606 | if (__make<__operator_minus>(op1, __root_)) |
| 13607 | { |
| 13608 | *type = 2; |
| 13609 | first = t2; |
| 13610 | } |
| 13611 | } |
| 13612 | } |
| 13613 | } |
| 13614 | else |
| 13615 | { |
| 13616 | if (__make<__operator_minus>()) |
| 13617 | first += 2; |
| 13618 | } |
| 13619 | break; |
| 13620 | case 'I': |
| 13621 | // -= |
| 13622 | if (type) |
| 13623 | { |
| 13624 | const char* t = __parse_expression(first+2, last); |
| 13625 | if (t != first+2) |
| 13626 | { |
| 13627 | __node* op1 = __root_; |
| 13628 | const char* t2 = __parse_expression(t, last); |
| 13629 | if (t != t2) |
| 13630 | { |
| 13631 | if (__make<__operator_minus_equal>(op1, __root_)) |
| 13632 | { |
| 13633 | *type = 2; |
| 13634 | first = t2; |
| 13635 | } |
| 13636 | } |
| 13637 | } |
| 13638 | } |
| 13639 | else |
| 13640 | { |
| 13641 | if (__make<__operator_minus_equal>()) |
| 13642 | first += 2; |
| 13643 | } |
| 13644 | break; |
| 13645 | case 'l': |
| 13646 | // * |
| 13647 | if (type) |
| 13648 | { |
| 13649 | const char* t = __parse_expression(first+2, last); |
| 13650 | if (t != first+2) |
| 13651 | { |
| 13652 | __node* op1 = __root_; |
| 13653 | const char* t2 = __parse_expression(t, last); |
| 13654 | if (t != t2) |
| 13655 | { |
| 13656 | if (__make<__operator_times>(op1, __root_)) |
| 13657 | { |
| 13658 | *type = 2; |
| 13659 | first = t2; |
| 13660 | } |
| 13661 | } |
| 13662 | } |
| 13663 | } |
| 13664 | else |
| 13665 | { |
| 13666 | if (__make<__operator_times>()) |
| 13667 | first += 2; |
| 13668 | } |
| 13669 | break; |
| 13670 | case 'L': |
| 13671 | // *= |
| 13672 | if (type) |
| 13673 | { |
| 13674 | const char* t = __parse_expression(first+2, last); |
| 13675 | if (t != first+2) |
| 13676 | { |
| 13677 | __node* op1 = __root_; |
| 13678 | const char* t2 = __parse_expression(t, last); |
| 13679 | if (t != t2) |
| 13680 | { |
| 13681 | if (__make<__operator_times_equal>(op1, __root_)) |
| 13682 | { |
| 13683 | *type = 2; |
| 13684 | first = t2; |
| 13685 | } |
| 13686 | } |
| 13687 | } |
| 13688 | } |
| 13689 | else |
| 13690 | { |
| 13691 | if (__make<__operator_times_equal>()) |
| 13692 | first += 2; |
| 13693 | } |
| 13694 | break; |
| 13695 | case 'm': |
| 13696 | // -- (postfix in <expression> context) |
| 13697 | if (type) |
| 13698 | { |
| 13699 | const char* t = __parse_expression(first+2, last); |
| 13700 | if (t != first+2) |
| 13701 | { |
| 13702 | if (__make<__operator_decrement>(false, __root_)) |
| 13703 | { |
| 13704 | *type = 1; |
| 13705 | first = t; |
| 13706 | } |
| 13707 | } |
| 13708 | } |
| 13709 | else |
| 13710 | { |
| 13711 | if (__make<__operator_decrement>()) |
| 13712 | first += 2; |
| 13713 | } |
| 13714 | break; |
| 13715 | } |
| 13716 | break; |
| 13717 | case 'n': |
| 13718 | switch (first[1]) |
| 13719 | { |
| 13720 | case 'a': |
| 13721 | // new[] |
| 13722 | if (__make<__operator_new_array>()) |
| 13723 | { |
| 13724 | first += 2; |
| 13725 | if (type) |
| 13726 | *type = -1; |
| 13727 | } |
| 13728 | break; |
| 13729 | case 'e': |
| 13730 | // != |
| 13731 | if (type) |
| 13732 | { |
| 13733 | const char* t = __parse_expression(first+2, last); |
| 13734 | if (t != first+2) |
| 13735 | { |
| 13736 | __node* op1 = __root_; |
| 13737 | const char* t2 = __parse_expression(t, last); |
| 13738 | if (t != t2) |
| 13739 | { |
| 13740 | if (__make<__operator_not_equal>(op1, __root_)) |
| 13741 | { |
| 13742 | *type = 2; |
| 13743 | first = t2; |
| 13744 | } |
| 13745 | } |
| 13746 | } |
| 13747 | } |
| 13748 | else |
| 13749 | { |
| 13750 | if (__make<__operator_not_equal>()) |
| 13751 | first += 2; |
| 13752 | } |
| 13753 | break; |
| 13754 | case 'g': |
| 13755 | // - (unary) |
| 13756 | if (type) |
| 13757 | { |
| 13758 | const char* t = __parse_expression(first+2, last); |
| 13759 | if (t != first+2) |
| 13760 | { |
| 13761 | if (__make<__operator_negate>(__root_)) |
| 13762 | { |
| 13763 | *type = 1; |
| 13764 | first = t; |
| 13765 | } |
| 13766 | } |
| 13767 | } |
| 13768 | else |
| 13769 | { |
| 13770 | if (__make<__operator_negate>()) |
| 13771 | first += 2; |
| 13772 | } |
| 13773 | break; |
| 13774 | case 't': |
| 13775 | // ! |
| 13776 | if (type) |
| 13777 | { |
| 13778 | const char* t = __parse_expression(first+2, last); |
| 13779 | if (t != first+2) |
| 13780 | { |
| 13781 | if (__make<__operator_logical_not>(__root_)) |
| 13782 | { |
| 13783 | *type = 1; |
| 13784 | first = t; |
| 13785 | } |
| 13786 | } |
| 13787 | } |
| 13788 | else |
| 13789 | { |
| 13790 | if (__make<__operator_logical_not>()) |
| 13791 | first += 2; |
| 13792 | } |
| 13793 | break; |
| 13794 | case 'w': |
| 13795 | // new |
| 13796 | if (__make<__operator_new>()) |
| 13797 | { |
| 13798 | first += 2; |
| 13799 | if (type) |
| 13800 | *type = -1; |
| 13801 | } |
| 13802 | break; |
| 13803 | } |
| 13804 | break; |
| 13805 | case 'o': |
| 13806 | switch (first[1]) |
| 13807 | { |
| 13808 | case 'o': |
| 13809 | // || |
| 13810 | if (type) |
| 13811 | { |
| 13812 | const char* t = __parse_expression(first+2, last); |
| 13813 | if (t != first+2) |
| 13814 | { |
| 13815 | __node* op1 = __root_; |
| 13816 | const char* t2 = __parse_expression(t, last); |
| 13817 | if (t != t2) |
| 13818 | { |
| 13819 | if (__make<__operator_logical_or>(op1, __root_)) |
| 13820 | { |
| 13821 | *type = 2; |
| 13822 | first = t2; |
| 13823 | } |
| 13824 | } |
| 13825 | } |
| 13826 | } |
| 13827 | else |
| 13828 | { |
| 13829 | if (__make<__operator_logical_or>()) |
| 13830 | first += 2; |
| 13831 | } |
| 13832 | break; |
| 13833 | case 'r': |
| 13834 | // | |
| 13835 | if (type) |
| 13836 | { |
| 13837 | const char* t = __parse_expression(first+2, last); |
| 13838 | if (t != first+2) |
| 13839 | { |
| 13840 | __node* op1 = __root_; |
| 13841 | const char* t2 = __parse_expression(t, last); |
| 13842 | if (t != t2) |
| 13843 | { |
| 13844 | if (__make<__operator_bit_or>(op1, __root_)) |
| 13845 | { |
| 13846 | *type = 2; |
| 13847 | first = t2; |
| 13848 | } |
| 13849 | } |
| 13850 | } |
| 13851 | } |
| 13852 | else |
| 13853 | { |
| 13854 | if (__make<__operator_bit_or>()) |
| 13855 | first += 2; |
| 13856 | } |
| 13857 | break; |
| 13858 | case 'R': |
| 13859 | // |= |
| 13860 | if (type) |
| 13861 | { |
| 13862 | const char* t = __parse_expression(first+2, last); |
| 13863 | if (t != first+2) |
| 13864 | { |
| 13865 | __node* op1 = __root_; |
| 13866 | const char* t2 = __parse_expression(t, last); |
| 13867 | if (t != t2) |
| 13868 | { |
| 13869 | if (__make<__operator_or_equal>(op1, __root_)) |
| 13870 | { |
| 13871 | *type = 2; |
| 13872 | first = t2; |
| 13873 | } |
| 13874 | } |
| 13875 | } |
| 13876 | } |
| 13877 | else |
| 13878 | { |
| 13879 | if (__make<__operator_or_equal>()) |
| 13880 | first += 2; |
| 13881 | } |
| 13882 | break; |
| 13883 | } |
| 13884 | break; |
| 13885 | case 'p': |
| 13886 | switch (first[1]) |
| 13887 | { |
| 13888 | case 'm': |
| 13889 | // ->* |
| 13890 | if (type) |
| 13891 | { |
| 13892 | const char* t = __parse_expression(first+2, last); |
| 13893 | if (t != first+2) |
| 13894 | { |
| 13895 | __node* op1 = __root_; |
| 13896 | const char* t2 = __parse_expression(t, last); |
| 13897 | if (t != t2) |
| 13898 | { |
| 13899 | if (__make<__operator_pointer_to_member>(op1, __root_)) |
| 13900 | { |
| 13901 | *type = 2; |
| 13902 | first = t2; |
| 13903 | } |
| 13904 | } |
| 13905 | } |
| 13906 | } |
| 13907 | else |
| 13908 | { |
| 13909 | if (__make<__operator_pointer_to_member>()) |
| 13910 | first += 2; |
| 13911 | } |
| 13912 | break; |
| 13913 | case 'l': |
| 13914 | // + |
| 13915 | if (type) |
| 13916 | { |
| 13917 | const char* t = __parse_expression(first+2, last); |
| 13918 | if (t != first+2) |
| 13919 | { |
| 13920 | __node* op1 = __root_; |
| 13921 | const char* t2 = __parse_expression(t, last); |
| 13922 | if (t != t2) |
| 13923 | { |
| 13924 | if (__make<__operator_plus>(op1, __root_)) |
| 13925 | { |
| 13926 | *type = 2; |
| 13927 | first = t2; |
| 13928 | } |
| 13929 | } |
| 13930 | } |
| 13931 | } |
| 13932 | else |
| 13933 | { |
| 13934 | if (__make<__operator_plus>()) |
| 13935 | first += 2; |
| 13936 | } |
| 13937 | break; |
| 13938 | case 'L': |
| 13939 | // += |
| 13940 | if (type) |
| 13941 | { |
| 13942 | const char* t = __parse_expression(first+2, last); |
| 13943 | if (t != first+2) |
| 13944 | { |
| 13945 | __node* op1 = __root_; |
| 13946 | const char* t2 = __parse_expression(t, last); |
| 13947 | if (t != t2) |
| 13948 | { |
| 13949 | if (__make<__operator_plus_equal>(op1, __root_)) |
| 13950 | { |
| 13951 | *type = 2; |
| 13952 | first = t2; |
| 13953 | } |
| 13954 | } |
| 13955 | } |
| 13956 | } |
| 13957 | else |
| 13958 | { |
| 13959 | if (__make<__operator_plus_equal>()) |
| 13960 | first += 2; |
| 13961 | } |
| 13962 | break; |
| 13963 | case 'p': |
| 13964 | // ++ (postfix in <expression> context) |
| 13965 | if (type) |
| 13966 | { |
| 13967 | const char* t = __parse_expression(first+2, last); |
| 13968 | if (t != first+2) |
| 13969 | { |
| 13970 | if (__make<__operator_increment>(false, __root_)) |
| 13971 | { |
| 13972 | *type = 1; |
| 13973 | first = t; |
| 13974 | } |
| 13975 | } |
| 13976 | } |
| 13977 | else |
| 13978 | { |
| 13979 | if (__make<__operator_increment>()) |
| 13980 | first += 2; |
| 13981 | } |
| 13982 | break; |
| 13983 | case 's': |
| 13984 | // + (unary) |
| 13985 | if (type) |
| 13986 | { |
| 13987 | const char* t = __parse_expression(first+2, last); |
| 13988 | if (t != first+2) |
| 13989 | { |
| 13990 | if (__make<__operator_unary_plus>(__root_)) |
| 13991 | { |
| 13992 | *type = 1; |
| 13993 | first = t; |
| 13994 | } |
| 13995 | } |
| 13996 | } |
| 13997 | else |
| 13998 | { |
| 13999 | if (__make<__operator_unary_plus>()) |
| 14000 | first += 2; |
| 14001 | } |
| 14002 | break; |
| 14003 | case 't': |
| 14004 | // -> |
| 14005 | if (type) |
| 14006 | { |
| 14007 | const char* t = __parse_expression(first+2, last); |
| 14008 | if (t != first+2) |
| 14009 | { |
| 14010 | __node* op1 = __root_; |
| 14011 | const char* t2 = __parse_expression(t, last); |
| 14012 | if (t != t2) |
| 14013 | { |
| 14014 | if (__make<__operator_arrow>(op1, __root_)) |
| 14015 | { |
| 14016 | *type = 2; |
| 14017 | first = t2; |
| 14018 | } |
| 14019 | } |
| 14020 | } |
| 14021 | } |
| 14022 | else |
| 14023 | { |
| 14024 | if (__make<__operator_arrow>()) |
| 14025 | first += 2; |
| 14026 | } |
| 14027 | break; |
| 14028 | } |
| 14029 | break; |
| 14030 | case 'q': |
| 14031 | // ? |
| 14032 | if (first[1] == 'u') |
| 14033 | { |
| 14034 | if (type) |
| 14035 | { |
| 14036 | const char* t = __parse_expression(first+2, last); |
| 14037 | if (t != first+2) |
| 14038 | { |
| 14039 | __node* op1 = __root_; |
| 14040 | const char* t2 = __parse_expression(t, last); |
| 14041 | if (t != t2) |
| 14042 | { |
| 14043 | __node* op2 = __root_; |
| 14044 | const char* t3 = __parse_expression(t2, last); |
| 14045 | if (t3 != t2) |
| 14046 | { |
| 14047 | if (__make<__operator_conditional>(op1, op2, __root_)) |
| 14048 | { |
| 14049 | *type = 3; |
| 14050 | first = t3; |
| 14051 | } |
| 14052 | } |
| 14053 | } |
| 14054 | } |
| 14055 | } |
| 14056 | else |
| 14057 | { |
| 14058 | if (__make<__operator_conditional>()) |
| 14059 | first += 2; |
| 14060 | } |
| 14061 | } |
| 14062 | break; |
| 14063 | case 'r': |
| 14064 | switch (first[1]) |
| 14065 | { |
| 14066 | case 'm': |
| 14067 | // % |
| 14068 | if (type) |
| 14069 | { |
| 14070 | const char* t = __parse_expression(first+2, last); |
| 14071 | if (t != first+2) |
| 14072 | { |
| 14073 | __node* op1 = __root_; |
| 14074 | const char* t2 = __parse_expression(t, last); |
| 14075 | if (t != t2) |
| 14076 | { |
| 14077 | if (__make<__operator_mod>(op1, __root_)) |
| 14078 | { |
| 14079 | *type = 2; |
| 14080 | first = t2; |
| 14081 | } |
| 14082 | } |
| 14083 | } |
| 14084 | } |
| 14085 | else |
| 14086 | { |
| 14087 | if (__make<__operator_mod>()) |
| 14088 | first += 2; |
| 14089 | } |
| 14090 | break; |
| 14091 | case 'M': |
| 14092 | // %= |
| 14093 | if (type) |
| 14094 | { |
| 14095 | const char* t = __parse_expression(first+2, last); |
| 14096 | if (t != first+2) |
| 14097 | { |
| 14098 | __node* op1 = __root_; |
| 14099 | const char* t2 = __parse_expression(t, last); |
| 14100 | if (t != t2) |
| 14101 | { |
| 14102 | if (__make<__operator_mod_equal>(op1, __root_)) |
| 14103 | { |
| 14104 | *type = 2; |
| 14105 | first = t2; |
| 14106 | } |
| 14107 | } |
| 14108 | } |
| 14109 | } |
| 14110 | else |
| 14111 | { |
| 14112 | if (__make<__operator_mod_equal>()) |
| 14113 | first += 2; |
| 14114 | } |
| 14115 | break; |
| 14116 | case 's': |
| 14117 | // >> |
| 14118 | if (type) |
| 14119 | { |
| 14120 | const char* t = __parse_expression(first+2, last); |
| 14121 | if (t != first+2) |
| 14122 | { |
| 14123 | __node* op1 = __root_; |
| 14124 | const char* t2 = __parse_expression(t, last); |
| 14125 | if (t != t2) |
| 14126 | { |
| 14127 | if (__make<__operator_right_shift>(op1, __root_)) |
| 14128 | { |
| 14129 | *type = 2; |
| 14130 | first = t2; |
| 14131 | } |
| 14132 | } |
| 14133 | } |
| 14134 | } |
| 14135 | else |
| 14136 | { |
| 14137 | if (__make<__operator_right_shift>()) |
| 14138 | first += 2; |
| 14139 | } |
| 14140 | break; |
| 14141 | case 'S': |
| 14142 | // >>= |
| 14143 | if (type) |
| 14144 | { |
| 14145 | const char* t = __parse_expression(first+2, last); |
| 14146 | if (t != first+2) |
| 14147 | { |
| 14148 | __node* op1 = __root_; |
| 14149 | const char* t2 = __parse_expression(t, last); |
| 14150 | if (t != t2) |
| 14151 | { |
| 14152 | if (__make<__operator_right_shift_equal>(op1, __root_)) |
| 14153 | { |
| 14154 | *type = 2; |
| 14155 | first = t2; |
| 14156 | } |
| 14157 | } |
| 14158 | } |
| 14159 | } |
| 14160 | else |
| 14161 | { |
| 14162 | if (__make<__operator_right_shift_equal>()) |
| 14163 | first += 2; |
| 14164 | } |
| 14165 | break; |
| 14166 | } |
| 14167 | break; |
| 14168 | case 's': |
| 14169 | switch (first[1]) |
| 14170 | { |
| 14171 | case 't': |
| 14172 | // sizeof (a type) |
| 14173 | if (type) |
| 14174 | { |
| 14175 | const char* t = __parse_expression(first+2, last); |
| 14176 | if (t != first+2) |
| 14177 | { |
| 14178 | if (__make<__operator_sizeof_type>(__root_)) |
| 14179 | { |
| 14180 | *type = -1; |
| 14181 | first = t; |
| 14182 | } |
| 14183 | } |
| 14184 | } |
| 14185 | else |
| 14186 | { |
| 14187 | if (__make<__operator_sizeof_type>()) |
| 14188 | first += 2; |
| 14189 | } |
| 14190 | break; |
| 14191 | case 'z': |
| 14192 | // sizeof (an expression) |
| 14193 | if (type) |
| 14194 | { |
| 14195 | const char* t = __parse_expression(first+2, last); |
| 14196 | if (t != first+2) |
| 14197 | { |
| 14198 | if (__make<__operator_sizeof_expression>(__root_)) |
| 14199 | { |
| 14200 | *type = -1; |
| 14201 | first = t; |
| 14202 | } |
| 14203 | } |
| 14204 | } |
| 14205 | else |
| 14206 | { |
| 14207 | if (__make<__operator_sizeof_expression>()) |
| 14208 | first += 2; |
| 14209 | } |
| 14210 | break; |
| 14211 | } |
| 14212 | break; |
| 14213 | } |
| 14214 | } |
| 14215 | return first; |
| 14216 | } |
| 14217 | |
| 14218 | // <source-name> ::= <positive length number> <identifier> |
| 14219 | |
| 14220 | const char* |
| 14221 | __demangle_tree::__parse_source_name(const char* first, const char* last) |
| 14222 | { |
| 14223 | if (first != last) |
| 14224 | { |
| 14225 | char c = *first; |
| 14226 | if ('1' <= c && c <= '9' && first+1 != last) |
| 14227 | { |
| 14228 | const char* t = first+1; |
| 14229 | size_t n = c - '0'; |
| 14230 | for (c = *t; '0' <= c && c <= '9'; c = *t) |
| 14231 | { |
| 14232 | n = n * 10 + c - '0'; |
| 14233 | if (++t == last) |
| 14234 | return first; |
| 14235 | } |
| 14236 | if (last - t >= n && __make<__source_name>(t, n)) |
| 14237 | first = t + n; |
| 14238 | } |
| 14239 | } |
| 14240 | return first; |
| 14241 | } |
| 14242 | |
| 14243 | // <unqualified-name> ::= <operator-name> |
| 14244 | // ::= <ctor-dtor-name> |
| 14245 | // ::= <source-name> |
| 14246 | // ::= <unnamed-type-name> |
| 14247 | |
| 14248 | const char* |
| 14249 | __demangle_tree::__parse_unqualified_name(const char* first, const char* last) |
| 14250 | { |
| 14251 | const char* t = __parse_source_name(first, last); |
| 14252 | if (t == first) |
| 14253 | { |
| 14254 | t = __parse_ctor_dtor_name(first, last); |
| 14255 | if (t == first) |
| 14256 | { |
| 14257 | t = __parse_operator_name(first, last); |
| 14258 | if (t == first) |
| 14259 | first = __parse_unnamed_type_name(first, last); |
| 14260 | else |
| 14261 | first = t; |
| 14262 | } |
| 14263 | else |
| 14264 | first = t; |
| 14265 | } |
| 14266 | else |
| 14267 | first = t; |
| 14268 | return first; |
| 14269 | } |
| 14270 | |
| 14271 | // <unscoped-name> ::= <unqualified-name> |
| 14272 | // ::= St <unqualified-name> # ::std:: |
| 14273 | // extension ::= StL<unqualified-name> |
| 14274 | |
| 14275 | const char* |
| 14276 | __demangle_tree::__parse_unscoped_name(const char* first, const char* last) |
| 14277 | { |
| 14278 | if (last - first >= 2) |
| 14279 | { |
| 14280 | const char* t0 = first; |
| 14281 | if (first[0] == 'S' && first[1] == 't') |
| 14282 | { |
| 14283 | t0 += 2; |
| 14284 | if (t0 != last && *t0 == 'L') |
| 14285 | ++t0; |
| 14286 | } |
| 14287 | const char* t1 = __parse_unqualified_name(t0, last); |
| 14288 | if (t1 != t0) |
| 14289 | { |
| 14290 | if (t0 != first) |
| 14291 | { |
| 14292 | __node* name = __root_; |
| 14293 | if (__make<__std_qualified_name>()) |
| 14294 | { |
| 14295 | if (__make<__nested_delimeter>(__root_, name)) |
| 14296 | first = t1; |
| 14297 | } |
| 14298 | } |
| 14299 | else |
| 14300 | first = t1; |
| 14301 | } |
| 14302 | } |
| 14303 | return first; |
| 14304 | } |
| 14305 | |
| 14306 | // <nested-name> ::= N [<CV-qualifiers>] <prefix> <unqualified-name> E |
| 14307 | // ::= N [<CV-qualifiers>] <template-prefix> <template-args> E |
| 14308 | // |
| 14309 | // <prefix> ::= <prefix> <unqualified-name> |
| 14310 | // ::= <template-prefix> <template-args> |
| 14311 | // ::= <template-param> |
| 14312 | // ::= <decltype> |
| 14313 | // ::= # empty |
| 14314 | // ::= <substitution> |
| 14315 | // ::= <prefix> <data-member-prefix> |
| 14316 | // extension ::= L |
| 14317 | // |
| 14318 | // <template-prefix> ::= <prefix> <template unqualified-name> |
| 14319 | // ::= <template-param> |
| 14320 | // ::= <substitution> |
| 14321 | |
| 14322 | const char* |
| 14323 | __demangle_tree::__parse_nested_name(const char* first, const char* last) |
| 14324 | { |
| 14325 | if (first != last && *first == 'N') |
| 14326 | { |
| 14327 | unsigned cv = 0; |
| 14328 | const char* t0 = __parse_cv_qualifiers(first+1, last, cv, true); |
| 14329 | __node* prev = NULL; |
| 14330 | if (last - t0 >= 2 && t0[0] == 'S' && t0[1] == 't') |
| 14331 | { |
| 14332 | t0 += 2; |
| 14333 | if (!__make<__std_qualified_name>()) |
| 14334 | return first; |
| 14335 | prev = __root_; |
| 14336 | } |
| 14337 | while (t0 != last) |
| 14338 | { |
| 14339 | bool can_sub = true; |
| 14340 | bool make_nested = true; |
| 14341 | const char* t1; |
| 14342 | switch (*t0) |
| 14343 | { |
| 14344 | case '1': |
| 14345 | case '2': |
| 14346 | case '3': |
| 14347 | case '4': |
| 14348 | case '5': |
| 14349 | case '6': |
| 14350 | case '7': |
| 14351 | case '8': |
| 14352 | case '9': |
| 14353 | t1 = __parse_source_name(t0, last); |
| 14354 | if (t1 == t0 || t1 == last) |
| 14355 | return first; |
| 14356 | if (*t1 == 'M') |
| 14357 | { |
| 14358 | // This is a data-member-prefix |
| 14359 | ++t1; |
| 14360 | } |
| 14361 | else if (*t1 == 'I') |
| 14362 | { |
| 14363 | // has following <template-args> |
| 14364 | if (prev) |
| 14365 | { |
| 14366 | if (!__make<__nested_delimeter>(prev, __root_)) |
| 14367 | return first; |
| 14368 | make_nested = false; |
| 14369 | } |
| 14370 | if (__sub_end_ == __sub_cap_) |
| 14371 | { |
| 14372 | __status_ = memory_alloc_failure; |
| 14373 | return first; |
| 14374 | } |
| 14375 | else |
| 14376 | *__sub_end_++ = __root_; |
| 14377 | const char* t2 = __parse_template_args(t1, last); |
| 14378 | if (t2 == t1) |
| 14379 | return first; |
| 14380 | t1 = t2; |
| 14381 | } |
| 14382 | break; |
| 14383 | case 'D': |
| 14384 | if (t0+1 != last && (t0[1] == 't' || t0[1] == 'T')) |
| 14385 | { |
| 14386 | t1 = __parse_decltype(t0, last); |
| 14387 | break; |
| 14388 | } |
| 14389 | // check for Dt, DT here, else drop through |
| 14390 | case 'C': |
| 14391 | t1 = __parse_ctor_dtor_name(t0, last); |
| 14392 | if (t1 == t0 || t1 == last) |
| 14393 | return first; |
| 14394 | if (*t1 == 'I') |
| 14395 | { |
| 14396 | // has following <template-args> |
| 14397 | if (prev) |
| 14398 | { |
| 14399 | if (!__make<__nested_delimeter>(prev, __root_)) |
| 14400 | return first; |
| 14401 | make_nested = false; |
| 14402 | } |
| 14403 | if (__sub_end_ == __sub_cap_) |
| 14404 | { |
| 14405 | __status_ = memory_alloc_failure; |
| 14406 | return first; |
| 14407 | } |
| 14408 | else |
| 14409 | *__sub_end_++ = __root_; |
| 14410 | const char* t2 = __parse_template_args(t1, last); |
| 14411 | if (t2 == t1) |
| 14412 | return first; |
| 14413 | t1 = t2; |
| 14414 | } |
| 14415 | break; |
| 14416 | case 'U': |
| 14417 | assert(!"__parse_nested_name U"); |
| 14418 | // could have following <template-args> |
| 14419 | break; |
| 14420 | case 'T': |
| 14421 | t1 = __parse_template_param(t0, last); |
| 14422 | if (t1 == t0 || t1 == last) |
| 14423 | return first; |
| 14424 | if (*t1 == 'I') |
| 14425 | { |
| 14426 | // has following <template-args> |
| 14427 | if (prev) |
| 14428 | { |
| 14429 | if (!__make<__nested_delimeter>(prev, __root_)) |
| 14430 | return first; |
| 14431 | make_nested = false; |
| 14432 | } |
| 14433 | if (__sub_end_ == __sub_cap_) |
| 14434 | { |
| 14435 | __status_ = memory_alloc_failure; |
| 14436 | return first; |
| 14437 | } |
| 14438 | else |
| 14439 | *__sub_end_++ = __root_; |
| 14440 | const char* t2 = __parse_template_args(t1, last); |
| 14441 | if (t2 == t1) |
| 14442 | return first; |
| 14443 | t1 = t2; |
| 14444 | } |
| 14445 | break; |
| 14446 | case 'S': |
| 14447 | t1 = __parse_substitution(t0, last); |
| 14448 | if (t1 == t0 || t1 == last) |
| 14449 | return first; |
| 14450 | if (*t1 == 'I') |
| 14451 | { |
| 14452 | const char* t2 = __parse_template_args(t1, last); |
| 14453 | if (t2 == t1) |
| 14454 | return first; |
| 14455 | t1 = t2; |
| 14456 | } |
| 14457 | else |
| 14458 | can_sub = false; |
| 14459 | break; |
| 14460 | case 'L': |
| 14461 | // extension: ignore L here |
| 14462 | ++t0; |
| 14463 | continue; |
| 14464 | default: |
| 14465 | t1 = __parse_operator_name(t0, last); |
| 14466 | if (t1 == t0 || t1 == last) |
| 14467 | return first; |
| 14468 | if (*t1 == 'I') |
| 14469 | { |
| 14470 | // has following <template-args> |
| 14471 | if (prev) |
| 14472 | { |
| 14473 | if (!__make<__nested_delimeter>(prev, __root_)) |
| 14474 | return first; |
| 14475 | make_nested = false; |
| 14476 | } |
| 14477 | if (__sub_end_ == __sub_cap_) |
| 14478 | { |
| 14479 | __status_ = memory_alloc_failure; |
| 14480 | return first; |
| 14481 | } |
| 14482 | else |
| 14483 | *__sub_end_++ = __root_; |
| 14484 | const char* t2 = __parse_template_args(t1, last); |
| 14485 | if (t2 == t1) |
| 14486 | return first; |
| 14487 | t1 = t2; |
| 14488 | } |
| 14489 | break; |
| 14490 | } |
| 14491 | if (t1 == t0 || t1 == last) |
| 14492 | return first; |
| 14493 | if (prev && make_nested) |
| 14494 | { |
| 14495 | if (!__make<__nested_delimeter>(prev, __root_)) |
| 14496 | return first; |
| 14497 | can_sub = true; |
| 14498 | } |
| 14499 | if (can_sub && *t1 != 'E') |
| 14500 | { |
| 14501 | if (__sub_end_ == __sub_cap_) |
| 14502 | { |
| 14503 | __status_ = memory_alloc_failure; |
| 14504 | return first; |
| 14505 | } |
| 14506 | else |
| 14507 | *__sub_end_++ = __root_; |
| 14508 | } |
| 14509 | if (*t1 == 'E') |
| 14510 | { |
| 14511 | if (cv != 0) |
| 14512 | { |
| 14513 | if (!__make<__cv_qualifiers>(cv, __root_)) |
| 14514 | return first; |
| 14515 | } |
| 14516 | first = t1+1; |
| 14517 | break; |
| 14518 | } |
| 14519 | prev = __root_; |
| 14520 | t0 = t1; |
| 14521 | } |
| 14522 | } |
| 14523 | return first; |
| 14524 | } |
| 14525 | |
| 14526 | // <template-arg> ::= <type> # type or template |
| 14527 | // ::= X <expression> E # expression |
| 14528 | // ::= <expr-primary> # simple expressions |
| 14529 | // ::= J <template-arg>* E # argument pack |
| 14530 | // ::= LZ <encoding> E # extension |
| 14531 | |
| 14532 | const char* |
| 14533 | __demangle_tree::__parse_template_arg(const char* first, const char* last) |
| 14534 | { |
| 14535 | if (first != last) |
| 14536 | { |
| 14537 | const char* t; |
| 14538 | switch (*first) |
| 14539 | { |
| 14540 | case 'X': |
| 14541 | t = __parse_expression(first+1, last); |
| 14542 | if (t != first+1) |
| 14543 | { |
| 14544 | if (t != last && *t == 'E') |
| 14545 | first = t+1; |
| 14546 | } |
| 14547 | break; |
| 14548 | case 'J': |
| 14549 | t = first+1; |
| 14550 | if (t == last) |
| 14551 | return first; |
| 14552 | if (*t == 'E') |
| 14553 | { |
| 14554 | if (__make<__list>((__node*)0)) |
| 14555 | first = t+1; |
| 14556 | } |
| 14557 | else |
| 14558 | { |
| 14559 | __node* list = NULL; |
| 14560 | __node* prev = NULL; |
| 14561 | do |
| 14562 | { |
| 14563 | const char* t2 = __parse_template_arg(t, last); |
| 14564 | if (t2 == t || !__make<__list>(__root_)) |
| 14565 | return first; |
| 14566 | if (list == 0) |
| 14567 | list = __root_; |
| 14568 | if (prev) |
| 14569 | { |
| 14570 | prev->__right_ = __root_; |
| 14571 | __root_->__size_ = prev->__size_ + 1; |
| 14572 | } |
| 14573 | prev = __root_; |
| 14574 | t = t2; |
| 14575 | } while (t != last && *t != 'E'); |
| 14576 | first = t+1; |
| 14577 | __root_ = list; |
| 14578 | } |
| 14579 | break; |
| 14580 | case 'L': |
| 14581 | // <expr-primary> or LZ <encoding> E |
| 14582 | if (first+1 != last && first[1] == 'Z') |
| 14583 | { |
| 14584 | t = __parse_encoding(first+2, last); |
| 14585 | if (t != first+2 && t != last && *t == 'E') |
| 14586 | first = t+1; |
| 14587 | } |
| 14588 | else |
| 14589 | first = __parse_expr_primary(first, last); |
| 14590 | break; |
| 14591 | default: |
| 14592 | // <type> |
| 14593 | first = __parse_type(first, last); |
| 14594 | break; |
| 14595 | } |
| 14596 | } |
| 14597 | return first; |
| 14598 | } |
| 14599 | |
| 14600 | // <template-args> ::= I <template-arg>* E |
| 14601 | // extension, the abi says <template-arg>+ |
| 14602 | |
| 14603 | const char* |
| 14604 | __demangle_tree::__parse_template_args(const char* first, const char* last) |
| 14605 | { |
| 14606 | if (last - first >= 2 && *first == 'I') |
| 14607 | { |
| 14608 | __node* args = NULL; |
| 14609 | __node* prev = NULL; |
| 14610 | __node* name = __root_; |
| 14611 | bool prev_tag_templates = __tag_templates_; |
| 14612 | __tag_templates_ = false; |
| 14613 | if (prev_tag_templates) |
| 14614 | __t_end_ = __t_begin_; |
| 14615 | const char* t = first+1; |
| 14616 | while (*t != 'E') |
| 14617 | { |
| 14618 | const char* t2 = __parse_template_arg(t, last); |
| 14619 | if (t2 == t || t2 == last) |
| 14620 | break; |
| 14621 | if (!__make<__list>(__root_)) |
| 14622 | return first; |
| 14623 | if (args == 0) |
| 14624 | args = __root_; |
| 14625 | if (prev) |
| 14626 | { |
| 14627 | prev->__right_ = __root_; |
| 14628 | __root_->__size_ = prev->__size_ + 1; |
| 14629 | } |
| 14630 | prev = __root_; |
| 14631 | if (prev_tag_templates) |
| 14632 | { |
| 14633 | if (__t_end_ == __t_cap_) |
| 14634 | { |
| 14635 | __status_ = memory_alloc_failure; |
| 14636 | return first; |
| 14637 | } |
| 14638 | if (__root_->__left_) |
| 14639 | *__t_end_++ = __root_->__left_; |
| 14640 | else |
| 14641 | *__t_end_++ = __root_; |
| 14642 | } |
| 14643 | t = t2; |
| 14644 | } |
| 14645 | if (t != last && *t == 'E') |
| 14646 | { |
| 14647 | if (__make<__template_args>(name, args)) |
| 14648 | first = t+1; |
| 14649 | } |
| 14650 | __tag_templates_ = prev_tag_templates; |
| 14651 | } |
| 14652 | return first; |
| 14653 | } |
| 14654 | |
| 14655 | // <substitution> ::= S <seq-id> _ |
| 14656 | // ::= S_ |
| 14657 | // <substitution> ::= Sa # ::std::allocator |
| 14658 | // <substitution> ::= Sb # ::std::basic_string |
| 14659 | // <substitution> ::= Ss # ::std::basic_string < char, |
| 14660 | // ::std::char_traits<char>, |
| 14661 | // ::std::allocator<char> > |
| 14662 | // <substitution> ::= Si # ::std::basic_istream<char, std::char_traits<char> > |
| 14663 | // <substitution> ::= So # ::std::basic_ostream<char, std::char_traits<char> > |
| 14664 | // <substitution> ::= Sd # ::std::basic_iostream<char, std::char_traits<char> > |
| 14665 | |
| 14666 | const char* |
| 14667 | __demangle_tree::__parse_substitution(const char* first, const char* last) |
| 14668 | { |
| 14669 | if (last - first >= 2) |
| 14670 | { |
| 14671 | if (*first == 'S') |
| 14672 | { |
| 14673 | switch (first[1]) |
| 14674 | { |
| 14675 | case 'a': |
| 14676 | if (__make<__sub_allocator>()) |
| 14677 | first += 2; |
| 14678 | break; |
| 14679 | case 'b': |
| 14680 | if (__make<__sub_basic_string>()) |
| 14681 | first += 2; |
| 14682 | break; |
| 14683 | case 's': |
| 14684 | if (__make<__sub_string>()) |
| 14685 | first += 2; |
| 14686 | break; |
| 14687 | case 'i': |
| 14688 | if (__make<__sub_istream>()) |
| 14689 | first += 2; |
| 14690 | break; |
| 14691 | case 'o': |
| 14692 | if (__make<__sub_ostream>()) |
| 14693 | first += 2; |
| 14694 | break; |
| 14695 | case 'd': |
| 14696 | if (__make<__sub_iostream>()) |
| 14697 | first += 2; |
| 14698 | break; |
| 14699 | case '_': |
| 14700 | if (__sub_begin_ != __sub_end_) |
| 14701 | { |
| 14702 | if (__make<__sub>(*__sub_begin_)) |
| 14703 | first += 2; |
| 14704 | } |
| 14705 | break; |
| 14706 | default: |
| 14707 | if (isdigit(first[1]) || isupper(first[1])) |
| 14708 | { |
| 14709 | size_t sub = 0; |
| 14710 | const char* t = first+1; |
| 14711 | if (isdigit(*t)) |
| 14712 | sub = *t - '0'; |
| 14713 | else |
| 14714 | sub = *t - 'A' + 10; |
| 14715 | for (++t; t != last && (isdigit(*t) || isupper(*t)); ++t) |
| 14716 | { |
| 14717 | sub *= 36; |
| 14718 | if (isdigit(*t)) |
| 14719 | sub += *t - '0'; |
| 14720 | else |
| 14721 | sub += *t - 'A' + 10; |
| 14722 | } |
| 14723 | if (t == last || *t != '_') |
| 14724 | return first; |
| 14725 | ++sub; |
| 14726 | if (sub < __sub_end_ - __sub_begin_) |
| 14727 | { |
| 14728 | if (__make<__sub>(__sub_begin_[sub])) |
| 14729 | first = t+1; |
| 14730 | } |
| 14731 | } |
| 14732 | break; |
| 14733 | } |
| 14734 | } |
| 14735 | } |
| 14736 | return first; |
| 14737 | } |
| 14738 | |
| 14739 | // <name> ::= <nested-name> |
| 14740 | // ::= <local-name> # See Scope Encoding below |
| 14741 | // ::= <unscoped-template-name> <template-args> |
| 14742 | // ::= <unscoped-name> |
| 14743 | |
| 14744 | const char* |
| 14745 | __demangle_tree::__parse_name(const char* first, const char* last) |
| 14746 | { |
| 14747 | if (first != last) |
| 14748 | { |
| 14749 | const char* t0 = first; |
| 14750 | // extension: ignore L here |
| 14751 | if (*t0 == 'L') |
| 14752 | ++t0; |
| 14753 | const char* t = __parse_nested_name(t0, last); |
| 14754 | if (t == t0) |
| 14755 | { |
| 14756 | t = __parse_local_name(t0, last); |
| 14757 | if (t == t0) |
| 14758 | { |
| 14759 | // not <nested-name> nor <local-name> |
| 14760 | // Try to parse <unscoped-template-name> <template-args> or |
| 14761 | // <unscoped-name> which are nearly ambiguous. |
| 14762 | // This logic occurs nowhere else. |
| 14763 | if (last - t0 >= 2) |
| 14764 | { |
| 14765 | if (t0[0] == 'S' && (t0[1] == '_' || |
| 14766 | isdigit(t0[1]) || |
| 14767 | isupper(t0[1]) || |
| 14768 | t0[1] == 'a' || |
| 14769 | t0[1] == 'b')) |
| 14770 | { |
| 14771 | t = __parse_substitution(t0, last); |
| 14772 | if (t != t0) |
| 14773 | { |
| 14774 | const char* t2 = __parse_template_args(t, last); |
| 14775 | if (t2 != t) |
| 14776 | first = t2; |
| 14777 | } |
| 14778 | } |
| 14779 | else // Not a substitution, except maybe St |
| 14780 | { |
| 14781 | t = __parse_unscoped_name(t0, last); |
| 14782 | if (t != t0) |
| 14783 | { |
| 14784 | // unscoped-name might be <unscoped-template-name> |
| 14785 | if (t != last && *t == 'I') |
| 14786 | { |
| 14787 | if (__sub_end_ == __sub_cap_) |
| 14788 | { |
| 14789 | __status_ = memory_alloc_failure; |
| 14790 | return first; |
| 14791 | } |
| 14792 | *__sub_end_++ = __root_; |
| 14793 | const char* t2 = __parse_template_args(t, last); |
| 14794 | if (t2 != t) |
| 14795 | first = t2; |
| 14796 | } |
| 14797 | else |
| 14798 | { |
| 14799 | // <unscoped-name> |
| 14800 | first = t; |
| 14801 | } |
| 14802 | } |
| 14803 | } |
| 14804 | } |
| 14805 | } |
| 14806 | else |
| 14807 | first = t; |
| 14808 | } |
| 14809 | else |
| 14810 | first = t; |
| 14811 | } |
| 14812 | return first; |
| 14813 | } |
| 14814 | |
| 14815 | // extension |
| 14816 | // <dot-suffix> := .<anything and everything> |
| 14817 | |
| 14818 | const char* |
| 14819 | __demangle_tree::__parse_dot_suffix(const char* first, const char* last) |
| 14820 | { |
| 14821 | if (first != last && *first == '.') |
| 14822 | { |
| 14823 | if (__make<__dot_suffix>(__root_, first, last-first)) |
| 14824 | first = last; |
| 14825 | } |
| 14826 | return first; |
| 14827 | } |
| 14828 | |
| 14829 | // <encoding> ::= <function name> <bare-function-type> |
| 14830 | // ::= <data name> |
| 14831 | // ::= <special-name> |
| 14832 | |
| 14833 | const char* |
| 14834 | __demangle_tree::__parse_encoding(const char* first, const char* last) |
| 14835 | { |
| 14836 | const char* t = __parse_name(first, last); |
| 14837 | if (t != first) |
| 14838 | { |
Howard Hinnant | 6f716a0 | 2011-06-22 19:27:39 +0000 | [diff] [blame] | 14839 | if (t != last && *t != 'E' && *t != '.') |
Howard Hinnant | 4fbf16a | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 14840 | { |
| 14841 | __node* name = __root_; |
| 14842 | bool has_return = name->ends_with_template() && |
| 14843 | !name->is_ctor_dtor_conv(); |
| 14844 | __node* ret = NULL; |
| 14845 | const char* t2; |
| 14846 | __tag_templates_ = false; |
| 14847 | if (has_return) |
| 14848 | { |
| 14849 | t2 = __parse_type(t, last); |
| 14850 | if (t2 != t) |
| 14851 | { |
| 14852 | ret = __root_; |
| 14853 | t = t2; |
| 14854 | } |
| 14855 | else |
| 14856 | return first; |
| 14857 | } |
| 14858 | t2 = __parse_bare_function_type(t, last); |
| 14859 | if (t2 != t) |
| 14860 | { |
| 14861 | if (dynamic_cast<__void*>(__root_->__left_) != NULL) |
| 14862 | __root_->__left_ = NULL; |
| 14863 | if (__make<__function_signature>(ret, __root_)) |
| 14864 | { |
| 14865 | __node* cv = name->extract_cv(name); |
| 14866 | if (__make<__function>(name, __root_)) |
| 14867 | { |
| 14868 | if (cv) |
| 14869 | { |
| 14870 | cv->__left_ = __root_; |
| 14871 | cv->__size_ <<= 5; |
| 14872 | __root_ = cv; |
| 14873 | } |
| 14874 | first = t2; |
| 14875 | } |
| 14876 | } |
| 14877 | } |
| 14878 | __tag_templates_ = true; |
| 14879 | } |
| 14880 | else |
| 14881 | first = t; |
| 14882 | } |
| 14883 | else |
| 14884 | first = __parse_special_name(first, last); |
| 14885 | return first; |
| 14886 | } |
| 14887 | |
| 14888 | // <mangled-name> ::= _Z<encoding> |
| 14889 | // ::= <type> |
| 14890 | |
| 14891 | void |
| 14892 | __demangle_tree::__parse() |
| 14893 | { |
| 14894 | if (__mangled_name_begin_ == __mangled_name_end_) |
| 14895 | { |
| 14896 | __status_ = invalid_mangled_name; |
| 14897 | return; |
| 14898 | } |
| 14899 | const char* t = NULL; |
| 14900 | if (__mangled_name_end_ - __mangled_name_begin_ >= 2 && |
| 14901 | __mangled_name_begin_[0] == '_' && |
| 14902 | __mangled_name_begin_[1] == 'Z') |
| 14903 | { |
| 14904 | t = __parse_encoding(__mangled_name_begin_+2, __mangled_name_end_); |
| 14905 | if (t != __mangled_name_begin_+2 && t != __mangled_name_end_ && *t == '.') |
| 14906 | t = __parse_dot_suffix(t, __mangled_name_end_); |
| 14907 | } |
| 14908 | else |
| 14909 | t = __parse_type(__mangled_name_begin_, __mangled_name_end_); |
| 14910 | if (t == __mangled_name_end_ && __root_) |
| 14911 | { |
| 14912 | if (__fix_forward_references_) |
| 14913 | { |
| 14914 | if (__root_->fix_forward_references(__t_begin_, __t_end_)) |
| 14915 | __status_ = success; |
| 14916 | } |
| 14917 | else |
| 14918 | __status_ = success; |
| 14919 | } |
| 14920 | } |
| 14921 | |
| 14922 | #pragma GCC visibility pop |
| 14923 | #pragma GCC visibility push(default) |
| 14924 | |
| 14925 | __demangle_tree |
| 14926 | __demangle(const char* mangled_name, char* buf, size_t bs) |
| 14927 | { |
| 14928 | __demangle_tree t(mangled_name, buf, bs); |
| 14929 | if (t.__status() == invalid_mangled_name) |
| 14930 | t.__parse(); |
| 14931 | return t; |
| 14932 | } |
| 14933 | |
| 14934 | __demangle_tree |
| 14935 | __demangle(const char* mangled_name) |
| 14936 | { |
| 14937 | return __demangle(mangled_name, 0, 0); |
| 14938 | } |
| 14939 | |
| 14940 | char* |
| 14941 | __demangle(__demangle_tree dmg_tree, char* buf, size_t* n, int* status) |
| 14942 | { |
| 14943 | if (dmg_tree.__status() != success) |
| 14944 | { |
| 14945 | if (status) |
| 14946 | *status = dmg_tree.__status(); |
| 14947 | return NULL; |
| 14948 | } |
| 14949 | #ifdef DEBUGGING |
| 14950 | display(dmg_tree.__root_); |
| 14951 | printf("\n"); |
| 14952 | #endif |
| 14953 | const size_t bs = buf == NULL ? 0 : *n; |
Howard Hinnant | 4fbf16a | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 14954 | ptrdiff_t sm = dmg_tree.__mangled_name_end_ - dmg_tree.__mangled_name_begin_; |
| 14955 | ptrdiff_t est = sm + 50 * (dmg_tree.__node_end_ - dmg_tree.__node_begin_); |
| 14956 | const unsigned N = 4096; |
| 14957 | char tmp[N]; |
| 14958 | ptrdiff_t s; |
| 14959 | if (est <= bs) |
| 14960 | { |
| 14961 | char* e = dmg_tree.__get_demangled_name(buf); |
| 14962 | *e++ = '\0'; |
| 14963 | s = e - buf; |
| 14964 | } |
| 14965 | else if (est <= N) |
| 14966 | { |
| 14967 | char* e = dmg_tree.__get_demangled_name(tmp); |
| 14968 | *e++ = '\0'; |
| 14969 | s = e - tmp; |
| 14970 | } |
| 14971 | else |
| 14972 | s = dmg_tree.size() + 1; |
| 14973 | if (s > bs) |
| 14974 | { |
| 14975 | buf = static_cast<char*>(realloc(buf, s)); |
| 14976 | if (buf == NULL) |
| 14977 | { |
| 14978 | if (status) |
| 14979 | *status = memory_alloc_failure; |
| 14980 | return NULL; |
| 14981 | } |
| 14982 | if (n) |
| 14983 | *n = s; |
| 14984 | } |
| 14985 | if (est > bs) |
| 14986 | { |
| 14987 | if (est <= N) |
| 14988 | strncpy(buf, tmp, s); |
| 14989 | else |
| 14990 | *dmg_tree.__get_demangled_name(buf) = '\0'; |
| 14991 | } |
Howard Hinnant | 4fbf16a | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 14992 | if (status) |
| 14993 | *status = success; |
| 14994 | return buf; |
| 14995 | } |
| 14996 | |
| 14997 | } // __libcxxabi |
| 14998 | |
| 14999 | extern "C" |
| 15000 | { |
| 15001 | |
| 15002 | char* |
| 15003 | __cxa_demangle(const char* mangled_name, char* buf, size_t* n, int* status) |
| 15004 | { |
| 15005 | if (mangled_name == NULL || (buf != NULL && n == NULL)) |
| 15006 | { |
| 15007 | if (status) |
| 15008 | *status = __libcxxabi::invalid_args; |
| 15009 | return NULL; |
| 15010 | } |
| 15011 | const size_t bs = 64 * 1024; |
Howard Hinnant | 828959c | 2011-11-28 21:03:21 +0000 | [diff] [blame^] | 15012 | __attribute((aligned(16))) char static_buf[bs]; |
Howard Hinnant | 4fbf16a | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 15013 | |
| 15014 | buf = __libcxxabi::__demangle(__libcxxabi::__demangle(mangled_name, |
| 15015 | static_buf, bs), |
| 15016 | buf, n, status); |
| 15017 | return buf; |
| 15018 | } |
| 15019 | |
| 15020 | } // extern "C" |
| 15021 | |
| 15022 | } // abi |