glsl2: Allow use of _mesa_print_ir without a parse state on hand.
authorEric Anholt <eric@anholt.net>
Thu, 29 Jul 2010 22:04:45 +0000 (15:04 -0700)
committerEric Anholt <eric@anholt.net>
Thu, 29 Jul 2010 22:09:31 +0000 (15:09 -0700)
src/glsl/ir_print_visitor.cpp

index 7df9d8adcda5a6512459992cb48d7bdd2ebdd907..73476e7e9b6791bd365d306c4d1f9cde8a02f794 100644 (file)
@@ -40,19 +40,21 @@ void
 _mesa_print_ir(exec_list *instructions,
               struct _mesa_glsl_parse_state *state)
 {
-   for (unsigned i = 0; i < state->num_user_structures; i++) {
-      const glsl_type *const s = state->user_structures[i];
+   if (state) {
+      for (unsigned i = 0; i < state->num_user_structures; i++) {
+        const glsl_type *const s = state->user_structures[i];
 
-      printf("(structure (%s) (%s@%p) (%u) (\n",
-            s->name, s->name, s, s->length);
+        printf("(structure (%s) (%s@%p) (%u) (\n",
+               s->name, s->name, s, s->length);
 
-      for (unsigned j = 0; j < s->length; j++) {
-        printf("\t((");
-        print_type(s->fields.structure[j].type);
-        printf(")(%s))\n", s->fields.structure[j].name);
-      }
+        for (unsigned j = 0; j < s->length; j++) {
+           printf("\t((");
+           print_type(s->fields.structure[j].type);
+           printf(")(%s))\n", s->fields.structure[j].name);
+        }
 
-      printf(")\n");
+        printf(")\n");
+      }
    }
 
    printf("(\n");