Cleanup code. Change constructor prototype.
authorMichal Krol <mjkrol@gmail.org>
Tue, 16 May 2006 10:01:07 +0000 (10:01 +0000)
committerMichal Krol <mjkrol@gmail.org>
Tue, 16 May 2006 10:01:07 +0000 (10:01 +0000)
src/mesa/shader/slang/slang_compile_function.c
src/mesa/shader/slang/slang_compile_function.h
src/mesa/shader/slang/slang_compile_operation.c
src/mesa/shader/slang/slang_compile_struct.c
src/mesa/shader/slang/slang_compile_struct.h
src/mesa/shader/slang/slang_compile_variable.c
src/mesa/shader/slang/slang_compile_variable.h

index ff9854f..eb8fd1b 100644 (file)
@@ -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;
index b1f2bc7..f9e908d 100644 (file)
@@ -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
 }
index 30df4b0..7e92013 100644 (file)
@@ -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;
 }
 
index c8f851b..15585a6 100644 (file)
 #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;
 }
 
index a2a9070..79e6306 100644 (file)
@@ -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);
index 063709b..b62743a 100644 (file)
@@ -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)
        {
index fd0d7a8..6b9679a 100644 (file)
@@ -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 *);