<commit_before>package me.coley.recaf.parse.assembly.visitors;

import me.coley.recaf.parse.assembly.LineParseException;
import me.coley.recaf.parse.assembly.parsers.NameParser;
import me.coley.recaf.parse.assembly.parsers.NumericParser;
import org.objectweb.asm.tree.IincInsnNode;

import java.util.List;

import static org.objectweb.asm.Opcodes.IINC;

/**
 * Iinc type instruction parser.
 *
 * @author Matt
 */
public class IincVisitor extends InstructionVisitor {
	/**
	 * @param asm
	 * 		Parent assembly visitor for feeding back parsed content.
	 */
	public IincVisitor(AssemblyVisitor asm) {
		super(asm);
		addSection(new NameParser(NameParser.VarType.VARIABLE));
		addSection(new NumericParser("incr"));
	}

	@Override
	public void visitPre(String text) throws LineParseException {
		List<Object> args = parse(text);
		String name = (String) args.get(1);
		asm.getVariables().register(name, IINC);
	}

	@Override
	public void visit(String text) throws LineParseException {
		List<Object> args = parse(text);
		String name = (String) args.get(1);
		int index = asm.getVariables().getIndex(name);
		Number value = (Number) args.get(2);
		if (!(value instanceof Integer)){
			String type = value.getClass().getSimpleName();
			throw new LineParseException(text, "Expected integer, but found: " + type);
		}
		asm.appendInsn(new IincInsnNode(index, value.intValue()));
	}
}
<commit_msg>Add variable verif to iinc<commit_after>package me.coley.recaf.parse.assembly.visitors;

import me.coley.recaf.parse.assembly.LineParseException;
import me.coley.recaf.parse.assembly.parsers.NameParser;
import me.coley.recaf.parse.assembly.parsers.NumericParser;
import org.objectweb.asm.tree.IincInsnNode;

import java.util.List;

import static org.objectweb.asm.Opcodes.IINC;

/**
 * Iinc type instruction parser.
 *
 * @author Matt
 */
public class IincVisitor extends InstructionVisitor {
	/**
	 * @param asm
	 * 		Parent assembly visitor for feeding back parsed content.
	 */
	public IincVisitor(AssemblyVisitor asm) {
		super(asm);
		addSection(new NameParser(NameParser.VarType.VARIABLE));
		addSection(new NumericParser("incr"));
	}

	@Override
	public void visitPre(String text) throws LineParseException {
		List<Object> args = parse(text);
		String name = (String) args.get(1);
		asm.getVariables().register(name, IINC);
	}

	@Override
	public void visit(String text) throws LineParseException {
		List<Object> args = parse(text);
		String name = (String) args.get(1);
		if (!name.matches("\\d+") && !asm.getVariables().names().contains(name))
			throw new LineParseException(text, "No variable by the given name: " + name);
		int index = asm.getVariables().getIndex(name);
		Number value = (Number) args.get(2);
		if (!(value instanceof Integer)){
			String type = value.getClass().getSimpleName();
			throw new LineParseException(text, "Expected integer, but found: " + type);
		}
		asm.appendInsn(new IincInsnNode(index, value.intValue()));
	}
}

{'fraction_non_alphanumeric': 0.13046424940698068, 'fraction_numerical': 0.0020332090816672314, 'mean_word_length': 4.857142857142857, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '7060507', 'n_tokens_mistral': 999, 'n_tokens_neox': 945, 'n_words': 215}