From: Michael Starzinger Date: Mon, 2 Nov 2009 16:39:36 +0000 (+0100) Subject: * src/vm/primitive.cpp (Primitive::get_type_by_primitiveclass): Implemented. X-Git-Url: http://wien.tomnetworks.com/gitweb/?p=cacao.git;a=commitdiff_plain;h=9737de9e5622be1c7c2cba765f71cc0e14017baf * src/vm/primitive.cpp (Primitive::get_type_by_primitiveclass): Implemented. * src/vm/primitive.hpp (Primitive): Added get_type_by_primitiveclass function. --- diff --git a/src/vm/primitive.cpp b/src/vm/primitive.cpp index 9d6b79200..59c97eb20 100644 --- a/src/vm/primitive.cpp +++ b/src/vm/primitive.cpp @@ -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. diff --git a/src/vm/primitive.hpp b/src/vm/primitive.hpp index 2016786f0..c65052103 100644 --- a/src/vm/primitive.hpp +++ b/src/vm/primitive.hpp @@ -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);