blob: 3d355c8337294759372dfd20cafd4c556b348b55 [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.internal.operation;
import org.eclipse.viatra2.gtasm.patternmatcher.impl.patternmatcher.internal.MatchingFrame;
import org.eclipse.viatra2.gtasm.patternmatcher.impl.patternmatcher.internal.callgraph.FlattenedPattern;
import org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.asm.core.AnnotatedElement;
public class InjectivityCheckOperation extends CheckOperation {
protected boolean check(MatchingFrame frame) {
FlattenedPattern pattern = frame.getPattern();
int size = pattern.getInjectivityFrameSize();
for (int i = 1; i < size; i++) {
for (int j = 0; j < i; j++) {
// TODO refactor frame.getValue(j) -> frame.frame[j] as it may be faster
if(frame.getValue(j) != null && frame.getValue(i) != null ) //TODO: akinator: this is just a hack because of NAC and injectivity check!!! have to be fixed
if (pattern.isIncludedInInjectivityCheck(i, j) &&
frame.getValue(j).equals(frame.getValue(i))) {
return false;
}
}
}
return true;
}
public AnnotatedElement getErrorfulElement(MatchingFrame frame) {
return frame.getPattern().getParent().getPattern();
}
}