offsets.h depends on genoffsets and config.h, all other headers are
[cacao.git] / src / vm / method.c
index 7012c6873393f3fd56c2cd0b5eaac7f9b4865da9..89c3c843c6e12c453fa55ec14ec8c475bc9ef752 100644 (file)
@@ -32,7 +32,7 @@
             Edwin Steiner
             Christian Thalinger
 
-   $Id: method.c 2181 2005-04-01 16:53:33Z edwin $
+   $Id: method.c 2186 2005-04-02 00:43:25Z edwin $
 
 */
 
@@ -41,6 +41,7 @@
 #include "mm/memory.h"
 #include "vm/method.h"
 #include "vm/class.h"
+#include "vm/loader.h"
 #include "vm/jit/codegen.inc.h"
 
 
@@ -93,6 +94,45 @@ bool method_canoverwrite(methodinfo *m, methodinfo *old)
        return true;
 }
 
+/* method_descriptor2types *****************************************************
+
+   Fills in the following members of the given methodinfo:
+       returntype
+          paramcount
+       paramtypes         
+
+   Note:
+       This function uses dump_alloc functions to allocate memory.
+
+*******************************************************************************/               
+
+void method_descriptor2types(methodinfo *m)
+{
+       u1 *types, *tptr;
+       int pcount, i;
+       methoddesc *md = m->parseddesc;
+       typedesc *paramtype;
+       
+       pcount = md->paramcount;
+       if ((m->flags & ACC_STATIC) == 0)
+               pcount++; /* count this pointer */
+       
+       types = DMNEW(u1,pcount);
+       tptr = types;
+       
+       if (!(m->flags & ACC_STATIC)) {
+               /* this pointer */
+               *tptr++ = TYPE_ADR;
+       }
+
+       paramtype = md->paramtypes;
+       for (i=0; i<md->paramcount; ++i,++paramtype)
+               *tptr++ = paramtype->type;
+
+       m->returntype = md->returntype.type;
+       m->paramcount = pcount;
+       m->paramtypes = types;
+}
 
 /************** Function: method_display  (debugging only) **************/