Change constructor prototype.
authorMichal Krol <mjkrol@gmail.org>
Tue, 16 May 2006 09:52:02 +0000 (09:52 +0000)
committerMichal Krol <mjkrol@gmail.org>
Tue, 16 May 2006 09:52:02 +0000 (09:52 +0000)
Fix struct field accessing.

src/mesa/shader/slang/slang_assemble.c
src/mesa/shader/slang/slang_assemble.h

index 0b87f7ce86512d7f2e5f4d3ba3e7ca7b18006154..4e0395226dbaa0857e0b988c9b4677ea542d3ce6 100644 (file)
@@ -45,14 +45,16 @@ static GLvoid slang_assembly_destruct (slang_assembly *assem)
 {
 }
 
-/* slang_assembly_file */
+/*
+ * slang_assembly_file
+ */
 
-GLboolean slang_assembly_file_construct (slang_assembly_file *file)
+GLvoid
+_slang_assembly_file_ctr (slang_assembly_file *self)
 {
-       file->code = NULL;
-       file->count = 0;
-       file->capacity = 0;
-       return GL_TRUE;
+   self->code = NULL;
+   self->count = 0;
+   self->capacity = 0;
 }
 
 GLvoid slang_assembly_file_destruct (slang_assembly_file *file)
@@ -935,9 +937,10 @@ static GLboolean handle_field (slang_assemble_ctx *A, slang_assembly_typeinfo *t
        else
        {
                GLuint i, struct_size = 0, field_offset = 0, field_size = 0;
-               GLboolean relocate, shrink;
 
-               /* calculate struct size, field offset and field size */
+      /*
+       * Calculate struct size, field offset and field size.
+       */
                for (i = 0; i < tib->spec._struct->fields->num_variables; i++)
                {
                        slang_variable *field;
@@ -956,45 +959,44 @@ static GLboolean handle_field (slang_assemble_ctx *A, slang_assembly_typeinfo *t
                        size = _slang_sizeof_aggregate (&agg);
                        slang_storage_aggregate_destruct (&agg);
 
-                       if (op->a_id == field->a_name)
-                       {
-                               field_size = size;
-                               struct_size = field_offset + size;
-                       }
-                       else if (struct_size != 0)
-                               struct_size += size;
-                       else
-                               field_offset += size;
-               }
-
-               /*
-                * OPTIMIZATION: If selecting the last field, no relocation is needed.
-                */
-               relocate = field_offset != struct_size - field_size;
-
-               /*
-                * OPTIMIZATION: If field and struct sizes are equal, no partial free is needed.
-                */
-               shrink = field_size != struct_size;
-
-               if (relocate)
-               {
-                       if (!PLAB (A->file, slang_asm_addr_push, field_offset))
-                               return GL_FALSE;
+         if (op->a_id == field->a_name) {
+            field_size = size;
+            field_offset = struct_size;
+         }
+         struct_size += size;
                }
 
                if (ref == slang_ref_force)
                {
-                       if (relocate)
-                       {
+         GLboolean shift;
+
+         /*
+         * OPTIMIZATION: If selecting first field, no address shifting is needed.
+         */
+         shift = (field_offset != 0);
+
+         if (shift) {
+            if (!PLAB (A->file, slang_asm_addr_push, field_offset))
+               return GL_FALSE;
                                if (!PUSH (A->file, slang_asm_addr_add))
                                        return GL_FALSE;
                        }
                }
                else
                {
+         GLboolean relocate, shrink;
                        GLuint free_b = 0;
 
+         /*
+         * OPTIMIZATION: If selecting last field, no relocation is needed.
+         */
+         relocate = (field_offset != (struct_size - field_size));
+
+         /*
+         * OPTIMIZATION: If field and struct sizes are equal, no partial free is needed.
+         */
+         shrink = (field_size != struct_size);
+
                        if (relocate)
                        {
                                GLuint i;
@@ -1003,6 +1005,8 @@ static GLboolean handle_field (slang_assemble_ctx *A, slang_assembly_typeinfo *t
                                 * Move the selected element to the end of the master expression.
                                 * Do it in reverse order to avoid overwriting itself.
                                 */
+            if (!PLAB (A->file, slang_asm_addr_push, field_offset))
+               return GL_FALSE;
                                for (i = field_size; i > 0; i -= 4)
                                        if (!PLAB2 (A->file, slang_asm_float_move, struct_size - field_size + i, i))
                                                return GL_FALSE;
index f1aa1360ba8e237c881e46931947a3b10caf699c..5c3afcaa5d19250a0fd886926aaf3ac7f8f9f4dd 100644 (file)
@@ -114,7 +114,9 @@ typedef struct slang_assembly_file_
        GLuint capacity;
 } slang_assembly_file;
 
-GLboolean slang_assembly_file_construct (slang_assembly_file *);
+extern GLvoid
+_slang_assembly_file_ctr (slang_assembly_file *);
+
 GLvoid slang_assembly_file_destruct (slang_assembly_file *);
 GLboolean slang_assembly_file_push (slang_assembly_file *, slang_assembly_type);
 GLboolean slang_assembly_file_push_label (slang_assembly_file *, slang_assembly_type, GLuint);