ir_expression: Add static operator_string method

I've used this in quite a few debug commits that never reached an
up-stream tree.
This commit is contained in:
Ian Romanick
2010-08-27 13:53:25 -07:00
parent 79082b8aca
commit 351525d534
2 changed files with 13 additions and 3 deletions

View File

@@ -287,11 +287,15 @@ static const char *const operator_strs[] = {
"pow", "pow",
}; };
const char *ir_expression::operator_string(ir_expression_operation op)
{
assert((unsigned int) op < Elements(operator_strs));
return operator_strs[op];
}
const char *ir_expression::operator_string() const char *ir_expression::operator_string()
{ {
assert((unsigned int) operation <= return operator_string(this->operation);
sizeof(operator_strs) / sizeof(operator_strs[0]));
return operator_strs[operation];
} }
ir_expression_operation ir_expression_operation

View File

@@ -730,6 +730,12 @@ public:
*/ */
const char *operator_string(); const char *operator_string();
/**
* Return a string representing this expression's operator.
*/
static const char *operator_string(ir_expression_operation);
/** /**
* Do a reverse-lookup to translate the given string into an operator. * Do a reverse-lookup to translate the given string into an operator.
*/ */