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. */
19 } nitattribute_t
; /* general C type representing a Nit attribute. */
20 struct class { int box_kind
; nitmethod_t vft
[]; }; /* general C type representing a Nit class. */
21 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. */
22 struct instance
{ const struct type
*type
; const struct class *class; nitattribute_t attrs
[]; }; /* general C type representing a Nit instance. */
23 struct types
{ int dummy
; const struct type
*types
[]; }; /* a list types (used for vts, fts and unresolved lists). */
24 typedef struct instance val
; /* general C type representing a Nit instance. */
25 struct nitni_instance
{
26 struct nitni_instance
*next
,
27 *prev
; /* adjacent global references in global list */
28 int count
; /* number of time this global reference has been marked */
29 struct instance
*value
;
32 /* Native reference to Nit objects */
33 /* This structure is used to represent every Nit type in extern methods and custom C code. */
35 struct nitni_ref
*next
,
36 *prev
; /* adjacent global references in global list */
37 int count
; /* number of time this global reference has been marked */
40 /* List of global references from C code to Nit objects */
41 /* Instanciated empty at init of Nit system and filled explicitly by user in C code */
42 struct nitni_global_ref_list_t
{
43 struct nitni_ref
*head
, *tail
;
45 extern struct nitni_global_ref_list_t
*nitni_global_ref_list
;
47 /* Initializer of global reference list */
48 extern void nitni_global_ref_list_init();
50 /* Intern function to add a global reference to the list */
51 extern void nitni_global_ref_add( struct nitni_ref
*ref
);
53 /* Intern function to remove a global reference from the list */
54 extern void nitni_global_ref_remove( struct nitni_ref
*ref
);
56 /* Increase count on an existing global reference */
57 extern void nitni_global_ref_incr( struct nitni_ref
*ref
);
59 /* Decrease count on an existing global reference */
60 extern void nitni_global_ref_decr( struct nitni_ref
*ref
);
62 void show_backtrace(int) __attribute__ ((noreturn
));
63 #define likely(x) __builtin_expect((x),1)
64 #define unlikely(x) __builtin_expect((x),0)
66 extern char **glob_argv
;
68 struct instance_standard__NativeString
{
69 const struct type
*type
;
70 const struct class *class;
73 struct instance_standard__Bool
{
74 const struct type
*type
;
75 const struct class *class;
78 struct instance_standard__Float
{
79 const struct type
*type
;
80 const struct class *class;
83 struct instance_standard__Int
{
84 const struct type
*type
;
85 const struct class *class;
88 struct instance_standard__Char
{
89 const struct type
*type
;
90 const struct class *class;
93 struct instance_standard__Pointer
{
94 const struct type
*type
;
95 const struct class *class;
98 struct instance_standard__NativeArray
{
99 const struct type
*type
;
100 const struct class *class;