Add ir_call call to represent function calls.
authorIan Romanick <ian.d.romanick@intel.com>
Thu, 11 Mar 2010 22:34:27 +0000 (14:34 -0800)
committerIan Romanick <ian.d.romanick@intel.com>
Thu, 11 Mar 2010 22:35:37 +0000 (14:35 -0800)
ast_to_hir.cpp
ir.cpp
ir.h
ir_print_visitor.cpp
ir_print_visitor.h
ir_visitor.h

index 3c4b69fdc241f37de0630835c1640946136167a2..1fea7299dbdfb1881a8e3b831a7b809f2d8ce207 100644 (file)
@@ -725,7 +725,7 @@ ast_function_expression::hir(exec_list *instructions,
     */
    (void) instructions;
    (void) state;
-   return NULL;
+   return ir_call::get_error_instruction();
 }
 
 ir_instruction *
diff --git a/ir.cpp b/ir.cpp
index 3166cdc9efffe89e9c4aab7ad709bda2746c943d..5aec70bfce88c1c2658baacf5ef0951ec20b4b78 100644 (file)
--- a/ir.cpp
+++ b/ir.cpp
@@ -108,3 +108,13 @@ ir_function::ir_function(void)
 {
    /* empty */
 }
+
+
+ir_call *
+ir_call::get_error_instruction()
+{
+   ir_call *call = new ir_call;
+
+   call->type = glsl_error_type;
+   return call;
+}
diff --git a/ir.h b/ir.h
index 7de7c38532382fffe3fce9167c582ba414c2b43b..136b45b72be26691d0b877c438328f207c20e594 100644 (file)
--- a/ir.h
+++ b/ir.h
@@ -39,7 +39,8 @@ enum ir_opcodes {
    ir_op_label,
    ir_op_constant,
    ir_op_func_sig,
-   ir_op_func
+   ir_op_func,
+   ir_op_call,
 };
 
 /**
@@ -277,6 +278,33 @@ public:
 };
 
 
+/**
+ * IR instruction representing a function call
+ */
+class ir_call : public ir_instruction {
+public:
+   ir_call()
+      : ir_instruction(ir_op_call), callee(NULL)
+   {
+      /* empty */
+   }
+
+   virtual void accept(ir_visitor *v)
+   {
+      v->visit(this);
+   }
+
+   /**
+    * Get a generic ir_call object when an error occurs
+    */
+   static ir_call *get_error_instruction();
+
+private:
+   ir_function_signature *callee;
+   exec_list actual_parameters;
+};
+
+
 struct ir_swizzle_mask {
    unsigned x:2;
    unsigned y:2;
index c09de83ffd6b03eca59e0a75ba3b237395a2a5ec..b1c718d99ea512b99c9c743d917ce61b9155d03c 100644 (file)
@@ -132,3 +132,13 @@ void ir_print_visitor::visit(ir_constant *ir)
    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");
+}
index 778d4ee00dffd7c833d34ab183570e4b5a58b9a9..b76de504617b4c39bd5052849767c2a75c5bb80b 100644 (file)
@@ -60,6 +60,7 @@ public:
    virtual void visit(ir_dereference *);
    virtual void visit(ir_assignment *);
    virtual void visit(ir_constant *);
+   virtual void visit(ir_call *);
    /*@}*/
 };
 
index 43246d1058d48574c27a60ec42d92c5d5d2a3cf2..a2b2dd678b40b26ed03f7125255ab157c6ce206c 100644 (file)
@@ -52,6 +52,7 @@ public:
    virtual void visit(class ir_dereference *) = 0;
    virtual void visit(class ir_assignment *) = 0;
    virtual void visit(class ir_constant *) = 0;
+   virtual void visit(class ir_call *) = 0;
    /*@}*/
 };