diff options
| author | Yong He <yonghe@outlook.com> | 2022-03-28 22:14:33 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-03-28 22:14:33 -0700 |
| commit | 255fd5873f65a6b01d5385c277d55612dc3cc587 (patch) | |
| tree | 54eda0ae98bc9c1b30ca75e534ca203d8e03f241 /source/slang/slang-emit-c-like.cpp | |
| parent | 79b81083b75dc0abdbb8184568dbe36d082e04f3 (diff) | |
Allow slangc to generate exe from .slang file. (#2170)
Diffstat (limited to 'source/slang/slang-emit-c-like.cpp')
| -rw-r--r-- | source/slang/slang-emit-c-like.cpp | 37 |
1 files changed, 8 insertions, 29 deletions
diff --git a/source/slang/slang-emit-c-like.cpp b/source/slang/slang-emit-c-like.cpp index d3dd0e5b8..eb178a366 100644 --- a/source/slang/slang-emit-c-like.cpp +++ b/source/slang/slang-emit-c-like.cpp @@ -78,6 +78,7 @@ struct CLikeSourceEmitter::ComputeEmitActionsContext return SourceLanguage::C; } case CodeGenTarget::CPPSource: + case CodeGenTarget::HostCPPSource: { return SourceLanguage::CPP; } @@ -741,28 +742,6 @@ String CLikeSourceEmitter::_generateUniqueName(const UnownedStringSlice& name) String CLikeSourceEmitter::generateName(IRInst* inst) { - // Handle `__exportDirectly` decoration before all else - if (inst->findDecoration<IR__exportDirectly>()) - { - // If instruction has a NameHint, we naively emit it as a namespace - // This is automatically handled in `getNameforNameHint` when the - // `__exportDirectly` decoration is found, so we can just return it. - // TODO: This is a very hacky solution. - // - // Another option would be to have two separate decorations, one that - // handles this namespace, and a separate decoration for unmangled names. - if (auto nameHintDecoration = inst->findDecoration<IRNameHintDecoration>()) - { - return nameHintDecoration->getName(); - } - // Otherwise, we just want the instruction to not be mangled, which is - // similarly handled in `getMangledName`. - if (auto linkageDecoration = inst->findDecoration<IRLinkageDecoration>()) - { - return linkageDecoration->getMangledName(); - } - } - // If the instruction names something // that should be emitted as a target intrinsic, // then use that name instead. @@ -802,6 +781,13 @@ String CLikeSourceEmitter::generateName(IRInst* inst) return generateEntryPointNameImpl(entryPointDecor); } + // If the instruction has a linkage decoration, just use that. + if (auto externCppDecoration = inst->findDecoration<IRExternCppDecoration>()) + { + // Just use the linkages mangled name directly. + return externCppDecoration->getName(); + } + // If we have a name hint on the instruction, then we will try to use that // to provide the basis for the actual name in the output code. if(auto nameHintDecoration = inst->findDecoration<IRNameHintDecoration>()) @@ -2915,13 +2901,6 @@ void CLikeSourceEmitter::emitStruct(IRStructType* structType) return; } - // If the selected `struct` type is externally defined - // then we also don't want to emit anything. - if (auto externLibDecoration = structType->findDecoration<IR__externLib>()) - { - return; - } - m_writer->emit("struct "); emitPostKeywordTypeAttributes(structType); |
