summaryrefslogtreecommitdiff
path: root/src/mesa/shader/slang
diff options
context:
space:
mode:
authorMichal Krol <mjkrol@gmail.org>2006-05-16 10:01:07 +0000
committerMichal Krol <mjkrol@gmail.org>2006-05-16 10:01:07 +0000
commita67330d157ffe05602a3163c946aa97e29cb6bb5 (patch)
tree887c324eb714adc2f2ba0b7b83cdf138202f5bd9 /src/mesa/shader/slang
parentd1b40400d64a8ab7f4dc64410e165e7c49d30a28 (diff)
Cleanup code. Change constructor prototype.
Diffstat (limited to 'src/mesa/shader/slang')
-rw-r--r--src/mesa/shader/slang/slang_compile_function.c46
-rw-r--r--src/mesa/shader/slang/slang_compile_function.h11
-rw-r--r--src/mesa/shader/slang/slang_compile_operation.c6
-rw-r--r--src/mesa/shader/slang/slang_compile_struct.c31
-rw-r--r--src/mesa/shader/slang/slang_compile_struct.h6
-rw-r--r--src/mesa/shader/slang/slang_compile_variable.c17
-rw-r--r--src/mesa/shader/slang/slang_compile_variable.h6
7 files changed, 58 insertions, 65 deletions
diff --git a/src/mesa/shader/slang/slang_compile_function.c b/src/mesa/shader/slang/slang_compile_function.c
index ff9854f33b..eb8fd1bd40 100644
--- a/src/mesa/shader/slang/slang_compile_function.c
+++ b/src/mesa/shader/slang/slang_compile_function.c
@@ -58,12 +58,7 @@ int slang_function_construct (slang_function *func)
slang_variable_destruct (&func->header);
return 0;
}
- if (!slang_variable_scope_construct (func->parameters))
- {
- slang_alloc_free (func->parameters);
- slang_variable_destruct (&func->header);
- return 0;
- }
+ _slang_variable_scope_ctr (func->parameters);
func->param_count = 0;
func->body = NULL;
func->address = ~0;
@@ -84,14 +79,16 @@ void slang_function_destruct (slang_function *func)
slang_fixup_table_free (&func->fixups);
}
-/* slang_function_scope */
+/*
+ * slang_function_scope
+ */
-int slang_function_scope_construct (slang_function_scope *scope)
+GLvoid
+_slang_function_scope_ctr (slang_function_scope *self)
{
- scope->functions = NULL;
- scope->num_functions = 0;
- scope->outer_scope = NULL;
- return 1;
+ self->functions = NULL;
+ self->num_functions = 0;
+ self->outer_scope = NULL;
}
void slang_function_scope_destruct (slang_function_scope *scope)
@@ -147,8 +144,9 @@ slang_function *slang_function_scope_find (slang_function_scope *funcs, slang_fu
* _slang_build_export_code_table()
*/
-GLboolean _slang_build_export_code_table (slang_export_code_table *tbl, slang_function_scope *funs,
- slang_translation_unit *unit)
+GLboolean
+_slang_build_export_code_table (slang_export_code_table *tbl, slang_function_scope *funs,
+ slang_code_unit *unit)
{
slang_atom mainAtom;
GLuint i;
@@ -168,21 +166,21 @@ GLboolean _slang_build_export_code_table (slang_export_code_table *tbl, slang_fu
e = slang_export_code_table_add (tbl);
if (e == NULL)
return GL_FALSE;
- e->address = unit->assembly->count;
+ 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->assembly;
- A.mach = unit->machine;
- A.atoms = unit->atom_pool;
- A.space.funcs = &unit->functions;
- A.space.structs = &unit->structs;
- A.space.vars = &unit->globals;
- slang_assembly_file_push_label (unit->assembly, slang_asm_local_alloc, 20);
- slang_assembly_file_push_label (unit->assembly, slang_asm_enter, 20);
+ 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->assembly, slang_asm_exit);
+ slang_assembly_file_push (&unit->object->assembly, slang_asm_exit);
}
}
return GL_TRUE;
diff --git a/src/mesa/shader/slang/slang_compile_function.h b/src/mesa/shader/slang/slang_compile_function.h
index b1f2bc7565..f9e908d91c 100644
--- a/src/mesa/shader/slang/slang_compile_function.h
+++ b/src/mesa/shader/slang/slang_compile_function.h
@@ -64,17 +64,20 @@ void slang_function_destruct (slang_function *);
typedef struct slang_function_scope_
{
slang_function *functions;
- unsigned int num_functions;
+ GLuint num_functions;
struct slang_function_scope_ *outer_scope;
} slang_function_scope;
-int slang_function_scope_construct (slang_function_scope *);
+extern GLvoid
+_slang_function_scope_ctr (slang_function_scope *);
+
void slang_function_scope_destruct (slang_function_scope *);
int slang_function_scope_find_by_name (slang_function_scope *, slang_atom, int);
slang_function *slang_function_scope_find (slang_function_scope *, slang_function *, int);
-GLboolean _slang_build_export_code_table (slang_export_code_table *, slang_function_scope *,
- struct slang_translation_unit_ *);
+extern GLboolean
+_slang_build_export_code_table (slang_export_code_table *, slang_function_scope *,
+ struct slang_code_unit_ *);
#ifdef __cplusplus
}
diff --git a/src/mesa/shader/slang/slang_compile_operation.c b/src/mesa/shader/slang/slang_compile_operation.c
index 30df4b00a9..7e92013559 100644
--- a/src/mesa/shader/slang/slang_compile_operation.c
+++ b/src/mesa/shader/slang/slang_compile_operation.c
@@ -43,11 +43,7 @@ int slang_operation_construct (slang_operation *oper)
oper->locals = (slang_variable_scope *) slang_alloc_malloc (sizeof (slang_variable_scope));
if (oper->locals == NULL)
return 0;
- if (!slang_variable_scope_construct (oper->locals))
- {
- slang_alloc_free (oper->locals);
- return 0;
- }
+ _slang_variable_scope_ctr (oper->locals);
return 1;
}
diff --git a/src/mesa/shader/slang/slang_compile_struct.c b/src/mesa/shader/slang/slang_compile_struct.c
index c8f851b4ad..15585a62af 100644
--- a/src/mesa/shader/slang/slang_compile_struct.c
+++ b/src/mesa/shader/slang/slang_compile_struct.c
@@ -31,14 +31,16 @@
#include "imports.h"
#include "slang_compile.h"
-/* slang_struct_scope */
+/*
+ * slang_struct_scope
+ */
-int slang_struct_scope_construct (slang_struct_scope *scope)
+GLvoid
+_slang_struct_scope_ctr (slang_struct_scope *self)
{
- scope->structs = NULL;
- scope->num_structs = 0;
- scope->outer_scope = NULL;
- return 1;
+ self->structs = NULL;
+ self->num_structs = 0;
+ self->outer_scope = NULL;
}
void slang_struct_scope_destruct (slang_struct_scope *scope)
@@ -56,8 +58,7 @@ int slang_struct_scope_copy (slang_struct_scope *x, const slang_struct_scope *y)
slang_struct_scope z;
unsigned int i;
- if (!slang_struct_scope_construct (&z))
- return 0;
+ _slang_struct_scope_ctr (&z);
z.structs = (slang_struct *) slang_alloc_malloc (y->num_structs * sizeof (slang_struct));
if (z.structs == NULL)
{
@@ -102,11 +103,7 @@ int slang_struct_construct (slang_struct *stru)
stru->fields = (slang_variable_scope *) slang_alloc_malloc (sizeof (slang_variable_scope));
if (stru->fields == NULL)
return 0;
- if (!slang_variable_scope_construct (stru->fields))
- {
- slang_alloc_free (stru->fields);
- return 0;
- }
+ _slang_variable_scope_ctr (stru->fields);
stru->structs = (slang_struct_scope *) slang_alloc_malloc (sizeof (slang_struct_scope));
if (stru->structs == NULL)
{
@@ -114,13 +111,7 @@ int slang_struct_construct (slang_struct *stru)
slang_alloc_free (stru->fields);
return 0;
}
- if (!slang_struct_scope_construct (stru->structs))
- {
- slang_variable_scope_destruct (stru->fields);
- slang_alloc_free (stru->fields);
- slang_alloc_free (stru->structs);
- return 0;
- }
+ _slang_struct_scope_ctr (stru->structs);
return 1;
}
diff --git a/src/mesa/shader/slang/slang_compile_struct.h b/src/mesa/shader/slang/slang_compile_struct.h
index a2a90704cd..79e6306616 100644
--- a/src/mesa/shader/slang/slang_compile_struct.h
+++ b/src/mesa/shader/slang/slang_compile_struct.h
@@ -32,11 +32,13 @@ extern "C" {
typedef struct slang_struct_scope_
{
struct slang_struct_ *structs;
- unsigned int num_structs;
+ GLuint num_structs;
struct slang_struct_scope_ *outer_scope;
} slang_struct_scope;
-int slang_struct_scope_construct (slang_struct_scope *);
+extern GLvoid
+_slang_struct_scope_ctr (slang_struct_scope *);
+
void slang_struct_scope_destruct (slang_struct_scope *);
int slang_struct_scope_copy (slang_struct_scope *, const slang_struct_scope *);
struct slang_struct_ *slang_struct_scope_find (slang_struct_scope *, slang_atom, int);
diff --git a/src/mesa/shader/slang/slang_compile_variable.c b/src/mesa/shader/slang/slang_compile_variable.c
index 063709b303..b62743addb 100644
--- a/src/mesa/shader/slang/slang_compile_variable.c
+++ b/src/mesa/shader/slang/slang_compile_variable.c
@@ -120,14 +120,16 @@ int slang_fully_specified_type_copy (slang_fully_specified_type *x, const slang_
return 1;
}
-/* slang_variable_scope */
+/*
+ * slang_variable_scope
+ */
-int slang_variable_scope_construct (slang_variable_scope *scope)
+GLvoid
+_slang_variable_scope_ctr (slang_variable_scope *self)
{
- scope->variables = NULL;
- scope->num_variables = 0;
- scope->outer_scope = NULL;
- return 1;
+ self->variables = NULL;
+ self->num_variables = 0;
+ self->outer_scope = NULL;
}
void slang_variable_scope_destruct (slang_variable_scope *scope)
@@ -145,8 +147,7 @@ int slang_variable_scope_copy (slang_variable_scope *x, const slang_variable_sco
slang_variable_scope z;
unsigned int i;
- if (!slang_variable_scope_construct (&z))
- return 0;
+ _slang_variable_scope_ctr (&z);
z.variables = (slang_variable *) slang_alloc_malloc (y->num_variables * sizeof (slang_variable));
if (z.variables == NULL)
{
diff --git a/src/mesa/shader/slang/slang_compile_variable.h b/src/mesa/shader/slang/slang_compile_variable.h
index fd0d7a8737..6b9679a3b7 100644
--- a/src/mesa/shader/slang/slang_compile_variable.h
+++ b/src/mesa/shader/slang/slang_compile_variable.h
@@ -58,11 +58,13 @@ int slang_fully_specified_type_copy (slang_fully_specified_type *, const slang_f
typedef struct slang_variable_scope_
{
struct slang_variable_ *variables;
- unsigned int num_variables;
+ GLuint num_variables;
struct slang_variable_scope_ *outer_scope;
} slang_variable_scope;
-int slang_variable_scope_construct (slang_variable_scope *);
+extern GLvoid
+_slang_variable_scope_ctr (slang_variable_scope *);
+
void slang_variable_scope_destruct (slang_variable_scope *);
int slang_variable_scope_copy (slang_variable_scope *, const slang_variable_scope *);