* src/vm/method.c (method_descriptor2types): Removed.
[cacao.git] / src / vm / method.c
1 /* src/vm/method.c - method functions
2
3    Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
4    C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
5    E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
6    J. Wenninger, Institut f. Computersprachen - TU Wien
7
8    This file is part of CACAO.
9
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.
14
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.
19
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., 51 Franklin Street, Fifth Floor, Boston, MA
23    02110-1301, USA.
24
25    Contact: cacao@cacaojvm.org
26
27    Authors: Reinhard Grafl
28
29    Changes: Andreas Krall
30             Roman Obermaiser
31             Mark Probst
32             Edwin Steiner
33             Christian Thalinger
34
35    $Id: method.c 4381 2006-01-28 14:18:06Z twisti $
36
37 */
38
39
40 #include "config.h"
41
42 #include <stdio.h>
43
44 #include "vm/types.h"
45
46 #include "mm/memory.h"
47 #include "vm/class.h"
48 #include "vm/global.h"
49 #include "vm/loader.h"
50 #include "vm/method.h"
51
52
53 /* method_free *****************************************************************
54
55    Frees all memory that was allocated for this method.
56
57 *******************************************************************************/
58
59 void method_free(methodinfo *m)
60 {
61         if (m->jcode)
62                 MFREE(m->jcode, u1, m->jcodelength);
63
64         if (m->exceptiontable)
65                 MFREE(m->exceptiontable, exceptiontable, m->exceptiontablelength);
66
67         if (m->mcode)
68                 CFREE((void *) (ptrint) m->mcode, m->mcodelength);
69
70         if (m->stubroutine) {
71                 if (m->flags & ACC_NATIVE) {
72                         removenativestub(m->stubroutine);
73
74                 } else {
75                         removecompilerstub(m->stubroutine);
76                 }
77         }
78 }
79
80
81 /* method_canoverwrite *********************************************************
82
83    Check if m and old are identical with respect to type and
84    name. This means that old can be overwritten with m.
85         
86 *******************************************************************************/
87
88 bool method_canoverwrite(methodinfo *m, methodinfo *old)
89 {
90         if (m->name != old->name)
91                 return false;
92
93         if (m->descriptor != old->descriptor)
94                 return false;
95
96         if (m->flags & ACC_STATIC)
97                 return false;
98
99         return true;
100 }
101
102
103 /* method_printflags ***********************************************************
104
105    Prints the flags of a method to stdout like.
106
107 *******************************************************************************/
108
109 #if !defined(NDEBUG)
110 void method_printflags(methodinfo *m)
111 {
112         if (m->flags & ACC_PUBLIC)       printf(" PUBLIC");
113         if (m->flags & ACC_PRIVATE)      printf(" PRIVATE");
114         if (m->flags & ACC_PROTECTED)    printf(" PROTECTED");
115         if (m->flags & ACC_STATIC)       printf(" STATIC");
116         if (m->flags & ACC_FINAL)        printf(" FINAL");
117         if (m->flags & ACC_SYNCHRONIZED) printf(" SYNCHRONIZED");
118         if (m->flags & ACC_VOLATILE)     printf(" VOLATILE");
119         if (m->flags & ACC_TRANSIENT)    printf(" TRANSIENT");
120         if (m->flags & ACC_NATIVE)       printf(" NATIVE");
121         if (m->flags & ACC_INTERFACE)    printf(" INTERFACE");
122         if (m->flags & ACC_ABSTRACT)     printf(" ABSTRACT");
123 }
124 #endif /* !defined(NDEBUG) */
125
126
127 /* method_print ****************************************************************
128
129    Prints a method to stdout like:
130
131    java.lang.Object.<init>()V
132
133 *******************************************************************************/
134
135 #if !defined(NDEBUG)
136 void method_print(methodinfo *m)
137 {
138         utf_display_classname(m->class->name);
139         printf(".");
140         utf_display(m->name);
141         utf_display(m->descriptor);
142
143         method_printflags(m);
144 }
145 #endif /* !defined(NDEBUG) */
146
147
148 /* method_println **************************************************************
149
150    Prints a method plus new line to stdout like:
151
152    java.lang.Object.<init>()V
153
154 *******************************************************************************/
155
156 #if !defined(NDEBUG)
157 void method_println(methodinfo *m)
158 {
159         method_print(m);
160         printf("\n");
161 }
162 #endif /* !defined(NDEBUG) */
163
164
165 /*
166  * These are local overrides for various environment variables in Emacs.
167  * Please do not remove this and leave it at the end of the file, where
168  * Emacs will automagically detect them.
169  * ---------------------------------------------------------------------
170  * Local variables:
171  * mode: c
172  * indent-tabs-mode: t
173  * c-basic-offset: 4
174  * tab-width: 4
175  * End:
176  */