1 #ifndef HALIDE_INTROSPECTION_H
2 #define HALIDE_INTROSPECTION_H
18 namespace Introspection {
39 #define HALIDE_DUMP_STACK_FRAME \
41 static bool check = Halide::Internal::Introspection::dump_stack_frame(); \
51 static T *introspection_helper =
nullptr;
52 return &introspection_helper;
63 bool (*test_a)(
const void *,
const std::string &),
74 #ifndef COMPILING_HALIDE
78 static bool check_introspection(
const void *var,
const std::string &type,
79 const std::string &correct_name,
80 const std::string &correct_file,
int line) {
81 std::string correct_loc = correct_file +
":" + std::to_string(line);
84 return name == correct_name && loc == correct_loc;
95 static void offset_marker() {
96 std::cerr <<
"You should not have called this function\n";
103 int private_member = 17;
109 a_float = private_member * 2.0f;
119 bool test(
const std::string &my_name);
122 static bool test_a(
const void *a_ptr,
const std::string &my_name) {
123 const A *a = (
const A *)a_ptr;
125 success &= Halide::Internal::check_introspection(&a->an_int,
"int", my_name +
".an_int", __FILE__, __LINE__);
126 success &= Halide::Internal::check_introspection(&a->a_b,
"HalideIntrospectionCanary::A::B", my_name +
".a_b", __FILE__, __LINE__);
127 success &= Halide::Internal::check_introspection(&a->a_b.parent,
"HalideIntrospectionCanary::A \\*", my_name +
".a_b.parent", __FILE__, __LINE__);
128 success &= Halide::Internal::check_introspection(&a->a_b.a_float,
"float", my_name +
".a_b.a_float", __FILE__, __LINE__);
129 success &= Halide::Internal::check_introspection(a->a_b.parent,
"HalideIntrospectionCanary::A", my_name, __FILE__, __LINE__);
133 static bool test(
bool (*f)(
const void *,
const std::string &)) {
137 return f(&a1,
"a1") && f(&a2,
"a2");
142 struct TestCompilationUnit {
143 TestCompilationUnit() {
149 static TestCompilationUnit test_object;