]> git.unchartedbackwaters.co.uk Git - francis/libjit.git/commitdiff
Move the "JIT_TYPE_xxx" constants into the public headers and
authorRhys Weatherley <rweather@southern-storm.com.au>
Sat, 8 May 2004 02:31:32 +0000 (02:31 +0000)
committerRhys Weatherley <rweather@southern-storm.com.au>
Sat, 8 May 2004 02:31:32 +0000 (02:31 +0000)
add "jit_type_get_kind" so that front end code can classify types quickly.

ChangeLog
include/jit/jit-type.h
jit/jit-internal.h
jit/jit-type.c
jitdynamic/jit-cpp-mangle.c

index 30210d7fb8727c1143256b09663fd273f68d8deb..4b7e6e47d83b7ec7614b921d43bd6390a2ec4d6a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
        "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,
index 03ec5578255e3115f69fcb44a45872f5f74bb9c6..efb342a83c7c7755ed2f469a585b1e33d5989460 100644 (file)
@@ -66,6 +66,31 @@ extern jit_type_t const jit_type_sys_float;
 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.
  */
@@ -128,6 +153,7 @@ void jit_type_set_size_and_alignment
        (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;
index 724fc2e5c71d9709628cab58c7b1ef06d90eff9f..249f8107ff04b32b2f89532b19841606f4fb7ee6 100644 (file)
@@ -554,30 +554,6 @@ int _jit_load_opcode(int base_opcode, jit_type_t type,
  */
 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.
  */
index ff9a2fa6d2a7280c4acfd75bb925a4b6917a8743..05675e8ee67d3a4ddb2d6742f40072fb18f8a647 100644 (file)
@@ -890,6 +890,114 @@ void jit_type_set_offset(jit_type_t type, unsigned int field_index,
        }
 }
 
+/*@
+ * @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.
index ee028e579438eeff0cec06d79c6e16529ffcdd9d..a56ab07ff1d30e9744e8605a61eb93ec4687dbb3 100644 (file)
@@ -19,7 +19,7 @@
  */
 
 #include <jit/jit-dynamic.h>
-#include "jit-internal.h"
+#include <jit/jit.h>
 #include <config.h>
 #include <stdio.h>
 
@@ -298,7 +298,7 @@ static jit_type_t fix_system_types(jit_type_t type)
        {
                return 0;
        }
-       switch(type->kind)
+       switch(jit_type_get_kind(type))
        {
                case JIT_TYPE_SBYTE:
                        return get_system_type(type, sizeof(jit_sbyte), 1);
@@ -329,17 +329,14 @@ static jit_type_t fix_system_types(jit_type_t type)
  */
 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;
 }
@@ -520,11 +517,12 @@ static void mangle_type_gcc2(jit_mangler_t mangler, jit_type_t type)
        }
 
        /* 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;
 
@@ -825,11 +823,12 @@ static void mangle_type_gcc3(jit_mangler_t mangler, jit_type_t type)
        }
 
        /* 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;
 
@@ -1096,11 +1095,12 @@ static void mangle_type_msvc6(jit_mangler_t mangler, jit_type_t type)
        }
 
        /* 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;