The purpose of this function is to create a new temporary expression
and generate store statement which will copy the result of given
expression into a temporary expression.

Signed-off-by: Tomek Grabiec <tgrab...@gmail.com>
---
 include/jit/expression.h |    3 +++
 jit/expression.c         |   30 ++++++++++++++++++++++++++++++
 2 files changed, 33 insertions(+), 0 deletions(-)

diff --git a/include/jit/expression.h b/include/jit/expression.h
index f95e021..4af40ad 100644
--- a/include/jit/expression.h
+++ b/include/jit/expression.h
@@ -12,6 +12,8 @@
 
 #include <arch/instruction.h>
 
+struct parse_context;
+
 enum expression_type {
        EXPR_VALUE,
        EXPR_FVALUE,
@@ -308,6 +310,7 @@ struct expression *exception_ref_expr(void);
 struct expression *null_check_expr(struct expression *);
 struct expression *array_size_check_expr(struct expression *);
 struct expression *multiarray_size_check_expr(struct expression *);
+struct expression *copy_expr_value(struct parse_context *, struct expression 
*);
 
 unsigned long nr_args(struct expression *);
 int expr_nr_kids(struct expression *);
diff --git a/jit/expression.c b/jit/expression.c
index 7ea8fbd..8e79829 100644
--- a/jit/expression.c
+++ b/jit/expression.c
@@ -5,6 +5,7 @@
  * LICENSE for details.
  */
 
+#include <jit/statement.h>
 #include <jit/expression.h>
 #include <jit/bc-offset-mapping.h>
 
@@ -387,3 +388,32 @@ struct expression *multiarray_size_check_expr(struct 
expression *dimensions)
 
        return expr;
 }
+
+struct expression *
+copy_expr_value(struct parse_context *ctx, struct expression *expr)
+
+{      struct var_info *tmp_high;
+       struct var_info *tmp_low;
+       struct expression *dest;
+       struct statement *stmt;
+
+       tmp_low = get_var(ctx->cu);
+
+       if (expr->vm_type == J_LONG)
+               tmp_high = get_var(ctx->cu);
+       else
+               tmp_high = NULL;
+
+       dest = temporary_expr(expr->vm_type, tmp_high, tmp_low);
+
+       stmt = alloc_statement(STMT_STORE);
+       if (!stmt)
+               return NULL;
+
+       expr_get(dest);
+       stmt->store_dest = &dest->node;
+       stmt->store_src  = &expr->node;
+       convert_statement(ctx, stmt);
+
+       return dest;
+}
-- 
1.6.0.6


------------------------------------------------------------------------------
_______________________________________________
Jatovm-devel mailing list
Jatovm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jatovm-devel

Reply via email to