blob: 945b90665dc98c9b0c77fa2890218c206d011508 [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.patternmatcher.term;
import java.util.HashMap;
import java.util.Map;
import java.util.Vector;
import org.eclipse.emf.common.util.EList;
import org.eclipse.viatra2.framework.IFramework;
import org.eclipse.viatra2.gtasm.interpreter.exception.ViatraTransformationException;
import org.eclipse.viatra2.gtasm.interpreter.executionEnvironment.IExecutionEnvironment;
import org.eclipse.viatra2.gtasm.patternmatcher.impl.patternmatcher.internal.MatchingFrame;
import org.eclipse.viatra2.gtasm.patternmatcher.impl.patternmatcher.internal.VariableID;
import org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.asm.definitions.ASMFunction;
import org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.asm.definitions.Variable;
import org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.asm.terms.Term;
import org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.gt.GTPattern;
public class TermCheckExecutionEnvironment implements IExecutionEnvironment {
private IExecutionEnvironment parent;
private GTPattern pattern;
private int uid;
private MatchingFrame frame;
public TermCheckExecutionEnvironment(IExecutionEnvironment parent, GTPattern pattern, int uid, MatchingFrame frame) {
this.parent = parent;
this.pattern = pattern;
this.uid = uid;
this.frame = frame;
}
public Object getVariableValue(Variable variable) {
Integer index = frame.getPattern().getIndex(new VariableID(pattern,uid,variable.getName()));
return frame.getValue(index);
}
public void addVariable(Variable key, Object value) throws ViatraTransformationException {
// Do nothing
}
public void fetchVariableVariations(HashMap<Variable, Vector<Object>> possibleVariableValues, Term termToBeEvaluated) {
parent.fetchVariableVariations(possibleVariableValues, termToBeEvaluated);
}
public IFramework getFramework() {
return parent.getFramework();
}
public Object getValueOfASMFunction(ASMFunction asmFunction, EList location) {
return parent.getValueOfASMFunction(asmFunction, location);
}
public Map<Variable, Object> getVariableValues() {
return parent.getVariableValues();
}
public void setVariableValue(Variable variable, Object value) throws ViatraTransformationException {
// Do nothing
}
public void updateASMFunction(ASMFunction asmFunction, EList location, Object value) throws ViatraTransformationException {
parent.updateASMFunction(asmFunction, location, value);
}
}