<commit_before>// set of supported atom types
Serialization.AbbrevHash atypes = Serialization.AbbrevHash();
// set of supported pike type, either basetype() or object_program()
// we could think about supporting inheritance at some point
mapping ptypes = ([]);

mixed apply(Serialization.Atom a, mixed state, void|object misc) {
    multiset t;

    if (!misc) misc = Serialization.ApplyInfo();

    if (t = atypes[a->type]) foreach (t; object type;) {
	if (functionp(type->apply) && type->low_can_decode(a)) {
	    mixed ret = type->apply(a, state, misc);   
	    return ret;
	}
    }

    misc->faildepth = misc->depth;
    misc->failed = 1;
    return state;
}

void register_type(string|program ptype, string atype, object type) {
    if (!has_index(ptypes, ptype)) {
	ptypes[ptype] = (< type >);
    } else {
	ptypes[ptype] += (< type >);
    }
    multiset t = atypes[atype];
    if (t) {
	t[type] = 1;
    } else {
	atypes[atype] = (< type >);
    }
}

void unregister_type(string|program ptype, string atype, object type) {
    if (has_index(ptypes, ptype)) {
	ptypes[ptype] -= (< type >);

	if (!sizeof(ptypes[ptype])) m_delete(ptypes, ptype);
    }<commit_msg>locking and new apply semantics<commit_after>// set of supported atom types
Serialization.AbbrevHash atypes = Serialization.AbbrevHash();
// set of supported pike type, either basetype() or object_program()
// we could think about supporting inheritance at some point
mapping ptypes = ([]);

mixed apply(Serialization.Atom a, mixed state, void|object misc) {
    multiset t;

    if (!misc) misc = .ApplyInfo();

    if (t = atypes[a->type]) foreach (t; object type;) {
	if (functionp(type->apply) && type->low_can_decode(a)) {
	    mixed ret = type->apply(a, state, misc);   
	    return ret;
	}
    }

    misc->faildepth = misc->depth;
    misc->failed = 1;
    return .UNSUPPORTED;
}

void register_type(string|program ptype, string atype, object type) {
    if (!has_index(ptypes, ptype)) {
	ptypes[ptype] = (< type >);
    } else {
	ptypes[ptype] += (< type >);
    }
    multiset t = atypes[atype];
    if (t) {
	t[type] = 1;
    } else {
	atypes[atype] = (< type >);
    }
}

void unregister_type(string|program ptype, string atype, object type) {
    if (has_index(ptypes, ptype)) {
	ptypes[ptype] -= (< type >);

	if (!sizeof(ptypes[ptype])) m_delete(ptypes, ptype);
    }
{'fraction_non_alphanumeric': 0.1526360544217687, 'fraction_numerical': 0.0017006802721088435, 'mean_word_length': 3.4904580152671754, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5825115', 'n_tokens_mistral': 859, 'n_tokens_neox': 820, 'n_words': 216}