mirror of
https://github.com/N64Recomp/N64ModernRuntime.git
synced 2026-05-11 03:12:15 +00:00
Add constexpr to _return
This commit is contained in:
parent
ad45f73007
commit
288a52ef79
1 changed files with 8 additions and 2 deletions
|
|
@ -39,12 +39,18 @@ T _arg(uint8_t* rdram, recomp_context* ctx) {
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void _return(recomp_context* ctx, T val) {
|
void _return(recomp_context* ctx, T val) {
|
||||||
static_assert(sizeof(T) <= 4 && "Only 32-bit value returns supported currently");
|
static_assert(sizeof(T) <= 4 && "Only 32-bit value returns supported currently");
|
||||||
if (std::is_same_v<T, float>) {
|
if constexpr (std::is_same_v<T, float>) {
|
||||||
ctx->f0.fl = val;
|
ctx->f0.fl = val;
|
||||||
}
|
}
|
||||||
else if (std::is_integral_v<T> && sizeof(T) <= 4) {
|
else if constexpr (std::is_integral_v<T> && sizeof(T) <= 4) {
|
||||||
ctx->r2 = int32_t(val);
|
ctx->r2 = int32_t(val);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
// static_assert in else workaround
|
||||||
|
[] <bool flag = false>() {
|
||||||
|
static_assert(flag, "Unsupported type");
|
||||||
|
}();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
Loading…
Add table
Reference in a new issue