mesa: glsl: re-enable assignment type checking
authorBrian Paul <brian.paul@tungstengraphics.com>
Tue, 5 Aug 2008 22:58:31 +0000 (16:58 -0600)
committerBrian Paul <brian.paul@tungstengraphics.com>
Tue, 5 Aug 2008 22:58:31 +0000 (16:58 -0600)
src/mesa/shader/slang/slang_codegen.c

index 582b47c239202582dba0aeb348b52be088fbbae7..036196a8d2b4c50b28b10804cffe0848808f7bc0 100644 (file)
@@ -2860,36 +2860,46 @@ _slang_gen_swizzle(slang_ir_node *child, GLuint swizzle)
  * XXX more cases needed.
  */
 static GLboolean
-_slang_assignment_compatible(const slang_typeinfo *t0,
-                             const slang_typeinfo *t1)
-
+_slang_assignment_compatible(slang_assemble_ctx *A,
+                             slang_operation *op0,
+                             slang_operation *op1)
 {
-#if 1
-   GLuint sz0 = _slang_sizeof_type_specifier(&t0->spec);
-   GLuint sz1 = _slang_sizeof_type_specifier(&t1->spec);
+   slang_typeinfo t0, t1;
+   GLuint sz0, sz1;
+
+   
+   slang_typeinfo_construct(&t0);
+   _slang_typeof_operation(A, op0, &t0);
+
+   slang_typeinfo_construct(&t1);
+   _slang_typeof_operation(A, op1, &t1);
+
+   sz0 = _slang_sizeof_type_specifier(&t0.spec);
+   sz1 = _slang_sizeof_type_specifier(&t1.spec);
 
+#if 1
    if (sz0 != sz1) {
       printf("size mismatch %u vs %u\n", sz0, sz1);
       return GL_FALSE;
    }
 #endif
 
-   if (t0->spec.type == SLANG_SPEC_STRUCT &&
-       t1->spec.type == SLANG_SPEC_STRUCT &&
-       t0->spec._struct->a_name != t1->spec._struct->a_name)
+   if (t0.spec.type == SLANG_SPEC_STRUCT &&
+       t1.spec.type == SLANG_SPEC_STRUCT &&
+       t0.spec._struct->a_name != t1.spec._struct->a_name)
       return GL_FALSE;
 
 #if 0 /* not used just yet - causes problems elsewhere */
-   if (t0->spec.type == SLANG_SPEC_INT &&
-       t1->spec.type == SLANG_SPEC_FLOAT)
+   if (t0.spec.type == SLANG_SPEC_INT &&
+       t1.spec.type == SLANG_SPEC_FLOAT)
       return GL_FALSE;
 
-   if (t0->spec.type == SLANG_SPEC_BOOL &&
-       t1->spec.type == SLANG_SPEC_FLOAT)
+   if (t0.spec.type == SLANG_SPEC_BOOL &&
+       t1.spec.type == SLANG_SPEC_FLOAT)
       return GL_FALSE;
 
-   if (t0->spec.type == SLANG_SPEC_BOOL &&
-       t1->spec.type == SLANG_SPEC_INT)
+   if (t0.spec.type == SLANG_SPEC_BOOL &&
+       t1.spec.type == SLANG_SPEC_INT)
       return GL_FALSE;
 #endif
    return GL_TRUE;
@@ -2943,21 +2953,11 @@ _slang_gen_assignment(slang_assemble_ctx * A, slang_operation *oper)
       slang_ir_node *n, *lhs, *rhs;
 
       /* lhs and rhs type checking */
-      if (0)
-      {
-         slang_typeinfo t0, t1;
-   
-         slang_typeinfo_construct(&t0);
-         _slang_typeof_operation(A, &oper->children[0], &t0);
-
-         slang_typeinfo_construct(&t1);
-         _slang_typeof_operation(A, &oper->children[1], &t1);
-
-         if (!_slang_assignment_compatible(&t0, &t1)) {
-            slang_info_log_error(A->log,
-                                 "illegal types in assignment");
-            return NULL;
-         }
+      if (!_slang_assignment_compatible(A,
+                                        &oper->children[0],
+                                        &oper->children[1])) {
+         slang_info_log_error(A->log, "illegal types in assignment");
+         return NULL;
       }
 
       lhs = _slang_gen_operation(A, &oper->children[0]);