From e0389f5a1f32cb611e5a595a5974ee1d5c15f43d Mon Sep 17 00:00:00 2001 From: Tim Foley Date: Thu, 15 Jun 2017 16:35:10 -0700 Subject: 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` 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` for some specific `T` as a parameter. --- source/slang/parameter-binding.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'source/slang/parameter-binding.cpp') 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 static bool findLayoutArg( - DeclRef declRef, + DeclRef declRef, int* outVal) { - return findLayoutArg(declRef.GetDecl(), outVal); + return findLayoutArg(declRef.getDecl(), outVal); } // @@ -437,7 +437,7 @@ static void collectGlobalScopeParameter( // Now create a variable layout that we can use RefPtr varLayout = new VarLayout(); varLayout->typeLayout = typeLayout; - varLayout->varDecl = DeclRef(varDecl.Ptr(), nullptr).As(); + varLayout->varDecl = DeclRef(varDecl.Ptr(), nullptr).As(); // 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()) + for (auto semantic : varDecl.getDecl()->GetModifiersOfType()) { // 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()) + if (auto structDeclRef = declRef.As()) { // 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); -- cgit v1.2.3