+/* Native reference to Nit objects */
+/* This structure is used to represent every Nit type in extern methods and custom C code. */
+struct nitni_ref {
+ val_t val; /* reference to the real Nit object, is kept up-to-date by GC */
+};
+
+/* This structure is used by extern methods to keep track of local references to Nit objects */
+/* These references make sure an object is not collected by the GC while
+ * this extern methods is on the call stack. */
+/* This takes the form of an array link, each link of size 8 to avoid multiple mallocs. */
+#define NITNI_REF_ARRAY_LINK_SIZE 8
+struct nitni_ref_array_link {
+ struct nitni_ref *reg[ NITNI_REF_ARRAY_LINK_SIZE ];
+ int count; /* nubmer of elements in this link */
+ struct nitni_ref_array_link *next; /* next link in the list */
+};
+
+/* Register reference to Nit object with the latest extern method called. */
+extern void nitni_local_ref_add( struct nitni_ref *ref );
+
+/* Clean all references associated to the current (but returning) extern method. */
+extern void nitni_local_ref_clean( void );
+
+/* Stack frames.
+ * Are used to:
+ * - store local variables (REGS) of functions
+ * - store context for closure
+ * - provide information for stack dump
+ */