From a23adc221b1ea26db3f3313226b629eb9e308b0f Mon Sep 17 00:00:00 2001 From: Yong He Date: Sat, 23 Mar 2024 10:54:01 -0700 Subject: Make `-no-mangle` option work, add `-no-hlsl-binding`. (#3817) --- source/slang/slang-parser.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'source/slang/slang-parser.cpp') diff --git a/source/slang/slang-parser.cpp b/source/slang/slang-parser.cpp index d64329add..4522f977d 100644 --- a/source/slang/slang-parser.cpp +++ b/source/slang/slang-parser.cpp @@ -84,6 +84,7 @@ namespace Slang bool enableEffectAnnotations = false; bool allowGLSLInput = false; bool isInLanguageServer = false; + CompilerOptionSet optionSet; }; // TODO: implement two pass parsing for file reference and struct type recognition @@ -3207,7 +3208,20 @@ namespace Slang else { // Otherwise, we need to generate a name for the buffer variable. - bufferVarDecl->nameAndLoc.name = generateName(parser, "parameterGroup_" + String(reflectionNameToken.getContent())); + if (parser->options.optionSet.getBoolOption(CompilerOptionName::NoMangle)) + { + // If no-mangle option is set, use the reflection name as the variable name, + // and mark all members of the buffer object as no mangle. + bufferVarDecl->nameAndLoc.name = reflectionNameToken.getName(); + for (auto m : bufferDataTypeDecl->getMembersOfType()) + { + addModifier(m, parser->astBuilder->create()); + } + } + else + { + bufferVarDecl->nameAndLoc.name = generateName(parser, "parameterGroup_" + String(reflectionNameToken.getContent())); + } // We also need to make the declaration "transparent" so that their // members are implicitly made visible in the parent scope. @@ -7546,6 +7560,7 @@ namespace Slang translationUnit->compileRequest->optionSet.getBoolOption(CompilerOptionName::AllowGLSL) || sourceLanguage == SourceLanguage::GLSL; options.isInLanguageServer = translationUnit->compileRequest->getLinkage()->isInLanguageServer(); + options.optionSet = translationUnit->compileRequest->optionSet; Parser parser(astBuilder, tokens, sink, outerScope, options); parser.namePool = translationUnit->getNamePool(); -- cgit v1.2.3