Track the function that is currently being defined
Later this will allow type checking for return statements.
This commit is contained in:
@@ -63,6 +63,8 @@ _mesa_ast_to_hir(exec_list *instructions, struct _mesa_glsl_parse_state *state)
|
|||||||
|
|
||||||
_mesa_glsl_initialize_variables(instructions, state);
|
_mesa_glsl_initialize_variables(instructions, state);
|
||||||
|
|
||||||
|
state->current_function = NULL;
|
||||||
|
|
||||||
foreach (ptr, & state->translation_unit) {
|
foreach (ptr, & state->translation_unit) {
|
||||||
((ast_node *)ptr)->hir(instructions, state);
|
((ast_node *)ptr)->hir(instructions, state);
|
||||||
}
|
}
|
||||||
@@ -1070,6 +1072,9 @@ ast_function_definition::hir(exec_list *instructions,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
assert(state->current_function == NULL);
|
||||||
|
state->current_function = signature;
|
||||||
|
|
||||||
ast_function_parameters_to_hir(& this->prototype->parameters,
|
ast_function_parameters_to_hir(& this->prototype->parameters,
|
||||||
& signature->parameters,
|
& signature->parameters,
|
||||||
state);
|
state);
|
||||||
@@ -1115,6 +1120,8 @@ ast_function_definition::hir(exec_list *instructions,
|
|||||||
|
|
||||||
state->symbols->pop_scope();
|
state->symbols->pop_scope();
|
||||||
|
|
||||||
|
assert(state->current_function == signature);
|
||||||
|
state->current_function = NULL;
|
||||||
|
|
||||||
/* Function definitions do not have r-values.
|
/* Function definitions do not have r-values.
|
||||||
*/
|
*/
|
||||||
|
@@ -43,6 +43,14 @@ struct _mesa_glsl_parse_state {
|
|||||||
unsigned language_version;
|
unsigned language_version;
|
||||||
enum _mesa_glsl_parser_targets target;
|
enum _mesa_glsl_parser_targets target;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* During AST to IR conversion, pointer to current IR function
|
||||||
|
*
|
||||||
|
* Will be \c NULL whenever the AST to IR conversion is not inside a
|
||||||
|
* function definition.
|
||||||
|
*/
|
||||||
|
class ir_function_signature *current_function;
|
||||||
|
|
||||||
/** Was there an error during compilation? */
|
/** Was there an error during compilation? */
|
||||||
bool error;
|
bool error;
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user