internal/shaderir: remove isUntypedInteger

Updates #2550
This commit is contained in:
Hajime Hoshi 2023-07-23 13:04:17 +09:00
parent 8b4c744ca8
commit a5af8f3b0b

View File

@ -34,21 +34,17 @@ func canTruncateToFloat(v gconstant.Value) bool {
return gconstant.ToFloat(v).Kind() != gconstant.Unknown return gconstant.ToFloat(v).Kind() != gconstant.Unknown
} }
func isUntypedInteger(expr *shaderir.Expr) bool {
return expr.Const.Kind() == gconstant.Int && expr.ConstType == shaderir.ConstTypeNone
}
func isModAvailableForConsts(lhs, rhs *shaderir.Expr) bool { func isModAvailableForConsts(lhs, rhs *shaderir.Expr) bool {
// % is available only when // % is available only when
// 1) both are untyped integers // 1) both are untyped (constant) integers
// 2) either is an typed integer and the other is truncatable to an integer // 2) either is an typed integer and the other is truncatable to an integer
if isUntypedInteger(lhs) && isUntypedInteger(rhs) { if lhs.Const.Kind() == gconstant.Int && rhs.Const.Kind() == gconstant.Int {
return true return true
} }
if lhs.ConstType == shaderir.ConstTypeInt && canTruncateToInteger(rhs.Const) { if lhs.Const.Kind() == gconstant.Int && canTruncateToInteger(rhs.Const) {
return true return true
} }
if rhs.ConstType == shaderir.ConstTypeInt && canTruncateToInteger(lhs.Const) { if rhs.Const.Kind() == gconstant.Int && canTruncateToInteger(lhs.Const) {
return true return true
} }
return false return false