Signed-off-by: Tomek Grabiec <tgrab...@gmail.com>
---
 include/vm/types.h |    2 ++
 vm/types.c         |   39 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 41 insertions(+), 0 deletions(-)

diff --git a/include/vm/types.h b/include/vm/types.h
index 1455439..54d2c60 100644
--- a/include/vm/types.h
+++ b/include/vm/types.h
@@ -19,5 +19,7 @@ extern enum vm_type str_to_type(char *);
 extern enum vm_type get_method_return_type(char *);
 
 int count_arguments(const char *);
+enum vm_type bytecode_type_to_vmtype(int);
+int get_vmtype_size(enum vm_type);
 
 #endif
diff --git a/vm/types.c b/vm/types.c
index 1ff23bd..b21e7a9 100644
--- a/vm/types.c
+++ b/vm/types.c
@@ -1,4 +1,6 @@
 #include <vm/types.h>
+#include <vm/die.h>
+#include <vm/vm.h>
 
 /* See Table 4.2 in Section 4.3.2 ("Field Descriptors") of the JVM
    specification.  */
@@ -132,3 +134,40 @@ int count_arguments(const char *type)
 
        return args;
 }
+
+static enum vm_type bytecode_type_to_vmtype_map[] = {
+       [T_BOOLEAN] = J_BOOLEAN,
+       [T_CHAR] = J_CHAR,
+       [T_FLOAT] = J_FLOAT,
+       [T_DOUBLE] = J_DOUBLE,
+       [T_BYTE] = J_BYTE,
+       [T_SHORT] = J_SHORT,
+       [T_INT] = J_INT,
+       [T_LONG] = J_LONG,
+};
+
+enum vm_type bytecode_type_to_vmtype(int type)
+{
+       return bytecode_type_to_vmtype_map[type];
+}
+
+int get_vmtype_size(enum vm_type type)
+{
+       /* Currently we can load/store only multiples of machine word
+          at once. */
+       switch (type) {
+       case J_BOOLEAN:
+       case J_BYTE:
+       case J_CHAR:
+       case J_SHORT:
+       case J_FLOAT:
+       case J_INT:
+       case J_REFERENCE:
+               return sizeof(unsigned long);
+       case J_DOUBLE:
+       case J_LONG:
+               return 8;
+       default:
+               error("type has no size");
+       }
+}
-- 
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