From 43c146794aab638924d2ab838d10f8af2ebf02a7 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Fri, 5 Jun 2020 18:20:09 -0400 Subject: ASTNodes use MemoryArena (#1376) * Add a ASTBuilder to a Module Only construct on valid ASTBuilder (was being called on nullptr on occassion) * Add nodes to ASTBuilder. * Compiles with RefPtr removed from AST node types. * Initialize all AST node pointer variables in headers to nullptr; * Initialize AST node variables as nullptr. Make ASTBuilder keep a ref on node types. Make SyntaxParseCallback returns a NodeBase * Don't release canonicalType on dtor (managed by ASTBuilder). * Give ASTBuilders a name and id, to help in debugging. For now destroy the session TypeCache, to stop it holding things released when the compile request destroys ASTBuilders. * Moved the TypeCheckingCache over to Linkage from Session. * NodeBase no longer derived from RefObject. * Only add/dtor nodes that need destruction. First pass compile on linux. --- source/slang/slang-reflection.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'source/slang/slang-reflection.cpp') diff --git a/source/slang/slang-reflection.cpp b/source/slang/slang-reflection.cpp index 23831d498..c1e533140 100644 --- a/source/slang/slang-reflection.cpp +++ b/source/slang/slang-reflection.cpp @@ -148,14 +148,14 @@ SlangReflectionType* spReflectionUserAttribute_GetArgumentType(SlangReflectionUs { auto userAttr = convert(attrib); if (!userAttr) return nullptr; - return convert(userAttr->args[index]->type.type.Ptr()); + return convert(userAttr->args[index]->type.type); } SLANG_API SlangResult spReflectionUserAttribute_GetArgumentValueInt(SlangReflectionUserAttribute* attrib, unsigned int index, int * rs) { auto userAttr = convert(attrib); if (!userAttr) return SLANG_ERROR_INVALID_PARAMETER; if (index >= (unsigned int)userAttr->args.getCount()) return SLANG_ERROR_INVALID_PARAMETER; - RefPtr val; + NodeBase* val = nullptr; if (userAttr->intArgVals.TryGetValue(index, val)) { *rs = (int)as(val)->value; @@ -356,15 +356,15 @@ SLANG_API SlangReflectionType* spReflectionType_GetElementType(SlangReflectionTy if(auto arrayType = as(type)) { - return (SlangReflectionType*) arrayType->baseType.Ptr(); + return (SlangReflectionType*) arrayType->baseType; } else if( auto parameterGroupType = as(type)) { - return convert(parameterGroupType->elementType.Ptr()); + return convert(parameterGroupType->elementType); } else if( auto vectorType = as(type)) { - return convert(vectorType->elementType.Ptr()); + return convert(vectorType->elementType); } else if( auto matrixType = as(type)) { @@ -427,7 +427,7 @@ SLANG_API SlangScalarType spReflectionType_GetScalarType(SlangReflectionType* in } else if(auto vectorType = as(type)) { - type = vectorType->elementType.Ptr(); + type = vectorType->elementType; } if(auto basicType = as(type)) @@ -504,7 +504,7 @@ SLANG_API SlangResourceShape spReflectionType_GetResourceShape(SlangReflectionTy while(auto arrayType = as(type)) { - type = arrayType->baseType.Ptr(); + type = arrayType->baseType; } if(auto textureType = as(type)) @@ -540,7 +540,7 @@ SLANG_API SlangResourceAccess spReflectionType_GetResourceAccess(SlangReflection while(auto arrayType = as(type)) { - type = arrayType->baseType.Ptr(); + type = arrayType->baseType; } if(auto textureType = as(type)) @@ -604,8 +604,8 @@ SLANG_API SlangReflectionType * spReflection_FindTypeByName(SlangReflection * re try { - RefPtr result = program->getTypeFromString(name, &sink); - return (SlangReflectionType*)result.Ptr(); + Type* result = program->getTypeFromString(name, &sink); + return (SlangReflectionType*)result; } catch( ... ) { @@ -633,18 +633,18 @@ SLANG_API SlangReflectionType* spReflectionType_GetResourceResultType(SlangRefle while(auto arrayType = as(type)) { - type = arrayType->baseType.Ptr(); + type = arrayType->baseType; } if (auto textureType = as(type)) { - return convert(textureType->elementType.Ptr()); + return convert(textureType->elementType); } // TODO: need a better way to handle this stuff... #define CASE(TYPE, SHAPE, ACCESS) \ else if(as(type)) do { \ - return convert(as(type)->elementType.Ptr()); \ + return convert(as(type)->elementType); \ } while(0) // TODO: structured buffer needs to expose type layout! @@ -666,7 +666,7 @@ SLANG_API SlangReflectionType* spReflectionTypeLayout_GetType(SlangReflectionTyp auto typeLayout = convert(inTypeLayout); if(!typeLayout) return nullptr; - return (SlangReflectionType*) typeLayout->type.Ptr(); + return (SlangReflectionType*) typeLayout->type; } namespace -- cgit v1.2.3