* Removed all Id tags.
[cacao.git] / src / vm / primitive.h
1 /* src/vm/primitive.c - primitive types
2
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
7
8    This file is part of CACAO.
9
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.
14
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.
19
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
23    02110-1301, USA.
24
25 */
26
27
28 #ifndef _PRIMITIVE_H
29 #define _PRIMITIVE_H
30
31 #include "config.h"
32
33 #include <stdint.h>
34
35 #include "vm/global.h"
36
37 #include "vmcore/class.h"
38 #include "vmcore/linker.h"
39 #include "vmcore/utf8.h"
40
41
42 /* primitive data types *******************************************************/
43
44 /* These values are used in parsed descriptors and in some other
45    places were the different types handled internally as TYPE_INT have
46    to be distinguished. */
47
48 #define PRIMITIVETYPE_COUNT  11  /* number of primitive types (+ dummies)     */
49
50 /* CAUTION: Don't change the numerical values! These constants are
51    used as indices into the primitive type table. */
52
53 #define PRIMITIVETYPE_INT     TYPE_INT
54 #define PRIMITIVETYPE_LONG    TYPE_LNG
55 #define PRIMITIVETYPE_FLOAT   TYPE_FLT
56 #define PRIMITIVETYPE_DOUBLE  TYPE_DBL
57 #define PRIMITIVETYPE_DUMMY1  TYPE_ADR     /* not used! */
58 #define PRIMITIVETYPE_BYTE    5
59 #define PRIMITIVETYPE_CHAR    6
60 #define PRIMITIVETYPE_SHORT   7
61 #define PRIMITIVETYPE_BOOLEAN 8
62 #define PRIMITIVETYPE_DUMMY2  9            /* not used! */
63 #define PRIMITIVETYPE_VOID    TYPE_VOID
64
65
66 /* primitivetypeinfo **********************************************************/
67
68 struct primitivetypeinfo {
69         char      *cname;                    /* char name of primitive class      */
70         utf       *name;                     /* name of primitive class           */
71         classinfo *class_wrap;               /* class for wrapping primitive type */
72         classinfo *class_primitive;          /* primitive class                   */
73         char      *wrapname;                 /* name of class for wrapping        */
74         char       typesig;                  /* one character type signature      */
75         char      *arrayname;                /* name of primitive array class     */
76         classinfo *arrayclass;               /* primitive array class             */
77 };
78
79
80 /* global variables ***********************************************************/
81
82 /* This array can be indexed by the PRIMITIVETYPE_ and ARRAYTYPE_
83    constants (except ARRAYTYPE_OBJECT). */
84
85 extern primitivetypeinfo primitivetype_table[PRIMITIVETYPE_COUNT];
86
87
88 /* function prototypes ********************************************************/
89
90 /* this function is in src/vmcore/primitivecore.c */
91 bool       primitive_init(void);
92
93 classinfo *primitive_class_get_by_name(utf *name);
94 classinfo *primitive_class_get_by_type(int type);
95 classinfo *primitive_class_get_by_char(char ch);
96
97 classinfo *primitive_arrayclass_get_by_name(utf *name);
98 classinfo *primitive_arrayclass_get_by_type(int type);
99
100 int        primitive_type_get_by_wrapperclass(classinfo *c);
101
102 java_handle_t *primitive_box(int type, imm_union value);
103 imm_union      primitive_unbox(java_handle_t *o);
104
105 java_handle_t *primitive_box_boolean(int32_t value);
106 java_handle_t *primitive_box_byte(int32_t value);
107 java_handle_t *primitive_box_char(int32_t value);
108 java_handle_t *primitive_box_short(int32_t value);
109 java_handle_t *primitive_box_int(int32_t value);
110 java_handle_t *primitive_box_long(int64_t value);
111 java_handle_t *primitive_box_float(float value);
112 java_handle_t *primitive_box_double(double value);
113
114 int32_t        primitive_unbox_boolean(java_handle_t *o);
115 int32_t        primitive_unbox_byte(java_handle_t *o);
116 int32_t        primitive_unbox_char(java_handle_t *o);
117 int32_t        primitive_unbox_short(java_handle_t *o);
118 int32_t        primitive_unbox_int(java_handle_t *o);
119 int64_t        primitive_unbox_long(java_handle_t *o);
120 float          primitive_unbox_float(java_handle_t *o);
121 double         primitive_unbox_double(java_handle_t *o);
122
123 #endif /* _PRIMITIVE_H */
124
125
126 /*
127  * These are local overrides for various environment variables in Emacs.
128  * Please do not remove this and leave it at the end of the file, where
129  * Emacs will automagically detect them.
130  * ---------------------------------------------------------------------
131  * Local variables:
132  * mode: c
133  * indent-tabs-mode: t
134  * c-basic-offset: 4
135  * tab-width: 4
136  * End:
137  * vim:noexpandtab:sw=4:ts=4:
138  */