diff options
author | Ian Romanick <ian.d.romanick@intel.com> | 2010-03-31 16:28:51 -0700 |
---|---|---|
committer | Ian Romanick <ian.d.romanick@intel.com> | 2010-03-31 16:28:51 -0700 |
commit | 68515ee6c2a41cf5c0476b3309fcb050ef37b0d2 (patch) | |
tree | 418dae985498f947497f10b77c9cd78b266352c2 | |
parent | b6326abb859550963446affe9123085fd57f9525 (diff) |
Refactor parts of match_function_by_name into process_parameters and process_call
These will be used in the functions that implement calls to array constructors.
-rw-r--r-- | ast_function.cpp | 71 |
1 files changed, 49 insertions, 22 deletions
diff --git a/ast_function.cpp b/ast_function.cpp index 74ae5d8962..340873ae41 100644 --- a/ast_function.cpp +++ b/ast_function.cpp @@ -27,23 +27,14 @@ #include "glsl_types.h" #include "ir.h" -static ir_rvalue * -match_function_by_name(exec_list *instructions, const char *name, - YYLTYPE *loc, simple_node *parameters, - struct _mesa_glsl_parse_state *state) +static unsigned +process_parameters(exec_list *instructions, exec_list *actual_parameters, + simple_node *parameters, + struct _mesa_glsl_parse_state *state) { - ir_function *f = state->symbols->get_function(name); - - if (f == NULL) { - _mesa_glsl_error(loc, state, "function `%s' undeclared", name); - return ir_call::get_error_instruction(); - } - - /* Once we've determined that the function being called might exist, - * process the parameters. - */ - exec_list actual_parameters; simple_node *const first = parameters; + unsigned count = 0; + if (first != NULL) { simple_node *ptr = first; do { @@ -51,20 +42,31 @@ match_function_by_name(exec_list *instructions, const char *name, ((ast_node *) ptr)->hir(instructions, state); ptr = ptr->next; - actual_parameters.push_tail(result); + actual_parameters->push_tail(result); + count++; } while (ptr != first); } - /* After processing the function's actual parameters, try to find an - * overload of the function that matches. - */ + return count; +} + + +static ir_rvalue * +process_call(exec_list *instructions, ir_function *f, + YYLTYPE *loc, exec_list *actual_parameters, + struct _mesa_glsl_parse_state *state) +{ const ir_function_signature *sig = - f->matching_signature(& actual_parameters); + f->matching_signature(actual_parameters); + + /* The instructions param will be used when the FINISHMEs below are done */ + (void) instructions; + if (sig != NULL) { /* FINISHME: The list of actual parameters needs to be modified to * FINISHME: include any necessary conversions. */ - return new ir_call(sig, & actual_parameters); + return new ir_call(sig, actual_parameters); } else { /* FINISHME: Log a better error message here. G++ will show the types * FINISHME: of the actual parameters and the set of candidate @@ -72,9 +74,34 @@ match_function_by_name(exec_list *instructions, const char *name, * FINISHME: multiple functions match. */ _mesa_glsl_error(loc, state, "no matching function for call to `%s'", - name); + f->name); + return ir_call::get_error_instruction(); + } +} + + +static ir_rvalue * +match_function_by_name(exec_list *instructions, const char *name, + YYLTYPE *loc, simple_node *parameters, + struct _mesa_glsl_parse_state *state) +{ + ir_function *f = state->symbols->get_function(name); + + if (f == NULL) { + _mesa_glsl_error(loc, state, "function `%s' undeclared", name); return ir_call::get_error_instruction(); } + + /* Once we've determined that the function being called might exist, + * process the parameters. + */ + exec_list actual_parameters; + process_parameters(instructions, &actual_parameters, parameters, state); + + /* After processing the function's actual parameters, try to find an + * overload of the function that matches. + */ + return process_call(instructions, f, loc, &actual_parameters, state); } |