1 /* Declarations to interface gcj with bytecode verifier.
2 Copyright (C) 2003, 2004, 2005, 2006 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)
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, 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, 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>. */
36 #include "coretypes.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
;
54 int handler
, start
, end
, type
;
62 const unsigned char *bytes
;
63 vfy_exception
*exceptions
;
65 /* These fields are referred to directly by the verifier. */
66 vfy_jclass defining_class
;
73 /* Entry point to the verifier. */
74 int verify_jvm_instructions_new (JCF
*jcf
, const unsigned char *byte_ops
,
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_class_type (void);
116 vfy_jclass
vfy_string_type (void);
117 vfy_jclass
vfy_throwable_type (void);
118 vfy_jclass
vfy_unsuitable_type (void);
119 vfy_jclass
vfy_return_address_type (void);
120 vfy_jclass
vfy_null_type (void);
121 int vfy_fail (const char *message
, int pc
, vfy_jclass ignore1
,
123 vfy_jclass
vfy_get_primitive_type (int type
);
124 void vfy_note_stack_depth (vfy_method
*method
, int pc
, int depth
);
125 void vfy_note_stack_type (vfy_method
*method
, int pc
, int slot
,
127 void vfy_note_local_type (vfy_method
*method
, int pc
, int slot
,
129 void vfy_note_instruction_seen (int pc
);
130 bool vfy_class_has_field (vfy_jclass klass
, vfy_string name
,
131 vfy_string signature
);
133 #define GLOM(name, stuff) name ## stuff
134 #define VFY_PRIMITIVE_CLASS(name) \
135 vfy_get_primitive_type ((int) (GLOM (name, _type)))
139 #define JAVAOP(name, num, ignore1, ignore2, ignore3) \
140 GLOM (op_, name) = num,
141 #include "javaop.def"
146 #define JV_CONSTANT_Class CONSTANT_Class
147 #define JV_CONSTANT_ResolvedClass CONSTANT_ResolvedClass
148 #define JV_CONSTANT_String CONSTANT_String
149 #define JV_CONSTANT_ResolvedString CONSTANT_ResolvedString
150 #define JV_CONSTANT_Integer CONSTANT_Integer
151 #define JV_CONSTANT_Float CONSTANT_Float
152 #define JV_CONSTANT_Long CONSTANT_Long
153 #define JV_CONSTANT_Double CONSTANT_Double
154 #define JV_CONSTANT_Fieldref CONSTANT_Fieldref
155 #define JV_CONSTANT_InterfaceMethodref CONSTANT_InterfaceMethodref
156 #define JV_CONSTANT_Methodref CONSTANT_Methodref
158 int verify_method (vfy_method
*meth
);
164 #endif /* ! GCC_VERIFY_H */