#include "../../slang.h" #include "slang-ast-reflect.h" #include "../core/slang-smart-pointer.h" #include "slang-ast-all.h" #include #include #include "slang-ast-generated-macro.h" namespace Slang { #define SLANG_REFLECT_GET_REFLECT_CLASS_INFO(NAME, SUPER, ORIGIN, LAST, MARKER, TYPE, param) infos.infos[int(ASTNodeType::NAME)] = &NAME::kReflectClassInfo; static ReflectClassInfo::Infos _calcInfos() { ReflectClassInfo::Infos infos; memset(&infos, 0, sizeof(infos)); SLANG_ALL_ASTNode_NodeBase(SLANG_REFLECT_GET_REFLECT_CLASS_INFO, _) SLANG_ALL_ASTNode_Substitutions(SLANG_REFLECT_GET_REFLECT_CLASS_INFO, _) return infos; } /* static */const ReflectClassInfo::Infos ReflectClassInfo::kInfos = _calcInfos(); bool ReflectClassInfo::isSubClassOfSlow(const ThisType& super) const { ReflectClassInfo const* info = this; while (info) { if (info == &super) return true; info = info->m_superClass; } return false; } // Now try and implement all of the classes // Macro generated is of the format template struct CreateImpl { static void* create() { return new T; } }; #define SLANG_GET_SUPER_BASE(SUPER) nullptr #define SLANG_GET_SUPER_INNER(SUPER) &SUPER::kReflectClassInfo #define SLANG_GET_SUPER_LEAF(SUPER) &SUPER::kReflectClassInfo #define SLANG_GET_CREATE_FUNC_ABSTRACT(NAME) nullptr #define SLANG_GET_CREATE_FUNC_NONE(NAME) &CreateImpl::create #define SLANG_GET_CREATE_FUNC_NON_VISITOR_ABSTRACT(NAME) nullptr #define SLANG_GET_CREATE_FUNC_NON_VISITOR(NAME) &CreateImpl::create #define SLANG_REFLECT_CLASS_INFO(NAME, SUPER, ORIGIN, LAST, MARKER, TYPE, param) \ /* static */const ReflectClassInfo NAME::kReflectClassInfo = { uint32_t(ASTNodeType::NAME), uint32_t(ASTNodeType::LAST), SLANG_GET_SUPER_##TYPE(SUPER), #NAME, SLANG_GET_CREATE_FUNC_##MARKER(NAME) }; SLANG_ALL_ASTNode_NodeBase(SLANG_REFLECT_CLASS_INFO, _) SLANG_ALL_ASTNode_Substitutions(SLANG_REFLECT_CLASS_INFO, _) } // namespace Slang