mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 07:38:48 +00:00
Make quaternion untyped values convert to first typed value found
This fixes an issue (#2079) where a typed argument could cause the construction to fail on the basis of failed untyped -> typed conversion.
This commit is contained in:
+12
-10
@@ -2871,8 +2871,6 @@ gb_internal bool check_builtin_procedure(CheckerContext *c, Operand *operand, As
|
|||||||
// quaternion :: proc(imag, jmag, kmag, real: float_type) -> complex_type
|
// quaternion :: proc(imag, jmag, kmag, real: float_type) -> complex_type
|
||||||
Operand xyzw[4] = {};
|
Operand xyzw[4] = {};
|
||||||
|
|
||||||
u32 first_index = 0;
|
|
||||||
|
|
||||||
// NOTE(bill): Invalid will be the default till fixed
|
// NOTE(bill): Invalid will be the default till fixed
|
||||||
operand->type = t_invalid;
|
operand->type = t_invalid;
|
||||||
operand->mode = Addressing_Invalid;
|
operand->mode = Addressing_Invalid;
|
||||||
@@ -2934,7 +2932,6 @@ gb_internal bool check_builtin_procedure(CheckerContext *c, Operand *operand, As
|
|||||||
if (!ok || index < 0) {
|
if (!ok || index < 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
first_index = cast(u32)index;
|
|
||||||
*refs[index] = o;
|
*refs[index] = o;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2959,12 +2956,17 @@ gb_internal bool check_builtin_procedure(CheckerContext *c, Operand *operand, As
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
for (u32 i = 0; i < 4; i++ ){
|
// The first typed value found, if any exist, will dictate the type for all untyped values.
|
||||||
u32 j = (i + first_index) % 4;
|
for (u32 i = 0; i < 4; i++) {
|
||||||
if (j == first_index) {
|
if (is_type_typed(xyzw[i].type)) {
|
||||||
convert_to_typed(c, &xyzw[j], xyzw[(first_index+1)%4].type); if (xyzw[j].mode == Addressing_Invalid) return false;
|
for (u32 j = 0; j < 4; j++) {
|
||||||
} else {
|
// `convert_to_typed` should check if it is typed already.
|
||||||
convert_to_typed(c, &xyzw[j], xyzw[first_index].type); if (xyzw[j].mode == Addressing_Invalid) return false;
|
convert_to_typed(c, &xyzw[j], xyzw[i].type);
|
||||||
|
if (xyzw[j].mode == Addressing_Invalid) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (xyzw[0].mode == Addressing_Constant &&
|
if (xyzw[0].mode == Addressing_Constant &&
|
||||||
@@ -3024,7 +3026,7 @@ gb_internal bool check_builtin_procedure(CheckerContext *c, Operand *operand, As
|
|||||||
operand->mode = Addressing_Constant;
|
operand->mode = Addressing_Constant;
|
||||||
}
|
}
|
||||||
|
|
||||||
BasicKind kind = core_type(xyzw[first_index].type)->Basic.kind;
|
BasicKind kind = core_type(xyzw[0].type)->Basic.kind;
|
||||||
switch (kind) {
|
switch (kind) {
|
||||||
case Basic_f16: operand->type = t_quaternion64; break;
|
case Basic_f16: operand->type = t_quaternion64; break;
|
||||||
case Basic_f32: operand->type = t_quaternion128; break;
|
case Basic_f32: operand->type = t_quaternion128; break;
|
||||||
|
|||||||
Reference in New Issue
Block a user