summaryrefslogtreecommitdiffstats
path: root/source/slang/parameter-binding.cpp
diff options
context:
space:
mode:
authorTim Foley <tfoley@nvidia.com>2017-06-15 16:35:10 -0700
committerTim Foley <tfoley@nvidia.com>2017-06-15 16:35:10 -0700
commite0389f5a1f32cb611e5a595a5974ee1d5c15f43d (patch)
tree7bee1ed3a1f235ac97de9f8d9893f2994015c5c3 /source/slang/parameter-binding.cpp
parent04d43cd71f081f1b8d2f0fd803a47cb6342e4fcd (diff)
Replace `DeclRef` approach
For context: a `DeclRef` is supposed to capture both a pointer to a particualr declaration, and also any information needed to specialize that declaration for a context (e.g., generic parameter substitutions). The existing approach had a hiearchy of specialized decl-ref types that mirrored the AST hierarchy, but that led to a lot of boilerplate where you had to recapitulate the exact same hierarchy. The new appraoch basically treats `DeclRef<T>` as a sort of "smart pointer" in that it wraps a pointer to a `T` (the declaration), plus a side field for the specialization info, and then allows it to be cast as needed to other types (where the pointer cast would be allowed), while carrying along the side info. To enable this, all the things that used to be member functions of declaration-reference types are now free functions that take a `DeclRef<T>` for some specific `T` as a parameter.
Diffstat (limited to 'source/slang/parameter-binding.cpp')
-rw-r--r--source/slang/parameter-binding.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/source/slang/parameter-binding.cpp b/source/slang/parameter-binding.cpp
index 1a1fa4335..0756eb68c 100644
--- a/source/slang/parameter-binding.cpp
+++ b/source/slang/parameter-binding.cpp
@@ -262,10 +262,10 @@ static bool findLayoutArg(
template<typename T>
static bool findLayoutArg(
- DeclRef declRef,
+ DeclRef<Decl> declRef,
int* outVal)
{
- return findLayoutArg<T>(declRef.GetDecl(), outVal);
+ return findLayoutArg<T>(declRef.getDecl(), outVal);
}
//
@@ -437,7 +437,7 @@ static void collectGlobalScopeParameter(
// Now create a variable layout that we can use
RefPtr<VarLayout> varLayout = new VarLayout();
varLayout->typeLayout = typeLayout;
- varLayout->varDecl = DeclRef(varDecl.Ptr(), nullptr).As<VarDeclBaseRef>();
+ varLayout->varDecl = DeclRef<Decl>(varDecl.Ptr(), nullptr).As<VarDeclBase>();
// This declaration may represent the same logical parameter
// as a declaration that came from a different translation unit.
@@ -528,7 +528,7 @@ static void addExplicitParameterBindings_HLSL(
// here is where we want to extract and apply them...
// Look for HLSL `register` or `packoffset` semantics.
- for (auto semantic : varDecl.GetDecl()->GetModifiersOfType<HLSLLayoutSemantic>())
+ for (auto semantic : varDecl.getDecl()->GetModifiersOfType<HLSLLayoutSemantic>())
{
// Need to extract the information encoded in the semantic
LayoutSemanticInfo semanticInfo = ExtractLayoutSemanticInfo(context, semantic);
@@ -916,15 +916,15 @@ static void processEntryPointParameter(
{
auto declRef = declRefType->declRef;
- if (auto structDeclRef = declRef.As<StructDeclRef>())
+ if (auto structDeclRef = declRef.As<StructSyntaxNode>())
{
// Need to recursively walk the fields of the structure now...
- for( auto field : structDeclRef.GetFields() )
+ for( auto field : GetFields(structDeclRef) )
{
processEntryPointParameterWithPossibleSemantic(
context,
- field.GetDecl(),
- field.GetType(),
+ field.getDecl(),
+ GetType(field),
state);
}
}
@@ -1223,7 +1223,7 @@ void GenerateParameterBindings(
for( auto& varLayout : parameterInfo->varLayouts )
{
- globalScopeStructLayout->mapVarToLayout.Add(varLayout->varDecl.GetDecl(), varLayout);
+ globalScopeStructLayout->mapVarToLayout.Add(varLayout->varDecl.getDecl(), varLayout);
}
}
globalScopeRules->EndStructLayout(&structLayoutInfo);