summaryrefslogtreecommitdiff
path: root/source/slang/slang-ast-reflect.cpp
diff options
context:
space:
mode:
authorEllie Hermaszewska <ellieh@nvidia.com>2024-10-29 14:49:26 +0800
committerGitHub <noreply@github.com>2024-10-29 14:49:26 +0800
commitf65d756bff8d4c5cbc15bd0322a2ae8e6b896a21 (patch)
treeea1d61342cd29368e19135000ec2948813096205 /source/slang/slang-ast-reflect.cpp
parenta729c15e9dce9f5116a38afc66329ab2ca4cea54 (diff)
format
* format * Minor test fixes * enable checking cpp format in ci
Diffstat (limited to 'source/slang/slang-ast-reflect.cpp')
-rw-r--r--source/slang/slang-ast-reflect.cpp60
1 files changed, 31 insertions, 29 deletions
diff --git a/source/slang/slang-ast-reflect.cpp b/source/slang/slang-ast-reflect.cpp
index a91ec0618..c6c51cb73 100644
--- a/source/slang/slang-ast-reflect.cpp
+++ b/source/slang/slang-ast-reflect.cpp
@@ -1,39 +1,35 @@
-#include "slang.h"
-
#include "slang-ast-reflect.h"
#include "../core/slang-smart-pointer.h"
-
#include "slang-ast-all.h"
-
-#include <typeinfo>
-#include <assert.h>
-
+#include "slang-generated-ast-macro.h"
#include "slang-visitor.h"
+#include "slang.h"
-#include "slang-generated-ast-macro.h"
+#include <assert.h>
+#include <typeinfo>
namespace Slang
{
-#define SLANG_REFLECT_GET_REFLECT_CLASS_INFO(NAME, SUPER, ORIGIN, LAST, MARKER, TYPE, param) infos.infos[int(ASTNodeType::NAME)] = &NAME::kReflectClassInfo;
+#define SLANG_REFLECT_GET_REFLECT_CLASS_INFO(NAME, SUPER, ORIGIN, LAST, MARKER, TYPE, param) \
+ infos.infos[int(ASTNodeType::NAME)] = &NAME::kReflectClassInfo;
static ASTClassInfo::Infos _calcInfos()
{
ASTClassInfo::Infos infos;
memset(&infos, 0, sizeof(infos));
- SLANG_ALL_ASTNode_NodeBase(SLANG_REFLECT_GET_REFLECT_CLASS_INFO, _)
- return infos;
+ SLANG_ALL_ASTNode_NodeBase(SLANG_REFLECT_GET_REFLECT_CLASS_INFO, _) return infos;
}
-/* static */const ASTClassInfo::Infos ASTClassInfo::kInfos = _calcInfos();
+/* static */ const ASTClassInfo::Infos ASTClassInfo::kInfos = _calcInfos();
// Now try and implement all of the classes
// Macro generated is of the format
struct ASTConstructAccess
{
- template <typename T>
+ template<typename T>
struct Impl
{
static void* create(void* context)
@@ -61,25 +57,34 @@ struct ASTConstructAccess
#define SLANG_GET_DESTROY_FUNC_AST(NAME) &ASTConstructAccess::Impl<NAME>::destroy
#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_GET_DESTROY_FUNC_##MARKER(NAME), uint32_t(sizeof(NAME)), uint8_t(SLANG_ALIGN_OF(NAME)) };
+ /* 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_GET_DESTROY_FUNC_##MARKER(NAME), \
+ uint32_t(sizeof(NAME)), \
+ uint8_t(SLANG_ALIGN_OF(NAME))};
SLANG_ALL_ASTNode_NodeBase(SLANG_REFLECT_CLASS_INFO, _)
// We dispatch to non 'abstract' types
-#define SLANG_CASE_AST(NAME) case ASTNodeType::NAME: return visitor->dispatch_##NAME(static_cast<NAME*>(this), extra);
+#define SLANG_CASE_AST(NAME) \
+ case ASTNodeType::NAME: return visitor->dispatch_##NAME(static_cast<NAME*>(this), extra);
#define SLANG_CASE_ABSTRACT_AST(NAME)
-#define SLANG_CASE_DISPATCH(NAME, SUPER, ORIGIN, LAST, MARKER, TYPE, param) SLANG_CASE_##MARKER(NAME)
+#define SLANG_CASE_DISPATCH(NAME, SUPER, ORIGIN, LAST, MARKER, TYPE, param) \
+ SLANG_CASE_##MARKER(NAME)
-void Val::accept(IValVisitor* visitor, void* extra)
+ void Val::accept(IValVisitor* visitor, void* extra)
{
const ReflectClassInfo& classInfo = getClassInfo();
const ASTNodeType astType = ASTNodeType(classInfo.m_classId);
switch (astType)
{
- SLANG_CHILDREN_ASTNode_Val(SLANG_CASE_DISPATCH, _)
- default: SLANG_ASSERT(!"Unknown type");
+ SLANG_CHILDREN_ASTNode_Val(SLANG_CASE_DISPATCH, _) default : SLANG_ASSERT(!"Unknown type");
}
}
@@ -90,8 +95,7 @@ void Type::accept(ITypeVisitor* visitor, void* extra)
switch (astType)
{
- SLANG_CHILDREN_ASTNode_Type(SLANG_CASE_DISPATCH, _)
- default: SLANG_ASSERT(!"Unknown type");
+ SLANG_CHILDREN_ASTNode_Type(SLANG_CASE_DISPATCH, _) default : SLANG_ASSERT(!"Unknown type");
}
}
@@ -102,8 +106,8 @@ void Modifier::accept(IModifierVisitor* visitor, void* extra)
switch (astType)
{
- SLANG_CHILDREN_ASTNode_Modifier(SLANG_CASE_DISPATCH, _)
- default: SLANG_ASSERT(!"Unknown type");
+ SLANG_CHILDREN_ASTNode_Modifier(SLANG_CASE_DISPATCH, _) default
+ : SLANG_ASSERT(!"Unknown type");
}
}
@@ -114,8 +118,8 @@ void DeclBase::accept(IDeclVisitor* visitor, void* extra)
switch (astType)
{
- SLANG_CHILDREN_ASTNode_DeclBase(SLANG_CASE_DISPATCH, _)
- default: SLANG_ASSERT(!"Unknown type");
+ SLANG_CHILDREN_ASTNode_DeclBase(SLANG_CASE_DISPATCH, _) default
+ : SLANG_ASSERT(!"Unknown type");
}
}
@@ -126,8 +130,7 @@ void Expr::accept(IExprVisitor* visitor, void* extra)
switch (astType)
{
- SLANG_CHILDREN_ASTNode_Expr(SLANG_CASE_DISPATCH, _)
- default: SLANG_ASSERT(!"Unknown type");
+ SLANG_CHILDREN_ASTNode_Expr(SLANG_CASE_DISPATCH, _) default : SLANG_ASSERT(!"Unknown type");
}
}
@@ -138,8 +141,7 @@ void Stmt::accept(IStmtVisitor* visitor, void* extra)
switch (astType)
{
- SLANG_CHILDREN_ASTNode_Stmt(SLANG_CASE_DISPATCH, _)
- default: SLANG_ASSERT(!"Unknown type");
+ SLANG_CHILDREN_ASTNode_Stmt(SLANG_CASE_DISPATCH, _) default : SLANG_ASSERT(!"Unknown type");
}
}