ast_function.cpp seems to be mixing spaces and tabs.

attached 'fixes' a method I was interested in to use only spaces. might
be a better idea to just run indent on this stuff though.

-tom

diff --git a/src/glsl/ast_function.cpp b/src/glsl/ast_function.cpp
index f85b308..f022a66 100644
--- a/src/glsl/ast_function.cpp
+++ b/src/glsl/ast_function.cpp
@@ -1004,20 +1004,20 @@ ast_function_expression::hir(exec_list *instructions,
       /* Constructors for samplers are illegal.
        */
       if (constructor_type->is_sampler()) {
-	 _mesa_glsl_error(& loc, state, "cannot construct sampler type `%s'",
-			  constructor_type->name);
-	 return ir_call::get_error_instruction(ctx);
+         _mesa_glsl_error(& loc, state, "cannot construct sampler type `%s'",
+                          constructor_type->name);
+         return ir_call::get_error_instruction(ctx);
       }
 
       if (constructor_type->is_array()) {
-	 if (state->language_version <= 110) {
-	    _mesa_glsl_error(& loc, state,
-			     "array constructors forbidden in GLSL 1.10");
-	    return ir_call::get_error_instruction(ctx);
-	 }
-
-	 return process_array_constructor(instructions, constructor_type,
-					  & loc, &this->expressions, state);
+         if (state->language_version <= 110) {
+            _mesa_glsl_error(& loc, state,
+                             "array constructors forbidden in GLSL 1.10");
+            return ir_call::get_error_instruction(ctx);
+         }
+
+         return process_array_constructor(instructions, constructor_type,
+                                          & loc, &this->expressions, state);
       }
 
       /* There are two kinds of constructor call.  Constructors for built-in
@@ -1029,7 +1029,7 @@ ast_function_expression::hir(exec_list *instructions,
        * matching rules as functions.
        */
       if (!constructor_type->is_numeric() && !constructor_type->is_boolean())
-	 return ir_call::get_error_instruction(ctx);
+         return ir_call::get_error_instruction(ctx);
 
       /* Total number of components of the type being constructed. */
       const unsigned type_components = constructor_type->components();
@@ -1044,38 +1044,36 @@ ast_function_expression::hir(exec_list *instructions,
       exec_list actual_parameters;
 
       foreach_list (n, &this->expressions) {
-	 ast_node *ast = exec_node_data(ast_node, n, link);
-	 ir_rvalue *result = ast->hir(instructions, state)->as_rvalue();
-
-	 /* From page 50 (page 56 of the PDF) of the GLSL 1.50 spec:
-	  *
-	  *    "It is an error to provide extra arguments beyond this
-	  *    last used argument."
-	  */
-	 if (components_used >= type_components) {
-	    _mesa_glsl_error(& loc, state, "too many parameters to `%s' "
-			     "constructor",
-			     constructor_type->name);
-	    return ir_call::get_error_instruction(ctx);
-	 }
-
-	 if (!result->type->is_numeric() && !result->type->is_boolean()) {
-	    _mesa_glsl_error(& loc, state, "cannot construct `%s' from a "
-			     "non-numeric data type",
-			     constructor_type->name);
-	    return ir_call::get_error_instruction(ctx);
-	 }
-
-	 /* Count the number of matrix and nonmatrix parameters.  This
-	  * is used below to enforce some of the constructor rules.
-	  */
-	 if (result->type->is_matrix())
-	    matrix_parameters++;
-	 else
-	    nonmatrix_parameters++;
-
-	 actual_parameters.push_tail(result);
-	 components_used += result->type->components();
+         ast_node *ast = exec_node_data(ast_node, n, link);
+         ir_rvalue *result = ast->hir(instructions, state)->as_rvalue();
+
+         /* From page 50 (page 56 of the PDF) of the GLSL 1.50 spec:
+          *
+          *    "It is an error to provide extra arguments beyond this
+          *    last used argument."
+          */
+         if (components_used >= type_components) {
+            _mesa_glsl_error(& loc, state, "too many parameters to `%s' "
+                             "constructor", constructor_type->name);
+            return ir_call::get_error_instruction(ctx);
+         }
+
+         if (!result->type->is_numeric() && !result->type->is_boolean()) {
+            _mesa_glsl_error(& loc, state, "cannot construct `%s' from a "
+                             "non-numeric data type", constructor_type->name);
+            return ir_call::get_error_instruction(ctx);
+         }
+
+         /* Count the number of matrix and nonmatrix parameters.  This
+          * is used below to enforce some of the constructor rules.
+          */
+         if (result->type->is_matrix())
+            matrix_parameters++;
+         else
+            nonmatrix_parameters++;
+
+         actual_parameters.push_tail(result);
+         components_used += result->type->components();
       }
 
       /* From page 28 (page 34 of the PDF) of the GLSL 1.10 spec:
@@ -1084,11 +1082,10 @@ ast_function_expression::hir(exec_list *instructions,
        *    is reserved for future use."
        */
       if ((state->language_version <= 110) && (matrix_parameters > 0)
-	  && constructor_type->is_matrix()) {
-	 _mesa_glsl_error(& loc, state, "cannot construct `%s' from a "
-			  "matrix in GLSL 1.10",
-			  constructor_type->name);
-	 return ir_call::get_error_instruction(ctx);
+          && constructor_type->is_matrix()) {
+         _mesa_glsl_error(& loc, state, "cannot construct `%s' from a "
+                          "matrix in GLSL 1.10", constructor_type->name);
+         return ir_call::get_error_instruction(ctx);
       }
 
       /* From page 50 (page 56 of the PDF) of the GLSL 1.50 spec:
@@ -1097,12 +1094,12 @@ ast_function_expression::hir(exec_list *instructions,
        *    an error to have any other arguments."
        */
       if ((matrix_parameters > 0)
-	  && ((matrix_parameters + nonmatrix_parameters) > 1)
-	  && constructor_type->is_matrix()) {
-	 _mesa_glsl_error(& loc, state, "for matrix `%s' constructor, "
-			  "matrix must be only parameter",
-			  constructor_type->name);
-	 return ir_call::get_error_instruction(ctx);
+          && ((matrix_parameters + nonmatrix_parameters) > 1)
+          && constructor_type->is_matrix()) {
+         _mesa_glsl_error(& loc, state, "for matrix `%s' constructor, "
+			                 "matrix must be only parameter",
+                          constructor_type->name);
+         return ir_call::get_error_instruction(ctx);
       }
 
       /* From page 28 (page 34 of the PDF) of the GLSL 1.10 spec:
@@ -1112,10 +1109,9 @@ ast_function_expression::hir(exec_list *instructions,
        *    constructed value."
        */
       if ((components_used < type_components) && (components_used != 1)) {
-	 _mesa_glsl_error(& loc, state, "too few components to construct "
-			  "`%s'",
-			  constructor_type->name);
-	 return ir_call::get_error_instruction(ctx);
+         _mesa_glsl_error(& loc, state, "too few components to construct `%s'",
+                          constructor_type->name);
+         return ir_call::get_error_instruction(ctx);
       }
 
       /* Later, we cast each parameter to the same base type as the
@@ -1123,101 +1119,101 @@ ast_function_expression::hir(exec_list *instructions,
        * need to break them up into a series of column vectors.
        */
       if (constructor_type->base_type != GLSL_TYPE_FLOAT) {
-	 foreach_list_safe(n, &actual_parameters) {
-	    ir_rvalue *matrix = (ir_rvalue *) n;
-
-	    if (!matrix->type->is_matrix())
-	       continue;
-
-	    /* Create a temporary containing the matrix. */
-	    ir_variable *var = new(ctx) ir_variable(matrix->type, "matrix_tmp",
-						    ir_var_temporary);
-	    instructions->push_tail(var);
-	    instructions->push_tail(new(ctx) ir_assignment(new(ctx)
-	       ir_dereference_variable(var), matrix, NULL));
-	    var->constant_value = matrix->constant_expression_value();
-
-	    /* Replace the matrix with dereferences of its columns. */
-	    for (int i = 0; i < matrix->type->matrix_columns; i++) {
-	       matrix->insert_before(new (ctx) ir_dereference_array(var,
-		  new(ctx) ir_constant(i)));
-	    }
-	    matrix->remove();
-	 }
+         foreach_list_safe(n, &actual_parameters) {
+            ir_rvalue *matrix = (ir_rvalue *) n;
+
+            if (!matrix->type->is_matrix())
+               continue;
+
+            /* Create a temporary containing the matrix. */
+            ir_variable *var = new(ctx) ir_variable(matrix->type, "matrix_tmp",
+                                                    ir_var_temporary);
+            instructions->push_tail(var);
+            instructions->push_tail(new(ctx) ir_assignment(new(ctx)
+                                    ir_dereference_variable(var), matrix,
+                                    NULL));
+            var->constant_value = matrix->constant_expression_value();
+
+            /* Replace the matrix with dereferences of its columns. */
+            for (int i = 0; i < matrix->type->matrix_columns; i++) {
+               matrix->insert_before(new (ctx) ir_dereference_array(var,
+                                     new(ctx) ir_constant(i)));
+            }
+            matrix->remove();
+         }
       }
 
       bool all_parameters_are_constant = true;
 
       /* Type cast each parameter and, if possible, fold constants.*/
       foreach_list_safe(n, &actual_parameters) {
-	 ir_rvalue *ir = (ir_rvalue *) n;
-
-	 const glsl_type *desired_type =
-	    glsl_type::get_instance(constructor_type->base_type,
-				    ir->type->vector_elements,
-				    ir->type->matrix_columns);
-	 ir_rvalue *result = convert_component(ir, desired_type);
-
-	 /* Attempt to convert the parameter to a constant valued expression.
-	  * After doing so, track whether or not all the parameters to the
-	  * constructor are trivially constant valued expressions.
-	  */
-	 ir_rvalue *const constant = result->constant_expression_value();
-
-	 if (constant != NULL)
-	    result = constant;
-	 else
-	    all_parameters_are_constant = false;
-
-	 if (result != ir) {
-	    ir->replace_with(result);
-	 }
+         ir_rvalue *ir = (ir_rvalue *) n;
+
+         const glsl_type *desired_type =
+            glsl_type::get_instance(constructor_type->base_type,
+                                    ir->type->vector_elements,
+                                    ir->type->matrix_columns);
+         ir_rvalue *result = convert_component(ir, desired_type);
+
+         /* Attempt to convert the parameter to a constant valued expression.
+          * After doing so, track whether or not all the parameters to the
+          * constructor are trivially constant valued expressions.
+          */
+         ir_rvalue *const constant = result->constant_expression_value();
+
+         if (constant != NULL)
+            result = constant;
+         else
+            all_parameters_are_constant = false;
+
+         if (result != ir) {
+         ir->replace_with(result);
+         }
       }
 
       /* If all of the parameters are trivially constant, create a
        * constant representing the complete collection of parameters.
        */
       if (all_parameters_are_constant) {
-	 if (components_used >= type_components)
-	    return new(ctx) ir_constant(constructor_type,
-					& actual_parameters);
-
-	 /* The above case must handle all scalar constructors.
-	  */
-	 assert(constructor_type->is_vector()
-		|| constructor_type->is_matrix());
-
-	 /* Constructors with exactly one component are special for
-	  * vectors and matrices.  For vectors it causes all elements of
-	  * the vector to be filled with the value.  For matrices it
-	  * causes the matrix to be filled with 0 and the diagonal to be
-	  * filled with the value.
-	  */
-	 ir_constant_data data;
-	 ir_constant *const initializer =
-	    (ir_constant *) actual_parameters.head;
-	 if (constructor_type->is_matrix())
-	    generate_constructor_matrix(constructor_type, initializer,
-					&data);
-	 else
-	    generate_constructor_vector(constructor_type, initializer,
-					&data);
-
-	 return new(ctx) ir_constant(constructor_type, &data);
+         if (components_used >= type_components)
+            return new(ctx) ir_constant(constructor_type,
+                                        & actual_parameters);
+
+         /* The above case must handle all scalar constructors.
+          */
+         assert(constructor_type->is_vector()
+                || constructor_type->is_matrix());
+
+         /* Constructors with exactly one component are special for
+          * vectors and matrices.  For vectors it causes all elements of
+          * the vector to be filled with the value.  For matrices it
+          * causes the matrix to be filled with 0 and the diagonal to be
+          * filled with the value.
+          */
+         ir_constant_data data;
+         ir_constant *const initializer =
+            (ir_constant *) actual_parameters.head;
+         if (constructor_type->is_matrix())
+            generate_constructor_matrix(constructor_type, initializer,
+                                        &data);
+         else
+            generate_constructor_vector(constructor_type, initializer,
+                                        &data);
+
+         return new(ctx) ir_constant(constructor_type, &data);
       } else if (constructor_type->is_scalar()) {
-	 return dereference_component((ir_rvalue *) actual_parameters.head,
-				      0);
+         return dereference_component((ir_rvalue *) actual_parameters.head, 0);
       } else if (constructor_type->is_vector()) {
-	 return emit_inline_vector_constructor(constructor_type,
-					       instructions,
-					       &actual_parameters,
-					       ctx);
+         return emit_inline_vector_constructor(constructor_type,
+                                               instructions,
+                                               &actual_parameters,
+                                               ctx);
       } else {
-	 assert(constructor_type->is_matrix());
-	 return emit_inline_matrix_constructor(constructor_type,
-					       instructions,
-					       &actual_parameters,
-					       ctx);
+         assert(constructor_type->is_matrix());
+         return emit_inline_matrix_constructor(constructor_type,
+                                               instructions,
+                                               &actual_parameters,
+                                               ctx);
       }
    } else {
       const ast_expression *id = subexpressions[0];
@@ -1225,22 +1221,22 @@ ast_function_expression::hir(exec_list *instructions,
       exec_list actual_parameters;
 
       process_parameters(instructions, &actual_parameters, &this->expressions,
-			 state);
+                         state);
 
       const glsl_type *const type =
-	 state->symbols->get_type(id->primary_expression.identifier);
+         state->symbols->get_type(id->primary_expression.identifier);
 
       if ((type != NULL) && type->is_record()) {
-	 ir_constant *constant =
-	    constant_record_constructor(type, &loc, &actual_parameters, state);
+         ir_constant *constant =
+            constant_record_constructor(type, &loc, &actual_parameters, state);
 
-	 if (constant != NULL)
-	    return constant;
+         if (constant != NULL)
+            return constant;
       }
 
       return match_function_by_name(instructions, 
-				    id->primary_expression.identifier, & loc,
-				    &actual_parameters, state);
+                                    id->primary_expression.identifier, & loc,
+                                    &actual_parameters, state);
    }
 
    return ir_call::get_error_instruction(ctx);
_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to