lib: fix a bug with String::has_substring and related methods
[nit.git] / lib / nit_common.h
index 02e3dff..840f021 100644 (file)
 #define calloc(x,y) GC_MALLOC((x)*(y))
 #endif
 
+
+
 /* *** Types *** */
-typedef int (*fun_t)(int);                                     /* generic function pointer */
-typedef unsigned int cid_t;                                    /* class identifier */
-typedef unsigned long int val_t;       /* value (everything is a val_t) */
+typedef signed long int bigint;        /* standard int value, must be larger that any poiner */
+typedef bigint (*fun_t) (bigint);                                      /* generic function pointer */
+typedef bigint cid_t;                                  /* class identifier */
+typedef bigint val_t;  /* value (everything is a val_t) */
 typedef union obj_tu {union classtable_elt_tu * vft; val_t attr;} *obj_t; /* standard object */
-typedef union classtable_elt_tu { int i; fun_t f; cid_t cid;} classtable_elt_t;        /* classtable element */
+typedef union classtable_elt_tu { bigint i; fun_t f; cid_t cid;} classtable_elt_t;     /* classtable element */
 
 typedef classtable_elt_t * classtable_t;                       /* classtable */
 
@@ -51,7 +54,7 @@ typedef classtable_elt_t * classtable_t;                      /* classtable */
 #      define IntTAG 1
 #endif
 #define TAG_Int(x) ((val_t)(((x)<<2)|IntTAG))
-#define UNTAG_Int(x) ((int)(x)>>2)
+#define UNTAG_Int(x) ((bigint)(x)>>2)
 #ifndef CharTAG
 #      define CharTAG 2
 #endif
@@ -122,4 +125,9 @@ void nit_exit(int);
 
 void prepare_signals(void);
 extern classtable_t TAG2VFT[4];
+
+/* This structure is used to store closure.
+ * Specific closure use a specific fun parameter.
+ */
+struct WBT_ {fun_t fun; val_t *has_broke; val_t broke_value; val_t *variable; struct WBT_ **closurevariable;};
 #endif