* * The two operands are scalars. In this case the operation is
* applied, resulting in a scalar."
*/
- if (is_glsl_type_scalar(type_a) && is_glsl_type_scalar(type_b))
+ if (type_a->is_scalar() && type_b->is_scalar())
return type_a;
/* "* One operand is a scalar, and the other is a vector or matrix.
* component of the vector or matrix, resulting in the same size
* vector or matrix."
*/
- if (is_glsl_type_scalar(type_a)) {
- if (!is_glsl_type_scalar(type_b))
+ if (type_a->is_scalar()) {
+ if (!type_b->is_scalar())
return type_b;
- } else if (is_glsl_type_scalar(type_b)) {
+ } else if (type_b->is_scalar()) {
return type_a;
}
*/
if (! is_numeric_base_type(type_a->base_type)
|| ! is_numeric_base_type(type_b->base_type)
- || ! is_glsl_type_scalar(type_a)
- || ! is_glsl_type_scalar(type_b))
+ || !type_a->is_scalar()
+ || !type_b->is_scalar())
return glsl_error_type;
/* "Either the operands' types must match, or the conversions from
*/
assert((type == glsl_error_type)
|| ((type->base_type == GLSL_TYPE_BOOL)
- && is_glsl_type_scalar(type)));
+ && type->is_scalar()));
result = new ir_expression(operations[this->oper], type,
op[0], op[1]);
{
this->fields.structure = fields;
}
-};
-#define is_glsl_type_scalar(t) \
- (((t)->vector_elements == 0) \
- && ((t)->base_type >= GLSL_TYPE_UINT) \
- && ((t)->base_type <= GLSL_TYPE_BOOL))
+ /**
+ * Query whether or not a type is a scalar (non-vector and non-matrix).
+ */
+ bool is_scalar() const
+ {
+ return (vector_elements == 0)
+ && (base_type >= GLSL_TYPE_UINT)
+ && (base_type <= GLSL_TYPE_BOOL);
+ }
+};
#define is_glsl_type_vector(t) \
(((t)->vector_elements > 0) \