summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-emit-cpp.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/slang/slang-emit-cpp.cpp')
-rw-r--r--source/slang/slang-emit-cpp.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/source/slang/slang-emit-cpp.cpp b/source/slang/slang-emit-cpp.cpp
index 3c43485cc..60b86b827 100644
--- a/source/slang/slang-emit-cpp.cpp
+++ b/source/slang/slang-emit-cpp.cpp
@@ -1028,10 +1028,15 @@ void CPPSourceEmitter::_emitGetAtDefinition(const UnownedStringSlice& funcName,
writer->emit("SLANG_PRELUDE_ASSERT(b >= 0 && b < ");
writer->emit(vecSize);
writer->emit(");\n");
+
+ writer->emit("return ((");
+ emitType(specOp->returnType);
+ writer->emit("*)");
+
if (lValue)
- writer->emit("return (&a->x) + b;\n");
+ writer->emit("a) + b;\n");
else
- writer->emit("return (&a.x)[b];\n");
+ writer->emit("&a)[b];\n");
}
else if (auto matrixType = as<IRMatrixType>(srcType))
{