Merge pull request #7342 from kalsprite/alpha

quat/cmplx nan cmp & accessors
This commit is contained in:
Jeroen van Rijn
2026-08-16 12:31:55 +02:00
committed by GitHub
4 changed files with 454 additions and 9 deletions

View File

@@ -3867,10 +3867,6 @@ gb_internal bool check_builtin_procedure(CheckerContext *c, Operand *operand, As
default: GB_PANIC("Invalid type"); break;
}
if (type_hint != nullptr && check_is_castable_to(c, operand, type_hint)) {
operand->type = type_hint;
}
break;
}
@@ -3887,7 +3883,7 @@ gb_internal bool check_builtin_procedure(CheckerContext *c, Operand *operand, As
if (is_type_untyped(x->type)) {
if (x->mode == Addressing_Constant) {
if (is_type_numeric(x->type)) {
x->type = t_untyped_complex;
x->type = t_untyped_quaternion;
}
} else{
convert_to_typed(c, x, t_quaternion256);
@@ -3923,10 +3919,6 @@ gb_internal bool check_builtin_procedure(CheckerContext *c, Operand *operand, As
default: GB_PANIC("Invalid type"); break;
}
if (type_hint != nullptr && check_is_castable_to(c, operand, type_hint)) {
operand->type = type_hint;
}
break;
}

View File

@@ -1019,6 +1019,10 @@ gb_internal bool compare_exact_values(TokenKind op, ExactValue x, ExactValue y)
f64 b = x.value_complex->imag;
f64 c = y.value_complex->real;
f64 d = y.value_complex->imag;
if (isnan(a) || isnan(b) || isnan(c) || isnan(d)) {
return op == Token_NotEq;
}
switch (op) {
case Token_CmpEq: return cmp_f64(a, c) == 0 && cmp_f64(b, d) == 0;
case Token_NotEq: return cmp_f64(a, c) != 0 || cmp_f64(b, d) != 0;
@@ -1026,6 +1030,29 @@ gb_internal bool compare_exact_values(TokenKind op, ExactValue x, ExactValue y)
break;
}
case ExactValue_Quaternion: {
Quaternion256 a = *x.value_quaternion;
Quaternion256 b = *y.value_quaternion;
if (isnan(a.real) || isnan(a.imag) || isnan(a.jmag) || isnan(a.kmag) ||
isnan(b.real) || isnan(b.imag) || isnan(b.jmag) || isnan(b.kmag)) {
return op == Token_NotEq;
}
switch (op) {
case Token_CmpEq:
return cmp_f64(a.real, b.real) == 0 &&
cmp_f64(a.imag, b.imag) == 0 &&
cmp_f64(a.jmag, b.jmag) == 0 &&
cmp_f64(a.kmag, b.kmag) == 0;
case Token_NotEq:
return cmp_f64(a.real, b.real) != 0 ||
cmp_f64(a.imag, b.imag) != 0 ||
cmp_f64(a.jmag, b.jmag) != 0 ||
cmp_f64(a.kmag, b.kmag) != 0;
}
break;
}
case ExactValue_String: {
String a = x.value_string;
String b = y.value_string;