diff options
author | Brian Paul <[email protected]> | 2008-12-12 10:03:31 -0700 |
---|---|---|
committer | Brian Paul <[email protected]> | 2009-01-06 09:09:03 -0700 |
commit | fbc55bfbb852e16b445fb62dca3399949f87dfaf (patch) | |
tree | 6dfa2c854cd93ee0aea1e315a13b598fcaeb58d3 /src/mesa | |
parent | a7e3f85fd6ba0feb1c435b4e2f0a27016f7955cf (diff) |
mesa: move _slang_locate_function() to different file
(cherry picked from commit ea9dc3879f4cbbaa8ce9e305884a4afdc1fdd28a)
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/shader/slang/slang_compile_function.c | 71 | ||||
-rw-r--r-- | src/mesa/shader/slang/slang_compile_function.h | 11 | ||||
-rw-r--r-- | src/mesa/shader/slang/slang_typeinfo.c | 73 | ||||
-rw-r--r-- | src/mesa/shader/slang/slang_typeinfo.h | 14 |
4 files changed, 86 insertions, 83 deletions
diff --git a/src/mesa/shader/slang/slang_compile_function.c b/src/mesa/shader/slang/slang_compile_function.c index eca75dcb216..72132ac8dad 100644 --- a/src/mesa/shader/slang/slang_compile_function.c +++ b/src/mesa/shader/slang/slang_compile_function.c @@ -189,3 +189,74 @@ slang_function_scope_find(slang_function_scope * funcs, slang_function * fun, return slang_function_scope_find(funcs->outer_scope, fun, 1); return NULL; } + + +/** + * Lookup a function according to name and parameter count/types. + */ +slang_function * +_slang_locate_function(const slang_function_scope * funcs, slang_atom a_name, + slang_operation * args, GLuint num_args, + const slang_name_space * space, slang_atom_pool * atoms, + slang_info_log *log, GLboolean *error) +{ + slang_typeinfo arg_ti[100]; + GLuint i; + + *error = GL_FALSE; + + /* determine type of each argument */ + assert(num_args < 100); + for (i = 0; i < num_args; i++) { + if (!slang_typeinfo_construct(&arg_ti[i])) + return NULL; + if (!_slang_typeof_operation_(&args[i], space, &arg_ti[i], atoms, log)) { + return NULL; + } + } + + /* loop over function scopes */ + while (funcs) { + + /* look for function with matching name and argument/param types */ + for (i = 0; i < funcs->num_functions; i++) { + slang_function *f = &funcs->functions[i]; + const GLuint haveRetValue = _slang_function_has_return_value(f); + GLuint j; + + if (a_name != f->header.a_name) + continue; + if (f->param_count - haveRetValue != num_args) + continue; + + /* compare parameter / argument types */ + for (j = 0; j < num_args; j++) { + if (!slang_type_specifier_compatible(&arg_ti[j].spec, + &f->parameters->variables[j]->type.specifier)) { + /* param/arg types don't match */ + break; + } + + /* "out" and "inout" formal parameter requires the actual + * argument to be an l-value. + */ + if (!arg_ti[j].can_be_referenced && + (f->parameters->variables[j]->type.qualifier == SLANG_QUAL_OUT || + f->parameters->variables[j]->type.qualifier == SLANG_QUAL_INOUT)) { + /* param is not an lvalue! */ + *error = GL_TRUE; + return NULL; + } + } + + if (j == num_args) { + /* name and args match! */ + return f; + } + } + + funcs = funcs->outer_scope; + } + + return NULL; +} diff --git a/src/mesa/shader/slang/slang_compile_function.h b/src/mesa/shader/slang/slang_compile_function.h index bd44378b698..85e69432aca 100644 --- a/src/mesa/shader/slang/slang_compile_function.h +++ b/src/mesa/shader/slang/slang_compile_function.h @@ -26,8 +26,6 @@ #define SLANG_COMPILE_FUNCTION_H -struct slang_code_unit_; - /** * Types of functions. */ @@ -82,4 +80,13 @@ slang_function_scope_find_by_name(slang_function_scope *, slang_atom, int); extern slang_function * slang_function_scope_find(slang_function_scope *, slang_function *, int); +extern struct slang_function_ * +_slang_locate_function(const struct slang_function_scope_ *funcs, + slang_atom name, struct slang_operation_ *params, + GLuint num_params, + const slang_name_space *space, + slang_atom_pool *atoms, slang_info_log *log, + GLboolean *error); + + #endif /* SLANG_COMPILE_FUNCTION_H */ diff --git a/src/mesa/shader/slang/slang_typeinfo.c b/src/mesa/shader/slang/slang_typeinfo.c index 7fa357ca14d..430fc10b672 100644 --- a/src/mesa/shader/slang/slang_typeinfo.c +++ b/src/mesa/shader/slang/slang_typeinfo.c @@ -265,7 +265,7 @@ slang_type_specifier_equal(const slang_type_specifier * x, /** * As above, but allow float/int casting. */ -static GLboolean +GLboolean slang_type_specifier_compatible(const slang_type_specifier * x, const slang_type_specifier * y) { @@ -788,77 +788,6 @@ _slang_typeof_operation_(slang_operation * op, /** - * Lookup a function according to name and parameter count/types. - */ -slang_function * -_slang_locate_function(const slang_function_scope * funcs, slang_atom a_name, - slang_operation * args, GLuint num_args, - const slang_name_space * space, slang_atom_pool * atoms, - slang_info_log *log, GLboolean *error) -{ - slang_typeinfo arg_ti[100]; - GLuint i; - - *error = GL_FALSE; - - /* determine type of each argument */ - assert(num_args < 100); - for (i = 0; i < num_args; i++) { - if (!slang_typeinfo_construct(&arg_ti[i])) - return NULL; - if (!_slang_typeof_operation_(&args[i], space, &arg_ti[i], atoms, log)) { - return NULL; - } - } - - /* loop over function scopes */ - while (funcs) { - - /* look for function with matching name and argument/param types */ - for (i = 0; i < funcs->num_functions; i++) { - slang_function *f = &funcs->functions[i]; - const GLuint haveRetValue = _slang_function_has_return_value(f); - GLuint j; - - if (a_name != f->header.a_name) - continue; - if (f->param_count - haveRetValue != num_args) - continue; - - /* compare parameter / argument types */ - for (j = 0; j < num_args; j++) { - if (!slang_type_specifier_compatible(&arg_ti[j].spec, - &f->parameters->variables[j]->type.specifier)) { - /* param/arg types don't match */ - break; - } - - /* "out" and "inout" formal parameter requires the actual - * argument to be an l-value. - */ - if (!arg_ti[j].can_be_referenced && - (f->parameters->variables[j]->type.qualifier == SLANG_QUAL_OUT || - f->parameters->variables[j]->type.qualifier == SLANG_QUAL_INOUT)) { - /* param is not an lvalue! */ - *error = GL_TRUE; - return NULL; - } - } - - if (j == num_args) { - /* name and args match! */ - return f; - } - } - - funcs = funcs->outer_scope; - } - - return NULL; -} - - -/** * Determine if a type is a matrix. * \return GL_TRUE if is a matrix, GL_FALSE otherwise. */ diff --git a/src/mesa/shader/slang/slang_typeinfo.h b/src/mesa/shader/slang/slang_typeinfo.h index cde468bc4e2..5e57fbb03e3 100644 --- a/src/mesa/shader/slang/slang_typeinfo.h +++ b/src/mesa/shader/slang/slang_typeinfo.h @@ -68,15 +68,6 @@ typedef struct slang_assemble_ctx_ } slang_assemble_ctx; -extern struct slang_function_ * -_slang_locate_function(const struct slang_function_scope_ *funcs, - slang_atom name, struct slang_operation_ *params, - GLuint num_params, - const slang_name_space *space, - slang_atom_pool *atoms, slang_info_log *log, - GLboolean *error); - - extern GLboolean _slang_is_swizzle(const char *field, GLuint rows, slang_swizzle *swz); @@ -159,6 +150,11 @@ slang_type_specifier_equal(const slang_type_specifier *, const slang_type_specifier *); +extern GLboolean +slang_type_specifier_compatible(const slang_type_specifier * x, + const slang_type_specifier * y); + + typedef struct slang_typeinfo_ { GLboolean can_be_referenced; |