<commit_before>package wombat;

import java.lang.invoke.*;
import clojure.lang.*;

public class Global {
    public final static Var COMPILER_BINDINGS = RT.var("wombat.compiler", "global-bindings");
    public final static Var LOADER = RT.var("wombat.compiler", "*class-loader*");
    public final static Var JAVALIST_TO_LIST = RT.var("wombat.datatypes", "javalist->list");
    final static Keyword CALLSITE = Keyword.intern("call-site");
    
    public static CallSite getCallSite(Symbol name) {
        Atom bindAtom = (Atom) COMPILER_BINDINGS.deref();
        return (CallSite) RT.get(RT.get(bindAtom.deref(), name), CALLSITE);
    }

    public static Object getGlobal(Symbol name) {
        CallSite site = getCallSite(name);
        if (site == null)
            return null;

        try {
            return site.getTarget().invokeExact();
        } catch (Throwable t) {
            throw Util.sneakyThrow(t);
        }
    }

    public static CallSite bootstrap(MethodHandles.Lookup caller, String name, MethodType methodType, String symName) {
        CallSite site = getCallSite(Symbol.intern(symName));
        if (site == null)
            throw new IllegalStateException("Symbol " + symName + " is not defined!");

        return site;
    }

    public static Object invokeLambda(ILambda lambda, Object[] args) {
        try {
            MethodHandle handle = lambda.getHandle(args.length);
            Object ret;
            int arity = handle.type().parameterCount() - 1; // first parameter is ILambda
            if (handle.isVarargsCollector() && args.length >= arity - 1) {
                Object[] newArgs = new Object[arity];
                Object[] varArgs = new Object[args.length - arity + 1];
                System.arraycopy(args, 0, newArgs, 0, arity - 1);
                System.arraycopy(args, arity - 1, varArgs, 0, args.length - arity + 1);
                newArgs[arity - 1] = varArgs;

                ret = handle.asFixedArity().asSpreader(Object[].class, arity).invoke(lambda, newArgs);
            } else
                ret = handle.asSpreader(Object[].class, args.length).invoke(lambda, args);

            while (ret instanceof Continuation)
                ret = ((Continuation)ret).invoke();
            return ret;
        } catch (Throwable t) { throw Util.sneakyThrow(t); }
    }

}<commit_msg>update invokeLambda method<commit_after>package wombat;

import java.lang.invoke.*;
import java.util.Arrays;
import clojure.lang.*;

public class Global {
    public final static Var COMPILER_BINDINGS = RT.var("wombat.compiler", "global-bindings");
    public final static Var LOADER = RT.var("wombat.compiler", "*class-loader*");
    public final static Var JAVALIST_TO_LIST = RT.var("wombat.datatypes", "javalist->list");
    final static Keyword CALLSITE = Keyword.intern("call-site");
    
    public static CallSite getCallSite(Symbol name) {
        Atom bindAtom = (Atom) COMPILER_BINDINGS.deref();
        return (CallSite) RT.get(RT.get(bindAtom.deref(), name), CALLSITE);
    }

    public static Object getGlobal(Symbol name) {
        CallSite site = getCallSite(name);
        if (site == null)
            return null;

        try {
            return site.getTarget().invokeExact();
        } catch (Throwable t) {
            throw Util.sneakyThrow(t);
        }
    }

    public static CallSite bootstrap(MethodHandles.Lookup caller, String name, MethodType methodType, String symName) {
        CallSite site = getCallSite(Symbol.intern(symName));
        if (site == null)
            throw new IllegalStateException("Symbol " + symName + " is not defined!");

        return site;
    }

    
    public static Object invokeLambda(ILambda lambda, Object... args) {
        Object ret = lambda.applyTo(JAVALIST_TO_LIST.invoke(Arrays.asList(args)));
        while (ret instanceof Continuation)
            ret = ((Continuation)ret).invoke();
        return ret;
    }

}
{'fraction_non_alphanumeric': 0.11664548919949175, 'fraction_numerical': 0.0025412960609911056, 'mean_word_length': 2.5555555555555554, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, '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': '5365544', 'n_tokens_mistral': 1170, 'n_tokens_neox': 1134, 'n_words': 289}