PR164: Get rid of mysterious 10 trailing bytes in literal strings.
[cacao.git] / src / vm / primitive.cpp
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.