<commit_before>package net.sandius.rembulan.compiler.gen;

import net.sandius.rembulan.compiler.gen.block.Entry;
import net.sandius.rembulan.compiler.gen.block.Target;
import net.sandius.rembulan.compiler.types.Type;
import net.sandius.rembulan.compiler.types.TypeSeq;
import net.sandius.rembulan.lbc.Prototype;
import net.sandius.rembulan.util.IntVector;
import net.sandius.rembulan.util.ReadOnlyArray;

import java.util.HashSet;
import java.util.Map;
import java.util.Objects;

public class Unit {

	public final Prototype prototype;
	public final String name;

	private CompiledPrototype generic;

	public Unit(Prototype prototype, String name) {
		this.prototype = Objects.requireNonNull(prototype);
		this.name = name;

		this.generic = null;
	}

	public String name() {
		return name;
	}

	public CompiledPrototype generic() {
		return generic;
	}

	public TypeSeq genericParameters() {
		Type[] types = new Type[prototype.getNumberOfParameters()];
		for (int i = 0; i < types.length; i++) {
			types[i] = LuaTypes.ANY;
		}
		return new TypeSeq(ReadOnlyArray.wrap(types), prototype.isVararg());
	}

	public Entry makeNodes(TypeSeq params, Map<Prototype, Unit> units) {
		IntVector code = prototype.getCode();
		Target[] targets = new Target[code.length()];
		for (int pc = 0; pc < targets.length; pc++) {
			targets[pc] = new Target(Integer.toString(pc + 1));
		}

		ReadOnlyArray<Target> pcLabels = ReadOnlyArray.wrap(targets);

		LuaInstructionToNodeTranslator translator = new LuaInstructionToNodeTranslator(prototype, pcLabels, units);

		for (int pc = 0; pc < pcLabels.size(); pc++) {
			translator.translate(pc);
		}

		String suffix = params.toString();

		return new Entry("main_" + suffix, params, prototype.getMaximumStackSize(), pcLabels.get(0));
	}

	public CompiledPrototype makeCompiledPrototype(TypeSeq params, Map<Prototype, Unit> units) {
		CompiledPrototype cp = new CompiledPrototype(prototype, params);
		cp.callEntry = makeNodes(params, units);
		cp.returnType = TypeSeq.vararg();
		cp.resumePoints = new HashSet<>();
		return cp;
	}

	public void initGeneric(Map<Prototype, Unit> units) {
		this.generic = makeCompiledPrototype(genericParameters(), units);
	}

}
<commit_msg>Setting generic function call arguments to be of the dynamic type.<commit_after>package net.sandius.rembulan.compiler.gen;

import net.sandius.rembulan.compiler.gen.block.Entry;
import net.sandius.rembulan.compiler.gen.block.Target;
import net.sandius.rembulan.compiler.types.Type;
import net.sandius.rembulan.compiler.types.TypeSeq;
import net.sandius.rembulan.lbc.Prototype;
import net.sandius.rembulan.util.IntVector;
import net.sandius.rembulan.util.ReadOnlyArray;

import java.util.HashSet;
import java.util.Map;
import java.util.Objects;

public class Unit {

	public final Prototype prototype;
	public final String name;

	private CompiledPrototype generic;

	public Unit(Prototype prototype, String name) {
		this.prototype = Objects.requireNonNull(prototype);
		this.name = name;

		this.generic = null;
	}

	public String name() {
		return name;
	}

	public CompiledPrototype generic() {
		return generic;
	}

	public TypeSeq genericParameters() {
		Type[] types = new Type[prototype.getNumberOfParameters()];
		for (int i = 0; i < types.length; i++) {
			types[i] = LuaTypes.DYNAMIC;
		}
		return new TypeSeq(ReadOnlyArray.wrap(types), prototype.isVararg());
	}

	public Entry makeNodes(TypeSeq params, Map<Prototype, Unit> units) {
		IntVector code = prototype.getCode();
		Target[] targets = new Target[code.length()];
		for (int pc = 0; pc < targets.length; pc++) {
			targets[pc] = new Target(Integer.toString(pc + 1));
		}

		ReadOnlyArray<Target> pcLabels = ReadOnlyArray.wrap(targets);

		LuaInstructionToNodeTranslator translator = new LuaInstructionToNodeTranslator(prototype, pcLabels, units);

		for (int pc = 0; pc < pcLabels.size(); pc++) {
			translator.translate(pc);
		}

		String suffix = params.toString();

		return new Entry("main_" + suffix, params, prototype.getMaximumStackSize(), pcLabels.get(0));
	}

	public CompiledPrototype makeCompiledPrototype(TypeSeq params, Map<Prototype, Unit> units) {
		CompiledPrototype cp = new CompiledPrototype(prototype, params);
		cp.callEntry = makeNodes(params, units);
		cp.returnType = TypeSeq.vararg();
		cp.resumePoints = new HashSet<>();
		return cp;
	}

	public void initGeneric(Map<Prototype, Unit> units) {
		this.generic = makeCompiledPrototype(genericParameters(), units);
	}

}

{'fraction_non_alphanumeric': 0.12121891104638136, 'fraction_numerical': 0.002240645305848084, 'mean_word_length': 4.967914438502674, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 13, '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': '5327808', 'n_tokens_mistral': 1510, 'n_tokens_neox': 1434, 'n_words': 328}