* src/vm/primitive.cpp (Primitive::get_type_by_primitiveclass): Implemented.
authorMichael Starzinger <michi@complang.tuwien.ac.at>
Mon, 2 Nov 2009 16:39:36 +0000 (17:39 +0100)
committerMichael Starzinger <michi@complang.tuwien.ac.at>
Mon, 2 Nov 2009 16:39:36 +0000 (17:39 +0100)
* src/vm/primitive.hpp (Primitive): Added get_type_by_primitiveclass function.

src/vm/primitive.cpp
src/vm/primitive.hpp

index 9d6b79200e7ea2bcb753cbc69a915dee1869a12f..59c97eb205c0be159669b7a6bf40c952ae17abc2 100644 (file)
@@ -369,6 +369,27 @@ int Primitive::get_type_by_wrapperclass(classinfo *c)
 }
 
 
+/**
+ * Returns the primitive type of the given primitive-class.
+ *
+ * @param c Class structure.
+ *
+ * @return Integer type of the class.
+ */
+int Primitive::get_type_by_primitiveclass(classinfo *c)
+{
+       /* Search primitive table. */
+
+       for (int i = 0; i < PRIMITIVETYPE_COUNT; i++)
+               if (primitivetype_table[i].class_primitive == c)
+                       return i;
+       
+       /* Invalid primitive class. */
+
+       return -1;
+}
+
+
 /**
  * Box a primitive of the given type.  If the type is an object,
  * simply return it.
index 2016786f00b27cbe57d204f22a02916ca984250a..c650521039b15acec2407f1e5ff1ff41e73cc289 100644 (file)
@@ -50,6 +50,7 @@ public:
        static classinfo*     get_arrayclass_by_type(int type);
 
        static int            get_type_by_wrapperclass(classinfo *c);
+       static int            get_type_by_primitiveclass(classinfo *c);
 
        static java_handle_t* box(int type, imm_union value);