OSDN Git Service

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