summaryrefslogtreecommitdiff
path: root/src/mesa/shader/slang/slang_compile_function.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/shader/slang/slang_compile_function.c')
-rw-r--r--src/mesa/shader/slang/slang_compile_function.c85
1 files changed, 33 insertions, 52 deletions
diff --git a/src/mesa/shader/slang/slang_compile_function.c b/src/mesa/shader/slang/slang_compile_function.c
index e6e0d89ddb..2f74050b86 100644
--- a/src/mesa/shader/slang/slang_compile_function.c
+++ b/src/mesa/shader/slang/slang_compile_function.c
@@ -71,7 +71,7 @@ slang_fixup_save(slang_fixup_table *fixups, GLuint address)
int
slang_function_construct(slang_function * func)
{
- func->kind = slang_func_ordinary;
+ func->kind = SLANG_FUNC_ORDINARY;
if (!slang_variable_construct(&func->header))
return 0;
@@ -127,6 +127,16 @@ slang_function_scope_destruct(slang_function_scope * scope)
/**
+ * Does this function have a non-void return value?
+ */
+GLboolean
+_slang_function_has_return_value(const slang_function *fun)
+{
+ return fun->header.type.specifier.type != SLANG_SPEC_VOID;
+}
+
+
+/**
* Search a list of functions for a particular function by name.
* \param funcs the list of functions to search
* \param a_name the name to search for
@@ -166,69 +176,40 @@ slang_function_scope_find(slang_function_scope * funcs, slang_function * fun,
for (i = 0; i < funcs->num_functions; i++) {
slang_function *f = &funcs->functions[i];
+ const GLuint haveRetValue = 0;
+#if 0
+ = (f->header.type.specifier.type != SLANG_SPEC_VOID);
+#endif
unsigned int j;
+ /*
+ printf("Compare name %s to %s (ret %u, %d, %d)\n",
+ (char *) fun->header.a_name, (char *) f->header.a_name,
+ haveRetValue,
+ fun->param_count, f->param_count);
+ */
+
if (fun->header.a_name != f->header.a_name)
continue;
if (fun->param_count != f->param_count)
continue;
- for (j = 0; j < fun->param_count; j++) {
+ for (j = haveRetValue; j < fun->param_count; j++) {
if (!slang_type_specifier_equal
- (&fun->parameters->variables[j].type.specifier,
- &f->parameters->variables[j].type.specifier))
+ (&fun->parameters->variables[j]->type.specifier,
+ &f->parameters->variables[j]->type.specifier))
break;
}
- if (j == fun->param_count)
+ if (j == fun->param_count) {
+ /*
+ printf("Found match\n");
+ */
return f;
+ }
}
+ /*
+ printf("Not found\n");
+ */
if (all_scopes && funcs->outer_scope != NULL)
return slang_function_scope_find(funcs->outer_scope, fun, 1);
return NULL;
}
-
-/*
- * _slang_build_export_code_table()
- */
-
-GLboolean
-_slang_build_export_code_table(slang_export_code_table * tbl,
- slang_function_scope * funs,
- slang_code_unit * unit)
-{
- slang_atom mainAtom;
- GLuint i;
-
- mainAtom = slang_atom_pool_atom(tbl->atoms, "main");
- if (mainAtom == SLANG_ATOM_NULL)
- return GL_FALSE;
-
- for (i = 0; i < funs->num_functions; i++) {
- if (funs->functions[i].header.a_name == mainAtom) {
- slang_function *fun = &funs->functions[i];
- slang_export_code_entry *e;
- slang_assemble_ctx A;
-
- e = slang_export_code_table_add(tbl);
- if (e == NULL)
- return GL_FALSE;
- e->address = unit->object->assembly.count;
- e->name = slang_atom_pool_atom(tbl->atoms, "@main");
- if (e->name == SLANG_ATOM_NULL)
- return GL_FALSE;
-
- A.file = &unit->object->assembly;
- A.mach = &unit->object->machine;
- A.atoms = &unit->object->atompool;
- A.space.funcs = &unit->funs;
- A.space.structs = &unit->structs;
- A.space.vars = &unit->vars;
- slang_assembly_file_push_label(&unit->object->assembly,
- slang_asm_local_alloc, 20);
- slang_assembly_file_push_label(&unit->object->assembly,
- slang_asm_enter, 20);
- _slang_assemble_function_call(&A, fun, NULL, 0, GL_FALSE);
- slang_assembly_file_push(&unit->object->assembly, slang_asm_exit);
- }
- }
- return GL_TRUE;
-}