1 /* src/vm/method.c - method functions
3 Copyright (C) 1996-2005 R. Grafl, A. Krall, C. Kruegel, C. Oates,
4 R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner,
5 C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger,
6 Institut f. Computersprachen - TU Wien
8 This file is part of CACAO.
10 This program is free software; you can redistribute it and/or
11 modify it under the terms of the GNU General Public License as
12 published by the Free Software Foundation; either version 2, or (at
13 your option) any later version.
15 This program is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
25 Contact: cacao@complang.tuwien.ac.at
27 Authors: Reinhard Grafl
29 Changes: Andreas Krall
35 $Id: method.c 4301 2006-01-19 19:49:10Z twisti $
46 #include "mm/memory.h"
48 #include "vm/global.h"
49 #include "vm/loader.h"
50 #include "vm/method.h"
53 /* method_free *****************************************************************
55 Frees all memory that was allocated for this method.
57 *******************************************************************************/
59 void method_free(methodinfo *m)
62 MFREE(m->jcode, u1, m->jcodelength);
64 if (m->exceptiontable)
65 MFREE(m->exceptiontable, exceptiontable, m->exceptiontablelength);
68 CFREE((void *) (ptrint) m->mcode, m->mcodelength);
71 if (m->flags & ACC_NATIVE) {
72 removenativestub(m->stubroutine);
75 removecompilerstub(m->stubroutine);
81 /* method_canoverwrite *********************************************************
83 Check if m and old are identical with respect to type and
84 name. This means that old can be overwritten with m.
86 *******************************************************************************/
88 bool method_canoverwrite(methodinfo *m, methodinfo *old)
90 if (m->name != old->name)
93 if (m->descriptor != old->descriptor)
96 if (m->flags & ACC_STATIC)
102 /* method_descriptor2types *****************************************************
104 Fills in the following members of the given methodinfo:
110 This function uses dump_alloc functions to allocate memory.
112 *******************************************************************************/
114 void method_descriptor2types(methodinfo *m)
118 methoddesc *md = m->parseddesc;
121 pcount = md->paramcount;
122 if ((m->flags & ACC_STATIC) == 0)
123 pcount++; /* count this pointer */
125 types = DMNEW(u1,pcount);
128 if (!(m->flags & ACC_STATIC)) {
133 paramtype = md->paramtypes;
134 for (i=0; i<md->paramcount; ++i,++paramtype)
135 *tptr++ = paramtype->type;
137 m->returntype = md->returntype.type;
138 m->paramcount = pcount;
139 m->paramtypes = types;
143 /* method_printflags ***********************************************************
145 Prints the flags of a method to stdout like.
147 *******************************************************************************/
150 void method_printflags(methodinfo *m)
152 if (m->flags & ACC_PUBLIC) printf(" PUBLIC");
153 if (m->flags & ACC_PRIVATE) printf(" PRIVATE");
154 if (m->flags & ACC_PROTECTED) printf(" PROTECTED");
155 if (m->flags & ACC_STATIC) printf(" STATIC");
156 if (m->flags & ACC_FINAL) printf(" FINAL");
157 if (m->flags & ACC_SYNCHRONIZED) printf(" SYNCHRONIZED");
158 if (m->flags & ACC_VOLATILE) printf(" VOLATILE");
159 if (m->flags & ACC_TRANSIENT) printf(" TRANSIENT");
160 if (m->flags & ACC_NATIVE) printf(" NATIVE");
161 if (m->flags & ACC_INTERFACE) printf(" INTERFACE");
162 if (m->flags & ACC_ABSTRACT) printf(" ABSTRACT");
164 #endif /* !defined(NDEBUG) */
167 /* method_print ****************************************************************
169 Prints a method to stdout like:
171 java.lang.Object.<init>()V
173 *******************************************************************************/
176 void method_print(methodinfo *m)
178 utf_display_classname(m->class->name);
180 utf_display(m->name);
181 utf_display(m->descriptor);
183 method_printflags(m);
185 #endif /* !defined(NDEBUG) */
188 /* method_println **************************************************************
190 Prints a method plus new line to stdout like:
192 java.lang.Object.<init>()V
194 *******************************************************************************/
197 void method_println(methodinfo *m)
202 #endif /* !defined(NDEBUG) */
206 * These are local overrides for various environment variables in Emacs.
207 * Please do not remove this and leave it at the end of the file, where
208 * Emacs will automagically detect them.
209 * ---------------------------------------------------------------------
212 * indent-tabs-mode: t