diff options
| author | Yong He <yonghe@outlook.com> | 2024-03-23 10:54:01 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-23 10:54:01 -0700 |
| commit | a23adc221b1ea26db3f3313226b629eb9e308b0f (patch) | |
| tree | 6f758d64201f2c606dc3e61394899bff4fa72f51 /source/slang/slang-parser.cpp | |
| parent | 9b0df14cdf9d9ea8857b5b9d59505b18020f8414 (diff) | |
Make `-no-mangle` option work, add `-no-hlsl-binding`. (#3817)
Diffstat (limited to 'source/slang/slang-parser.cpp')
| -rw-r--r-- | source/slang/slang-parser.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
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<VarDecl>()) + { + addModifier(m, parser->astBuilder->create<ExternCppModifier>()); + } + } + 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(); |
