/**
+ * Test if an operation is boolean.
+ */
+static GLboolean
+_slang_is_boolean(slang_assemble_ctx *A, slang_operation *oper)
+{
+ slang_typeinfo type;
+ GLboolean isBool;
+
+ slang_typeinfo_construct(&type);
+ _slang_typeof_operation(A, oper, &type);
+ isBool = (type.spec.type == SLANG_SPEC_BOOL);
+ slang_typeinfo_destruct(&type);
+ return isBool;
+}
+
+
+/**
* Generate loop code using high-level IR_LOOP instruction
*/
static slang_ir_node *
GLboolean isConst, constTrue;
/* type-check expression */
- if (!_slang_is_scalar_or_boolean(A, &oper->children[0])) {
+ if (!_slang_is_boolean(A, &oper->children[0])) {
slang_info_log_error(A->log, "scalar/boolean expression expected for 'while'");
return NULL;
}
GLboolean isConst, constTrue;
/* type-check expression */
- if (!_slang_is_scalar_or_boolean(A, &oper->children[1])) {
+ if (!_slang_is_boolean(A, &oper->children[1])) {
slang_info_log_error(A->log, "scalar/boolean expression expected for 'do/while'");
return NULL;
}
GLboolean isConst, constTrue;
/* type-check expression */
+ if (!_slang_is_boolean(A, &oper->children[0])) {
+ slang_info_log_error(A->log, "boolean expression expected for 'while'");
+ return NULL;
+ }
+
if (!_slang_is_scalar_or_boolean(A, &oper->children[0])) {
slang_info_log_error(A->log, "scalar/boolean expression expected for 'if'");
return NULL;