use of com.rockwellcollins.atc.resolute.analysis.values.NamedElementValue in project osate2 by osate.
the class ExecuteResoluteUtil method executeResoluteFunctionOnce.
/**
* invokes Resolute claim function on targetComponent or targetElement if not null.
* instanceroot is used to initialize the Resolute evaluation context.
* targetComponent is the evaluation context
* targetElement is the model element within the component instance or null.
* parameterObjects is a list of additional parameters of types RealLiteral, IntegerLiteral, StringLiteral, BooleanLiteral
* parameterObjects can be null or an empty list.
* The return value is an Issue object with subissues for the list of issues returned in the Resolute ClaimResult.
* If the proof fails then the top Issue is set to FAIL, if successful it is set to SUCCESS
*/
public Diagnostic executeResoluteFunctionOnce(EObject fundef, final SystemInstance instanceroot, final ComponentInstance targetComponent, final InstanceObject targetElement, List<PropertyExpression> parameterObjects) {
FunctionDefinition fd = (FunctionDefinition) fundef;
initializeResoluteContext(instanceroot);
EvaluationContext context = new EvaluationContext(targetComponent, sets, featToConnsMap);
// check for claim function
FnCallExpr fcncall = createWrapperFunctionCall(fd, targetComponent, targetElement, parameterObjects);
if (fcncall != null) {
// using com.rockwellcollins.atc.resolute.analysis.results.ClaimResult
ResoluteProver prover = new ResoluteProver(context) {
@Override
protected ResoluteEvaluator createResoluteEvaluator() {
return new ResoluteEvaluator(context, varStack.peek()) {
@Override
public ResoluteValue caseThisExpr(ThisExpr object) {
NamedElement curr = context.getThisInstance();
if (object.getSub() != null) {
curr = object.getSub().getBase();
}
return new NamedElementValue(curr);
}
};
}
};
ResoluteResult res = prover.doSwitch(fcncall);
return doResoluteResults(res);
} else {
return ResultUtil.createErrorDiagnostic("Could not find Resolute Function " + fd.getName(), fd);
}
}
use of com.rockwellcollins.atc.resolute.analysis.values.NamedElementValue in project osate2 by osate.
the class NamedElementComparator method compare.
@Override
public int compare(NamedElement arg0, NamedElement arg1) {
if (arg0 == arg1) {
return 0;
}
String text0 = new NamedElementValue(arg0).toString();
String text1 = new NamedElementValue(arg1).toString();
int r = text0.compareToIgnoreCase(text1);
if (r != 0) {
return r;
}
r = Integer.compare(arg0.hashCode(), arg1.hashCode());
if (r == 0) {
throw new IllegalArgumentException("Unable to order distinct objects via hashcode");
}
return r;
}
use of com.rockwellcollins.atc.resolute.analysis.values.NamedElementValue in project osate2 by osate.
the class ResoluteInterface method executeResoluteFunctionOnce.
/**
* invokes Resolute claim function on targetComponent or targetElement if not null.
* instanceroot is used to initialize the Resolute evaluation context.
* targetComponent is the evaluation context
* targetElement is the model element within the component instance or null.
* parameterObjects is a list of additional parameters of types RealLiteral, IntegerLiteral, StringLiteral, BooleanLiteral
* parameterObjects can be null or an empty list.
* The return value is an Issue object with subissues for the list of issues returned in the Resolute ClaimResult.
* If the proof fails then the top Issue is set to FAIL, if successful it is set to SUCCESS
*/
public EObject executeResoluteFunctionOnce(EObject fundef, final ComponentInstance targetComponent, final InstanceObject targetElement, List<PropertyExpression> parameterObjects) {
FunctionDefinition fd = (FunctionDefinition) fundef;
initializeResoluteContext(targetComponent.getSystemInstance());
EvaluationContext context = new EvaluationContext(targetComponent, sets, featToConnsMap);
// check for claim function
FnCallExpr fcncall = createWrapperFunctionCall(fd, targetElement, parameterObjects);
if (fcncall != null) {
// if (fcncall.getFn().getBody() instanceof ClaimBody) {
// using com.rockwellcollins.atc.resolute.analysis.results.ClaimResult
ResoluteProver prover = new ResoluteProver(context) {
@Override
protected ResoluteEvaluator createResoluteEvaluator() {
return new ResoluteEvaluator(context, varStack.peek()) {
@Override
public ResoluteValue caseThisExpr(ThisExpr object) {
// We prepare a thisexpr with either the component instance as context object or a single reference to a model element
// See createWrapperFunctionCall
NamedElement curr = context.getThisInstance();
if (object.getSub() != null) {
curr = object.getSub().getBase();
}
return new NamedElementValue(curr);
}
};
}
};
try {
ResoluteResult res = prover.doSwitch(fcncall);
return doResoluteResults(res);
} catch (ResoluteFailException e) {
return ResultUtil.createFailureResult(e.getMessage(), targetElement);
}
// } else {
// // computational function
// ResoluteEvaluator engine = new ResoluteEvaluator(context, null) {
// @Override
// public ResoluteValue caseThisExpr(ThisExpr object) {
// // We prepare a thisexpr with either the component instance as context object or a single reference to a model element
// // See createWrapperFunctionCall
// NamedElement curr = context.getThisInstance();
// if (object.getSub() != null) {
// curr = object.getSub().getBase();
// }
// return new NamedElementValue(curr);
// }
// };
// Object res = engine.doSwitch(fcncall);
// return null;
// }
} else {
return ResultUtil.createErrorDiagnostic("Could not find Resolute Function " + fd.getName(), fd);
}
}
use of com.rockwellcollins.atc.resolute.analysis.values.NamedElementValue in project osate2 by osate.
the class FeatureToConnectionsMap method add.
private void add(FeatureInstance feat, ConnectionInstance conn) {
if (map.containsKey(feat)) {
map.get(feat).add(new NamedElementValue(conn));
} else {
List<NamedElementValue> list = new ArrayList<>();
list.add(new NamedElementValue(conn));
map.put(feat, list);
}
}
Aggregations