blob: 9deb39887b3f147b954a5e42d4b85f29697bd105 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2004-2008 Akos Horvath, Gergely Varro and Daniel Varro
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Akos Horvath, Gergely Varro - initial API and implementation
*******************************************************************************/
package org.eclipse.viatra2.gtasm.patternmatcher.impl.gtmatcher.internal;
import org.eclipse.viatra2.gtasm.interpreter.exception.ViatraTransformationException;
import org.eclipse.viatra2.gtasm.interpreter.executionEnvironment.IExecutionEnvironment;
import org.eclipse.viatra2.gtasm.patternmatcher.PatternMatcherParameters;
import org.eclipse.viatra2.gtasm.patternmatcher.impl.patternmatcher.term.ITermHandler;
import org.eclipse.viatra2.gtasm.patternmatcher.patterns.IPatternMatcher;
import org.eclipse.viatra2.gtasm.patternmatcher.patterns.PatternMatcherProvider;
import org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.asm.core.RuntimeAnnotation;
import org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.gt.GTRule;
/**
* Provides a complete GT rule matcher functionality with the possibility to use alternative pattern matchers for the LHS of the GT rule
* @author Akos Horvath
*
*/
public class ExtendedGTRuleMatcherwithAlternativePatternMatcher extends TraditionalGTRuleMatcher {
public ExtendedGTRuleMatcherwithAlternativePatternMatcher(GTRule gt,
IExecutionEnvironment enviroment, ITermHandler handler,
PatternMatcherParameters mp) throws ViatraTransformationException {
super(gt, enviroment, handler, mp);
}
/* The only method that has to be overridden in order to enable the Alternative Pattern Matchers in case when we want to use
* the already implemented Traditional GT Rule matcher
* (non-Javadoc)
* @see org.eclipse.viatra2.gtasm.patternmatcher.impl.gtmatcher.internal.TraditionalGTRuleMatcher#getPatternMatcherforPreCondition()
*/
@Override
protected IPatternMatcher getPatternMatcherforPreCondition() throws ViatraTransformationException{
// is true pseudorandom required?
isRandom = false;
for (Object annot : gtRule.getPrecondition().getCalledPattern().getRuntimeAnnotations()) {
if ("@random".equals(((RuntimeAnnotation) annot).getAnnotationName().toLowerCase())) {
isRandom = true; break;
}
}
return PatternMatcherProvider.getInstance().getPatternMatcher(
gtEnvironment, gtRule.getPrecondition().getCalledPattern());
}
}