1
0

torture.cpp 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /// Torture fixture for the C++ kernel walker (R7a) — namespaces (incl. C++17
  2. /// nested + anonymous), out-of-line Cls::method defs, templates + template
  3. /// bases, operator definitions, stack construction, local fn-ptrs, UE-macro
  4. /// shapes THROUGH the hoisted preParse, using-aliases, access specifiers,
  5. /// static-member value reads, and the cpp call shapes. Must parse ERROR-FREE
  6. /// post-preParse or the kernel arm defers (spaced operator CALL SITES live in
  7. /// torture-defer.cpp — they produce ERROR nodes by design).
  8. #include <vector>
  9. #include "widget_base.hpp"
  10. namespace app {
  11. /** Engine config (docstring). */
  12. class Config {
  13. public:
  14. int retries;
  15. void apply();
  16. int helper_count() const { return 2; }
  17. private:
  18. int secret;
  19. };
  20. void Config::apply() { retries = helper_count(); }
  21. namespace detail {
  22. struct Counter {
  23. int value;
  24. Counter *next;
  25. };
  26. } // namespace detail
  27. int detail_probe() { return 1; }
  28. } // namespace app
  29. namespace app::net {
  30. class Session {
  31. public:
  32. void open();
  33. virtual ~Session() {}
  34. };
  35. void Session::open() {}
  36. } // namespace app::net
  37. namespace {
  38. int hidden_helper() { return 3; }
  39. } // namespace
  40. template <typename T>
  41. class Base {
  42. public:
  43. T item;
  44. };
  45. template <typename T>
  46. class Box : public Base<T> {
  47. public:
  48. T get() const { return value_; }
  49. T unwrap();
  50. private:
  51. T value_;
  52. };
  53. template <typename T>
  54. T Box<T>::unwrap() {
  55. return value_;
  56. }
  57. class Derived : public Base<int>, private app::Config {
  58. public:
  59. Derived() : total_(0) {}
  60. int total() const { return total_; }
  61. private:
  62. int total_;
  63. };
  64. struct Vec2 {
  65. float x, y;
  66. Vec2 operator+(const Vec2 &o) const { return {x + o.x, y + o.y}; }
  67. explicit operator bool() const { return x != 0 || y != 0; }
  68. Vec2 origin();
  69. };
  70. enum class Mode : unsigned char { Off, On };
  71. enum Legacy { LEGACY_A, LEGACY_B };
  72. typedef struct {
  73. int id;
  74. } packet_t;
  75. using Handle = app::Config;
  76. // UE-macro shapes — every one below is recovered by the hoisted preParse
  77. // (export macro, reflection markup, inline specifier, API member prefix).
  78. class MYMODULE_API Widget : public app::Config {
  79. public:
  80. UPROPERTY(EditAnywhere, Category = "State")
  81. float Health;
  82. FORCEINLINE float GetHealth() const { return Health; }
  83. ENGINE_API virtual void Tick(float Delta);
  84. };
  85. void Widget::Tick(float Delta) { Health += Delta; }
  86. Config GlobalConfig;
  87. int build_number = 7;
  88. template <typename T>
  89. T compute_seed(T v) {
  90. return v + 1;
  91. }
  92. float drive_helper(float v) { return v; }
  93. Widget *make_widget() { return new Widget(); }
  94. float drive() {
  95. Widget local;
  96. app::Config cfg;
  97. Vec2 a{1, 2};
  98. Vec2 b(a);
  99. Vec2 c2(1.5f, 2.5f);
  100. float f = a.x + b.y + c2.x;
  101. make_widget()->Tick(0.5f);
  102. auto kernel = &compute_seed<float>;
  103. if (f > 1) {
  104. kernel = &drive_helper;
  105. }
  106. float r = kernel(f);
  107. int flags = GlobalConfig.retries;
  108. Mode m = Mode::Off;
  109. int leg = LEGACY_A;
  110. app::detail_probe();
  111. compute_seed<int>(2);
  112. auto mp = &app::Config::apply;
  113. (void)mp;
  114. (void)m;
  115. return r + f + flags + leg;
  116. }