mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-24 17:30:12 +01:00
ir_constant: Add get_record_field query
This commit is contained in:
parent
eeedd355cf
commit
b94c29a47b
2 changed files with 28 additions and 0 deletions
26
ir.cpp
26
ir.cpp
|
|
@ -406,6 +406,32 @@ ir_constant::get_uint_component(unsigned i) const
|
|||
}
|
||||
|
||||
|
||||
ir_constant *
|
||||
ir_constant::get_record_field(const char *name)
|
||||
{
|
||||
int idx = this->type->field_index(name);
|
||||
|
||||
if (idx < 0)
|
||||
return NULL;
|
||||
|
||||
if (this->components.is_empty())
|
||||
return NULL;
|
||||
|
||||
exec_node *node = this->components.head;
|
||||
for (int i = 0; i < idx; i++) {
|
||||
node = node->next;
|
||||
|
||||
/* If the end of the list is encountered before the element matching the
|
||||
* requested field is found, return NULL.
|
||||
*/
|
||||
if (node->is_tail_sentinal())
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return (ir_constant *) node;
|
||||
}
|
||||
|
||||
|
||||
ir_dereference_variable::ir_dereference_variable(ir_variable *var)
|
||||
{
|
||||
this->var = var;
|
||||
|
|
|
|||
2
ir.h
2
ir.h
|
|
@ -1071,6 +1071,8 @@ public:
|
|||
unsigned get_uint_component(unsigned i) const;
|
||||
/*@}*/
|
||||
|
||||
ir_constant *get_record_field(const char *name);
|
||||
|
||||
/**
|
||||
* Value of the constant.
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue