1 /* src/vm/array.c - array functions
3 Copyright (C) 2007 R. Grafl, A. Krall, C. Kruegel,
4 C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
5 E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
6 J. Wenninger, 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 $Id: access.c 8318 2007-08-16 10:05:34Z michi $
34 #include "native/llni.h"
37 #include "vm/global.h"
41 /* array_element_primitive_get *************************************************
43 Returns a primitive element of the given Java array.
45 *******************************************************************************/
47 imm_union array_element_primitive_get(java_handle_t *a, int32_t index)
53 v = LLNI_vftbl_direct(a);
55 elementtype = v->arraydesc->elementtype;
57 switch (elementtype) {
58 case ARRAYTYPE_BOOLEAN:
59 value.i = array_booleanarray_element_get(a, index);
62 value.i = array_bytearray_element_get(a, index);
65 value.i = array_chararray_element_get(a, index);
68 value.i = array_shortarray_element_get(a, index);
71 value.i = array_intarray_element_get(a, index);
74 value.l = array_longarray_element_get(a, index);
77 value.f = array_floatarray_element_get(a, index);
79 case ARRAYTYPE_DOUBLE:
80 value.d = array_doublearray_element_get(a, index);
82 case ARRAYTYPE_OBJECT:
83 value.a = array_objectarray_element_get(a, index);
87 vm_abort("array_element_primitive_get: invalid array element type %d",
95 /* array_xxxarray_element_get **************************************************
97 Returns a primitive element of the given Java array.
99 *******************************************************************************/
101 #define ARRAY_TYPEARRAY_ELEMENT_GET(name, type) \
102 type array_##name##array_element_get(java_handle_t *a, int32_t index) \
104 java_handle_##name##array_t *ja; \
107 ja = (java_handle_##name##array_t *) a; \
109 value = LLNI_array_direct(ja, index); \
114 ARRAY_TYPEARRAY_ELEMENT_GET(boolean, uint8_t)
115 ARRAY_TYPEARRAY_ELEMENT_GET(byte, int8_t)
116 ARRAY_TYPEARRAY_ELEMENT_GET(char, uint16_t)
117 ARRAY_TYPEARRAY_ELEMENT_GET(short, int16_t)
118 ARRAY_TYPEARRAY_ELEMENT_GET(int, int32_t)
119 ARRAY_TYPEARRAY_ELEMENT_GET(long, int64_t)
120 ARRAY_TYPEARRAY_ELEMENT_GET(float, float)
121 ARRAY_TYPEARRAY_ELEMENT_GET(double, double)
122 ARRAY_TYPEARRAY_ELEMENT_GET(object, java_handle_t*)
126 * These are local overrides for various environment variables in Emacs.
127 * Please do not remove this and leave it at the end of the file, where
128 * Emacs will automagically detect them.
129 * ---------------------------------------------------------------------
132 * indent-tabs-mode: t
136 * vim:noexpandtab:sw=4:ts=4: