1 /* Declarations to interface gcj with bytecode verifier.
2 Copyright (C) 2003, 2004, 2005, 2006, 2007 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 3, or (at your option)
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 COPYING3. If not see
18 <http://www.gnu.org/licenses/>.
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. */
24 /* Written by Tom Tromey <tromey@redhat.com>. */
35 #include "coretypes.h"
38 #include "java-tree.h"
40 typedef JCF vfy_constants
;
42 /* For our purposes a string is the same as an identifier. */
43 typedef tree vfy_string
;
45 /* The TYPE_DECL for a class or primitive type. */
46 typedef tree vfy_jclass
;
48 /* An unsigned jshort. */
49 typedef uint16 vfy_uint_16
;
53 int handler
, start
, end
, type
;
61 const unsigned char *bytes
;
62 vfy_exception
*exceptions
;
64 /* These fields are referred to directly by the verifier. */
65 vfy_jclass defining_class
;
72 /* Entry point to the verifier. */
73 int verify_jvm_instructions_new (JCF
*jcf
, const unsigned char *byte_ops
,
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
,
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
,
125 void vfy_note_local_type (vfy_method
*method
, int pc
, int slot
,
127 void vfy_note_instruction_seen (int pc
);
128 bool vfy_class_has_field (vfy_jclass klass
, vfy_string name
,
129 vfy_string signature
);
131 #define GLOM(name, stuff) name ## stuff
132 #define VFY_PRIMITIVE_CLASS(name) \
133 vfy_get_primitive_type ((int) (GLOM (name, _type)))
137 #define JAVAOP(name, num, ignore1, ignore2, ignore3) \
138 GLOM (op_, name) = num,
139 #include "javaop.def"
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
156 int verify_method (vfy_method
*meth
);
162 #endif /* ! GCC_VERIFY_H */