Factor out qualifier checking code for later reuse.
This commit is contained in:

committed by
Ian Romanick

parent
0e385196f6
commit
abd40b1521
@@ -1952,27 +1952,13 @@ ast_function::hir(exec_list *instructions,
|
|||||||
* definition.
|
* definition.
|
||||||
*/
|
*/
|
||||||
if (parameter_lists_match(& hir_parameters, & sig->parameters)) {
|
if (parameter_lists_match(& hir_parameters, & sig->parameters)) {
|
||||||
exec_list_iterator iter_a = hir_parameters.iterator();
|
const char *mismatch = sig->qualifiers_match(&hir_parameters);
|
||||||
exec_list_iterator iter_b = sig->parameters.iterator();
|
if (mismatch != NULL) {
|
||||||
|
YYLTYPE loc = this->get_location();
|
||||||
|
|
||||||
/* check that the qualifiers match. */
|
_mesa_glsl_error(&loc, state, "function `%s' parameter `%s' "
|
||||||
while (iter_a.has_next()) {
|
"qualifiers don't match prototype",
|
||||||
ir_variable *a = (ir_variable *)iter_a.get();
|
name, mismatch);
|
||||||
ir_variable *b = (ir_variable *)iter_b.get();
|
|
||||||
|
|
||||||
if (a->read_only != b->read_only ||
|
|
||||||
a->interpolation != b->interpolation ||
|
|
||||||
a->centroid != b->centroid) {
|
|
||||||
YYLTYPE loc = this->get_location();
|
|
||||||
|
|
||||||
_mesa_glsl_error(& loc, state,
|
|
||||||
"function `%s' parameter `%s' qualifiers "
|
|
||||||
"don't match prototype",
|
|
||||||
name, a->name);
|
|
||||||
}
|
|
||||||
|
|
||||||
iter_a.next();
|
|
||||||
iter_b.next();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sig->return_type != return_type) {
|
if (sig->return_type != return_type) {
|
||||||
|
26
ir.cpp
26
ir.cpp
@@ -338,6 +338,32 @@ ir_function_signature::ir_function_signature(const glsl_type *return_type)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const char *
|
||||||
|
ir_function_signature::qualifiers_match(exec_list *params)
|
||||||
|
{
|
||||||
|
exec_list_iterator iter_a = parameters.iterator();
|
||||||
|
exec_list_iterator iter_b = params->iterator();
|
||||||
|
|
||||||
|
/* check that the qualifiers match. */
|
||||||
|
while (iter_a.has_next()) {
|
||||||
|
ir_variable *a = (ir_variable *)iter_a.get();
|
||||||
|
ir_variable *b = (ir_variable *)iter_b.get();
|
||||||
|
|
||||||
|
if (a->read_only != b->read_only ||
|
||||||
|
a->interpolation != b->interpolation ||
|
||||||
|
a->centroid != b->centroid) {
|
||||||
|
|
||||||
|
/* parameter a's qualifiers don't match */
|
||||||
|
return a->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
iter_a.next();
|
||||||
|
iter_b.next();
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
ir_function::ir_function(const char *name)
|
ir_function::ir_function(const char *name)
|
||||||
: name(name)
|
: name(name)
|
||||||
{
|
{
|
||||||
|
7
ir.h
7
ir.h
@@ -206,6 +206,13 @@ public:
|
|||||||
*/
|
*/
|
||||||
const char *function_name() const;
|
const char *function_name() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check whether the qualifiers match between this signature's parameters
|
||||||
|
* and the supplied parameter list. If not, returns the name of the first
|
||||||
|
* parameter with mismatched qualifiers (for use in error messages).
|
||||||
|
*/
|
||||||
|
const char *qualifiers_match(exec_list *params);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function return type.
|
* Function return type.
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user