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

import net.sandius.rembulan.compiler.gen.CompilationUnit;
import net.sandius.rembulan.compiler.gen.CompiledClass;
import net.sandius.rembulan.lbc.Prototype;
import net.sandius.rembulan.util.ByteVector;
import net.sandius.rembulan.util.Check;

import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Chunk {

	private final Prototype prototype;
	private final Map<Prototype, CompilationUnit> units;
	private final List<CompiledClass> classes;

	public Chunk(Prototype prototype, Map<Prototype, CompilationUnit> units, List<CompiledClass> classes) {
		this.prototype = Check.notNull(prototype);
		this.units = Collections.unmodifiableMap(Check.notNull(units));
		this.classes = Collections.unmodifiableList(Check.notNull(classes));
	}

	public Prototype prototype() {
		return prototype;
	}

	public Iterable<CompilationUnit> units() {
		return Collections.unmodifiableCollection(units.values());
	}

	// Returns classes defined in this chunk ordered in such a way that all classes are
	// preceded by their dependencies (i.e. it's post-order).
	public Iterable<CompiledClass> classes() {
		return Collections.unmodifiableList(classes);
	}

	public Map<String, ByteVector> classMap() {
		Map<String, ByteVector> m = new HashMap<>();
		for (CompiledClass cc : classes()) {
			m.put(cc.name(), cc.bytes());
		}
		return Collections.unmodifiableMap(m);
	}

	public String mainClassName() {
		throw new UnsupportedOperationException();  // TODO
	}

}
<commit_msg>Retrieving class name of the chunk main class.<commit_after>package net.sandius.rembulan.compiler;

import net.sandius.rembulan.compiler.gen.CompilationUnit;
import net.sandius.rembulan.compiler.gen.CompiledClass;
import net.sandius.rembulan.lbc.Prototype;
import net.sandius.rembulan.util.ByteVector;
import net.sandius.rembulan.util.Check;

import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Chunk {

	private final Prototype prototype;
	private final Map<Prototype, CompilationUnit> units;
	private final List<CompiledClass> classes;

	public Chunk(Prototype prototype, Map<Prototype, CompilationUnit> units, List<CompiledClass> classes) {
		this.prototype = Check.notNull(prototype);
		this.units = Collections.unmodifiableMap(Check.notNull(units));
		this.classes = Collections.unmodifiableList(Check.notNull(classes));
	}

	public Prototype prototype() {
		return prototype;
	}

	public Iterable<CompilationUnit> units() {
		return Collections.unmodifiableCollection(units.values());
	}

	// Returns classes defined in this chunk ordered in such a way that all classes are
	// preceded by their dependencies (i.e. it's post-order).
	public Iterable<CompiledClass> classes() {
		return Collections.unmodifiableList(classes);
	}

	public Map<String, ByteVector> classMap() {
		Map<String, ByteVector> m = new HashMap<>();
		for (CompiledClass cc : classes()) {
			m.put(cc.name(), cc.bytes());
		}
		return Collections.unmodifiableMap(m);
	}

	public String mainClassName() {
		// FIXME: this is ugly

		for (CompilationUnit u : units.values()) {
			if (u.prototype == prototype) {
				return u.name();
			}
		}

		throw new IllegalStateException();
	}

}

{'fraction_non_alphanumeric': 0.11380880121396054, 'fraction_numerical': 0.0, 'mean_word_length': 5.0924214417744915, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, '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': '983918', 'n_tokens_mistral': 1066, 'n_tokens_neox': 1020, 'n_words': 241}