summaryrefslogtreecommitdiff
path: root/ast_to_hir.cpp
diff options
context:
space:
mode:
authorIan Romanick <ian.d.romanick@intel.com>2010-03-19 16:45:19 -0700
committerIan Romanick <ian.d.romanick@intel.com>2010-03-19 16:51:16 -0700
commit16a246c049fa3c8d7841f87c8defdd0f26f302ee (patch)
treece6196bc679ba06cce5962b82adecd7d78abe8e7 /ast_to_hir.cpp
parent9578c87ce23a98472d52f15b0a7063f4df036c4d (diff)
Initial bits for converting AST return nodes to IR return instructions
Diffstat (limited to 'ast_to_hir.cpp')
-rw-r--r--ast_to_hir.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp
index 63f0c82d3d..79d32165a1 100644
--- a/ast_to_hir.cpp
+++ b/ast_to_hir.cpp
@@ -1120,3 +1120,40 @@ ast_function_definition::hir(exec_list *instructions,
*/
return NULL;
}
+
+
+ir_instruction *
+ast_jump_statement::hir(exec_list *instructions,
+ struct _mesa_glsl_parse_state *state)
+{
+
+ if (mode == ast_return) {
+ ir_return *inst;
+
+ if (opt_return_value) {
+ /* FINISHME: Make sure the enclosing function has a non-void return
+ * FINISHME: type.
+ */
+
+ ir_expression *const ret = (ir_expression *)
+ opt_return_value->hir(instructions, state);
+ assert(ret != NULL);
+
+ /* FINISHME: Make sure the type of the return value matches the return
+ * FINISHME: type of the enclosing function.
+ */
+
+ inst = new ir_return(ret);
+ } else {
+ /* FINISHME: Make sure the enclosing function has a void return type.
+ */
+ inst = new ir_return;
+ }
+
+ instructions->push_tail(inst);
+ }
+
+ /* Jump instructions do not have r-values.
+ */
+ return NULL;
+}