summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/slang/slang-emit-wgsl.cpp20
1 files changed, 14 insertions, 6 deletions
diff --git a/source/slang/slang-emit-wgsl.cpp b/source/slang/slang-emit-wgsl.cpp
index d8a243b32..61f34d408 100644
--- a/source/slang/slang-emit-wgsl.cpp
+++ b/source/slang/slang-emit-wgsl.cpp
@@ -66,16 +66,24 @@ void WGSLSourceEmitter::emitSwitchCaseSelectorsImpl(
// "case 2, 3, 4: ...;" instead of the C-like syntax
// "case 2: case 3: case 4: ...;".
- m_writer->emit("case ");
- for (auto caseVal : currentCase->values)
+ if (!isDefault)
{
- emitOperand(caseVal, getInfo(EmitOp::General));
- m_writer->emit(", ");
+ m_writer->emit("case ");
+ auto& values = currentCase->values;
+ for (Index i = 0; i < values.getCount(); ++i)
+ {
+ emitOperand(values[i], getInfo(EmitOp::General));
+ if (i < values.getCount() - 1)
+ {
+ m_writer->emit(", ");
+ }
+ }
}
- if (isDefault)
+ else
{
- m_writer->emit("default, ");
+ m_writer->emit("default ");
}
+
m_writer->emit(":\n");
}