package org.metaborg.meta.lang.dynsem.interpreter.nodes.matching;

import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.source.SourceSection;

public abstract class IntLiteralTermMatchPattern extends LiteralMatchPattern {

	protected final int lit;

	public IntLiteralTermMatchPattern(int lit, SourceSection source) {
		super(source);
		this.lit = lit;
	}

	@Specialization(guards = "i == lit")
	public void doSuccess(int i) {

	}

	@Specialization
	public void doFailure(int i) {
		throw PatternMatchFailure.INSTANCE;
	}

}
package org.metaborg.meta.lang.dynsem.interpreter.nodes.matching;

import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.profiles.ConditionProfile;
import com.oracle.truffle.api.source.SourceSection;

public abstract class IntLiteralTermMatchPattern extends LiteralMatchPattern {

	protected final int lit;

	public IntLiteralTermMatchPattern(int lit, SourceSection source) {
		super(source);
		this.lit = lit;
	}

	private final ConditionProfile profile = ConditionProfile.createCountingProfile();

	@Specialization
	public void doSuccess(int i) {
		if (profile.profile(i != lit)) {
			throw PatternMatchFailure.INSTANCE;
		}
	}

}
Fix competely invalid value specialization in integer literal matching
Fix competely invalid value specialization in integer literal matching

Fixes #124.
