10 #include "gc_chooser.h"
12 #include <android/log.h>
13 #define PRINT_ERROR(...) (void)__android_log_print(ANDROID_LOG_WARN, "Nit", __VA_ARGS__)
15 #define PRINT_ERROR(...) fprintf(stderr, __VA_ARGS__)
17 typedef void(*nitmethod_t
)(void); /* general C type representing a Nit method. */
26 } nitattribute_t
; /* general C type representing a Nit attribute. */
27 struct class { int box_kind
; nitmethod_t vft
[]; }; /* general C type representing a Nit class. */
28 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. */
29 struct instance
{ const struct type
*type
; const struct class *class; nitattribute_t attrs
[]; }; /* general C type representing a Nit instance. */
30 struct types
{ int dummy
; const struct type
*types
[]; }; /* a list types (used for vts, fts and unresolved lists). */
31 typedef struct instance val
; /* general C type representing a Nit instance. */
32 extern const struct class *class_info
[];
33 extern const struct type
*type_info
[];
34 struct nitni_instance
{
35 struct nitni_instance
*next
,
36 *prev
; /* adjacent global references in global list */
37 int count
; /* number of time this global reference has been marked */
38 struct instance
*value
;
41 /* Native reference to Nit objects */
42 /* This structure is used to represent every Nit type in extern methods and custom C code. */
44 struct nitni_ref
*next
,
45 *prev
; /* adjacent global references in global list */
46 int count
; /* number of time this global reference has been marked */
49 /* List of global references from C code to Nit objects */
50 /* Instanciated empty at init of Nit system and filled explicitly by user in C code */
51 struct nitni_global_ref_list_t
{
52 struct nitni_ref
*head
, *tail
;
54 extern struct nitni_global_ref_list_t
*nitni_global_ref_list
;
56 /* Initializer of global reference list */
57 extern void nitni_global_ref_list_init();
59 /* Intern function to add a global reference to the list */
60 extern void nitni_global_ref_add( struct nitni_ref
*ref
);
62 /* Intern function to remove a global reference from the list */
63 extern void nitni_global_ref_remove( struct nitni_ref
*ref
);
65 /* Increase count on an existing global reference */
66 extern void nitni_global_ref_incr( struct nitni_ref
*ref
);
68 /* Decrease count on an existing global reference */
69 extern void nitni_global_ref_decr( struct nitni_ref
*ref
);
71 void fatal_exit(int) __attribute__ ((noreturn
));
72 #define likely(x) __builtin_expect((x),1)
73 #define unlikely(x) __builtin_expect((x),0)
75 extern char **glob_argv
;
77 struct instance_standard__NativeString
{
78 const struct type
*type
;
79 const struct class *class;
82 struct instance_standard__Float
{
83 const struct type
*type
;
84 const struct class *class;
87 struct instance_standard__Byte
{
88 const struct type
*type
;
89 const struct class *class;
92 struct instance_standard__Pointer
{
93 const struct type
*type
;
94 const struct class *class;
97 struct instance_standard__NativeArray
{
98 const struct type
*type
;
99 const struct class *class;