slang_resolve_variable(slang_operation *oper)
{
if (oper->type == SLANG_OPER_IDENTIFIER && !oper->var) {
- oper->var = _slang_locate_variable(oper->locals, oper->a_id, GL_TRUE);
+ oper->var = _slang_variable_locate(oper->locals, oper->a_id, GL_TRUE);
}
}
switch (oper->type) {
case SLANG_OPER_VARIABLE_DECL:
{
- slang_variable *v = _slang_locate_variable(oper->locals,
+ slang_variable *v = _slang_variable_locate(oper->locals,
oper->a_id, GL_TRUE);
assert(v);
if (v->initializer && oper->num_children == 0) {
slang_atom id = oper->a_id;
slang_variable *v;
GLuint i;
- v = _slang_locate_variable(oper->locals, id, GL_TRUE);
+ v = _slang_variable_locate(oper->locals, id, GL_TRUE);
if (!v) {
_mesa_problem(NULL, "var %s not found!\n", (char *) oper->a_id);
return;
_slang_make_struct_constructor(slang_assemble_ctx *A, slang_struct *str)
{
const GLint numFields = str->fields->num_variables;
- slang_function *fun = slang_new_function(SLANG_FUNC_CONSTRUCTOR);
+ slang_function *fun = slang_function_new(SLANG_FUNC_CONSTRUCTOR);
/* function header (name, return type) */
fun->header.a_name = str->a_name;
static slang_function *
_slang_make_array_constructor(slang_assemble_ctx *A, slang_operation *oper)
{
- slang_function *fun = slang_new_function(SLANG_FUNC_CONSTRUCTOR);
+ slang_function *fun = slang_function_new(SLANG_FUNC_CONSTRUCTOR);
if (fun) {
slang_type_specifier_type baseType =
slang_type_specifier_type_from_string((char *) oper->a_id);
}
else {
/* Try to find function by name and exact argument type matching */
- fun = _slang_locate_function(A->space.funcs, atom, params, param_count,
+ fun = _slang_function_locate(A->space.funcs, atom, params, param_count,
&A->space, A->atoms, A->log, &error);
}
}
/* lookup the object/variable */
- var = _slang_locate_variable(oper->locals, oper->a_obj, GL_TRUE);
+ var = _slang_variable_locate(oper->locals, oper->a_obj, GL_TRUE);
if (!var || var->type.specifier.type != SLANG_SPEC_ARRAY) {
slang_info_log_error(A->log,
"Undefined object '%s'", (char *) oper->a_obj);
#if 1 /* DEBUG */
{
- slang_variable *v
- = _slang_locate_variable(oper->locals, a_retVal, GL_TRUE);
+ slang_variable *v =
+ _slang_variable_locate(oper->locals, a_retVal, GL_TRUE);
if (!v) {
/* trying to return a value in a void-valued function */
return NULL;
switch (oper->type) {
case SLANG_OPER_IDENTIFIER:
- var = _slang_locate_variable(oper->locals, oper->a_id, GL_TRUE);
+ var = _slang_variable_locate(oper->locals, oper->a_id, GL_TRUE);
if (var && var->type.qualifier == SLANG_QUAL_CONST)
return GL_TRUE;
return GL_FALSE;
assert(oper->num_children <= 1);
/* lookup the variable by name */
- var = _slang_locate_variable(oper->locals, oper->a_id, GL_TRUE);
+ var = _slang_variable_locate(oper->locals, oper->a_id, GL_TRUE);
if (!var)
return NULL; /* "shouldn't happen" */
* use it. Otherwise, use the oper's var id.
*/
slang_atom name = oper->var ? oper->var->a_name : oper->a_id;
- slang_variable *var = _slang_locate_variable(oper->locals, name, GL_TRUE);
+ slang_variable *var = _slang_variable_locate(oper->locals, name, GL_TRUE);
slang_ir_node *n = new_var(A, var);
if (!n) {
slang_info_log_error(A->log, "undefined variable '%s'", (char *) name);
if (oper->children[0].type == SLANG_OPER_IDENTIFIER) {
/* Check that var is writeable */
slang_variable *var
- = _slang_locate_variable(oper->children[0].locals,
+ = _slang_variable_locate(oper->children[0].locals,
oper->children[0].a_id, GL_TRUE);
if (!var) {
slang_info_log_error(A->log, "undefined variable '%s'",
result = GL_TRUE;
*len = (GLint) array_size.literal[0];
} else if (array_size.type == SLANG_OPER_IDENTIFIER) {
- slang_variable *var = _slang_locate_variable(array_size.locals, array_size.a_id, GL_TRUE);
+ slang_variable *var = _slang_variable_locate(array_size.locals, array_size.a_id, GL_TRUE);
if (!var) {
slang_info_log_error(C->L, "undefined variable '%s'",
(char *) array_size.a_id);
RETURN0;
}
a_name = parse_identifier(C);
- if (_slang_locate_variable(st->fields, a_name, GL_FALSE)) {
+ if (_slang_variable_locate(st->fields, a_name, GL_FALSE)) {
slang_info_log_error(C->L, "duplicate field '%s'", (char *) a_name);
RETURN0;
}
a_name = parse_identifier(C);
/* check if name is already in this scope */
- if (_slang_locate_variable(O->vars, a_name, GL_FALSE)) {
+ if (_slang_variable_locate(O->vars, a_name, GL_FALSE)) {
slang_info_log_error(C->L,
"declaration of '%s' conflicts with previous declaration",
(char *) a_name);
slang_function *
-slang_new_function(slang_function_kind kind)
+slang_function_new(slang_function_kind kind)
{
slang_function *fun = (slang_function *)
_mesa_malloc(sizeof(slang_function));
* 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_function_locate(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)
extern int slang_function_construct(slang_function *);
extern void slang_function_destruct(slang_function *);
-extern slang_function *slang_new_function(slang_function_kind kind);
+extern slang_function *slang_function_new(slang_function_kind kind);
+
+extern GLboolean
+_slang_function_has_return_value(const slang_function *fun);
/**
extern void
slang_function_scope_destruct(slang_function_scope *);
-extern GLboolean
-_slang_function_has_return_value(const slang_function *fun);
-
extern int
slang_function_scope_find_by_name(slang_function_scope *, slang_atom, int);
slang_function_scope_find(slang_function_scope *, slang_function *, int);
extern struct slang_function_ *
-_slang_locate_function(const struct slang_function_scope_ *funcs,
+_slang_function_locate(const struct slang_function_scope_ *funcs,
slang_atom name, struct slang_operation_ *params,
GLuint num_params,
const struct slang_name_space_ *space,
if (oper->type == SLANG_OPER_VARIABLE_DECL) {
/* search/replace in the initializer */
slang_variable *var;
- var = _slang_locate_variable(oper->locals, oper->a_id, GL_TRUE);
+ var = _slang_variable_locate(oper->locals, oper->a_id, GL_TRUE);
if (var && var->initializer) {
slang_replace_scope(var->initializer, oldScope, newScope);
}
* \param all if true, search parent scopes too.
*/
slang_variable *
-_slang_locate_variable(const slang_variable_scope * scope,
+_slang_variable_locate(const slang_variable_scope * scope,
const slang_atom a_name, GLboolean all)
{
while (scope) {
slang_variable_copy(slang_variable *, const slang_variable *);
extern slang_variable *
-_slang_locate_variable(const slang_variable_scope *, const slang_atom a_name,
+_slang_variable_locate(const slang_variable_scope *, const slang_atom a_name,
GLboolean all);
assert(op->num_children == 0 || op->num_children == 1);
{
slang_variable *v;
- v = _slang_locate_variable(op->locals, op->a_id, GL_TRUE);
+ v = _slang_variable_locate(op->locals, op->a_id, GL_TRUE);
if (v) {
const slang_variable_scope *scope;
spaces(indent);
case SLANG_OPER_CALL:
#if 0
slang_function *fun
- = _slang_locate_function(A->space.funcs, oper->a_id,
+ = _slang_function_locate(A->space.funcs, oper->a_id,
oper->children,
oper->num_children, &A->space, A->atoms);
#endif
/* look for user-defined constant */
{
slang_variable *var;
- var = _slang_locate_variable(oper->locals, oper->a_id, GL_TRUE);
+ var = _slang_variable_locate(oper->locals, oper->a_id, GL_TRUE);
if (var) {
if (var->type.qualifier == SLANG_QUAL_CONST &&
var->initializer &&
{
GLboolean error;
- *funFound = _slang_locate_function(space->funcs, a_name, params,
+ *funFound = _slang_function_locate(space->funcs, a_name, params,
num_params, space, atoms, log, &error);
if (error)
return GL_FALSE;
case SLANG_OPER_VARIABLE_DECL:
{
slang_variable *var;
- var = _slang_locate_variable(op->locals, op->a_id, GL_TRUE);
+ var = _slang_variable_locate(op->locals, op->a_id, GL_TRUE);
if (!var) {
slang_info_log_error(log, "undefined variable '%s'",
(char *) op->a_id);
if (_ti.spec.type == SLANG_SPEC_STRUCT) {
slang_variable *field;
- field = _slang_locate_variable(_ti.spec._struct->fields, op->a_id,
+ field = _slang_variable_locate(_ti.spec._struct->fields, op->a_id,
GL_FALSE);
if (field == NULL) {
slang_typeinfo_destruct(&_ti);