blob: 2de7dbb7586ca1ed915c8701a9e6dd2425521e81 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2004-2008 Gabor Bergmann 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:
* Gabor Bergmann - initial API and implementation
*******************************************************************************/
package org.eclipse.viatra2.gtasm.patternmatcher.incremental;
import java.util.HashMap;
import org.eclipse.viatra2.gtasm.patternmatcher.IMatching;
import org.eclipse.viatra2.gtasm.patternmatcher.incremental.rete.tuple.Tuple;
import org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.asm.definitions.Variable;
/**
* @author Gabor Bergmann
*
*/
class ReteMatching implements IMatching {
private Tuple substitutions;
private HashMap<Object, Integer> positionMapping;
/**
* @param substitutions
* @param positionMapping
*/
public ReteMatching(Tuple substitutions,
HashMap<Object, Integer> positionMapping) {
super();
this.substitutions = substitutions;
this.positionMapping = positionMapping;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.viatra2.gtasm.patternmatcher.IMatching#lookup(int)
*/
public Object lookup(int position) {
return substitutions.get(position);
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.viatra2.gtasm.patternmatcher.IMatching#lookup(hu.bme.mit.viatra.gtasmmodel.gtasm
* .metamodel.asm.definitions.Variable)
*/
public Object lookup(Variable variable) {
return substitutions.get(positionMapping.get(variable));
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
return "Matching: " + substitutions.toString();
}
}