From c985f5f2f95dc95998fdfb8400baa0a04760ada2 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Thu, 5 Nov 2020 13:43:00 -0500 Subject: Standard library save/loadable (#1592) * #include an absolute path didn't work - because paths were taken to always be relative. * Fix handling of access modifiers inside type definition. * Fix access problem for AST node. Make dumping produce a single function with switch, to potentially make available without Dump specific access. * WIP on serialization design doc. * Remove project references to previously generated files. * More docs on serialization design. * Improve serialization documentation. Remove unused function from IRSerialReader. * Small fixes around naming. Remove long comment from slang-serialize.h - as covered in serialization.md * Remove long comment in slang-serialize.h as covered in serialization.md * More information about doing replacements on read for AST and problems surrounding. * Typo fix. * Spelling fixes. * Value serialize. * Value types with inheritence. * Use value reflection serial conversion for more AST types * Use automatic serialization on more of AST. * Get the types via decltype, simplifies what the extractor has to do. * Update the serialization.md for the value serialization. * Small doc improvements. * Update project. * Remove ImportExternalDecl type Added addImportSymbol and ImportSymbol type Fixed bug in container which meant it wouldn't read back AST module * Because of change of how imports and handled, store objects as SerialPointers. * First pass symbol lookup from mangled names. * Cache current module looked up from mangled name. * Fix SourceLoc bug. Improve comments. * Added diagnostic on mangled symbol not being found * Fix typo. * WIP serializing stdlib. * WIP serializing stdlib in. * Fix problem serializing arrays that hold data that is already serialized. * Remove clash of names in MagicTypeModifier. * Make conversion from char to String explicit. Fix reference count issue with SerialReader. * Add code to save/load stdlib. * Use return code to avoid warning - SerialContainerUtil::write(module, options, &stream)) * Make all String numeric ctors explicit. Added isChar to UnownedStringSlice. Added operator== for UnownedStringSlice to String to avoid need to convert to String and allocate. * Add error check to readAllText. * tabs -> spaces on String.h * tab -> spaces String.cpp * Remove msg for StringBuilder, just build inplace for exceptions. * Check SerialClasses - for name clashes. Renamed Modifier::name as Modifier::keywordName * Handling of extensions when deserializing AST - updating the moduleDecl->mapTypeToCandidateExtensions Co-authored-by: Tim Foley --- source/slang/slang-syntax.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'source/slang/slang-syntax.cpp') diff --git a/source/slang/slang-syntax.cpp b/source/slang/slang-syntax.cpp index ea17ad1d1..82e94fb6a 100644 --- a/source/slang/slang-syntax.cpp +++ b/source/slang/slang-syntax.cpp @@ -453,14 +453,14 @@ Index getFilterCountImpl(const ReflectClassInfo& clsInfo, MemberFilterStyle filt } } - if (magicMod->name == "SamplerState") + if (magicMod->magicName == "SamplerState") { auto type = astBuilder->create(); type->declRef = declRef; type->flavor = SamplerStateFlavor(magicMod->tag); return type; } - else if (magicMod->name == "Vector") + else if (magicMod->magicName == "Vector") { SLANG_ASSERT(subst && subst->args.getCount() == 2); auto vecType = astBuilder->create(); @@ -469,14 +469,14 @@ Index getFilterCountImpl(const ReflectClassInfo& clsInfo, MemberFilterStyle filt vecType->elementCount = ExtractGenericArgInteger(subst->args[1]); return vecType; } - else if (magicMod->name == "Matrix") + else if (magicMod->magicName == "Matrix") { SLANG_ASSERT(subst && subst->args.getCount() == 3); auto matType = astBuilder->create(); matType->declRef = declRef; return matType; } - else if (magicMod->name == "Texture") + else if (magicMod->magicName == "Texture") { SLANG_ASSERT(subst && subst->args.getCount() >= 1); auto textureType = astBuilder->create( @@ -485,7 +485,7 @@ Index getFilterCountImpl(const ReflectClassInfo& clsInfo, MemberFilterStyle filt textureType->declRef = declRef; return textureType; } - else if (magicMod->name == "TextureSampler") + else if (magicMod->magicName == "TextureSampler") { SLANG_ASSERT(subst && subst->args.getCount() >= 1); auto textureType = astBuilder->create( @@ -494,7 +494,7 @@ Index getFilterCountImpl(const ReflectClassInfo& clsInfo, MemberFilterStyle filt textureType->declRef = declRef; return textureType; } - else if (magicMod->name == "GLSLImageType") + else if (magicMod->magicName == "GLSLImageType") { SLANG_ASSERT(subst && subst->args.getCount() >= 1); auto textureType = astBuilder->create( @@ -503,7 +503,7 @@ Index getFilterCountImpl(const ReflectClassInfo& clsInfo, MemberFilterStyle filt textureType->declRef = declRef; return textureType; } - else if (magicMod->name == "FeedbackType") + else if (magicMod->magicName == "FeedbackType") { SLANG_ASSERT(subst == nullptr); auto type = astBuilder->create(); @@ -517,7 +517,7 @@ Index getFilterCountImpl(const ReflectClassInfo& clsInfo, MemberFilterStyle filt // of this ridiculously slow `if` cascade. #define CASE(n,T) \ - else if(magicMod->name == #n) { \ + else if(magicMod->magicName == #n) { \ auto type = astBuilder->create(); \ type->declRef = declRef; \ return type; \ @@ -529,7 +529,7 @@ Index getFilterCountImpl(const ReflectClassInfo& clsInfo, MemberFilterStyle filt #undef CASE #define CASE(n,T) \ - else if(magicMod->name == #n) { \ + else if(magicMod->magicName == #n) { \ SLANG_ASSERT(subst && subst->args.getCount() == 1); \ auto type = astBuilder->create(); \ type->elementType = ExtractGenericArgType(subst->args[0]); \ @@ -558,7 +558,7 @@ Index getFilterCountImpl(const ReflectClassInfo& clsInfo, MemberFilterStyle filt // "magic" builtin types which have no generic parameters #define CASE(n,T) \ - else if(magicMod->name == #n) { \ + else if(magicMod->magicName == #n) { \ auto type = astBuilder->create(); \ type->declRef = declRef; \ return type; \ @@ -575,7 +575,7 @@ Index getFilterCountImpl(const ReflectClassInfo& clsInfo, MemberFilterStyle filt else { - auto classInfo = astBuilder->findSyntaxClass(magicMod->name.getUnownedSlice()); + auto classInfo = astBuilder->findSyntaxClass(magicMod->magicName.getUnownedSlice()); if (!classInfo.classInfo) { SLANG_UNEXPECTED("unhandled type"); -- cgit v1.2.3