int SerializedAlready(Obj obj) { Obj ref = LookupObjMap(TLS(SerializationRegistry), obj); if (ref) { WriteTNum(T_BACKREF); WriteImmediateObj(OBJ_BACKREF(INT_INTOBJ(ref))); return 1; } else { TLS(SerializationIndex)++; AddObjMap(TLS(SerializationRegistry), obj, INTOBJ_INT(TLS(SerializationIndex))); return 0; } }
int SerializedAlready(Obj obj) { Obj ref = LookupObjMap(MODULE_STATE(Serialize).registry, obj); if (ref) { WriteTNum(T_BACKREF); WriteImmediateObj(OBJ_BACKREF(INT_INTOBJ(ref))); return 1; } else { MODULE_STATE(Serialize).index++; AddObjMap(MODULE_STATE(Serialize).registry, obj, INTOBJ_INT(MODULE_STATE(Serialize).index)); return 0; } }