summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2010-03-31 09:11:39 -1000
committerEric Anholt <eric@anholt.net>2010-03-31 09:17:39 -1000
commitb82c0c31aea2d02721f162b94b9f591242d9364e (patch)
treedad610e6b6442b86f18fe21b4baa1e0a7b07ff1b
parentb97ee2e260efb68849ee13402072b7d7185746d5 (diff)
Implement logical operators.
Fixes parser9.frag.
-rw-r--r--ast_to_hir.cpp20
1 files changed, 19 insertions, 1 deletions
diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp
index 708656a6fc..1ebcf45e70 100644
--- a/ast_to_hir.cpp
+++ b/ast_to_hir.cpp
@@ -691,7 +691,25 @@ ast_expression::hir(exec_list *instructions,
case ast_logic_xor:
case ast_logic_or:
case ast_logic_not:
- /* FINISHME: Implement logical operators. */
+ op[0] = this->subexpressions[0]->hir(instructions, state);
+ op[1] = this->subexpressions[1]->hir(instructions, state);
+
+ if (!op[0]->type->is_boolean() || !op[0]->type->is_scalar()) {
+ YYLTYPE loc = this->subexpressions[0]->get_location();
+
+ _mesa_glsl_error(& loc, state, "LHS of `%s' must be scalar boolean",
+ operator_string(this->oper));
+ }
+
+ if (!op[1]->type->is_boolean() || !op[1]->type->is_scalar()) {
+ YYLTYPE loc = this->subexpressions[1]->get_location();
+
+ _mesa_glsl_error(& loc, state, "RHS of `%s' must be scalar boolean",
+ operator_string(this->oper));
+ }
+
+ result = new ir_expression(operations[this->oper], glsl_type::bool_type,
+ op[0], op[1]);
break;
case ast_mul_assign: