<commit_before>package org.metaborg.meta.lang.dynsem.interpreter.nodes.rules.premises.reduction;

import org.metaborg.meta.lang.dynsem.interpreter.DynSemContext;
import org.metaborg.meta.lang.dynsem.interpreter.nodes.DynSemNode;
import org.metaborg.meta.lang.dynsem.interpreter.nodes.matching.PatternMatchFailure;
import org.metaborg.meta.lang.dynsem.interpreter.nodes.rules.ReductionFailure;
import org.metaborg.meta.lang.dynsem.interpreter.nodes.rules.RuleResult;
import org.metaborg.meta.lang.dynsem.interpreter.nodes.rules.RuleUnionNode;
import org.metaborg.meta.lang.dynsem.interpreter.nodes.rules.RuleUnionRoot;
import org.metaborg.meta.lang.dynsem.interpreter.terms.IApplTerm;
import org.metaborg.meta.lang.dynsem.interpreter.utils.InterpreterUtils;

import com.oracle.truffle.api.dsl.Cached;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.nodes.NodeUtil;
import com.oracle.truffle.api.source.SourceSection;

public abstract class SortRulesUnionNode extends DynSemNode {

	private final String arrowName;

	public SortRulesUnionNode(SourceSection source, String arrowName) {
		super(source);
		this.arrowName = arrowName;
	}

	public abstract RuleResult execute(Object o, Object[] arguments);

	@Specialization(limit = "1", guards = "o.getClass() != sortDispatchClass")
	public RuleResult doFallback(IApplTerm o, Object[] arguments,
			@Cached("o.getSortClass()") Class<?> sortDispatchClass,
			@Cached("createSortUnionNode(o, sortDispatchClass)") RuleUnionNode sortRuleUnion) {
		return sortRuleUnion.execute(arguments);
	}

	@Specialization<commit_msg>Fix bad bug in sort rule selection limit which would cause the interpreter to enter an infinite loop if all sort-based rules failed for a term.<commit_after>package org.metaborg.meta.lang.dynsem.interpreter.nodes.rules.premises.reduction;

import org.metaborg.meta.lang.dynsem.interpreter.DynSemContext;
import org.metaborg.meta.lang.dynsem.interpreter.nodes.DynSemNode;
import org.metaborg.meta.lang.dynsem.interpreter.nodes.matching.PatternMatchFailure;
import org.metaborg.meta.lang.dynsem.interpreter.nodes.rules.ReductionFailure;
import org.metaborg.meta.lang.dynsem.interpreter.nodes.rules.RuleResult;
import org.metaborg.meta.lang.dynsem.interpreter.nodes.rules.RuleUnionNode;
import org.metaborg.meta.lang.dynsem.interpreter.nodes.rules.RuleUnionRoot;
import org.metaborg.meta.lang.dynsem.interpreter.terms.IApplTerm;
import org.metaborg.meta.lang.dynsem.interpreter.utils.InterpreterUtils;

import com.oracle.truffle.api.dsl.Cached;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.nodes.NodeUtil;
import com.oracle.truffle.api.source.SourceSection;

public abstract class SortRulesUnionNode extends DynSemNode {

	private final String arrowName;

	public SortRulesUnionNode(SourceSection source, String arrowName) {
		super(source);
		this.arrowName = arrowName;
	}

	public abstract RuleResult execute(Object o, Object[] arguments);

	@Specialization(limit = "1", guards = "o.getSortClass() != sortDispatchClass")
	public RuleResult doFallback(IApplTerm o, Object[] arguments,
			@Cached("o.getSortClass()") Class<?> sortDispatchClass,
			@Cached("createSortUnionNode(o, sortDispatchClass)") RuleUnionNode sortRuleUnion) {
		return sortRuleUnion.execute(arguments);
	}

	@Specialization
{'fraction_non_alphanumeric': 0.10897049969897651, 'fraction_numerical': 0.0006020469596628537, 'mean_word_length': 6.417410714285714, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1380453', 'n_tokens_mistral': 1087, 'n_tokens_neox': 1076, 'n_words': 172}