* src/vmcore/descriptor.c (vm/vm.h): Added.
authortwisti <none@none>
Wed, 25 Jul 2007 14:51:40 +0000 (14:51 +0000)
committertwisti <none@none>
Wed, 25 Jul 2007 14:51:40 +0000 (14:51 +0000)
(descriptor_to_basic_type): Code cleanup.
(descriptor_typesize): Likewise.

src/vmcore/descriptor.c

index 3acfcb73a82cc6364a5b5ac165027becce79dd39..0529c9bde7f49a91d2d9d648875724873e80973d 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: descriptor.c 8210 2007-07-18 12:51:00Z twisti $
+   $Id: descriptor.c 8232 2007-07-25 14:51:40Z twisti $
 
 */
 
@@ -38,8 +38,8 @@
 #include "mm/memory.h"
 
 #include "vm/exceptions.h"
-
 #include "vm/jit_interface.h"
+#include "vm/vm.h"
 
 #include "vmcore/descriptor.h"
 #include "vmcore/primitive.h"
@@ -150,24 +150,38 @@ u2 descriptor_to_basic_type(utf *descriptor)
        assert(descriptor->blength >= 1);
        
        switch (descriptor->text[0]) {
-               case 'B': 
-               case 'C':
-               case 'I':
-               case 'S':  
-               case 'Z':  return TYPE_INT;
-               case 'D':  return TYPE_DBL;
-               case 'F':  return TYPE_FLT;
-               case 'J':  return TYPE_LNG;
-               case 'L':
-               case '[':  return TYPE_ADR;
+       case 'Z':
+       case 'B':
+       case 'C':
+       case 'S':
+       case 'I':
+               return TYPE_INT;
+
+       case 'J':
+               return TYPE_LNG;
+
+       case 'F':
+               return TYPE_FLT;
+
+       case 'D':
+               return TYPE_DBL;
+
+       case 'L':
+       case '[':
+               return TYPE_ADR;
+
+       default:
+               vm_abort("descriptor_to_basic_type: invalid type %c",
+                                descriptor->text[0]);
        }
-                       
-       assert(0);
 
-       return 0; /* keep the compiler happy */
+       /* keep the compiler happy */
+
+       return 0;
 }
 
-/* descriptor_typesize**** ****************************************************
+
+/* descriptor_typesize *********************************************************
 
    Return the size in bytes needed for the given type.
 
@@ -184,18 +198,27 @@ u2 descriptor_typesize(typedesc *td)
        assert(td);
 
        switch (td->type) {
-               case TYPE_INT: return 4;
-               case TYPE_LNG: return 8;
-               case TYPE_FLT: return 4;
-               case TYPE_DBL: return 8;
-               case TYPE_ADR: return sizeof(voidptr);
+       case TYPE_INT:
+       case TYPE_FLT:
+               return 4;
+
+       case TYPE_LNG:
+       case TYPE_DBL:
+               return 8;
+
+       case TYPE_ADR:
+               return SIZEOF_VOID_P;
+
+       default:
+               vm_abort("descriptor_typesize: invalid type %d", td->type);
        }
 
-       assert(0);
+       /* keep the compiler happy */
 
-       return 0; /* keep the compiler happy */
+       return 0;
 }
 
+
 /* name_from_descriptor ********************************************************
 
    Return the class name indicated by the given descriptor