f9feb5103c7c844a73ef3ba59ef8218681125834
[cacao.git] / src / vmcore / primitive.h
1 /* src/vmcore/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    $Id: linker.c 8042 2007-06-07 17:43:29Z twisti $
26
27 */
28
29
30 #ifndef _PRIMITIVE_H
31 #define _PRIMITIVE_H
32
33 #include "config.h"
34
35 #include <stdint.h>
36
37 #include "vm/global.h"
38
39 #include "vmcore/class.h"
40 #include "vmcore/linker.h"
41 #include "vmcore/utf8.h"
42
43
44 /* primitive data types *******************************************************/
45
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. */
49
50 #define PRIMITIVETYPE_COUNT  11  /* number of primitive types (+ dummies)     */
51
52 /* CAUTION: Don't change the numerical values! These constants are
53    used as indices into the primitive type table. */
54
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
66
67
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. */
71
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! */
81
82
83 /* primitivetypeinfo **********************************************************/
84
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             */
94 };
95
96
97 /* global variables ***********************************************************/
98
99 /* This array can be indexed by the PRIMITIVETYPE_ and ARRAYTYPE_
100    constants (except ARRAYTYPE_OBJECT). */
101
102 extern primitivetypeinfo primitivetype_table[PRIMITIVETYPE_COUNT];
103
104
105 /* function prototypes ********************************************************/
106
107 bool       primitive_init(void);
108 classinfo *primitive_class_get_by_name(utf *name);
109 classinfo *primitive_class_get_by_type(int32_t type);
110 classinfo *primitive_class_get_by_char(char ch);
111 classinfo *primitive_arrayclass_get_by_name(utf *name);
112 classinfo *primitive_arrayclass_get_by_type(int32_t type);
113
114 #endif /* _PRIMITIVE_H */
115
116
117 /*
118  * These are local overrides for various environment variables in Emacs.
119  * Please do not remove this and leave it at the end of the file, where
120  * Emacs will automagically detect them.
121  * ---------------------------------------------------------------------
122  * Local variables:
123  * mode: c
124  * indent-tabs-mode: t
125  * c-basic-offset: 4
126  * tab-width: 4
127  * End:
128  * vim:noexpandtab:sw=4:ts=4:
129  */