OSDN Git Service

* jcf-io.c: Don't include fnmatch.h. Don't use JCF_USE_SCANDIR.
[pf3gnuchains/gcc-fork.git] / gcc / java / verify.h
1 /* Declarations to interface gcj with bytecode verifier.
2    Copyright (C) 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
3
4 This file is part of GCC.
5
6 GCC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3, or (at your option)
9 any later version.
10
11 GCC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING3.  If not see
18 <http://www.gnu.org/licenses/>.
19
20 Java and all Java-based marks are trademarks or registered trademarks
21 of Sun Microsystems, Inc. in the United States and other countries.
22 The Free Software Foundation is independent of Sun Microsystems, Inc.  */
23
24 /* Written by Tom Tromey <tromey@redhat.com>.  */
25
26 #ifndef GCC_VERIFY_H
27 #define GCC_VERIFY_H
28
29 #ifdef __cplusplus
30 extern "C"
31 {
32 #endif
33
34 #include "system.h"
35 #include "coretypes.h"
36 #include "jcf.h"
37 #include "tree.h"
38 #include "java-tree.h"
39
40 typedef JCF vfy_constants;
41
42 /* For our purposes a string is the same as an identifier.  */
43 typedef tree vfy_string;
44
45 /* The TYPE_DECL for a class or primitive type.  */
46 typedef tree vfy_jclass;
47
48 /* An unsigned jshort.  */
49 typedef uint16 vfy_uint_16;
50
51 typedef struct
52 {
53   int handler, start, end, type;
54 } vfy_exception;
55
56 typedef struct
57 {
58   tree method;
59   vfy_string signature;
60   vfy_string name;
61   const unsigned char *bytes;
62   vfy_exception *exceptions;
63
64   /* These fields are referred to directly by the verifier.  */
65   vfy_jclass defining_class;
66   int max_stack;
67   int max_locals;
68   int code_length;
69   int exc_count;
70 } vfy_method;
71
72 /* Entry point to the verifier.  */
73 int verify_jvm_instructions_new (JCF *jcf, const unsigned char *byte_ops,
74                                  long length);
75
76 void *vfy_alloc (size_t bytes);
77 void vfy_free (void *mem);
78 bool vfy_strings_equal (vfy_string one, vfy_string two);
79 const char *vfy_string_bytes (vfy_string str);
80 int vfy_string_length (vfy_string str);
81 vfy_string vfy_get_string (const char *chars, int length);
82 vfy_string vfy_init_name (void);
83 vfy_string vfy_clinit_name (void);
84 int vfy_count_arguments (vfy_string signature);
85 vfy_string vfy_get_signature (vfy_method *method);
86 vfy_string vfy_get_method_name (vfy_method *method);
87 bool vfy_is_static (vfy_method *method);
88 const unsigned char *vfy_get_bytecode (vfy_method *method);
89 vfy_exception *vfy_get_exceptions (vfy_method *method);
90 void vfy_get_exception (vfy_exception *, int index, int *handler,
91                         int *start, int *end, int *handler_type);
92 int vfy_tag (vfy_constants *pool, int index);
93 void vfy_load_indexes (vfy_constants *pool, int index,
94                        vfy_uint_16 *index0, vfy_uint_16 *index1);
95 vfy_constants *vfy_get_constants (vfy_jclass klass);
96 int vfy_get_constants_size (vfy_jclass klass);
97 vfy_string vfy_get_pool_string (vfy_constants *pool, int index);
98 vfy_jclass vfy_get_pool_class (vfy_constants *pool, int index);
99 vfy_string vfy_get_class_name (vfy_jclass klass);
100 bool vfy_is_assignable_from (vfy_jclass target, vfy_jclass source);
101 char vfy_get_primitive_char (vfy_jclass klass);
102 int vfy_get_interface_count (vfy_jclass klass);
103 vfy_jclass vfy_get_interface (vfy_jclass klass, int index);
104 bool vfy_is_array (vfy_jclass klass);
105 bool vfy_is_interface (vfy_jclass klass);
106 bool vfy_is_primitive (vfy_jclass klass);
107 vfy_jclass vfy_get_superclass (vfy_jclass klass);
108 vfy_jclass vfy_get_array_class (vfy_jclass klass);
109 vfy_jclass vfy_get_component_type (vfy_jclass klass);
110 bool vfy_is_abstract (vfy_jclass klass);
111 vfy_jclass vfy_find_class (vfy_jclass klass, vfy_string name);
112 vfy_jclass vfy_object_type (void);
113 vfy_jclass vfy_class_type (void);
114 vfy_jclass vfy_string_type (void);
115 vfy_jclass vfy_throwable_type (void);
116 vfy_jclass vfy_unsuitable_type (void);
117 vfy_jclass vfy_return_address_type (void);
118 vfy_jclass vfy_null_type (void);
119 int vfy_fail (const char *message, int pc, vfy_jclass ignore1,
120               vfy_method *method);
121 vfy_jclass vfy_get_primitive_type (int type);
122 void vfy_note_stack_depth (vfy_method *method, int pc, int depth);
123 void vfy_note_stack_type (vfy_method *method, int pc, int slot,
124                           vfy_jclass type);
125 void vfy_note_local_type (vfy_method *method, int pc, int slot,
126                           vfy_jclass type);
127 void vfy_note_instruction_seen (int pc);
128 bool vfy_class_has_field (vfy_jclass klass, vfy_string name,
129                           vfy_string signature);
130
131 #define GLOM(name, stuff) name ## stuff
132 #define VFY_PRIMITIVE_CLASS(name) \
133   vfy_get_primitive_type ((int) (GLOM (name, _type)))
134
135 typedef enum
136 {
137 #define JAVAOP(name, num, ignore1, ignore2, ignore3) \
138   GLOM (op_, name) = num,
139 #include "javaop.def"
140   java_opcode_end
141 } java_opcode;
142
143
144 #define JV_CONSTANT_Class CONSTANT_Class
145 #define JV_CONSTANT_ResolvedClass CONSTANT_ResolvedClass
146 #define JV_CONSTANT_String CONSTANT_String
147 #define JV_CONSTANT_ResolvedString CONSTANT_ResolvedString
148 #define JV_CONSTANT_Integer CONSTANT_Integer
149 #define JV_CONSTANT_Float CONSTANT_Float
150 #define JV_CONSTANT_Long CONSTANT_Long
151 #define JV_CONSTANT_Double CONSTANT_Double
152 #define JV_CONSTANT_Fieldref CONSTANT_Fieldref
153 #define JV_CONSTANT_InterfaceMethodref CONSTANT_InterfaceMethodref
154 #define JV_CONSTANT_Methodref CONSTANT_Methodref
155
156 int verify_method (vfy_method *meth);
157
158 #ifdef __cplusplus
159 }
160 #endif
161
162 #endif /* ! GCC_VERIFY_H */