List<TCGOCLExpression> in_colExpressions,
Map<TCGOCLAtom, ValueTypeRange> in_colAtomToVTR,
Map<TCGOCLAtom, TestCaseValidValue> in_colCurrentValueAssignment,
List<TCGOCLExpression> in_colAlreadyEvaluatedExpressions) {
ValueTypeRange oGlobalVTR = null;
boolean bResult = true;
//ATOM: for(TCGOCLAtom oAtom : in_oAtom) {
if(!in_oAtom.isEmpty()) {
TCGOCLAtom oAtom = in_oAtom.get(0);
if(oGlobalVTR == null) {
oGlobalVTR = ValueTypeRangeFactory.createValueTypeRangeForObject(oAtom);
}
//hier statt eines �bergebenen atoms eine Liste "gleicher" Atome �berpr�fen???
// get value type range
ValueTypeRange oVTR = in_colAtomToVTR.get(oAtom);
if(oVTR != null)
oVTR = oVTR.clone();
else
oVTR = ValueTypeRangeFactory.createValueTypeRangeForObject(oAtom);
// TODO Typ von in_colCurrentValueAssignment �ndern auf Map<EObject,TestCaseValidValue>
// if there is a value assignment for the given atom
for(TCGOCLAtom oAtomWithAssignedValue : in_colCurrentValueAssignment.keySet()) {
if(oAtomWithAssignedValue.getElement().equals(oAtom.getElement())) {
// adapt value type range
bResult = bResult &&
oVTR.adaptRange(in_colCurrentValueAssignment.get(oAtomWithAssignedValue).getValue());
bResult = bResult &&
oGlobalVTR.adaptRange(oVTR);
if(!bResult)
return new IndefinableValueTypeRange();
// break ATOM;
// continue ATOM;
}
}
// keep track of all the expressions still to evaluate ...
List<TCGOCLExpression> colTmpExpressionsCopy = new ArrayList<TCGOCLExpression>();
colTmpExpressionsCopy.addAll(in_colExpressions);
for(TCGOCLExpression oExpression : in_colExpressions) {
OCLTreeExpressionFindAtomReferenceVisitor oVisitor =
//new OCLTreeExpressionFindAtomReferenceVisitor(in_oAtom);
new OCLTreeExpressionFindAtomReferenceVisitor(oAtom);
OCLTreeExpressionIterator.run(oExpression, oVisitor);
// oExpression contains oAtom
if(oVisitor.isFound()) {
for(TCGOCLAtom oInterestingAtom : oVisitor.getFoundAtoms()) {
if(oExpression instanceof TCGOCLAtom) {
ValueTypeRange oTmpVTR = OCLExpressionValueTypeRangeFactory.
getValueTypeRangeForRightSideOfExpression(
oInterestingAtom, oExpression);
if(oVTR == null)
oVTR = oTmpVTR;
else {
if(!oVTR.adaptRange(oTmpVTR)) {
// bResult = false;
return new IndefinableValueTypeRange();
// break ATOM;
}
}
}
else if(oExpression instanceof TCGOCLOperation) {
TCGOCLOperation oOperation = (TCGOCLOperation)oExpression;
// shift atom to the left
shiftSubexpressionToTheLeft(oInterestingAtom, oOperation);
// now investigate the right side of the expression
// combine with other expressions of the list
colTmpExpressionsCopy.remove(oOperation);
Map<TCGOCLAtom, ValueTypeRange> colTemporaryAtomToVTR
= new LinkedHashMap<TCGOCLAtom, ValueTypeRange>();
colTemporaryAtomToVTR.putAll(in_colAtomToVTR);
colTemporaryAtomToVTR.remove(oAtom);
//colTemporaryAtomToVTR.remove(in_oAtom);
// colTemporaryEPIToAtoms contains all remaining epi to atoms
Map<TCGOCLAtom, ValueTypeRange> colAtomToVTR =
new LinkedHashMap<TCGOCLAtom, ValueTypeRange>();
// restart the evaluation for each ATOM of the right side
OCLTreeTCGOCLAtomCollectorVisitor oAtomCollector =
new OCLTreeTCGOCLAtomCollectorVisitor();
OCLTreeExpressionIterator.run(oOperation.getRight(), oAtomCollector);
for(TCGOCLAtom oExpAtom : oAtomCollector.getExpressions()) {
// check only atoms that reference variables or properties
if(oExpAtom.getElement() instanceof Variable ||
oExpAtom.getElement() instanceof Property) {
List<TCGOCLAtom> colExpAtoms = new ArrayList<TCGOCLAtom>();
colExpAtoms.add(oExpAtom);
ValueTypeRange oTmpVTR =
getValueTypeRangeForEventParameterInstance(
colExpAtoms, colTmpExpressionsCopy, colTemporaryAtomToVTR,
in_colCurrentValueAssignment, in_colAlreadyEvaluatedExpressions);
if(oTmpVTR instanceof IndefinableValueTypeRange) {
return new IndefinableValueTypeRange();
// bResult = false;
// break ATOM;
}
colAtomToVTR.put(oExpAtom, oTmpVTR);
}
}
// evaluate expressions with the help of value type ranges
ValueTypeRange oTmpVTR = ValueTypeRangeFactory.createValueTypeRangeForObject(oInterestingAtom);
oTmpVTR = OCLExpressionValueTypeRangeFactory.
getValueTypeRangeForRightSideOfExpression(
oTmpVTR, oOperation,
in_colCurrentValueAssignment, colAtomToVTR);