4 #include "gc_chooser.h"
6 #include <android/log.h>
7 #define PRINT_ERROR(...) (void)__android_log_print(ANDROID_LOG_WARN, "Nit", __VA_ARGS__)
9 #define PRINT_ERROR(...) fprintf(stderr, __VA_ARGS__)
11 typedef void(*nitmethod_t
)(void); /* general C type representing a Nit method. */
20 } nitattribute_t
; /* general C type representing a Nit attribute. */
21 struct class { int box_kind
; nitmethod_t vft
[]; }; /* general C type representing a Nit class. */
22 struct type
{ int id
; const char *name
; int color
; short int is_nullable
; const struct types
*resolution_table
; int table_size
; int type_table
[]; }; /* general C type representing a Nit type. */
23 struct instance
{ const struct type
*type
; const struct class *class; nitattribute_t attrs
[]; }; /* general C type representing a Nit instance. */
24 struct types
{ int dummy
; const struct type
*types
[]; }; /* a list types (used for vts, fts and unresolved lists). */
25 typedef struct instance val
; /* general C type representing a Nit instance. */
26 struct nitni_instance
{
27 struct nitni_instance
*next
,
28 *prev
; /* adjacent global references in global list */
29 int count
; /* number of time this global reference has been marked */
30 struct instance
*value
;
33 /* Native reference to Nit objects */
34 /* This structure is used to represent every Nit type in extern methods and custom C code. */
36 struct nitni_ref
*next
,
37 *prev
; /* adjacent global references in global list */
38 int count
; /* number of time this global reference has been marked */
41 /* List of global references from C code to Nit objects */
42 /* Instanciated empty at init of Nit system and filled explicitly by user in C code */
43 struct nitni_global_ref_list_t
{
44 struct nitni_ref
*head
, *tail
;
46 extern struct nitni_global_ref_list_t
*nitni_global_ref_list
;
48 /* Initializer of global reference list */
49 extern void nitni_global_ref_list_init();
51 /* Intern function to add a global reference to the list */
52 extern void nitni_global_ref_add( struct nitni_ref
*ref
);
54 /* Intern function to remove a global reference from the list */
55 extern void nitni_global_ref_remove( struct nitni_ref
*ref
);
57 /* Increase count on an existing global reference */
58 extern void nitni_global_ref_incr( struct nitni_ref
*ref
);
60 /* Decrease count on an existing global reference */
61 extern void nitni_global_ref_decr( struct nitni_ref
*ref
);
63 void show_backtrace(int) __attribute__ ((noreturn
));
64 #define likely(x) __builtin_expect((x),1)
65 #define unlikely(x) __builtin_expect((x),0)
67 extern char **glob_argv
;
69 struct instance_kernel__Bool
{
70 const struct type
*type
;
71 const struct class *class;
74 struct instance_kernel__Float
{
75 const struct type
*type
;
76 const struct class *class;
79 struct instance_kernel__Int
{
80 const struct type
*type
;
81 const struct class *class;
84 struct instance_kernel__Char
{
85 const struct type
*type
;
86 const struct class *class;
89 struct instance_kernel__Pointer
{
90 const struct type
*type
;
91 const struct class *class;
94 struct instance_array__NativeArray
{
95 const struct type
*type
;
96 const struct class *class;