<commit_before>package edu.mit.streamjit.impl.compiler;

import java.util.Objects;

/**
 * A Use represents a single use of a Value.  Note that a User can use the same
 * value more than once if it has multiple operands; this class thus keeps an
 * operand index to disambiguate.
 * @author <NAME> <<EMAIL>>
 * @since 3/6/2013
 */
public class Use {
	private final User user;
	private int operandIndex;
	private Value value;

	public Use(User user, int operandIndex, Value value) {
		this.user = user;
		this.operandIndex = operandIndex;
		this.value = value;
		if (value != null)
			value.addUse(this);
	}

	public User getUser() {
		return user;
	}

	public int getOperandIndex() {
		return operandIndex;
	}

	public void setOperandIndex(int index) {
		operandIndex = index;
	}

	public Value getOperand() {
		return value;
	}

	public void setOperand(Value other) {
		user.checkOperand(operandIndex, other);
		if (Objects.equals(getOperand(), other))
			return;
		if (value != null)
			value.removeUse(this);
		this.value = other;<commit_msg>Use.setOperandIndex package-private and caller-checked<commit_after>package edu.mit.streamjit.impl.compiler;

import edu.mit.streamjit.util.ReflectionUtils;
import java.util.Objects;

/**
 * A Use represents a single use of a Value.  Note that a User can use the same
 * value more than once if it has multiple operands; this class thus keeps an
 * operand index to disambiguate.
 * @author <NAME> <<EMAIL>>
 * @since 3/6/2013
 */
public class Use {
	private final User user;
	private int operandIndex;
	private Value value;

	public Use(User user, int operandIndex, Value value) {
		this.user = user;
		this.operandIndex = operandIndex;
		this.value = value;
		if (value != null)
			value.addUse(this);
	}

	public User getUser() {
		return user;
	}

	public int getOperandIndex() {
		return operandIndex;
	}

	//for internal use only!
	void setOperandIndex(int index) {
		assert ReflectionUtils.calledDirectlyFrom(User.class);
		operandIndex = index;
	}

	public Value getOperand() {
		return value;
	}

	public void setOperand(Value other) {
		user.checkOperand(operandIndex, other);
		if (Objects.equals(getOperand(), other))
			return;
		if (value != null)
			value.removeUse(this);
		this.value = other;
{'fraction_non_alphanumeric': 0.10470275066548358, 'fraction_numerical': 0.005323868677905945, 'mean_word_length': 3.891540130151844, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '4143273', 'n_tokens_mistral': 768, 'n_tokens_neox': 734, 'n_words': 231}