summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-emit-cpp.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2020-06-25 13:19:45 -0700
committerYong He <yonghe@outlook.com>2020-06-25 13:23:28 -0700
commita1fed5e49bc1c8452752d13d401ee0bbbc5c71c4 (patch)
tree03e54a0d33caf5196416315489a8d01b973c7a5e /source/slang/slang-emit-cpp.cpp
parentffa9a3575ff888dc494ba4878f52441c64a9e08c (diff)
Partial fixes to code review comments
Diffstat (limited to 'source/slang/slang-emit-cpp.cpp')
-rw-r--r--source/slang/slang-emit-cpp.cpp35
1 files changed, 7 insertions, 28 deletions
diff --git a/source/slang/slang-emit-cpp.cpp b/source/slang/slang-emit-cpp.cpp
index eeace4aa7..a449a2c56 100644
--- a/source/slang/slang-emit-cpp.cpp
+++ b/source/slang/slang-emit-cpp.cpp
@@ -390,27 +390,12 @@ static UnownedStringSlice _getResourceTypePrefix(IROp op)
}
}
-static bool isVoidPtrType(IRType* type)
-{
- auto ptrType = as<IRPtrType>(type);
- if (!ptrType) return false;
- return ptrType->getValueType()->op == kIROp_VoidType;
-}
-
SlangResult CPPSourceEmitter::calcTypeName(IRType* type, CodeGenTarget target, StringBuilder& out)
{
switch (type->op)
{
case kIROp_PtrType:
{
- if (isVoidPtrType(type))
- {
- // A `void*` type will always emit as `void*`.
- // `void*` types are generated as a result of generics lowering
- // for dynamic dispatch.
- out << "void*";
- return SLANG_OK;
- }
auto ptrType = static_cast<IRPtrType*>(type);
SLANG_RETURN_ON_FAIL(calcTypeName(ptrType->getValueType(), target, out));
// TODO(JS): It seems although it says it is a pointer, it can actually be output as a reference
@@ -513,6 +498,11 @@ SlangResult CPPSourceEmitter::calcTypeName(IRType* type, CodeGenTarget target, S
out << "*";
return SLANG_OK;
}
+ case kIROp_RawPointerType:
+ {
+ out << "void*";
+ return SLANG_OK;
+ }
default:
{
if (isNominalOp(type->op))
@@ -1774,7 +1764,7 @@ void CPPSourceEmitter::_maybeEmitWitnessTableTypeDefinition(
{
emitType(funcVal->getResultType());
m_writer->emit(" (KernelContext::*");
- m_writer->emit(getName(entry->requirementKey.get()));
+ m_writer->emit(getName(entry->getRequirementKey()));
m_writer->emit(")");
m_writer->emit("(");
bool isFirstParam = true;
@@ -1804,7 +1794,7 @@ void CPPSourceEmitter::_maybeEmitWitnessTableTypeDefinition(
{
emitType(constraintInterfaceType);
m_writer->emit("* ");
- m_writer->emit(getName(entry->requirementKey.get()));
+ m_writer->emit(getName(entry->getRequirementKey()));
m_writer->emit(";\n");
}
}
@@ -2007,17 +1997,6 @@ void CPPSourceEmitter::emitSimpleValueImpl(IRInst* inst)
void CPPSourceEmitter::emitSimpleFuncParamImpl(IRParam* param)
{
- // Polymorphic types are already translated to void* type in
- // lower-generics pass. However, the current emitting logic will
- // emit "void&" instead of "void*" for pointer types.
- // In the future, we will handle pointer types more properly,
- // and this override logic will not be necessary.
- if (isVoidPtrType(param->getDataType()))
- {
- m_writer->emit("void* ");
- m_writer->emit(getName(param));
- return;
- }
CLikeSourceEmitter::emitSimpleFuncParamImpl(param);
}