1 /* src/vm/primitive.c - primitive types
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: linker.c 8042 2007-06-07 17:43:29Z twisti $
37 #include "vm/global.h"
39 #include "vmcore/class.h"
40 #include "vmcore/linker.h"
41 #include "vmcore/utf8.h"
44 /* primitive data types *******************************************************/
46 /* These values are used in parsed descriptors and in some other
47 places were the different types handled internally as TYPE_INT have
48 to be distinguished. */
50 #define PRIMITIVETYPE_COUNT 11 /* number of primitive types (+ dummies) */
52 /* CAUTION: Don't change the numerical values! These constants are
53 used as indices into the primitive type table. */
55 #define PRIMITIVETYPE_INT TYPE_INT
56 #define PRIMITIVETYPE_LONG TYPE_LNG
57 #define PRIMITIVETYPE_FLOAT TYPE_FLT
58 #define PRIMITIVETYPE_DOUBLE TYPE_DBL
59 #define PRIMITIVETYPE_DUMMY1 TYPE_ADR /* not used! */
60 #define PRIMITIVETYPE_BYTE 5
61 #define PRIMITIVETYPE_CHAR 6
62 #define PRIMITIVETYPE_SHORT 7
63 #define PRIMITIVETYPE_BOOLEAN 8
64 #define PRIMITIVETYPE_DUMMY2 9 /* not used! */
65 #define PRIMITIVETYPE_VOID TYPE_VOID
68 /* CAUTION: Don't change the numerical values! These constants (with
69 the exception of ARRAYTYPE_OBJECT) are used as indices in the
70 primitive type table. */
72 #define ARRAYTYPE_INT PRIMITIVETYPE_INT
73 #define ARRAYTYPE_LONG PRIMITIVETYPE_LONG
74 #define ARRAYTYPE_FLOAT PRIMITIVETYPE_FLOAT
75 #define ARRAYTYPE_DOUBLE PRIMITIVETYPE_DOUBLE
76 #define ARRAYTYPE_BYTE PRIMITIVETYPE_BYTE
77 #define ARRAYTYPE_CHAR PRIMITIVETYPE_CHAR
78 #define ARRAYTYPE_SHORT PRIMITIVETYPE_SHORT
79 #define ARRAYTYPE_BOOLEAN PRIMITIVETYPE_BOOLEAN
80 #define ARRAYTYPE_OBJECT PRIMITIVETYPE_VOID /* don't use as index! */
83 /* primitivetypeinfo **********************************************************/
85 struct primitivetypeinfo {
86 char *cname; /* char name of primitive class */
87 utf *name; /* name of primitive class */
88 classinfo *class_wrap; /* class for wrapping primitive type */
89 classinfo *class_primitive; /* primitive class */
90 char *wrapname; /* name of class for wrapping */
91 char typesig; /* one character type signature */
92 char *arrayname; /* name of primitive array class */
93 classinfo *arrayclass; /* primitive array class */
97 /* global variables ***********************************************************/
99 /* This array can be indexed by the PRIMITIVETYPE_ and ARRAYTYPE_
100 constants (except ARRAYTYPE_OBJECT). */
102 extern primitivetypeinfo primitivetype_table[PRIMITIVETYPE_COUNT];
105 /* function prototypes ********************************************************/
107 /* this function is in src/vmcore/primitivecore.c */
108 bool primitive_init(void);
110 classinfo *primitive_class_get_by_name(utf *name);
111 classinfo *primitive_class_get_by_type(int type);
112 classinfo *primitive_class_get_by_char(char ch);
113 classinfo *primitive_arrayclass_get_by_name(utf *name);
114 classinfo *primitive_arrayclass_get_by_type(int type);
116 java_handle_t *primitive_box(int type, imm_union value);
117 imm_union primitive_unbox(int type, java_handle_t *o);
119 java_handle_t *primitive_box_boolean(int32_t value);
120 java_handle_t *primitive_box_byte(int32_t value);
121 java_handle_t *primitive_box_char(int32_t value);
122 java_handle_t *primitive_box_short(int32_t value);
123 java_handle_t *primitive_box_int(int32_t value);
124 java_handle_t *primitive_box_long(int64_t value);
125 java_handle_t *primitive_box_float(float value);
126 java_handle_t *primitive_box_double(double value);
128 int32_t primitive_unbox_boolean(java_handle_t *o);
129 int32_t primitive_unbox_byte(java_handle_t *o);
130 int32_t primitive_unbox_char(java_handle_t *o);
131 int32_t primitive_unbox_short(java_handle_t *o);
132 int32_t primitive_unbox_int(java_handle_t *o);
133 int64_t primitive_unbox_long(java_handle_t *o);
134 float primitive_unbox_float(java_handle_t *o);
135 double primitive_unbox_double(java_handle_t *o);
137 #endif /* _PRIMITIVE_H */
141 * These are local overrides for various environment variables in Emacs.
142 * Please do not remove this and leave it at the end of the file, where
143 * Emacs will automagically detect them.
144 * ---------------------------------------------------------------------
147 * indent-tabs-mode: t
151 * vim:noexpandtab:sw=4:ts=4: