Begin processing constructors
[mesa.git] / ir_print_visitor.cpp
index 8c4271e466aed2be1a4454800caa9f1b27c5ff3c..f9f3d3f17d8936dce5ce15ab04a6e2878e70a640 100644 (file)
  */
 #include <cstdio>
 #include "ir_print_visitor.h"
+#include "glsl_types.h"
+
+static void
+print_type(const glsl_type *t)
+{
+   if (t->base_type == GLSL_TYPE_ARRAY) {
+      printf("array\n");
+      printf("    (");
+      print_type(t->fields.array);
+      printf(")\n");
+
+      printf("    (%u)\n", t->length);
+      printf(")");
+   } else if (t->base_type == GLSL_TYPE_STRUCT) {
+      printf("struct (%s %u\n", t->name ? t->name : "@", t->length);
+      printf("    (FINISHME: structure fields go here)\n");
+      printf(")");
+   } else {
+      printf("%s", t->name);
+   }
+}
+
 
 void ir_print_visitor::visit(ir_variable *ir)
 {
@@ -35,7 +57,10 @@ void ir_print_visitor::visit(ir_variable *ir)
    printf("    (%s%s%s%s)\n",
          cent, inv, mode[ir->mode], interp[ir->interpolation]);
 
-   printf("    (FINISHME: type goes here)\n");
+   printf("    (");
+   print_type(ir->type);
+   printf(")\n");
+
    printf("    (%s)\n", ir->name);
    printf(")\n");
 }
@@ -77,13 +102,58 @@ void ir_print_visitor::visit(ir_dereference *ir)
 
 void ir_print_visitor::visit(ir_assignment *ir)
 {
-   printf("%s:%d:\n", __func__, __LINE__);
-   (void) ir;
+   printf("(assign\n");
+
+   printf("    (");
+   if (ir->condition)
+      ir->condition->accept(this);
+   else
+      printf("true");
+   printf(")\n");
+
+   printf("    (");
+   ir->lhs->accept(this);
+   printf(")\n");
+
+   printf("    (");
+   ir->rhs->accept(this);
+   printf(")\n");
 }
 
 
 void ir_print_visitor::visit(ir_constant *ir)
 {
-   printf("%s:%d:\n", __func__, __LINE__);
    (void) ir;
+
+   printf("(constant\n");
+   printf("    (");
+   print_type(ir->type);
+   printf(")\n");
+   printf("    (FINISHME: value goes here)\n");
+   printf(")\n");
+}
+
+
+void
+ir_print_visitor::visit(ir_call *ir)
+{
+   (void) ir;
+
+   printf("(call FINISHME: function name here\n");
+   printf("    (FINISHME: function paramaters here))\n");
+}
+
+
+void
+ir_print_visitor::visit(ir_return *ir)
+{
+   printf("(return");
+
+   ir_expression *const value = ir->get_value();
+   if (value) {
+      printf(" ");
+      value->accept(this);
+   }
+
+   printf(")\n");
 }