Merge from the pain train
[official-gcc.git] / gcc / java / verify.h
blobb23a08a988849baddac661ec3a7cd594c61351f2
1 /* Declarations to interface gcj with bytecode verifier.
2 Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
4 This file is part of GCC.
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 2, or (at your option)
9 any later version.
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.
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING. If not, write to
18 the Free Software Foundation, 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA.
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. */
25 /* Written by Tom Tromey <tromey@redhat.com>. */
27 #ifndef GCC_VERIFY_H
28 #define GCC_VERIFY_H
30 #ifdef __cplusplus
31 extern "C"
33 #endif
35 #include "system.h"
36 #include "coretypes.h"
37 #include "jcf.h"
38 #include "tree.h"
39 #include "java-tree.h"
41 typedef JCF vfy_constants;
43 /* For our purposes a string is the same as an identifier. */
44 typedef tree vfy_string;
46 /* The TYPE_DECL for a class or primitive type. */
47 typedef tree vfy_jclass;
49 /* An unsigned jshort. */
50 typedef uint16 vfy_uint_16;
52 typedef struct
54 int handler, start, end, type;
55 } vfy_exception;
57 typedef struct
59 tree method;
60 vfy_string signature;
61 vfy_string name;
62 const unsigned char *bytes;
63 vfy_exception *exceptions;
65 /* These fields are referred to directly by the verifier. */
66 vfy_jclass defining_class;
67 int max_stack;
68 int max_locals;
69 int code_length;
70 int exc_count;
71 } vfy_method;
73 /* Entry point to the verifier. */
74 int verify_jvm_instructions_new (JCF *jcf, const unsigned char *byte_ops,
75 long length);
77 void *vfy_alloc (size_t bytes);
78 void vfy_free (void *mem);
79 bool vfy_strings_equal (vfy_string one, vfy_string two);
80 const char *vfy_string_bytes (vfy_string str);
81 int vfy_string_length (vfy_string str);
82 vfy_string vfy_get_string (const char *chars, int length);
83 vfy_string vfy_init_name (void);
84 vfy_string vfy_clinit_name (void);
85 int vfy_count_arguments (vfy_string signature);
86 vfy_string vfy_get_signature (vfy_method *method);
87 vfy_string vfy_get_method_name (vfy_method *method);
88 bool vfy_is_static (vfy_method *method);
89 const unsigned char *vfy_get_bytecode (vfy_method *method);
90 vfy_exception *vfy_get_exceptions (vfy_method *method);
91 void vfy_get_exception (vfy_exception *, int index, int *handler,
92 int *start, int *end, int *handler_type);
93 int vfy_tag (vfy_constants *pool, int index);
94 void vfy_load_indexes (vfy_constants *pool, int index,
95 vfy_uint_16 *index0, vfy_uint_16 *index1);
96 vfy_constants *vfy_get_constants (vfy_jclass klass);
97 int vfy_get_constants_size (vfy_jclass klass);
98 vfy_string vfy_get_pool_string (vfy_constants *pool, int index);
99 vfy_jclass vfy_get_pool_class (vfy_constants *pool, int index);
100 vfy_string vfy_make_string (const char *s, int len);
101 vfy_string vfy_get_class_name (vfy_jclass klass);
102 bool vfy_is_assignable_from (vfy_jclass target, vfy_jclass source);
103 char vfy_get_primitive_char (vfy_jclass klass);
104 int vfy_get_interface_count (vfy_jclass klass);
105 vfy_jclass vfy_get_interface (vfy_jclass klass, int index);
106 bool vfy_is_array (vfy_jclass klass);
107 bool vfy_is_interface (vfy_jclass klass);
108 bool vfy_is_primitive (vfy_jclass klass);
109 vfy_jclass vfy_get_superclass (vfy_jclass klass);
110 vfy_jclass vfy_get_array_class (vfy_jclass klass);
111 vfy_jclass vfy_get_component_type (vfy_jclass klass);
112 bool vfy_is_abstract (vfy_jclass klass);
113 vfy_jclass vfy_find_class (vfy_jclass klass, vfy_string name);
114 vfy_jclass vfy_object_type (void);
115 vfy_jclass vfy_string_type (void);
116 vfy_jclass vfy_throwable_type (void);
117 vfy_jclass vfy_unsuitable_type (void);
118 vfy_jclass vfy_return_address_type (void);
119 vfy_jclass vfy_null_type (void);
120 int vfy_fail (const char *message, int pc, vfy_jclass ignore1,
121 vfy_method *method);
122 vfy_jclass vfy_get_primitive_type (int type);
123 void vfy_note_stack_depth (vfy_method *method, int pc, int depth);
124 void vfy_note_stack_type (vfy_method *method, int pc, int slot,
125 vfy_jclass type);
126 void vfy_note_local_type (vfy_method *method, int pc, int slot,
127 vfy_jclass type);
128 void vfy_note_instruction_seen (int pc);
129 bool vfy_class_has_field (vfy_jclass klass, vfy_string name,
130 vfy_string signature);
132 #define GLOM(name, stuff) name ## stuff
133 #define VFY_PRIMITIVE_CLASS(name) \
134 vfy_get_primitive_type ((int) (GLOM (name, _type)))
136 typedef enum
138 #define JAVAOP(name, num, ignore1, ignore2, ignore3) \
139 GLOM (op_, name) = num,
140 #include "javaop.def"
141 java_opcode_end
142 } java_opcode;
145 #define JV_CONSTANT_Class CONSTANT_Class
146 #define JV_CONSTANT_ResolvedClass CONSTANT_ResolvedClass
147 #define JV_CONSTANT_String CONSTANT_String
148 #define JV_CONSTANT_ResolvedString CONSTANT_ResolvedString
149 #define JV_CONSTANT_Integer CONSTANT_Integer
150 #define JV_CONSTANT_Float CONSTANT_Float
151 #define JV_CONSTANT_Long CONSTANT_Long
152 #define JV_CONSTANT_Double CONSTANT_Double
153 #define JV_CONSTANT_Fieldref CONSTANT_Fieldref
154 #define JV_CONSTANT_InterfaceMethodref CONSTANT_InterfaceMethodref
155 #define JV_CONSTANT_Methodref CONSTANT_Methodref
157 int verify_method (vfy_method *meth);
159 #ifdef __cplusplus
161 #endif
163 #endif /* ! GCC_VERIFY_H */