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

import net.sandius.rembulan.lbc.Prototype;
import net.sandius.rembulan.lbc.PrototypePrinter;
import net.sandius.rembulan.util.Check;

import java.util.Objects;

public abstract class Origin {

	private Origin() {
		// not to be extended by the outside world
	}

	public static class Argument extends Origin {

		public final int index;

		public Argument(int index) {
			Check.nonNegative(index);
			this.index = index;
		}

		@Override
		public boolean equals(Object o) {
			if (this == o) return true;
			if (o == null || getClass() != o.getClass()) return false;

			Argument argument = (Argument) o;

			return index == argument.index;
		}

		@Override
		public int hashCode() {
			return index;
		}

		@Override
		public String toString() {
			return "#" + index;
		}

	}

	public static class Constant extends Origin {

		public final int index;

		public Constant(int index) {
			Check.nonNegative(index);
			this.index = index;
		}

		@Override
		public boolean equals(Object o) {
			if (this == o) return true;
			if (o == null || getClass() != o.getClass()) return false;

			Constant constant = (Constant) o;
			return index == constant.index;
		}

		@Override
		public int hashCode() {
			return index;
		}

		@Override
		public String toString() {
			return "$" + index;
		}

	}

	public static class Closure extends Origin {

		public final Prototype prototype;

		public Closure(Prototype prototype) {
			this.prototype = Objects.requireNonNull(prototype);
		}

		@Override
		public boolean equals(Object o) {
			if (this == o) return true;
			if (o == null || getClass() != o.getClass()) return false;

			Closure closure = (Closure) o;

			return prototype.equals(closure.prototype);
		}

		@Override
		public int hashCode() {
			return prototype.hashCode();
		}

		@Override
		public String toString() {
			return "*" + PrototypePrinter.pseudoAddr(prototype);
		}

	}

	public static class Upvalue extends Origin {

		public final int index;

		public Upvalue(int index) {
			Check.nonNegative(index);
			this.index = index;
		}

		@Override
		public boolean equals(Object o) {
			if (this == o) return true;
			if (o == null || getClass() != o.getClass()) return false;

			Upvalue constant = (Upvalue) o;
			return index == constant.index;
		}

		@Override
		public int hashCode() {
			return index;
		}

		@Override
		public String toString() {
			return "^" + index;
		}

	}

	public static class Computed extends Origin {

		@Override
		public String toString() {
			return "_" + Integer.toHexString(this.hashCode());
		}

	}

	public static Entry entry() {
		return Entry.INSTANCE;
	}

	public static class Entry extends Origin {

		public static final Entry INSTANCE = new Entry();
<commit_msg>Adding a note on adding references to the computed origin's predecessors.<commit_after>package net.sandius.rembulan.compiler.gen;

import net.sandius.rembulan.lbc.Prototype;
import net.sandius.rembulan.lbc.PrototypePrinter;
import net.sandius.rembulan.util.Check;

import java.util.Objects;

public abstract class Origin {

	private Origin() {
		// not to be extended by the outside world
	}

	public static class Argument extends Origin {

		public final int index;

		public Argument(int index) {
			Check.nonNegative(index);
			this.index = index;
		}

		@Override
		public boolean equals(Object o) {
			if (this == o) return true;
			if (o == null || getClass() != o.getClass()) return false;

			Argument argument = (Argument) o;

			return index == argument.index;
		}

		@Override
		public int hashCode() {
			return index;
		}

		@Override
		public String toString() {
			return "#" + index;
		}

	}

	public static class Constant extends Origin {

		public final int index;

		public Constant(int index) {
			Check.nonNegative(index);
			this.index = index;
		}

		@Override
		public boolean equals(Object o) {
			if (this == o) return true;
			if (o == null || getClass() != o.getClass()) return false;

			Constant constant = (Constant) o;
			return index == constant.index;
		}

		@Override
		public int hashCode() {
			return index;
		}

		@Override
		public String toString() {
			return "$" + index;
		}

	}

	public static class Closure extends Origin {

		public final Prototype prototype;

		public Closure(Prototype prototype) {
			this.prototype = Objects.requireNonNull(prototype);
		}

		@Override
		public boolean equals(Object o) {
			if (this == o) return true;
			if (o == null || getClass() != o.getClass()) return false;

			Closure closure = (Closure) o;

			return prototype.equals(closure.prototype);
		}

		@Override
		public int hashCode() {
			return prototype.hashCode();
		}

		@Override
		public String toString() {
			return "*" + PrototypePrinter.pseudoAddr(prototype);
		}

	}

	public static class Upvalue extends Origin {

		public final int index;

		public Upvalue(int index) {
			Check.nonNegative(index);
			this.index = index;
		}

		@Override
		public boolean equals(Object o) {
			if (this == o) return true;
			if (o == null || getClass() != o.getClass()) return false;

			Upvalue constant = (Upvalue) o;
			return index == constant.index;
		}

		@Override
		public int hashCode() {
			return index;
		}

		@Override
		public String toString() {
			return "^" + index;
		}

	}

	// TODO: add references to predecessors? might complicate equality computation...
	public static class Computed extends Origin {

		@Override
		public String toString() {
			return "_" + Integer.toHexString(this.hashCode());
		}

	}

	public static Entry entry() {
		return Entry.INSTANCE;
	}

	public static class Entry extends Origin {

		public static final Entry INSTANCE = new Entry();

{'fraction_non_alphanumeric': 0.11212493419898228, 'fraction_numerical': 0.0, 'mean_word_length': 3.2600896860986546, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '7153405', 'n_tokens_mistral': 2048, 'n_tokens_neox': 1735, 'n_words': 541}