/*#io
docCopyright("Steve Dekorte", 2002)
docLicense("BSD revised")
*/

#ifndef IOMARK_DEFINED
#define IOMARK_DEFINED 1

#include "Common.h"

#ifdef __cplusplus
extern "C" {
#endif
    
#define IOMARK_INITIAL_FREE  0
#define IOMARK_INITIAL_WHITE 4
#define IOMARK_INITIAL_GRAY  2
#define IOMARK_INITIAL_BLACK 1
    
#define IOMARK_GRAY  IOMARK_INITIAL_GRAY

//#define IOMARK_BLACK ((IoState *)IOSTATE)->blackGroup->mark.color
//#define IOMARK_WHITE ((IoState *)IOSTATE)->whiteGroup->mark.color

#define IOMARK_BLACK ((IoState *)IOSTATE)->currentBlackColor
#define IOMARK_WHITE ((IoState *)IOSTATE)->currentWhiteColor
    
//#define IO_BLOCK_RECYCLING
    
#define IoObject_hasDoneLookup(self) self->mark.hasDoneLookup
#define IoObject_setHasDoneLookup_(self, v) self->mark.hasDoneLookup = v;
    
#define IoObject_isReferenced(self) self->mark.isReferenced
#define IoObject_setIsReferenced_(self, v) self->mark.isReferenced = v; 
    
typedef struct
{
    void *previous;                    // an IoObject - next in gc color list 
    void *next;                        // an IoObject - previous in gc color list 
    
    unsigned int isReferenced : 1;     // set to 1 when the object is referenced by another 
                                       // this can be used to do immediate recycling of 
                                       // locals objects 
    
    unsigned int color : 3;            // for tri-color garbage collector
    
    unsigned int hasWeakLink : 1;      // marked if there's ever been a weak link to the value
    unsigned int hasDoneLookup : 1;    // used to avoid slot lookup loops
    unsigned int ownsSlots : 1;        // if true, free slots Hash when freeing object
    unsigned int isSymbol : 1;         // true if the object is literal - such as a literal string
    
    unsigned int isDirty : 1;          // set to true when the object changes it's storable state
    unsigned int doesNotOwnData : 1;   // if false, call freeFunc when freeing object
    unsigned int isLocals : 1;         // true if the Object is a locals object
    unsigned int isActivatable : 1;    // if true, upon activation, call activate slot
    
    unsigned int knownToCollector : 1; // set to true when object is added to collector
    unsigned int extra : 3;            // 
                                       //unsigned int distributedColor : 2; // possible future use - distributed gc use
} IoMark;

#ifdef __cplusplus
}
#endif
#endif
