mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-07 02:48:06 +02:00
Allow int->float argument conversion in _slang_locate_function().
This commit is contained in:
parent
d003877c66
commit
9ea2315d2d
1 changed files with 37 additions and 7 deletions
|
|
@ -231,17 +231,44 @@ slang_type_specifier_copy(slang_type_specifier * x,
|
||||||
return GL_TRUE;
|
return GL_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test if two types are equal.
|
||||||
|
*/
|
||||||
GLboolean
|
GLboolean
|
||||||
slang_type_specifier_equal(const slang_type_specifier * x,
|
slang_type_specifier_equal(const slang_type_specifier * x,
|
||||||
const slang_type_specifier * y)
|
const slang_type_specifier * y)
|
||||||
{
|
{
|
||||||
if (x->type != y->type)
|
if (x->type != y->type)
|
||||||
return 0;
|
return GL_FALSE;
|
||||||
if (x->type == slang_spec_struct)
|
if (x->type == slang_spec_struct)
|
||||||
return slang_struct_equal(x->_struct, y->_struct);
|
return slang_struct_equal(x->_struct, y->_struct);
|
||||||
if (x->type == slang_spec_array)
|
if (x->type == slang_spec_array)
|
||||||
return slang_type_specifier_equal(x->_array, y->_array);
|
return slang_type_specifier_equal(x->_array, y->_array);
|
||||||
return 1;
|
return GL_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* As above, but allow float/int casting.
|
||||||
|
*/
|
||||||
|
static GLboolean
|
||||||
|
slang_type_specifier_compatible(const slang_type_specifier * x,
|
||||||
|
const slang_type_specifier * y)
|
||||||
|
{
|
||||||
|
/* special case: float == int */
|
||||||
|
if (x->type == slang_spec_int && y->type == slang_spec_float) {
|
||||||
|
return GL_TRUE;
|
||||||
|
}
|
||||||
|
/* XXX may need to add bool/int compatibility, etc */
|
||||||
|
|
||||||
|
if (x->type != y->type)
|
||||||
|
return GL_FALSE;
|
||||||
|
if (x->type == slang_spec_struct)
|
||||||
|
return slang_struct_equal(x->_struct, y->_struct);
|
||||||
|
if (x->type == slang_spec_array)
|
||||||
|
return slang_type_specifier_compatible(x->_array, y->_array);
|
||||||
|
return GL_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -660,12 +687,13 @@ _slang_typeof_operation_(const slang_operation * op,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lookup a function according to name and parameter count/types.
|
||||||
|
*/
|
||||||
slang_function *
|
slang_function *
|
||||||
_slang_locate_function(const slang_function_scope * funcs, slang_atom a_name,
|
_slang_locate_function(const slang_function_scope * funcs, slang_atom a_name,
|
||||||
const slang_operation * args, GLuint num_args,
|
const slang_operation * args, GLuint num_args,
|
||||||
const slang_name_space * space,
|
const slang_name_space * space, slang_atom_pool * atoms)
|
||||||
slang_atom_pool * atoms)
|
|
||||||
{
|
{
|
||||||
GLuint i;
|
GLuint i;
|
||||||
|
|
||||||
|
|
@ -689,14 +717,16 @@ _slang_locate_function(const slang_function_scope * funcs, slang_atom a_name,
|
||||||
slang_typeinfo_destruct(&ti);
|
slang_typeinfo_destruct(&ti);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (!slang_type_specifier_equal(&ti.spec,
|
if (!slang_type_specifier_compatible(&ti.spec,
|
||||||
&f->parameters->variables[j]->type.specifier)) {
|
&f->parameters->variables[j]->type.specifier)) {
|
||||||
slang_typeinfo_destruct(&ti);
|
slang_typeinfo_destruct(&ti);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
slang_typeinfo_destruct(&ti);
|
slang_typeinfo_destruct(&ti);
|
||||||
|
|
||||||
/* "out" and "inout" formal parameter requires the actual parameter to be l-value */
|
/* "out" and "inout" formal parameter requires the actual
|
||||||
|
* parameter to be l-value.
|
||||||
|
*/
|
||||||
if (!ti.can_be_referenced &&
|
if (!ti.can_be_referenced &&
|
||||||
(f->parameters->variables[j]->type.qualifier == slang_qual_out ||
|
(f->parameters->variables[j]->type.qualifier == slang_qual_out ||
|
||||||
f->parameters->variables[j]->type.qualifier == slang_qual_inout))
|
f->parameters->variables[j]->type.qualifier == slang_qual_inout))
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue