<commit_before>package lila.runtime;

import java.lang.invoke.MethodHandle;
import java.lang.invoke.MutableCallSite;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class LilaGenericFunction extends LilaCallable {

	public static final LilaClass lilaClass =
		new LilaClass(true, "<generic-function>", LilaGenericFunction.class,
		              LilaObject.lilaClass);

	// specializers => method handle
	Map<List<LilaClass>, MethodHandle> methods = new HashMap<>();

	List<LilaObject> closedArguments =
		Collections.<LilaObject>emptyList();

	public LilaGenericFunction() {
		super(lilaClass);
	}

	@Override
	public LilaGenericFunction close(LilaObject value) {
		LilaGenericFunction gf = new LilaGenericFunction();
		gf.closedArguments = new ArrayList<LilaObject>();
		gf.closedArguments.addAll(this.closedArguments);
		gf.closedArguments.add(value);
		gf.methods = this.methods;
		return gf;
	}

	@Override
	public LilaObject apply(LilaObject[] arguments) {
		//TODO:
		return null;
	}

	public void addMethod(MethodHandle methodHandle,
						  List<LilaClass> specializers)
	{
		methods.put(specializers, methodHandle);
	}

	@Override
	public String toString() {
		// TODO: show type signature
		return "#[GenericFunction]";
	}

	@Override
	LilaObject fallback
		(MutableCallSite callSite, LilaCallable callable, LilaObject[] args)
		throws Throwable<commit_msg>runtime: generate identifier for each method of generic function<commit_after>package lila.runtime;

import java.lang.invoke.MethodHandle;
import java.lang.invoke.MutableCallSite;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import lila.runtime.dispatch.Method;
import lila.runtime.dispatch.Predicate;
import lila.runtime.dispatch.DispatchFunction;

public class LilaGenericFunction extends LilaCallable {

	public static final LilaClass lilaClass =
		new LilaClass(true, "<generic-function>", LilaGenericFunction.class,
		              LilaObject.lilaClass);

	public Map<Predicate, Method> methods = new HashMap<>();

	List<LilaObject> closedArguments = Collections.emptyList();

	public LilaGenericFunction() {
		super(lilaClass);
	}

	public void addMethod(Predicate predicate, MethodHandle handle) {
		Method method = new Method(handle);
		// generate identifier, for debugging purposes
		method.identifier = "m" + (methods.size() + 1);
		methods.put(predicate, method);
	}

	public DispatchFunction toDispatchFunction() {
		return DispatchFunction.fromMethods(this.methods);
	}

	@Override
	public LilaGenericFunction close(LilaObject value) {
		LilaGenericFunction gf = new LilaGenericFunction();
		gf.closedArguments = new ArrayList<LilaObject>();
		gf.closedArguments.addAll(this.closedArguments);
		gf.closedArguments.add(value);
		gf.methods = this.methods;
		return gf;
	}

	@Override
	public LilaObject apply(LilaObject[] arguments) {
		// TODO:
		return null;
	}

	@Override
	public String toString() {
		// TODO: show type signature
		return "#[GenericFunction]";
	}

	@Override
	LilaObject fallback
		(MutableCallSite callSite, LilaCallable callable, LilaObject[] args)
		throws Throwable
{'fraction_non_alphanumeric': 0.10235258172930034, 'fraction_numerical': 0.00030553009471432935, 'mean_word_length': 5.074211502782932, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 17, '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': '6193956', 'n_tokens_mistral': 1049, 'n_tokens_neox': 973, 'n_words': 231}