1 /* src/vm/annotation.c - class annotations
3 Copyright (C) 2006 R. Grafl, A. Krall, C. Kruegel, C. Oates,
4 R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner,
5 C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger,
6 Institut f. Computersprachen - TU Wien
8 This file is part of CACAO.
10 This program is free software; you can redistribute it and/or
11 modify it under the terms of the GNU General Public License as
12 published by the Free Software Foundation; either version 2, or (at
13 your option) any later version.
15 This program is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
25 Contact: cacao@cacaojvm.org
27 Authors: Christian Thalinger
29 $Id: utf8.h 5920 2006-11-05 21:23:09Z twisti $
37 #include "mm/memory.h"
38 #include "vm/annotation.h"
43 /* annotation_load_attribute_runtimevisibleannotations *************************
45 RuntimeVisibleAnnotations_attribute {
46 u2 attribute_name_index;
49 annotation annotations[num_annotations];
54 u2 num_element_value_pairs;
56 u2 element_name_index;
57 element_value element;
58 } element_value_pairs[num_element_value_pairs];
61 *******************************************************************************/
63 #if defined(ENABLE_JAVASE)
64 bool annotation_load_attribute_runtimevisibleannotations(classbuffer *cb)
72 u2 num_element_value_pairs;
73 u2 element_name_index;
80 if (!suck_check_classbuffer_size(cb, 4 + 2))
83 /* attribute_length */
85 attribute_length = suck_u4(cb);
87 if (!suck_check_classbuffer_size(cb, attribute_length))
90 /* get number of annotations */
92 num_annotations = suck_u2(cb);
94 printf("num_annotations: %d\n", num_annotations);
96 /* allocate annotations-array */
98 aa = MNEW(annotation_t, num_annotations);
100 /* parse all annotations */
102 for (i = 0; i < num_annotations; i++) {
103 /* get annotation type */
105 type_index = suck_u2(cb);
107 if (!(aa[i].type = class_getconstant(c, type_index, CONSTANT_Utf8)))
111 utf_display_printable_ascii(aa[i].type);
114 /* get number of element values */
116 num_element_value_pairs = suck_u2(cb);
118 printf("num_element_value_pairs: %d\n", num_element_value_pairs);
120 aev = MNEW(element_value_t, num_element_value_pairs);
122 /* parse all element values */
124 for (j = 0; j < num_element_value_pairs; j++) {
125 /* get element name */
127 element_name_index = suck_u2(cb);
130 class_getconstant(c, element_name_index, CONSTANT_Utf8)))
133 /* get element tag */
135 aev[i].tag = suck_u1(cb);
138 /* store element value data */
140 aa[i].element_valuescount = num_element_value_pairs;
141 aa[i].element_values = aev;
144 /* store annotation variables */
146 c->runtimevisibleannotationscount = num_annotations;
147 c->runtimevisibleannotations = aa;
151 #endif /* defined(ENABLE_JAVASE) */
155 * These are local overrides for various environment variables in Emacs.
156 * Please do not remove this and leave it at the end of the file, where
157 * Emacs will automagically detect them.
158 * ---------------------------------------------------------------------
161 * indent-tabs-mode: t
165 * vim:noexpandtab:sw=4:ts=4: