add "jit_type_get_kind" so that front end code can classify types quickly.
"jitdynamic" library, which will handle all of the cross-language
naming and dynamic invocation logic.
+ * include/jit/jit-type.h, jit/jit-internal.h, jit/jit-type.c,
+ jitdynamic/jit-cpp-mangle.c: move the "JIT_TYPE_xxx" constants
+ into the public headers and add "jit_type_get_kind" so that
+ front end code can classify types quickly.
+
2004-05-07 Rhys Weatherley <rweather@southern-storm.com.au>
* dpas/dpas-function.c, dpas/dpas-internal.h, dpas/dpas-main.c,
extern jit_type_t const jit_type_sys_double;
extern jit_type_t const jit_type_sys_long_double;
+/*
+ * Type kinds that may be returned by "jit_type_get_kind".
+ */
+#define JIT_TYPE_INVALID -1
+#define JIT_TYPE_VOID 0
+#define JIT_TYPE_SBYTE 1
+#define JIT_TYPE_UBYTE 2
+#define JIT_TYPE_SHORT 3
+#define JIT_TYPE_USHORT 4
+#define JIT_TYPE_INT 5
+#define JIT_TYPE_UINT 6
+#define JIT_TYPE_NINT 7
+#define JIT_TYPE_NUINT 8
+#define JIT_TYPE_LONG 9
+#define JIT_TYPE_ULONG 10
+#define JIT_TYPE_FLOAT32 11
+#define JIT_TYPE_FLOAT64 12
+#define JIT_TYPE_NFLOAT 13
+#define JIT_TYPE_MAX_PRIMITIVE JIT_TYPE_NFLOAT
+#define JIT_TYPE_STRUCT 14
+#define JIT_TYPE_UNION 15
+#define JIT_TYPE_SIGNATURE 16
+#define JIT_TYPE_PTR 17
+#define JIT_TYPE_FIRST_TAGGED 32
+
/*
* Special tag types.
*/
(jit_type_t type, jit_nint size, jit_nint alignment) JIT_NOTHROW;
void jit_type_set_offset
(jit_type_t type, unsigned int field_index, jit_nuint offset) JIT_NOTHROW;
+int jit_type_get_kind(jit_type_t type) JIT_NOTHROW;
jit_nuint jit_type_get_size(jit_type_t type) JIT_NOTHROW;
jit_nuint jit_type_get_alignment(jit_type_t type) JIT_NOTHROW;
unsigned int jit_type_num_fields(jit_type_t type) JIT_NOTHROW;
*/
int _jit_store_opcode(int base_opcode, int small_base, jit_type_t type);
-/*
- * Type descriptor kinds.
- */
-#define JIT_TYPE_VOID 0
-#define JIT_TYPE_SBYTE 1
-#define JIT_TYPE_UBYTE 2
-#define JIT_TYPE_SHORT 3
-#define JIT_TYPE_USHORT 4
-#define JIT_TYPE_INT 5
-#define JIT_TYPE_UINT 6
-#define JIT_TYPE_NINT 7
-#define JIT_TYPE_NUINT 8
-#define JIT_TYPE_LONG 9
-#define JIT_TYPE_ULONG 10
-#define JIT_TYPE_FLOAT32 11
-#define JIT_TYPE_FLOAT64 12
-#define JIT_TYPE_NFLOAT 13
-#define JIT_TYPE_MAX_PRIMITIVE JIT_TYPE_NFLOAT
-#define JIT_TYPE_STRUCT 14
-#define JIT_TYPE_UNION 15
-#define JIT_TYPE_SIGNATURE 16
-#define JIT_TYPE_PTR 17
-#define JIT_TYPE_FIRST_TAGGED 32
-
/*
* Internal structure of a type descriptor.
*/
}
}
+/*@
+ * @deftypefun int jit_type_get_kind (jit_type_t type)
+ * Get a value that indicates the kind of @code{type}. This allows
+ * callers to quickly classify a type to determine how it should be
+ * handled further.
+ *
+ * @table @code
+ * @vindex JIT_TYPE_INVALID
+ * @item JIT_TYPE_INVALID
+ * The value of the @code{type} parameter is NULL.
+ *
+ * @vindex JIT_TYPE_VOID
+ * @item JIT_TYPE_VOID
+ * The type is @code{jit_type_void}.
+ *
+ * @vindex JIT_TYPE_SBYTE
+ * @item JIT_TYPE_SBYTE
+ * The type is @code{jit_type_sbyte}.
+ *
+ * @vindex JIT_TYPE_UBYTE
+ * @item JIT_TYPE_UBYTE
+ * The type is @code{jit_type_ubyte}.
+ *
+ * @vindex JIT_TYPE_SHORT
+ * @item JIT_TYPE_SHORT
+ * The type is @code{jit_type_short}.
+ *
+ * @vindex JIT_TYPE_USHORT
+ * @item JIT_TYPE_USHORT
+ * The type is @code{jit_type_ushort}.
+ *
+ * @vindex JIT_TYPE_INT
+ * @item JIT_TYPE_INT
+ * The type is @code{jit_type_int}.
+ *
+ * @vindex JIT_TYPE_UINT
+ * @item JIT_TYPE_UINT
+ * The type is @code{jit_type_uint}.
+ *
+ * @vindex JIT_TYPE_NINT
+ * @item JIT_TYPE_NINT
+ * The type is @code{jit_type_nint}.
+ *
+ * @vindex JIT_TYPE_NUINT
+ * @item JIT_TYPE_NUINT
+ * The type is @code{jit_type_nuint}.
+ *
+ * @vindex JIT_TYPE_LONG
+ * @item JIT_TYPE_LONG
+ * The type is @code{jit_type_long}.
+ *
+ * @vindex JIT_TYPE_ULONG
+ * @item JIT_TYPE_ULONG
+ * The type is @code{jit_type_ulong}.
+ *
+ * @vindex JIT_TYPE_FLOAT32
+ * @item JIT_TYPE_FLOAT32
+ * The type is @code{jit_type_float32}.
+ *
+ * @vindex JIT_TYPE_FLOAT64
+ * @item JIT_TYPE_FLOAT64
+ * The type is @code{jit_type_float64}.
+ *
+ * @vindex JIT_TYPE_NFLOAT
+ * @item JIT_TYPE_NFLOAT
+ * The type is @code{jit_type_nfloat}.
+ *
+ * @vindex JIT_TYPE_STRUCT
+ * @item JIT_TYPE_STRUCT
+ * The type is the result of calling @code{jit_type_create_struct}.
+ *
+ * @vindex JIT_TYPE_UNION
+ * @item JIT_TYPE_UNION
+ * The type is the result of calling @code{jit_type_create_union}.
+ *
+ * @vindex JIT_TYPE_SIGNATURE
+ * @item JIT_TYPE_SIGNATURE
+ * The type is the result of calling @code{jit_type_create_signature}.
+ *
+ * @vindex JIT_TYPE_PTR
+ * @item JIT_TYPE_PTR
+ * The type is the result of calling @code{jit_type_create_pointer}.
+ * @end table
+ *
+ * @vindex JIT_TYPE_FIRST_TAGGED
+ * If this function returns @code{JIT_TYPE_FIRST_TAGGED} or higher,
+ * then the type is tagged and its tag kind is the return value minus
+ * @code{JIT_TYPE_FIRST_TAGGED}. That is, the following two expressions
+ * will be identical if @code{type} is tagged:
+ *
+ * @example
+ * jit_type_get_tagged_kind(type)
+ * jit_type_get_kind(type) - JIT_TYPE_FIRST_TAGGED
+ * @end example
+ * @end deftypefun
+@*/
+int jit_type_get_kind(jit_type_t type)
+{
+ if(!type)
+ {
+ return JIT_TYPE_INVALID;
+ }
+ else
+ {
+ return type->kind;
+ }
+}
+
/*@
* @deftypefun jit_nuint jit_type_get_size (jit_type_t type)
* Get the size of a type in bytes.
*/
#include <jit/jit-dynamic.h>
-#include "jit-internal.h"
+#include <jit/jit.h>
#include <config.h>
#include <stdio.h>
{
return 0;
}
- switch(type->kind)
+ switch(jit_type_get_kind(type))
{
case JIT_TYPE_SBYTE:
return get_system_type(type, sizeof(jit_sbyte), 1);
*/
static int is_unsigned(jit_type_t type)
{
- type = jit_type_remove_tags(type);
- if(type)
- {
- if(type->kind == JIT_TYPE_UBYTE ||
- type->kind == JIT_TYPE_USHORT ||
- type->kind == JIT_TYPE_UINT ||
- type->kind == JIT_TYPE_NUINT ||
- type->kind == JIT_TYPE_ULONG)
- {
- return 1;
- }
+ int kind = jit_type_get_kind(jit_type_remove_tags(type));
+ if(kind == JIT_TYPE_UBYTE ||
+ kind == JIT_TYPE_USHORT ||
+ kind == JIT_TYPE_UINT ||
+ kind == JIT_TYPE_NUINT ||
+ kind == JIT_TYPE_ULONG)
+ {
+ return 1;
}
return 0;
}
}
/* Handle the inner-most part of the type */
- if(type->kind >= JIT_TYPE_SBYTE && type->kind <= JIT_TYPE_ULONG)
+ kind = jit_type_get_kind(type);
+ if(kind >= JIT_TYPE_SBYTE && kind <= JIT_TYPE_ULONG)
{
type = fix_system_types(type);
}
- switch(type->kind)
+ switch(kind)
{
case JIT_TYPE_VOID: add_ch(mangler, 'v'); break;
}
/* Handle the inner-most part of the type */
- if(type->kind >= JIT_TYPE_SBYTE && type->kind <= JIT_TYPE_ULONG)
+ kind = jit_type_get_kind(type);
+ if(kind >= JIT_TYPE_SBYTE && kind <= JIT_TYPE_ULONG)
{
type = fix_system_types(type);
}
- switch(type->kind)
+ switch(kind)
{
case JIT_TYPE_VOID: add_ch(mangler, 'v'); break;
}
/* Handle the inner-most part of the type */
- if(type->kind >= JIT_TYPE_SBYTE && type->kind <= JIT_TYPE_ULONG)
+ kind = jit_type_get_kind(type);
+ if(kind >= JIT_TYPE_SBYTE && kind <= JIT_TYPE_ULONG)
{
type = fix_system_types(type);
}
- switch(type->kind)
+ switch(kind)
{
case JIT_TYPE_VOID: add_ch(mangler, 'X'); break;